Skip to content

Instantly share code, notes, and snippets.

@hezhao
hezhao / quickselect.cpp
Created May 29, 2015 00:00
Find the kth smallest element in an unordered list.
//
// http://en.wikipedia.org/wiki/Quickselect
// Quickselect
//
// Find the kth smallest element in an unordered list
//
#include <iostream>
using namespace std;
@hezhao
hezhao / ls_filesize_name.sh
Created August 4, 2015 19:47
Print file size and name
$ ls -ls | awk '{print $7,$11}'
@hezhao
hezhao / timatic.py
Last active February 10, 2024 20:32
IATA Timatic API
# 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 / django_cmd.sh
Last active May 1, 2024 07:22
Django Commands Cheatsheet
# 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 / JavaScript.sublime-settings
Last active January 4, 2018 01:01
Sublime Text 3 settings and packags
// 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 / short_to_gnd.md
Last active December 19, 2016 19:50
2N3904 NPN transistor circuit to short a pin to GND.

2N3904 NPN transistor circuit to short a pin to GND.

schematics

Also see reference

@hezhao
hezhao / heroku_cmd.sh
Last active February 6, 2017 18:15
Heroku Commands Cheatsheet
# https://devcenter.heroku.com/articles/getting-started-with-django
# Regions
$ heroku regions
$ heroku create --region eu
# Create
$ heroku create
$ git push heroku master
@hezhao
hezhao / .zshrc
Last active August 11, 2018 06:47
zsh and oh-my-zsh setup script
# 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 / alipay.html
Created March 28, 2016 03:34
支付宝生活支付按钮
<form action="https://shenghuo.alipay.com/send/payment/fill.htm" method="post" target="_blank" accept-charset="GBK" id="alipayForm">
<input name="optEmail" type="hidden" value="zph61@139.com" />
<input name="payAmount" type="hidden" value="1.00" />
<input id="title" name="title" type="hidden" value="捐赠给”前端技术分享”网站" />
<input name="memo" type="hidden" value="文章写的不错,支持站长,我来捐赠鼓励的!" />
<input name="pay" type="image" src="https://img.alipay.com/sys/personalprod/style/mc/btn-index.png" width="250" height="58">
</form>
@hezhao
hezhao / git_cmd.sh
Last active March 19, 2017 09:38
Git commands
# Create a new branch locally
$ git checkout -b [branch]
# Create and push the new branch to orign
$ git push origin [branch]
# Merge branch to master
$ git checkout master
$ git merge [branch]