Skip to content

Instantly share code, notes, and snippets.

hezhao

Block or report user

Report or block hezhao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hezhao
hezhao / django_cmd.sh
Last active Sep 28, 2019
Django Commands Cheatsheet
View django_cmd.sh
# Use Python 3 for easy unicode
$ virtualenv -p python3 .env
$ source .env/bin/activate
$ pip install django
$ deactivate
# Start new django project and app
$ django-admin.py startproject mysite
$ ./manage.py migrate
$ ./manage.py createsuperuser
@hezhao
hezhao / supervisor.conf
Last active Sep 26, 2019
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
View supervisor.conf
[program:myapp]
autostart = true
autorestart = true
command = python /home/pi/myapp.py
environment=SECRET_ID="secret_id",SECRET_KEY="secret_key_avoiding_%_chars"
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
@hezhao
hezhao / timatic.py
Last active Aug 26, 2019
IATA Timatic API
View timatic.py
# API
GULF_AIR = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&VISA=&page=visa&PASSTYPES=PASS&NA=CN&AR=00&DE=US&user=STAR&subuser=STARB2C'
STAR_ALLIANCE = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&VISA=&page=visa&PASSTYPES=PASS&NA=CN&AR=00&DE=US&user=GF&subuser=GFB2C'
KLM = 'https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?SpecData=1&HEALTH=1&VISA=1&NA=AT&EM=AT&DE=AU&PASSTYPES=PASS&user=KLMB2C&subuser=KLMB2C'
# Web
AIR_BIRLIN = 'http://www.timaticweb.com/cgi-bin/login_website.cgi?user=MALLORCA&subuser=ABCUST&password=SHUTTLE'
EMIRATES = 'http://www.emirates.com/english/plan_book/essential_information/visa_passport_information/find_visa_requirements/visa_passport_information_results.aspx?NC=AR&NV=Argentina&DC=AT&DV=Austria&h=79fb1336bcc87035c550b97e3825699d8667b952'
@hezhao
hezhao / twitter_pin_auth.py
Created Feb 12, 2013
Twitter PIN-based authorization using tweepy
View twitter_pin_auth.py
### See PIN-based authorization for details at
### https://dev.twitter.com/docs/auth/pin-based-authorization
import tweepy
consumer_key=<your_app_consumer_key>
consumer_secret=<your_app_consumer_secret>
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@hezhao
hezhao / timelapse.sh
Created Feb 8, 2017
Create timelapse video from images with ffmpeg
View timelapse.sh
$ ffmpeg -framerate 60 -pattern_type glob -i 'output/*.jpg' out.mp4
@hezhao
hezhao / .zshrc
Last active Aug 11, 2018
zsh and oh-my-zsh setup script
View .zshrc
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="gitster"
# Uncomment the following line to use case-sensitive completion.
@hezhao
hezhao / JavaScript.sublime-settings
Last active Jan 4, 2018
Sublime Text 3 settings and packags
View JavaScript.sublime-settings
// Packages/User/JavaScript.sublime-settings
// Packages/User/HTML.sublime-settings
// Packages/User/CSS.sublime-settings
{
"tab_size": 2,
"translate_tabs_to_spaces": true
}
@hezhao
hezhao / config.cson
Last active Sep 26, 2017
Atom config
View config.cson
"*":
"autocomplete-python":
extraPaths: "$PROJECT/build/sos/venv/lib/python2.7/site-packages/"
pythonPaths: "$PROJECT/build/sos/venv/bin/python"
useKite: false
useSnippets: "all"
core:
themes: [
"one-dark-ui"
"atom-dark-syntax"
@hezhao
hezhao / lcd_i2c.ino
Created Mar 24, 2014
YwRobot LCM1602 IIC V1 20x4 LCD Display with PCF8574T
View lcd_i2c.ino
// See http://forum.arduino.cc/index.php?topic=158312.0
// NewLiquidCrystal library
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Define I2C Address for the PCF8574T
@hezhao
hezhao / pdfjam.sh
Last active Mar 30, 2017
Print a PDF to N-up
View pdfjam.sh
wget http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic/firth/software/pdfjam/pdfjam_latest.tgz
cp pdfjam.conf ~/.pdfjam.conf
# pdflatex='/Library/TeX/texbin/pdflatex'
# paper='letterpaper'
./pdfjam --fitpaper true --nup 2x2 --delta '1mm 1mm' --scale 1.0 input.pdf --outfile output-4up.pdf
You can’t perform that action at this time.