Skip to content

Instantly share code, notes, and snippets.

@wbchn
wbchn / git-rewrite-user.md
Created February 26, 2016 09:44
Batch rewrite git commit log

批量修改git commit 记录。

git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "xxx@yyy.com" ];
    then
            GIT_AUTHOR_NAME="wb.chn";
            GIT_AUTHOR_EMAIL="wb.chn@yyy.com";
 git commit-tree "$@";
@wbchn
wbchn / python-timer-web-test.md
Created May 11, 2016 06:16
Python Timer for WEB

web framework

Base on Timer

import time
from threading import Timer

def on_time_handler(order_id=None, notify_url=None):
    """
    https://docs.python.org/2/library/threading.html#threading.Timer
 """

Notebook.1

Zeppelin: add dep

eg: add csv package,

%dep
z.reset()
z.addRepo("Spark Packages Repo").url("http://dl.bintray.com/spark-packages/maven")
z.load("com.databricks:spark-csv_2.11:1.4.0")
@wbchn
wbchn / stc12c5a-timer.c
Created May 22, 2016 11:55
STC12C5A-Timer
/* define constants */
#define FOSC 11059000L // 11.059 MHz
// #define T1MS (65536-FOSC/1000) //1ms timer calculation method in 1T mode
#define T1MS_H 0xD4
#define T1MS_L 0xCC
/* define variables */
WORD count = 1000; //1000 times counter
@wbchn
wbchn / pidgin.md
Created September 13, 2016 06:39
Install pidgin from source

Install pidgin from source

$ sudo apt-get install build-essential intltool
$ sudo wget http://sourceforge.net/projects/pidgin/files/Pidgin/2.10.12/pidgin-2.10.12.tar.bz2
$ sudo tar -xjvf pidgin-2.10.12.tar.bz2
$ cd pidgin-2.10.12
$ sudo ./configure

# configure: error: GLib 2.16.0, run below command #
$ sudo apt-get build-dep pidgin
@wbchn
wbchn / esp8266.py
Created October 27, 2016 02:34
micropython in esp8266
# using D1 mini for example:
## Firmware
'''
esptool.py --port /dev/ttyUSB0 erase_flash
make PORT=/dev/ttyUSB0 FLASH_MODE=dio FLASH_SIZE=32m deploy
minicom -D /dev/ttyUSB0 -b 115200
'''
@wbchn
wbchn / tmux-cheatsheet.markdown
Created January 23, 2017 02:08 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@wbchn
wbchn / aws_es_post.js
Created March 16, 2017 05:25
Dynamodb Stream to Elasticsearch
/*
https://aws.amazon.com/blogs/aws/amazon-elasticsearch-service-support-for-es-5-1/
*/
var AWS = require('aws-sdk');
var path = require('path');
//Object for all the ElasticSearch Domain Info
var esDomain = {
region: process.env.RegionForES,
endpoint: process.env.EndpointForES,
@wbchn
wbchn / check_timezone.py
Last active March 23, 2017 05:16
获取时区偏移,是否存在冬、夏令时切换
from datetime import datetime, timedelta
from pytz import timezone
import pytz
utc = pytz.utc
# 如果有冬令时、夏令时切换,下面两个时间的时区偏移不相同(仅针对美国来说,其他地区酌情调整)
utc_dt = datetime(2017, 3, 23, 0, 0, 0, tzinfo=utc)
utc_dt2 = datetime(2017, 1, 1, 0, 0, 0, tzinfo=utc)
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
@wbchn
wbchn / webdav.sh
Created April 7, 2017 08:27
webdav mount scripts
#!/bin/sh
[ $# -ne '4' ] && echo -e "Usage:\n bash $0 [WebDAV] [User] [Password] [MountPath]" && exit 1
WebDAV="$1"
User="$2"
Pwd="$3"
WebMount="$4"
apt-get install -y -qq davfs2 fuse-utils libneon27-gnutls
[ $? -ne '0' ] && echo "Install davfs2 fail! " && exit 1
mkdir -p "$WebMount"
rm -rf /etc/davfs2/davfs2.conf