hostodo ip 被墙

一场倒墙风波过后,我不怎么使用的vps ip也都被ban了,包括hostodo和vultr。

简单的检测方法:ping.chinaz.com

如果国内都不通,国外的通,很明显了。

解决办法:

hostodo 发了个service ticket,说vps cannot access via ssh

当天晚上就发mail,给了个新ip。

服务还是不错的。

vultr 需要新创建实例,然后把旧实例数据restore过去就好。

Delphi编程注意事项—摘录收藏

 

  • 如果需要传递对象参数则放在函数参数里,这样就由调用者来创建和释放对象。
    例:[允许] function SomeOne(list:PStrList):boolean;
    当然,NewXXX之类的创建对象的函数除外。一直存在的全局对象也除外,这些全局对象将在初始化时创建,结束时释放。
    类定义中如果重载了Destory必须在里面加上inherited,否则不会释放的。
  • 使用对象(object)还是记录结构(record)。
    在有关性能方面的服务程序中:
    只产生单个实例或少于10个实例则允许使用对象。
    否则一律使用记录结构。
    在GUI方面都使用对象,但是不得超过五级继承。
    纯数据信息必须使用记录结构。
  • 错误、异常处理规则:
    1.Test,Check,Is开头的函数并不抛出异常,只检验。
    2.其他函数遇到错误或异常都要抛出异常,使用raise显式抛出,
    并且在函数文档中注明抛出异常的种类,方便使用者处理。
    3.如果需要屏蔽异常,则显式地写 try..except语句拦截。
  • 创建和释放
    在什么情况下使用free,什么情况下使用freeandnil。
    1.free之后不再使用的函数局部变量要使用free。
    2. 全局变量或者Free后继续使用的变量要使用FreeAndNil;

【摘自】Delphi编程注意事项—转贴收藏 – henreash的专栏 – CSDN博客

justhost空间一个月的使用感受

购买justhost的空间有一个月了,现在说说使用感受。

(一)速度

当时购买justhost的原因,很大一个,是因为据说justhost是国内访问最快的美国空间,试着访问了一下其他的空间,好像也确实是比较可以接受的,ping值一般在200ms左右。实际上,我使用了,这么久以来,偶尔还是有波动的,比如说,刚开通的第二天,我ping的时候,竟然达到了450ms,我愤然要求客服给我换主机~~可是,客服给我的回答竟然是:交钱升级……
我晕死了。还好,没多久,大概半天不到吧,速度就回升了,ping值在230ms左右,ftp上传速度可以达到5M/s,我公司的网速还是不错的,峰值可以达到8M/s。

速度方面,除了偶尔会在傍晚时分,ping值偏高,访问有点延迟,其他时候,ping值都是稳定在200ms左右。上传下载速度基本上没啥限制的。

不好说速度是快还是不快,个人感觉国外空间有这个速度应该不错了,当然跟Google之类的比,那就没的比了。

(二)价格

购买的是2年的,$2.95/m,两年总共是$70多点,合人民币500块不到。算起来也是便宜的了,看美国的主机,好像就就一家比这个便宜的。使用的paypal付款的,还是方便。

这个可是无限流量,无限空间,附送一个免费域名。

ps:如果使用自己的域名注册,可在以后Email:support@justhost.com联系,提交要注册的域名即可。

(三)方便

安装wordpress,终于享受到了自动更新,自动安装插件的优越性。以前用的免费空间,没一个可以正常更新wordpress和插件的,总是会提示找不到wp-content,或者是找不到wordpress安装目录。现在终于可以了,要安装插件,直接搜索,install,activate,一切方便,快捷。

cpanel管理,都很方便的啦,添加域名、绑定域名,在线文件管理,等等。

Delphi tip#50: to execute a program and wait a result

How can I execute a program and have my code wait until it is finished?

The next procedure allows you to execute a program and to wait until it’s finished:

function WinExecAndWait32(FileName: string; Visibility: Integer): dWord;
var
  zAppName: array[0..512] of Char;
  zCurDir: array[0..255] of Char;
  WorkDir: string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  StrPCopy(zAppName, FileName);
  GetDir(0, WorkDir);
  StrPCopy(zCurDir, WorkDir);
  FillChar(StartupInfo, Sizeof(StartupInfo), #0);
  StartupInfo.cb := Sizeof(StartupInfo);

  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil,
           zAppName, { pointer to command line string }
           nil, { pointer to process security attributes }
           nil, { pointer to thread security attributes }
           false, { handle inheritance flag }
           CREATE_NEW_CONSOLE or { creation flags }
           NORMAL_PRIORITY_CLASS,
           nil, { pointer to new environment block }
           nil, { pointer to current directory name }
           StartupInfo, { pointer to STARTUPINFO }
           ProcessInfo) then
    Result := -1 { pointer to PROCESS_INF }
  else
  begin
    WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfo.hProcess, Result);
    CloseHandle(ProcessInfo.hProcess);
    CloseHandle(ProcessInfo.hThread);
  end;
end;

Delphi tip#50: to execute a program and wait a result

Delphi tip#48: CRC32 calculation

 

Algorithm of CRC32 calculation for file

If you need calculate a CRC32 for some file or some string, then you must do:
1. build a CRC table
2. calculate a CRC for each line of your file
3. calculate a total CRC
1. CRC table creation:

type
  Long = record
    LoWord: Word;
    HiWord: Word;
  end;

const
  CRCPOLY = $EDB88320;

var
  CRCTable: array[0..512] Of Longint;

procedure BuildCRCTable;
var
  i, j: Word;
  r: Longint;
begin
  FillChar(CRCTable, SizeOf(CRCTable), 0);
  for i := 0 to 255 do
  begin
    r := i shl 1;
    for j := 8 downto 0 do
      if (r and 1) <> 0 then
        r := (r Shr 1) xor CRCPOLY
      else
        r := r shr 1;
    CRCTable[i] := r;
   end;
end;

继续阅读

the network is available or not

判断电脑是否联网:

#41:PC is connected to a network or not

If you want to know if the PC is connected to a network under MS Windows then you can call a GetSystemMetrics() function (Windows API) with SM_NETWORK parameter:

if (GetSystemMetrics(SM_NETWORK) AND $01 = $01) then
    <PC is attached to network>
else
    <PC is not attached to network>

Best delphi site–来自board4all的整理,推荐

原帖见:Best delphi site? – Board4All

http://www.board4all.cz/

主要是各种控件下载,破解版,源码等,rs,hotfile下载,寻找最新破解组件的最佳去处。推荐

http://delphi.about.com/

主要讨论编程技巧,方法,有不少的技巧集合,综合等,也是学习Delphi的好地方。推荐

components

http://www.torry.net/ 组件,历史悠久了。

http://www.sourcecodeonline.com/sources/delphi.html

组件和控件列表,集中了不少开源和不开源的组件

http://www.koders.com/zeitgeist/delphi/

多种语言的控件,主要是可以看到源码

http://stackoverflow.com/questions/tagged/delphi

stackoverflow.com不用多介绍了吧,问答型的

http://delphibasics.co.uk/

delphi语言基础,类型,过程,语法等,例子很详细,推荐

http://www.scalabium.com/index.html

提供一个smcomponents免费控件,还有smimport和smexport等收费控件,好像都是数据库相关的多。

另外,有个Delphi的faq和tips,都很不错的,可以看看。

http://www.delphidabbler.com/tips

不只有tips,还提供了一个codesnips,就是代码片段管理器,另外,还有不少的有用,开源的控件和单元。

推荐

 

http://www.delphi3000.com

历史悠久了。

http://www.delphiforfun.org    (the best in algorithms)

算法相关的比较多,可以找到经典的大整数等的实现例子,还有相应源码。推荐

http://www.gtdelphicomponents.gr

几个Delphi控件和程序