Skip to content

Instantly share code, notes, and snippets.

View cloudaice's full-sized avatar
:octocat:

项超 cloudaice

:octocat:
  • Bytedance
  • Hangzhou China
View GitHub Profile
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
"os"
"runtime"
"sync"
"time"
)
@cloudaice
cloudaice / for.go
Created April 29, 2014 12:38
测试CPU使用情况
package main
import (
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
forfunc := func() {
@cloudaice
cloudaice / md5_example.go
Created April 29, 2014 12:41
Golang use md5 lib
package main
import (
"crypto/md5"
"fmt"
"time"
)
var secret string
@cloudaice
cloudaice / translate_google.py
Created February 7, 2012 08:41
a python program to translate
#coding=utf-8
# trans.py
# create :2010-6-2
# last modify: 2010-6-3
# author : ice_cube
import urllib,urllib2
from sgmllib import SGMLParser
class URLLister(SGMLParser):
@cloudaice
cloudaice / .vimrc
Created February 7, 2012 08:38
vim configure file
"设置TAB键为4个空格
set tabstop =4
"显示行号
set number
"关闭vi兼容模式
set nocompatible
"自动语法高亮
syntax enable
syntax on
@cloudaice
cloudaice / fab.py
Created February 7, 2012 08:48
python multi-thread
# -*- coding: utf-8 -*-
from myThread import MyThread
from time import ctime
from time import sleep
import sys
def fib(x):
# sleep(0.005)
if x<2:return 1
return (fib(x-2) + fib(x-1))
@cloudaice
cloudaice / tree.html
Created February 11, 2012 07:12
tree use js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>this rose</title>
<meta charset="utf-8">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1948154-1']);
_gaq.push(['_trackPageview']);
@cloudaice
cloudaice / rose.html
Created February 11, 2012 07:14
rose use js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>this is rose</title>
<meta charset="utf-8">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1948154-1']);
_gaq.push(['_trackPageview']);
var check = require('validator').check,
sanitize = require('validator').sanitize
//Validate
check('test@email.com').len(6, 64).isEmail(); //Methods are chainable
check('abc').isInt(); //Throws 'Invalid integer'
check('abc', 'Please enter a number').isInt(); //Throws 'Please enter a number'
check('abcdefghijklmnopzrtsuvqxyz').is(/^[a-z]+$/);
@cloudaice
cloudaice / how to use diff
Created February 26, 2012 12:41
linux下面的文本比较命令diff使用
一、文本文件比较命令diff
1>diff命令的功能
Linux中diff命令的功能为逐行比较两个文本文件,列出其不同之处。它对给出的文件进行系统的检查,并显示出两个文件中所有不同的行,不要求事先对文件进行排序。
2>语法
diff [options] file1 file2
该命令告诉用户,为了使两个文件file1和file2一致,需要修改它们的哪些行。如果用”-”表示file1或file2,则表示标准输入。如果file1或file2是目录,那么diff将使用该目录中的同名文件进行比较。