Skip to content

Instantly share code, notes, and snippets.

<!-- Disable auto-linking of phone numbers. -->
<meta name="format-detection" content="telephone=no">
<!-- Enables the web application runs in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Sets the style of the status bar for a web application. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- Sets the initial scale and turns off user scaling. -->
@lamchau
lamchau / 0_reuse_code.js
Created November 13, 2013 02:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lamchau
lamchau / font-list.jsx
Created November 15, 2013 10:34
List all fonts for Photoshop
function PostScriptNameRenderer(element) {
return element ? element.postScriptName : undefined;
}
function getFont(renderer) {
var list = app.fonts;
var result = [];
var name;
var i;
if (renderer) {
var characters = [
{
"user" : "mario",
"age" : 23,
"good" : true
},
{
"user" : "luigi",
"age" : 21,
"good" : true
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@lamchau
lamchau / GitGutter-dark.xml
Created December 14, 2013 09:49
GitGutter styles for dark color schemes (extracted from Monokai Extended)
<dict>
<key>name</key>
<string>GitGutter deleted</string>
<key>scope</key>
<string>markup.deleted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
@lamchau
lamchau / random-sha1.js
Created January 29, 2014 15:05
random sha1 string generator for testing
function sha1() {
function random() {
var characters = "abcdef0123456789";
return (function () {
var index = Math.floor(Math.random() * characters.length);
return characters.charAt(index);
})();
}
var MAX_LENGTH = 40;
@lamchau
lamchau / shuffle.js
Created January 29, 2014 15:19
Fisher-Yates Shuffle
function shuffle(array) {
var counter = array.length - 1;
var tmp;
var index;
for (; counter > 0; counter--) {
index = Math.floor(Math.random() * counter);
tmp = array[counter];
array[counter] = array[index];
array[index] = tmp;
}
@lamchau
lamchau / example.py
Created March 3, 2014 04:40
simple interview questions with unittests (pyunit)
#/usr/bin/python env
import abc
import unittest
class StringUtilities(object):
@staticmethod
def is_palindrome(s):
if not isinstance(s, str):
from datetime import datetime
import csv
import math
import sys
import time
class Record(object):
EARTH_RADIUS_IN_KM = 6371