Skip to content

Instantly share code, notes, and snippets.

@iCoolchar
iCoolchar / plt_example.py
Created July 25, 2017 02:50
Python Data Visualizations
# 图片 https://www.kaggle.com/benhamner/python-data-visualizations/notebook
# First, we'll import pandas, a data processing and CSV file I/O library
import pandas as pd
# We'll also import seaborn, a Python graphing library
import warnings # current version of seaborn generates a bunch of warnings that we'll ignore
warnings.filterwarnings("ignore")
import seaborn as sns
import matplotlib.pyplot as plt
t := time.Unix(1362984425, 0)
nt := t.Format("2006-01-02 15:04:05")
fmt.Println(nt)
@iCoolchar
iCoolchar / angular_delete.js
Created April 25, 2017 09:20
angular delete on row and take effect at once
var idx = $scope.adverts.indexOf(adv);
if (idx > -1) {
$scope.adverts.splice(idx, 1);
}
notify("删除成功!")
@iCoolchar
iCoolchar / mongo_bulk.go
Created April 25, 2017 09:18
bulk insert
for _, module := range moduleList {
mongodb.ExecBulk(mongodb.GetMgoSession(), DiscoveryOrderTable, func(bulk *mgo.Bulk) {
bulk.Insert(module)
})
}
@iCoolchar
iCoolchar / gracehttp.go
Last active April 25, 2017 09:12
graceful restart
package main
import (
"flag"
"fmt"
"linkedin/bootstrap"
config_handler "linkedin/handler/config"
"linkedin/log"
"linkedin/middleware"
"linkedin/xlnt/handler/experiment"
@iCoolchar
iCoolchar / http_request.go
Last active April 25, 2017 09:12
read http request body
client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
res, err := client.Do(req)
bodyBytes, _ := ioutil.ReadAll(res.Body)
fmt.Println("body is", string(bodyBytes))
@iCoolchar
iCoolchar / file_example.go
Last active March 7, 2017 07:20
read file in go
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func main() {
@iCoolchar
iCoolchar / jieba_example.go
Created March 6, 2017 07:19
jieba example in go
func main() {
serv := bootstrap.Service(make(map[string]bool))
serv.DefaultInit()
//serv.EnableESRedis()
bootstrap.Init(serv)
var seg jiebago.Segmenter
seg.LoadDictionary("/Users/xiuchen/Projects/chitu/html/relevance_share/dict_jieba.txt")
@iCoolchar
iCoolchar / ip.go
Created February 26, 2017 13:09
Golang ip to int
func IP4toInt(IPv4Addr string) int64 {
IPv4Int := big.NewInt(0)
IPv4Int.SetBytes(net.ParseIP(IPv4Addr).To4())
return IPv4Int.Int64()
}