Skip to content

Instantly share code, notes, and snippets.

View dz1984's full-sized avatar

Donald Zhan dz1984

View GitHub Profile
@dz1984
dz1984 / README.md
Last active August 29, 2015 14:20 — forked from zbryikt/README.md
@dz1984
dz1984 / index.jade
Last active August 29, 2015 14:15
Practice the Kernel.js to implement a small demo. Kernel.js Website : http://alanlindsay.me/kerneljs/ Demo: http://jsbin.com/sugoma/ Hackpad: https://hackpad.com/Kernel.js-Tips-0zTjJuntzbD
doctype html
html
head
title
| Kernel.js Demo
body
p
| Number of Click these buttons:
span.counter 0
@dz1984
dz1984 / Utility.js
Last active August 29, 2015 14:13
Utility functions in Javascript.
(function(root, factory) {
"use strict";
if (typeof define === "function" && define.amd) {
define(["jquery"], factory);
} else if (typeof exports === "object") {
module.exports = factory(require("jquery"));
} else {
root.Utility = factory(root.jQuery);
}
@dz1984
dz1984 / Beepbox.js
Last active August 29, 2015 14:10
A tiny Javvasript library to create programmatic dialog boxes using Bootstrap modals.
/**
* A tiny Javvasript library to create programmatic dialog boxes using Bootstrap modals.
*
* (require the bootstrap )
*
* @referenc: http://bootboxjs.com
* @author: Donald Zhan
*
* @examples
*
@dz1984
dz1984 / Dockerfile
Created October 18, 2014 15:37
Eia_crawler dockerfile.
# Dockerfile for eia_crawler project
FROM ubuntu:precise
MAINTAINER Donald Zhan <[email protected]>
# Add necessary respnsitory
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 627220E7
RUN echo 'deb http://archive.scrapy.org/ubuntu scrapy main' > /etc/apt/sources.list.d/scrapy.list
# Install scrapy
@dz1984
dz1984 / ufs.coffee
Created September 19, 2014 03:36
Union-Find sets 簡易操作範例
'use strict'
class UFS
constructor: (count) ->
@_father = []
@_rank = []
@_initSet = (count) ->
for i in [0..count-1]
@dz1984
dz1984 / countChange.coffee
Created September 17, 2014 04:34
Implement the exercise 3: Counting Change on "Functional Programming Principles in Scala" course via CoffeeScript.
countChange = (money, coins) ->
_targetMoney = money
loops = (_currentMoney, _canUsedCoins) ->
return 0 if (_.isEmpty(_canUsedCoins))
h = _.head _canUsedCoins
t = _.tail _canUsedCoins
@dz1984
dz1984 / balance.coffee
Created September 17, 2014 00:02
Check parentheses balancing on the "Functional Programming Principles in Scala" course in Coursera.
balance = (charList) ->
isBegin = (_char) -> _char == '('
isEnd = (_char) -> _char == ')'
check = (_counter,_char) ->
return _counter+1 if isBegin(_char)
return _counter-2 if isEnd(_char) and (_counter<=0)
return _counter-1 if isEnd(_char)
return _counter
@dz1984
dz1984 / catchAllArea.coffee
Created August 14, 2014 05:57
將臺北市各區 GeoJSON下來,存成 CSV 格式後,手動塞入 Fusion Table。 https://www.google.com/fusiontables/DataSource?docid=1WhhrQFN0vopgc5jJdcC4myMF5C4gsirYO436Snln
fs = require "fs"
crypto = require "crypto"
http = require "http"
NEWLINE = "\n"
FILENAME = "output.csv"
API = "http://poponfire.herokuapp.com/api/taipei/"
ALLAREA = [
"中正區",

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation