Skip to content

Instantly share code, notes, and snippets.

View zlargon's full-sized avatar
:electron:
Focusing

Leon Huang zlargon

:electron:
Focusing
  • Boston, MA
View GitHub Profile
@zlargon
zlargon / [Javascript] Demo asynchronous programming in for-loop .js
Last active August 29, 2015 14:08
Show how to handle the asynchronous function in the for-loop. until all the function complete, then print out "all the tasks are completed"
var demo = function (num, callback) {
var counter = 0;
var checkTasksComplete = function() {
counter++;
if (counter === num) {
callback();
}
};
// Closure: create a new function with console.log(string)
@zlargon
zlargon / [HTML] Trying to change the radio's view .html
Last active August 29, 2015 14:08
Using <input> CSS style 'appearance' to change the radio's view
<!--
Try to change radio's view
Using <input> CSS style 'appearance'
But How to display the words in input label?
Reference:
http://css-tricks.com/almanac/properties/a/appearance/
-->
<!doctype html>
<html>
@zlargon
zlargon / [bash_profile] My bash_profile on OS X .sh
Last active December 29, 2017 16:39
My bash_profile.sh on OS X
# enables color in the terminal bash shell
export CLICOLOR=1
# sets up the color scheme for list
export LSCOLORS=ExFxCxDxBxegedabagacad
# enables color for iTerm
export TERM=xterm-color
export TERM="xterm-color"
@zlargon
zlargon / [stdbool.h] Test true and false with type 'bool' and 'int' .c
Last active August 29, 2015 14:09
Test true and false with type 'bool' and 'int'
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define test_bool(var) _test_bool(var, #var)
void _test_bool(bool var, const char * var_name) {
printf("%s => %d\n", var_name, var);
printf("true ? %s\n", true == var ? "YES" : "NO");
printf("false ? %s\n\n", false == var ? "YES" : "NO");
}
@zlargon
zlargon / hggit-clone.sh
Last active August 29, 2015 14:10
clone mercurial repository, and using "fast-export" to convert it into git repository
#!/bin/sh
hg_remote=$1
project_path=$2
function usage() {
echo " Usage: ./hggit-clone.sh <mercurial repository remote url> <project path>"
echo "Example: ./hggit-clone.sh https://bitbucket.org/oojah/mosquitto mosquitto"
}
# check hg_remote
@zlargon
zlargon / [Git] My Git Config .sh
Last active October 25, 2015 16:04
My Git Config on OS X
git config --global color.ui true
git config --global core.editor vim
git config --global core.quotepath false
# git alias
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.cp cherry-pick
git config --global alias.st stash
git config --global alias.sub submodule
@zlargon
zlargon / [Repo][UNIX] install repo .sh
Last active August 29, 2015 14:10
install "repo" on UNIX platform
# http://source.android.com/source/downloading.html
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/repo
chmod a+x ~/repo
sudo mv ~/repo /usr/bin/
@zlargon
zlargon / [Git] remove remote tag
Created November 27, 2014 02:04
remove remote git tag
git tag -d <tag_name>
git push origin :refs/tags/<tag_name>
@zlargon
zlargon / [JS] byteArrayToString.js
Created November 27, 2014 08:45
convert byte (integer) array to string
function byteArrayToString(arr) {
var s = "";
arr.forEach(function(i) {
s += String.fromCharCode(i);
});
return s;
}
@zlargon
zlargon / [Eclipse] xcode theme.xml
Created December 8, 2014 05:54
The Xcode Style Eclipse IDE Theme
<?xml version="1.0" encoding="utf-8"?>
<colorTheme id="11666" name="XCode - Dusk - Actual" modified="2012-10-31 16:08:07" author="mechatronic">
<searchResultIndication color="#616161" />
<filteredSearchResultIndication color="#616161" />
<occurrenceIndication color="#616161" />
<writeOccurrenceIndication color="#616161" />
<findScope color="#E0E2E4" />
<deletionIndication color="#E0E2E4" italic="true" />
<sourceHoverBackground color="#000000" />
<singleLineComment color="#41B644" />