Skip to content

Instantly share code, notes, and snippets.

View hzlzh's full-sized avatar
🎯
Focusing

hzlzh hzlzh

🎯
Focusing
View GitHub Profile
@hzlzh
hzlzh / hzlzh.itermcolors
Created November 10, 2011 02:04
iTerm2 colors config by hzlzh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.20000000298023224</real>
<key>Green Component</key>
<real>0.20000000298023224</real>
@hzlzh
hzlzh / .bash_profile
Created November 10, 2011 02:07
iTerm highlight config
# using color
export CLICOLOR=1
# \h:\W \u\$
export PS1='\[\033[01;33m\]\u@\h\[\033[01;31m\] \W\$\[\033[00m\] '
# grep
alias grep='grep --color=always'
@hzlzh
hzlzh / .htaccess
Created November 23, 2011 02:37
Htaccess file 301
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^tag=(.+) [NC]
RewriteRule blog/$ http://www.xxx.com/tag/%1/? [NC,L,R=301]
RewriteRule blog/bid/(.*)/(.*)$ http://www.xxx.com/$2 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.yyy.com [OR]
RewriteCond %{HTTP_HOST} ^yyy.com [NC]
RewriteRule ^(.*)$ http://www.xxx.com/ [L,R=301]
</IfModule>
@hzlzh
hzlzh / purchase.js
Created December 2, 2011 02:52
Discount function of TextMate
pluralise_licenses: function() {
var qty = Math.abs($("input_quantity").value);
if (qty == 1) {
$("license_pluralism").innerHTML = 'license (' + this.price(39) + ')'
} else if (qty > 1) {
var discount = 0;
if (qty >= 15) { discount = 30 }
else if (qty >= 10) { discount = 25 }
else if (qty >= 4) { discount = 20 }
var eur = Math.round(qty * 39 * (100 - discount) / 100);
@hzlzh
hzlzh / gist:1441678
Created December 7, 2011 06:13
Code for call Show-Useragent function
<?php
if (function_exists("CID_init")) {
CID_print_comment_flag(); echo ' ';CID_print_comment_browser();
}
?>
@hzlzh
hzlzh / gist:1441823
Created December 7, 2011 07:12
Generate ip-to-country.bin file from ip-to-country.cvs
# use for WordPress Plugin: Show Useragent
# https://github.com/hzlzh/Show-Useragent
wget http://files.firestats.cc/ip2c/ip2c-2.0.0.zip
unzip ip2c-2.0.0.zip
cd ip2c
wget http://software77.net/geo-ip/?DL=1 -O IpToCountry.csv.gz
gunzip IpToCountry.csv.gz
java -jar ip2c.jar -c IpToCountry.csv IpToCountry.bin
ls -sSh
@hzlzh
hzlzh / catch-site-meta.php
Created December 8, 2011 02:35
Catch sites' meta description with SSH
<?php
$filename='src.txt';
$str=file_get_contents($filename);
$arr=explode("\n",$str);
$file = fopen("result.txt","w");
$count = 1;
foreach($arr as $row){
$html = @file_get_contents($row);
@hzlzh
hzlzh / gist:1480814
Created December 15, 2011 11:42
WordPress <Title> with categorys and tags
<?php
<title><?php
// Logic of printing the <title> tag
global $page, $paged;
echo trim(wp_title( '', false, 'right' ));
global $post;
$post_tags = wp_get_post_tags($post->ID);
$numItems = count($post_tags);
$i = 0;
@hzlzh
hzlzh / functions.php
Created December 16, 2011 09:21
Bit.ly URL for WordPress Posts
<?php
//create bit.ly url
function bitly()
{
//login information
$url = get_permalink(); //generates wordpress' permalink
$login = '****'; //your bit.ly login
$apikey = 'R_***'; //bit.ly apikey
$format = 'json'; //choose between json or xml
$version = '2.0.1';
@hzlzh
hzlzh / GitHub-Shop-Group-Purchase.md
Created February 22, 2012 06:25
GitHub Shop Group Purchase

#GitHub Shop Group Purchase ###By:@[hzlzh] 活动地址:http://shop.github.com/
V2EX:[http://www.v2ex.com/t/27492][V2EX]

##活动经验提炼:(写给今后可能的,别的组织者)

  • 仅此一次,本人不会再组织GitHub团了,如果只买贴纸可以考虑。因为瓷器和玻璃制品易碎,在快递行业中和iPad属于一个级别的易损坏品。申通和圆通这类的会拒发,而且不能保价。 (来源于SF快递员)
  • 如果有人要买GitHub Shop中的东西,依然建议另寻组团购买,原因如下:
  1. 组团官方使用大箱子发送到中国,这期间会很安全,你想想,会有那个快递员疯了去扔大箱子?(快递的分发是空抛这种扔来扔去的这个是快递行业内部无法避免的),一个小盒子过来中国,八成会碎,先走UPSP然后是国内邮政平邮
  2. 美国->中国 邮费 $20或$30两个档次,差不多¥100多邮费,比有些东西还贵,如果几个朋友一起,何乐而不为?