Skip to content

Instantly share code, notes, and snippets.

@ihipop
ihipop / Coreseek-4.1beta-gcc4.7+.patch
Created July 27, 2015 04:55
Patch for Sphinx/Coreseek 4.1 beta on Ubuntu14.04 LTS (gcc4.7+)
diff -ruN coreseek-4.1-beta/csft-4.1/buildconf.sh coreseek-4.1-beta.p0/csft-4.1/buildconf.sh
--- coreseek-4.1-beta/csft-4.1/buildconf.sh 2011-10-07 20:08:56.000000000 +0800
+++ coreseek-4.1-beta.p0/csft-4.1/buildconf.sh 2015-07-22 15:35:21.268304991 +0800
@@ -2,5 +2,5 @@
autoheader \
&& aclocal \
-&& automake --foreign \
+&& automake --add-missing --foreign \
&& autoconf
@ihipop
ihipop / decrypt 大众点评 POI with Python3
Created January 4, 2016 07:54
大众点评坐标解密样例代码
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
class test(object):
def base36encode(self,number):
"""Converts an integer into a base36 string."""
# From https://gist.github.com/kfr2/4287546
import string
ALPHABET = string.digits+string.ascii_lowercase
@ihipop
ihipop / getphone.sh
Last active February 2, 2016 09:47
中国电信在线选号测试
#!/bin/bash
#=====================Config======================
mainLog=phone.log
filterLog=phone.filter.log
maxTries=100
#=====================Config======================
function fetch {
curl -Ss --request GET \
--url 'http://js.189.cn/nmall/shop/number/queryNumber.json?areaId=16&areaCode=0510&numberHead=&showCount=50&isFour=&matchNum=&numberFee=-1&numberFlag=1' \
@ihipop
ihipop / IIS7 配置web.config使用重定向来规范主机域名 自适应HTTP HTTPS协议.md
Created June 12, 2016 04:03
IIS7 配置web.config使用重定向来规范主机域名 自适应HTTP/HTTPS协议 ///// IIS7 web.config Redirct to a Canonical Host Name with correct HTTP/HTTPS scheme
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WWW Redirect Right property" stopProcessing="true">
                    <match url=".*"/>
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.xxx\.cn$" negate="true" />
 
@ihipop
ihipop / awk中的时间处理例子.md
Last active November 4, 2016 09:15
awk中的时间处理例子

条件: 样本数据expr.txt列数未知 第一列是年份日期,第二列是时间,要求把第一二列整体代表的所在日期时间提前7583580秒(大约87.7天) 其他列原样输出

$ cat expr.txt 
2016-11-04 12:03 1478232180 col2 col2 col3
2016-08-08 17:30 1470648600 col2 none

例子如下

$ awk '{gsub(/-/," ",$1 );gsub(/:/," ",$2);d=$1" "$2" 00";d=mktime(d);d=d + 7583580;d=strftime("%Y-%m-%d %H:%M",d);out="";for (i=3;i&lt;=NF;i++){out=out" "$i};print d" "out }' expr.txt 
@ihipop
ihipop / phpbrew install 5.3.29 practise.md
Last active January 10, 2017 03:00
phpbrew install 5.3.29 practise
apt-get install build-essential autoconf
apt-get install libxml2-dev libevent-dev libgmp-dev libmysqlclient-dev libgd-dev libssl-dev libpng12-dev libjpeg-dev libbz2-dev libicu-dev libmcrypt-dev libreadline-dev libxslt-dev libltdl-dev libpq-dev libcurl4-openssl-dev libvmime-dev
ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
phpbrew install 5.3.29 +default+dbs +gd +fpm +pdo +curl +json +hash +mbstring +fileinfo +soap +session +opcache +imap +readline +iconv

then vim /etc/rc.loal replace #!/bin/sh -e to #!/bin/bash -e in it,then add:

@ihipop
ihipop / delayRun
Last active February 16, 2017 09:30
delay run Command at random but certain time period without sleep in crontab
#!/bin/bash
#receive command
#you neet atd daemon to do this
cmd="$*"
echo $cmd
[[ $cmd == "" ]] && { echo 'Command Can Not be Empty' ; exit 1; }
command -v at >/dev/null 2>&1 || { echo "I require 'at command' but it's not installed. Aborting." >&2; exit 1; }
#set how many minutes to delay
range=2-350
echo 'sleep ' $(shuf -i 1-60 -n 1) ';' $cmd |at now + $(shuf -i $range -n 1) min
@ihipop
ihipop / grok.md
Last active March 21, 2017 02:59
Logstash grok Patterns
NGINXACCESS_WITH_FORWARD_HOST %{IPORHOST:remote_addr}(\:%{INT:remote_port})? - %{USERNAME:remote_user} \[%{HTTPDATE:time_local}\] "(?:%{WORD:method} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:rawrequest})" %{INT:status} %{INT:bytes_sent} %{QS:http_referer} %{QS:http_user_agent} %{QS:http_x_forwarded_for} "%{IPORHOST:http_host}"

this works for

10.88.1.12 - - [07/Jan/2017:12:13:33 +0800] "GET / HTTP/1.1" 200 21783 "http://example.com/refererUrl" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36" "1.2.3.4,4.5.6.7" "www.example2.com" 
10.88.1.12:8123 - - [07/Jan/2017:12:13:33 +0800] "GET / HTTP/1.1" 200 21783 "http://example.com/refererUrl2" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36" "1.2.3.4,4.5.6.7" "www.example3.com" 
@ihipop
ihipop / phantomjs CJK Font.md
Last active May 9, 2017 08:10
phantomjs CJK Font
apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming xfonts-wqy ttf-mscorefonts-installer \
fonts-noto-cjk

IN Ubuntu 16.04 LTS

@ihipop
ihipop / touchpad_toggle.sh
Last active January 24, 2018 08:08
热键开关触摸板 touchpad_toggle
#!/bin/bash
#touchpad_toggle.sh
action=${1:-'auto'}
#echo $action;
declare -i ID
ID=`xinput list | grep -Eio '(touchpad|glidepoint)\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
declare -i STATE
if [ "$action" == "off" ];then
STATE=1;
elif [ "$action" == "on" ];then