Skip to content

Instantly share code, notes, and snippets.

View yangsu's full-sized avatar

Yang Su yangsu

  • San Francisco, CA
  • X @ys65
View GitHub Profile
@yangsu
yangsu / ajax.js
Last active August 29, 2015 14:18 — forked from xeoncross/ajax.js
/*globals ActiveXObject*/
// Cross browser Ajax implementation based on
// http://toddmotto.com/writing-a-standalone-ajax-xhr-javascript-micro-library/
// https://gist.github.com/Xeoncross/7663273
var encodeParams = function(data, bustCache) {
var key,
params = [];
for (key in data) {
@yangsu
yangsu / clojure-anonymous-fn.clj
Created April 16, 2013 18:53 — forked from sudowork/clojure-anonymous-fn.clj
Clojure Anonymous Function Example
; defining a function to square a number
user=> (defn square [x] (* x x))
#'user/square
user=> (square 3)
9
; now using an anonymous function
user=> (def square2 (fn [x] (* x x)))
#'user/square2
user=> (square2 3)
@yangsu
yangsu / clojure-more-destructuring.clj
Last active December 16, 2015 07:28 — forked from sudowork/clojure-more-destructuring.clj
Clojure Destructuring example
; First let's show two alternative ways to destructure a vector
user=> (defn first-three [a & [b & [c]]] (println a b c))
#'user/first-three
user=> (defn first-three [a b c & _] (println a b c))
#'user/first-three
user=> (first-three 1 2 3 4)
1 2 3
nil
user=> (first-three 1 2)
1 2 nil
// Basic `case` usage
val animal = "dog"
animal match {
case "dog" => "imadog"
case "cat" => "imacat"
case _ => "whatami"
}
// Pattern Matching with `case`
val DurhamWeather = ("cloudy", "durham")
@yangsu
yangsu / gist:4254608
Last active July 24, 2017 15:16 — forked from lucasfais/gist:1207002
Sublime Text 3 - Useful Shortcuts

Sublime Text 3 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
F12 go to definition
⌘KB toggle side bar