Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / django_cmd.sh
Last active March 19, 2021 09:51
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 / 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 / ls_filesize_name.sh
Created August 4, 2015 19:47
Print file size and name
$ ls -ls | awk '{print $7,$11}'
@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 / multithreading.cpp
Created May 26, 2015 19:25
Example of shared data with multiple threads in C++
#include <atomic>
#include <conio.h>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;
atomic<int> data(0);
@hezhao
hezhao / advanced_copy.sh
Last active August 29, 2015 14:13
Copy every nth file and show progress bar
# http://www.tecmint.com/advanced-copy-command-shows-progress-bar-while-copying-files/
#
$ wget https://dl.dropboxusercontent.com/u/6233134/cp
$ sudo chmod +x cp
$ ./cp -gR src/*[13579].jpg dest/
@hezhao
hezhao / arch.sh
Last active August 29, 2015 14:09
Check the architectures of a library
# Linux / Mac
$ lipo -info filename.a
$ file filename.a
# Windows
$ dumpbin /rawdata:1 library.lib
$ dumpbin /headers program.exe
@hezhao
hezhao / opencv_cmake.sh
Last active August 29, 2015 14:09
Build OpenCV static libraries from source using cmake
# build static libraries for both i386 and x86_64 arch
$ mkdir build
$ cd build
$ cmake -DBUILD_SHARED_LIBS=OFF "-DCMAKE_OSX_ARCHITECTURES=i386;x86_64" ..
$ make -j8