Archive for the '技术' Category

常用中文字体的英文名

星期一, 十一月 21st, 2011
中文名 英文名 Unicode Unicode 2
Mac OS
华文细黑 STHeiti Light [STXihei] \534E\6587\7EC6\9ED1 华文细黑
华文黑体 STHeiti \534E\6587\9ED1\4F53 华文黑体
华文楷体 STKaiti \534E\6587\6977\4F53 华文楷体
华文宋体 STSong \534E\6587\5B8B\4F53 华文宋体
华文仿宋 STFangsong \534E\6587\4EFF\5B8B 华文仿宋
丽黑 Pro LiHei Pro Medium \4E3D\9ED1 Pro 丽黑 Pro
丽宋 Pro LiSong Pro Light \4E3D\5B8B Pro 丽宋 Pro
标楷体 BiauKai \6807\6977\4F53 标楷体
苹果丽中黑 Apple LiGothic Medium \82F9\679C\4E3D\4E2D\9ED1 苹果丽中黑
苹果丽细宋 Apple LiSung Light \82F9\679C\4E3D\7EC6\5B8B 苹果丽细宋
Windows
新细明体 PMingLiU \65B0\7EC6\660E\4F53 新细明体
细明体 MingLiU \7EC6\660E\4F53 细明体
标楷体 DFKai-SB \6807\6977\4F53 标楷体
黑体 SimHei \9ED1\4F53 黑体
宋体 SimSun \5B8B\4F53 宋体
新宋体 NSimSun \65B0\5B8B\4F53 新宋体
仿宋 FangSong \4EFF\5B8B 仿宋
楷体 KaiTi \6977\4F53 楷体
仿宋_GB2312 FangSong_GB2312 \4EFF\5B8B_GB2312 仿宋_GB2312
楷体_GB2312 KaiTi_GB2312 \6977\4F53_GB2312 楷体_GB2312
微软正黑体 Microsoft JhengHei \5FAE\x8F6F\6B63\9ED1\4F53 微软正黑体
微软雅黑 Microsoft YaHei \5FAE\8F6F\96C5\9ED1 微软雅黑
Office
隶书 LiSu \96B6\4E66 隶书
幼圆 YouYuan \5E7C\5706 幼圆
华文细黑 STXihei \534E\6587\7EC6\9ED1 华文细黑
华文楷体 STKaiti \534E\6587\6977\4F53 华文楷体
华文宋体 STSong \534E\6587\5B8B\4F53 华文宋体
华文中宋 STZhongsong \534E\6587\4E2D\5B8B 华文中宋
华文仿宋 STFangsong \534E\6587\4EFF\5B8B 华文仿宋
方正舒体 FZShuTi \65B9\6B63\8212\4F53 方正舒体
方正姚体 FZYaoti \65B9\6B63\59DA\4F53 方正姚体
华文彩云 STCaiyun \534E\6587\5F69\4E91 华文彩云
华文琥珀 STHupo \534E\6587\7425\73C0 华文琥珀
华文隶书 STLiti \534E\6587\96B6\4E66 华文隶书
华文行楷 STXingkai \534E\6587\884C\6977 华文行楷
华文新魏 STXinwei \534E\6587\65B0\9B4F 华文新魏

 

转:十五分钟介绍 Redis 数据结构

星期二, 十一月 1st, 2011

http://www.oschina.net/question/54100_28977

Sphinx 安装备忘

星期五, 十月 28th, 2011

以前装过一次sphinx,现在有了中文站coreseek,他们整合了中文分词,相对来说还是方便了不少,coreseek的包里除了sphinx以外还有mmseg和一个用于测试的代码包,安装还算顺利。
安装文档见这里

http://www.coreseek.cn/products-install/install_on_bsd_linux/

在安装sphinx php扩展的时候略微麻烦了一下,直接用pecl install sphinx不成功,说找不到libsphinxclient库,后来发现libsphinxclient就在coreseek-4.1-beta/testpack/api/libsphinxclient路径下,安装之。
然后还是不能用pecl方式安装,在这里 http://pecl.php.net/package/sphinx 下载了安装包,用phpize方式安装ok。

如不安装php扩展,在testpack目录里也有一php版本的sphinx class可以使用。

对于mysql的应用,先按提示修改好csft_mysql.conf里的相关参数
然后建索引
/usr/local/coreseek/bin/indexer -c etc/csft_mysql.conf –all
如果服务器已经启动,建索引是不能覆盖的,需要加入–rotate参数
/usr/local/coreseek/bin/indexer -c etc/csft_mysql.conf –all –rotate

启动服务
/usr/local/coreseek/bin/searchd -c etc/csft_mysql.conf
停止服务
/usr/local/coreseek/bin/searchd -c etc/csft_mysql.conf –stop

启动服务后,可用php进行查询。。

1
2
3
4
5
6
7
8
9
10
11
require_once ( "sphinxapi.php" );

$cl = new SphinxClient ();
$cl->SetServer ( '127.0.0.1', 9312);
$cl->SetConnectTimeout ( 3 );
$cl->SetArrayResult ( true );
$cl->SetMatchMode ( SPH_MATCH_ANY);
$res = $cl->Query ( '网络搜索', "*" );

print_r($cl);
print_r($res);

另外还有一些高级用法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//注意文件的编码格式需要保存为为UTF-8格式
require ( "sphinxapi.php" );

$cl = new SphinxClient ();
$cl->SetServer ( '127.0.0.1', 9312);
//以下设置用于返回数组形式的结果
$cl->SetArrayResult ( true );

/*
//ID的过滤
$cl->SetIDRange(3,4);

//sql_attr_uint等类型的属性字段,需要使用setFilter过滤,类似SQL的WHERE group_id=2
$cl->setFilter('group_id',array(2));

//sql_attr_uint等类型的属性字段,也可以设置过滤范围,类似SQL的WHERE group_id2>=6 AND group_id2<=8
$cl->SetFilterRange('group_id2',6,8);
*/


//取从头开始的前20条数据,0,20类似SQl语句的LIMIT 0,20
$cl->SetLimits(0,20);

//在做索引时,没有进行 sql_attr_类型 设置的字段,可以作为“搜索字符串”,进行全文搜索
$res = $cl->Query ( '搜索字符串', "*" );    //"*"表示在所有索引里面同时搜索,"索引名称(例如test或者test,test2)"则表示搜索指定的

//如果需要搜索指定全文字段的内容,可以使用扩展匹配模式:
//$cl->SetMatchMode(SPH_MATCH_EXTENDED);
//$res=cl->Query( '@title (测试)' , "*");
//$res=cl->Query( '@title (测试) @content ('网络')' , "*");


echo '<pre>';
print_r($res['matches']);
print_r($res);
print_r($cl->GetLastError());
print_r($cl->GetLastWarning());
echo '</pre>';

给字典加入新词
/usr/local/mmseg3/etc下有个unigram.txt文件
这个是字典的文本版本
加入新词需要加入两行,如
新浪微博 1
x:1
然后执行命令mmseg -u unigram.txt
将生成一个unigram.txt.lib文件,将etc目录里的uni.lib改名,并把这个文件改名为uni.lib,重新生成索引

详细一点的可以看这里

http://hi.baidu.com/cubeking/blog/item/9aedb7a67b5b95e29152ee5c.html

jQuery plugin

星期四, 九月 22nd, 2011

http://docs.jquery.com/Plugins/Authoring

how to – 用php抓取iTunes Store的搜索结果

星期六, 八月 6th, 2011

从iTunes Store中copy出来的链接无法直接在浏览器中打开,google之,有人已经用php+curl做了相关工作,只要在http header中加上一个参数即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function htmlForiTunesStoreURL($path)
// Download and return the HTML for an iTunes Store page at the given URL.
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $path);
 
    // The following header is what causes the server to think we are iTunes.app.
    // This header in particular is for the China Store.
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Apple-Store-Front: 143465-19,12'));
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $html = curl_exec($ch);
 
    return trim($html);
}

其中X-Apple-Store-Front: 143465-19,12,143465是中国的iTunes Store代码,-19,12不知道什么意思,这是用截取http封包的工具截出来的,-19的位置是语言代码,但网上搜索不到中文代码是什么,也许就是19

以下是其他国家的代码:

United States 143441
Argentina 143505
Australia 143460
Belgium 143446
Brazil 143503
Canada 143455
Chile 143483
China 143465
Colombia 143501
Costa Rica 143495
Croatia 143494
Czech Republic 143489
Denmark 143458
Deutschland 143443
El Salvador 143506
Espana 143454
Finland 143447
France 143442
Greece 143448
Guatemala 143504
Hong Kong 143463
Hungary 143482
India 143467
Indonesia 143476
Ireland 143449
Israel 143491
Italia 143450
Korea 143466
Kuwait 143493
Lebanon 143497
Luxembourg 143451
Malaysia 143473
Mexico 143468
Nederland 143452
New Zealand 143461
Norway 143457
Osterreich 143445
Pakistan 143477
Panama 143485
Peru 143507
Phillipines 143474
Poland 143478
Portugal 143453
Qatar 143498
Romania 143487
Russia 143469
Saudi Arabia 143479
Schweitz/Suisse 143459
Singapore 143464
Slovakia 143496
Slovenia 143499
South Africa 143472
Sri Lanka 143486
Sweden 143456
Taiwan 143470
Thailand 143475
Turkey 143480
United Arab Emirates 143481
United Kingdom 143444
Venezuela 143502
Vietnam 143471
Japan 143462

关于第二位数字的解释
1: English
2: English (slightly different texts)
3: French
4: German
5: French (slightly different texts)

现在可以就可以正常获得数据了,如

1
2
3
echo htmlForiTunesStoreURL(
"http://ax.search.itunes.apple.com/WebObjects/MZSearch.woa/wa/advancedSearch?startIndex=180&entity=software&media=software&page=2&restrict=true&free=1&genreIndex=10"
);

How to – install Apache, PHP and Mysql on Mac XOS

星期三, 七月 27th, 2011

本文采用的方式是使用Mac OS X 10.5.6自带的Apache和PHP,安装MySQL的dmg版本,以下操作非特殊说明均以root用户在命令行下进行。

  启用root用户

  1.打开“目录实用工具”,它位于“应用程序”文件夹的“实用工具”文件夹中。

  2.点按锁图标以进行更改。您将需要输入管理员名称和密码。

  3.选取“编辑”>“启用 Root 用户”。

  4.为 root 用户输入安全密码,然后在“验证”栏再次输入它,最后点按“好”。

  启用Apache

  Mac OS X 10.5.6自带了Apache 2.2.9,直接在命令行运行apachectl start,Apache就搞定了。

  现在Apache的主目录就是/Libary/WebServer/Documents/,你可以在这目录里放置文件测试了。

  启用PHP

  Mac OS X 10.5.6自带了PHP 5.2.6,我们需要做的就是将PHP加入Apache中。

  修改/etc/apache2/httpd.conf中的

  #loadModule php5_module libexec/apache2/libphp5.so

  为

  loadModule php5_module libexec/apache2/libphp5.so然后将/etc/php.ini.default复制为/etc/php.ini。

  cp /etc/php.ini.default /etc/php.ini之后就可以按照自己的习惯修改php.ini的配置

  比如将error_reporting = E_ALL & ~E_NOTICE

  修改为

  error_reporting = E_ALL最后,重启Apache,可以在/Libary/WebServer/Documents/目录中建立个phpinfo.php来测试了。

  apachectl restart

安装Mysql

How to – build libcurl in xcode4 for iphone

星期二, 七月 26th, 2011

Download CURL source from:http://curl.haxx.se/download.html

1
2
3
4
5
6
7
tar -xvzf curl-7.21.2.tar.gz
cd curl-7.21.2
export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.0.1
export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk"
export LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk"
export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10

By configuring with isysroot and syslibroot set the correct SDK, the CURL_SIZEOF_LONG and SIZEOF_LONG will get set to the correct value (4).
In Xcode, choose File->New Project->iOS->Library->Cocoa Touch Static Library.
Add->Existing Files (select curl’s “src” folder)
Add->Existing Files (select curl’s “lib” folder)
Remove “src/macos” folder from project. (Delete->Delete references)
Unselect Makefile and Makefile.inc checkboxes for target.
In “Build” tab search for OTHER_CFLAGS and add the following options:
-DHAVE_CONFIG_H -I/ca/dev/code/lib/curl/curl-latest/include -I/ca/dev/code/lib/curl/curl-latest/lib
Replace /ca/dev/code/lib/curl/curl-latest with the path at which you untarred the CURL source.
Build both Simulator/Release and Device/Release.
To make a universal library for both the simulator and the device, execute lipo from the command line of the Xcode project folder:

lipo -create build/Release-iphonesimulator/libcurl.a build/Release-iphoneos/libcurl.a -output libcurl.a
The last step is to add libCURL to your app by right-clicking (or option-clicking) Frameworks->Add->Add Existing Frameworks…->Other and choosing the libCURL.a file created by lipo.
In attachment You can find project and compiled lib.
the original resource – http://www.creativealgorithms.com/blog/content/building-libcurl-ios-42
Source code: Download

注意替换相应的路径
编译后的文件在
~/Library/Developer/Xcode/DerivedData/curl-aaqusppogmokgpgnggbgmkotqydh/Build/Products
(假设你的target名字是curl)
另外这里没写的
1.在search path里把curl/include加进去
2.修改build scheme,将build类型改成release

原文:http://blog.ideas-world.com/2011/03/14/building-libcurl-for-ios-4-2/(须翻墙)
还有一篇:http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/

pokeb / asi-http-request

星期日, 七月 24th, 2011

https://github.com/pokeb/asi-http-request/tree

enormego.com

星期日, 七月 24th, 2011

http://developers.enormego.com/

enormego cocoa helper

星期日, 七月 24th, 2011

https://github.com/enormego/cocoa-helpers