Skip to content

Instantly share code, notes, and snippets.

@lintianzhi
lintianzhi / trans.py
Created November 9, 2012 06:55
parse Google translate for convenient query
#!/usr/bin/python
#coding=utf-8
import urllib
import urllib2
import sys
import simplejson
values_t = {'client':'t',
'hl':'zh_CN',
@lintianzhi
lintianzhi / search_domain.py
Created November 14, 2012 13:01
search availible domain name
#!/usr/bin/python
#coding=utf-8
import urllib
import urllib2
import re
import threading
import Queue
url = 'https://who.is/whois/name_search/'
@lintianzhi
lintianzhi / rect1.cpp
Created November 24, 2012 13:50
USACO:Shaping Regions
//倒序染色
#include <fstream>
using namespace std;
int a, b, n;
int llx[1001], lly[1001], urx[1001], ury[1001], color[1001];
int cut(int lx, int ly, int rx, int ry, int b)
{
if (lx==rx||ly==ry) return 0;
if (b>n)
@lintianzhi
lintianzhi / find.sh
Created November 29, 2012 14:10
some pipe use, find sed grep
# 目录下面所有文件的tab换成4个space 注意 '\t' 不是 "\t"
grep -lr '\t' . | xargs sed -i "s/\t/ /g"
# 查找 .py 结尾的文件 | 如果里面含有tab | 把文件的tab换成4个space # 其实第二个是多余的
find . -name "*.py" | xargs grep -lr '\t' | xargs sed -i "s/\t/ /g"
# <ctrl-v><tab> 可以打出一个tab
#就像 <ctrl-v><ctrl-m> 可以打出一个^M
@lintianzhi
lintianzhi / gist:4181545
Created December 1, 2012 11:10
vim set file format, dos or unix
:set fileformat=dos (unix
@lintianzhi
lintianzhi / daemonize.c
Created December 8, 2012 10:04
daemonize the program
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
int main(int argc, char *argv[])
{
int i;
pid_t pid;
if(argc < 2)
@lintianzhi
lintianzhi / double.scm
Created December 13, 2012 15:40
How to understand the result?
(define (inc x) (+ x 1))
(define (double fun) (lambda (x) (fu (fu x))))
(((double (double double)) inc) 5)
@lintianzhi
lintianzhi / fetch.go
Last active December 20, 2015 10:59
搜索一个网站内所有包含关键字的页面,并统计
package main
import (
"os"
"log"
"fmt"
"io/ioutil"
"net/http"
"regexp"
)
@lintianzhi
lintianzhi / imageView_Des.md
Last active December 20, 2015 17:49
Description of imageView

我们将 mode 看做 3 个 bits,即 mode = X Y Z,其中:

  • X = 0(表示WH - 限定宽高),1(表示LS - 限定长短边)
  • Y = 0(表示LimitOut - 限定图片恰好超出矩形),1(表示LimitIn - 限定图片不能超出矩形)
  • Z = 0(表示NoCrop - 不进行裁剪),1(表示Crop - 进行裁剪,对于 LimitIn 而言无意义)

注意

@lintianzhi
lintianzhi / build.sh
Created September 11, 2013 05:16
go build different os arch
#!/bin/bash
if [ $# -lt 1 ]; then
echo xxx
exit 0
fi
GOOS=windows
GOARCH=386
go build