Skip to content
View first.ml
let () =
let person = match Array.to_list Sys.argv with
| [_; x] -> x
| [_] | _ -> "stranger"
in
Printf.printf "hi, %s\n" person
View Enum Example.swift
enum Router: URLRequestConvertible {
static let baseURLString = "http://dev.example.com"
static var OAuthToken: String?
case MapView(Int)
case PhotoInfo(Int, ImageSize)
case Comments(Int, Int)
var URLRequest: NSURLRequest {
let (path: String, parameters: [String: AnyObject]) = {
View gist:55e75827a6b795e4507d
class ObserverSetEntry<Parameters> {
weak var object: AnyObject?
let f: AnyObject -> Parameters -> Void
init(object: AnyObject, f: AnyObject -> Parameters -> Void) {
self.object = object
self.f = f
}
}
View fancy-call.clj
(defn testfn [bar foo]
[:retval foo bar])
(defn fancy-call [f m]
(let [args (->> f meta :arglists first (map keyword))
params (map m args)]
(apply f params)))
(is (= [:retval :a :b]
(fancy-call #'testfn {:foo :a :bar :b})))
View choose.vim
" find file in git repo
function! ChooseFile()
let dir = expand("%:h")
if empty(dir) | let dir = getcwd() | endif
let root = system("cd " . dir . " && git rev-parse --show-toplevel")
if v:shell_error != 0 | echo "Not in a git repo" | return | endif
let root = root[0:-2]
let selection = system("cd " . root . " && git ls-files -co --exclude-standard | choose")
View first.swift
var L = luaL_newstate()
luaL_openlibs(L)
luaL_loadstring(L, ("return function(x,y) return x + y end" as NSString).UTF8String)
lua_callk(L, 0, 1, 0, nil)
lua_pushnumber(L, 23)
lua_pushnumber(L, 45)
lua_callk(L, 2, 1, 0, nil)
var x = lua_tonumberx(L, -1, nil)
Something went wrong with that request. Please try again.