Skip to content

Instantly share code, notes, and snippets.

View alswl's full-sized avatar

Jingchao alswl

View GitHub Profile
@alswl
alswl / README.md
Last active November 7, 2016 10:31
usopp, vote robot via HTTP Proxy

usage

bash usopp.sh proxy.txt

Tips

remember update proxy.txt.

@alswl
alswl / jq.py
Created August 26, 2016 07:13
simple jq call via subprocess
# coding=utf-8
import subprocess
import json
import os
import time
JQ_BIN_LINUX = '/usr/bin/jq'
JQ_BIN_MAC = '/usr/local/bin/jq'
@alswl
alswl / paste.bash
Created August 17, 2016 07:23
image paste to markdown
IMAGE_DIR=/Users/example/Dropbox/Public/upload_dropbox/temp
URL_PREFIX=http://example.qiniudn.com/upload_dropbox/temp
FILE_NAME=paste_`date '+%Y-%m-%dT%H:%M'`.png
pngpaste $IMAGE_DIR/$FILE_NAME
echo -n "![$FILE_NAME]($URL_PREFIX/$FILE_NAME)"
@alswl
alswl / gist:b9b805b45fad6429d6c731a0bc769b28
Last active June 4, 2018 15:12
crontabe for update ip
1/5 * * * * DEVICE="wlan0"; SUB_DOMAIN="eth0-pi"; BASE_DOMAIN="example.com"; DOMAIN="$SUB_DOMAIN.$BASE_DOMAIN"; DOMAIN_ID="11111111"; RECORD_ID="22222222"; TOKEN="33333,44444444444444444444444444444444"; IP=`ip addr | grep $DEVICE: -A 2 | grep inet | awk '{print $2}' | awk -F '/' '{print $1}'`; C_IP=`dig $DOMAIN | grep "^$DOMAIN" | awk '{print $5}'`; [ "$IP" = "$C_IP" ] && exit 0; [ -z $IP ] && exit 0; curl https://dnsapi.cn/Record.Modify -d "domain_id=$DOMAIN_ID&record_id=$RECORD_ID&sub_domain=$SUB_DOMAIN&record_type=A&record_line=默认&value=$IP&login_token=$TOKEN&format=json"
@alswl
alswl / toodledo_a.py
Last active June 14, 2016 12:03
toodledo_a toodledo tasks analytic script.
# coding=utf-8
import csv
import argparse
import itertools
from collections import OrderedDict
import sys
from datetime import datetime, timedelta, time
from dateutil import relativedelta
from dateutil.parser import parse
@alswl
alswl / convert_named_group_to_position_based_group.py
Created April 20, 2016 10:45
python convert_named_group_to_position_based_group
# coding=utf-8
from __future__ import print_function, unicode_literals
import re
def convert_named_group_to_position_based_group(regex, replacement):
position_based_regex = regex
position_based_replacement = replacement
named_groups = [x[3:-1] for x in re.findall(r'(\?P<[a-z_]+>)', regex)]
@alswl
alswl / read_sogou_bin.py
Created February 14, 2016 07:41
「鼠须管」导入搜狗 Bin 词库
# -*- coding: UTF-8 -*-
import sys
import struct
import codecs
PinYinDic = [
"a",
"ai",
"an",
"ang",
# coding=utf-8
import csv, codecs, cStringIO
class UTF8Recoder:
"""
Iterator that reads an encoded stream and reencodes the input to UTF-8
"""
def __init__(self, f, encoding):
self.reader = codecs.getreader(encoding)(f)
@alswl
alswl / script.py
Last active December 29, 2015 12:49
run `python script.py`
# coding=utf-8
import csv
import codecs
import cStringIO
import sys
class UTF8Recoder:
"""
@alswl
alswl / r15.R
Last active December 21, 2015 06:09
# 15. 等级丰度曲线
# 根据 name 返回 color, lty
get_line_type = function(name) {
if (length(grep('-1$', name)) > 0) {
color <- 1
} else if (length(grep('-2$', name)) > 0) {
color <- 2
} else if (length(grep('-3$', name)) > 0) {