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 / [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 / [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 / [Swift] using swift command line.md
Last active August 29, 2015 14:12
Using Swift command line
@zlargon
zlargon / [C] Pointer Tutorial.c
Created April 30, 2015 03:02
C 指標基本觀念,function 總是 pass by value
#include "stdio.h"
void setNumberTo10(int n) {
printf("\n%s:\n", __func__);
printf("n 記憶體位址 = %p, n 記憶體位址 size = %zu\n", &n, sizeof(&n));
printf("n 記憶體空間的值 = %d, n 記憶體空間的 size = %zu\n", n, sizeof(n));
n = 10;
printf("n = %d\n\n", n);
}
@zlargon
zlargon / update_xcode_plugin_compat.sh
Last active August 29, 2015 14:24
When Xcode is upgrade, Xcode Plugin will not work at all. Use this script to update all your Xcode plugin's compatibility.
#!/bin/bash
# When Xcode is upgrade, Xcode Plugin will not work at all.
# Use this script to update all your Xcode plugin's compatibility.
# https://github.com/supermarin/Alcatraz/issues/213#issuecomment-91288935
# show Xcode version and UUID
xcodebuild -version
uuid=$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)
echo "UUID $uuid"
echo ""