Skip to content

Instantly share code, notes, and snippets.

@hivefans
hivefans / watchfile.py
Last active March 17, 2020 02:03
监控目录文件读写|-|{"files":{"watchfile2.py":{"env":"plain"},"watchfile.py":{"env":"plain"}},"tag":"Uncategorized"}
#!/usr/bin/python
import sys, os, glob, time
from stat import *
class WatchedFile:
def __init__(self, path, inode, length):
self.path = path
self.inode = inode
self.length = length
@hivefans
hivefans / hgetall.go
Last active March 17, 2020 02:03 — forked from vireshas/hgetall.go
hgetall from go using redigo|-|{"files":{"hgetall.go":{"env":"plain"}},"tag":"bigdata"}
values, err := redis.String(c.Do("HGETALL", queue_id, "result"))
if err != nil {
fmt.Println("HGETALL", err)
}
for i := 0; i < len(values); i += 2 {
key, _ := redis.String(values[i], nil)
value, _ := redis.String(values[i+1], nil)
fmt.Println(" %s: %s", key, value)
@hivefans
hivefans / md5-example.go
Last active March 17, 2020 02:03 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.|-|{"files":{"md5-example.go":{"env":"plain"}},"tag":"bigdata"}
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@hivefans
hivefans / sarama_produce_test_with_timestamp.go
Last active March 17, 2020 02:03 — forked from niels-s/sarama_produce_test_with_timestamp.go
|-|{"files":{"sarama_produce_test_with_timestamp.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"log"
"os"
"time"
"github.com/Shopify/sarama"
)
@hivefans
hivefans / kafka_quick_hack.go
Last active March 17, 2020 02:04 — forked from hackintoshrao/kafka_quick_hack.go
A quick hack to get the Golang kafka driver to publish to "test" topic created from the quick start guide here http://kafka.apache.org/documentation.html#quickstart|-|{"files":{"kafka_quick_hack.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"github.com/Shopify/sarama"
"crypto/tls"
"crypto/x509"
"encoding/json"
"flag"
"fmt"
@hivefans
hivefans / config.go
Last active March 17, 2020 02:03 — forked from nl5887/config.go
|-|{"files":{"main.go":{"env":"plain"},"config.yaml":{"env":"plain"},"config.go":{"env":"plain"}},"tag":"Uncategorized"}
package honeycast
import (
"io/ioutil"
"regexp"
"github.com/imdario/mergo"
"gopkg.in/yaml.v2"
)
@hivefans
hivefans / golang_job_queue.md
Last active March 17, 2020 02:03 — forked from harlow/golang_job_queue.md
Job queues in Golang|-|{"files":{"worker_standalone.go":{"env":"plain"},"golang_job_queue.md":{"env":"plain"},"worker_refactored.go":{"env":"plain"},"worker_original.go":{"env":"plain"}},"tag":"Uncategorized"}
@hivefans
hivefans / shell_output.go
Last active September 30, 2025 15:03
get the realtime output for a shell command in golang|-|{"files":{"shell_output.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
@hivefans
hivefans / citycode.txt
Last active January 16, 2026 06:21
城市编码列表|-|{"files":{"citycode.txt":{"env":"plain"},"citycode.xml":{"env":"plain"}},"tag":"Uncategorized"}
101010100=北京
101010200=海淀
101010300=朝阳
101010400=顺义
101010500=怀柔
101010600=通州
101010700=昌平
101010800=延庆
101010900=丰台
101011000=石景山
@hivefans
hivefans / SimpleHTTPServerWithUpload.py
Last active March 17, 2020 02:04 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload|-|{"files":{"SimpleHTTPServerWithUpload.py":{"env":"plain"}},"tag":"bigdata"}
# !/usr/bin/env python
# coding=utf-8
# http://my.oschina.net/leejun2005/blog/71444
"""
简介:这是一个 python 写的轻量级的文件共享服务器(基于内置的SimpleHTTPServer模块),
支持文件上传下载,只要你安装了python(建议版本2.6~2.7,不支持3.x),
然后去到想要共享的目录下,执行:
python SimpleHTTPServerWithUpload.py
或者 python SimpleHTTPServerWithUpload.py filename
"""