Skip to content

Instantly share code, notes, and snippets.

View ferstar's full-sized avatar
🎯
Focusing

J. F. Zhang ferstar

🎯
Focusing
View GitHub Profile
@ferstar
ferstar / gist:5efc8ed0fe16beccc9e9
Last active January 23, 2016 13:41 — forked from robertmarsal/gist:9feaa9150926efa4175a
Install f.lux on Ubuntu 14.10
sudo apt-get install python-glade2 python-appindicator
git clone https://github.com/Kilian/f.lux-indicator-applet.git
cd f.lux-indicator-applet
chmod +x setup.py
sudo ./setup.py install
sudo chmod +x /usr/local/bin/xflux
fluxgui
@ferstar
ferstar / install-mongodb.sh
Created January 25, 2016 14:13 — forked from w0rldart/install-mongodb.sh
Installing MongoDB on Ubuntu 15.04
#!/bin/sh
##
## Bash install script for mongo 3.2 for Ubuntu 15.04, because of
## the replacement of upstart with systemd
##
## - AUTHOR: Alexandru Budurovici <https://w0rldart.com>
## - VERSION: 1.0
##
@ferstar
ferstar / decorator.py
Created February 18, 2016 09:57
廖雪峰博客 Python3 教程练习
'''装饰器
在函数调用的前后打印出'begin call'和'end call'的日志;
即支持@log又支持@log('xxx')的调用
'''
import functools
def log(arg):
def decorator(func=arg):
@ferstar
ferstar / AESCipher.py
Last active March 1, 2016 08:38 — forked from swinton/AESCipher.py
Encrypt & Decrypt using PyCrypto AES 256From http://stackoverflow.com/a/12525165/119849
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
class AESCipher(object):
"""
A classical AES Cipher. Can use any size of data and any size of password thanks to padding.
@ferstar
ferstar / flask-upload
Created March 18, 2016 05:56 — forked from dAnjou/flask-upload
Flask upload example
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess www user=max group=max threads=5
WSGIScriptAlias / /home/max/Projekte/flask-upload/flask-upload.wsgi
<Directory /home/max/Projekte/flask-upload>
WSGIProcessGroup www
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
@ferstar
ferstar / install-2.17.sh
Created June 28, 2016 07:19
debian version of bcl2fastq without examples
sudo apt-get update
wget http://support.illumina.com/content/dam/illumina-support/documents/downloads/software/bcl2fastq/bcl2fastq2-v2.17.1.14-Linux-x86_64.rpm
sudo apt-get install alien --assume-yes
sudo alien bcl2fastq2-v2.17.1.14-Linux-x86_64.rpm
sudo dpkg -i bcl2fastq2_0v2.17.1.14-2_amd64.deb
@ferstar
ferstar / gist:71179b2e90e48d2a022da5dbef5e1199
Last active June 14, 2017 05:40 — forked from mjg59/gist:ab1e9a6e60ef96ca9565ae09690a396b
Running fine on Windows 10 x64 & Python 3.5.2 but nothing happened.
#!/usr/bin/python
import subprocess
import socket
import sys
def encode_packet(data):
output = bytearray()
for i in range(0, len(data)):
@ferstar
ferstar / color_msg.sh
Last active June 26, 2017 03:31
color bash prompt with timestamp ahead
#!/bin/bash
color_msg() {
if [ $# -gt 2 ]; then
echo -e "\033[1;31mUsage: ${0} [error|-e|info|-i|warn|-w] "your message".\033[0m"
fi
now_time=$(date '+[%Y/%m/%d %H:%M:%S]')
case ${1} in
# red
error|-e )
echo -e "${now_time}\t\033[1;31m${2}\033[0m"
@ferstar
ferstar / kk_change_ip.sh
Created June 20, 2017 03:08
change switch ip when it changes
#!/bin/sh
PATH=/usr/bin:/sbin:/bin
SW_FILE=/www/switches.json
NOW_IP=$(ifconfig wlan0 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
OLD_IP=$(jq -r '.switches[0].ip' ${SW_FILE})
if [ ${NOW_IP} != ${OLD_IP} ]; then
echo "ip changes detected, I'll update the ${SW_FILE}"
jq --arg v ${NOW_IP} '.switches[0].ip=$v' ${SW_FILE} > /tmp/tmp.json
@ferstar
ferstar / code_highlight_addon.py
Last active April 8, 2018 15:09
fix an anki plugin bugs which was called "Syntax Highlighting for Code"
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import codecs
import os
import sys
from aqt import editor, addons, mw