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 / short_to_gnd.md
Last active Dec 19, 2016
2N3904 NPN transistor circuit to short a pin to GND.
View short_to_gnd.md

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

schematics

Also see reference

@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 / 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 / timatic.py
Last active Nov 19, 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 / ls_filesize_name.sh
Created Aug 4, 2015
Print file size and name
View ls_filesize_name.sh
$ ls -ls | awk '{print $7,$11}'
@hezhao
hezhao / quickselect.cpp
Created May 29, 2015
Find the kth smallest element in an unordered list.
View quickselect.cpp
//
// 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
Example of shared data with multiple threads in C++
View multithreading.cpp
#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 Aug 29, 2015
Copy every nth file and show progress bar
View advanced_copy.sh
# 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 Aug 29, 2015
Check the architectures of a library
View arch.sh
# 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 Aug 29, 2015
Build OpenCV static libraries from source using cmake
View opencv_cmake.sh
# 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
You can’t perform that action at this time.