Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / git-pick.sh
Created November 30, 2015 06:32
Pick current commit to other branches
#!/bin/bash
# This script will pick commits from current branch(default) to other
# specified branch.
# Usage:
# git-pick.sh -<num> -- pick <num> commits start from HEAD
# git-pick.sh <commit range, etc> -- pick the correspondidng commits
# git-pick.sh -- default: pick commits
#
@lotabout
lotabout / mail-executor.py
Created December 12, 2015 12:47
for Raspberry Pi: check mail and execute (download) tasks.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# We will need 3 threads
import os
import Queue
from os.path import isfile, join
import email
import re
@lotabout
lotabout / runner.py
Last active December 18, 2015 09:33
check the network speed of a running process(actually is IO speed) and if it is slow, restart the process. (the command should support continous download)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess as sp
import time
import re
import sys
import signal
# global configuration
@lotabout
lotabout / simple_server.py
Last active December 18, 2015 10:22
A simple server based on BaseHTTPServer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from urlparse import parse_qs
PORT_NUMBER = 8000
class MyHandler(BaseHTTPRequestHandler):
@lotabout
lotabout / send-to-download.js
Last active August 12, 2022 11:33
Greasemonkey script for send content to backend localhost.
// ==UserScript==
// @name Post test
// @namespace jinzhou
// @description Post Test
// @include *
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// ==/UserScript==
@lotabout
lotabout / douban_star.py
Last active January 14, 2016 09:15
get a list of douban starred songs
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
from PIL import Image
import io
import pickle
import os
import json
import time
@lotabout
lotabout / colors.sh
Last active January 15, 2016 09:47 — forked from cyrilis/colors.sh
A ImageMagick Script Can Generate Color Palettes JSON Format.Usage: ./colors.sh IMAGE-PATH COLOR-NUMBERS eg: ./colors.sh /Users/Cyril/Downloads/photo2.jpg 10
dir="." #Set the default temp dir
tmpA1="$dir/spectrumhist_1_$$.png"
tmpB1="$dir/spectrumhist_1_$$.cache"
trap "rm -f $tmpA1 $tmpB1; exit 0" 0 #remove temp files
trap "rm -f $tmpA1 $tmpB1; exit 1" 1 2 3 15 #remove temp files
if [ $# -eq 2 ]
then
colors=$2
else
colors=8
@lotabout
lotabout / extract_color.py
Created January 15, 2016 10:24
Extract the main color(and usage) used by an image, like color thief but in python.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, argparse
from PIL import Image
from PIL.ImageDraw import Draw
import sys
def to_hash(color):
@lotabout
lotabout / crawler_dribbble.py
Created January 17, 2016 14:08
A crawler for dribbble.com
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import re
import os
import json
import logging
import traceback
@lotabout
lotabout / google-translate.py
Last active November 11, 2020 13:07
Translate texts
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# translate utility that utilize google translator, support python2 & python3
# Note that the order or arguments in the URL matters.
try:
from urllib import urlencode
except:
from urllib.parse import urlencode