Skip to content

Instantly share code, notes, and snippets.

View jaekwon's full-sized avatar

Jae Kwon jaekwon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jaekwon on github.
  • I am jaekwon (https://keybase.io/jaekwon) on keybase.
  • I have a public key whose fingerprint is F3E6 04B9 02C6 3CC5 EA2E 4FB6 BBCF 2AC7 7899 206D

To claim this, I am signing this object:

@jaekwon
jaekwon / gist:76bcb80081ce39b1588d
Created June 29, 2015 20:33
SortString in Golang
package main
import (
"sort"
"testing"
)
// SortString sorts a string
func SortString(w string) string {
wBytes := uint8Slice([]uint8(w))
@jaekwon
jaekwon / gist:761071
Created December 31, 2010 15:10 — forked from dwillis/gist:756581
Derek-Williss-MacBook-Pro:zappa-test derek$ zappa cuppa.coffee
Error: ENOENT, No such file or directory 'node'
at Object.openSync (fs:153:18)
at Object.readFileSync (fs:94:15)
at Zappa.read (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:67:17)
at Zappa.run_file (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:71:75)
at Object.run_file (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:650:23)
at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.3/package/bin/zappa.coffee:96:15)
at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.3/package/bin/zappa.coffee:100:4)
at Module._compile (node.js:462:23)
@jaekwon
jaekwon / gist:879058
Created March 21, 2011 04:58
declaring inner scope variables in coffeescript
foo = ->
dog = "a dog"
transmorg = ->
`var dog = "a cat"`
console.log "in transmorg: dog == #{dog}"
transmorg()
console.log "outside, dog == #{dog}"
foo()
# Add custom shader
# http://www.html5rocks.com/en/tutorials/webgl/shaders/
vertexShader = """
// create a shared variable for the
// VS and FS containing the normal
varying vec3 vNormal;
void main() {
// set the vNormal value with
@jaekwon
jaekwon / gist:6042197
Created July 19, 2013 20:42
cjdns problems
1374266202 INFO cjdroute2.c:454 Forking angel to background.
1374266202 DEBUG AdminClient.c:263 Connecting to [127.0.0.1:11234]
1374266202 DEBUG UDPAddrInterface.c:151 Bound to address [0.0.0.0]
1374266202 INFO Configurator.c:90 Checking authorized password 0.
1374266202 INFO Configurator.c:102 Flushing existing authorized passwords
1374266202 INFO Configurator.c:108 Adding authorized password #[0].
1374266202 INFO RandomSeed.c:57 Attempting to seed random number generator
1374266202 INFO RandomSeed.c:72 Trying random seed [RtlGenRandom() (Windows)] Failed
1374266202 INFO RandomSeed.c:72 Trying random seed [sysctl(KERN_ARND) (BSD)] Failed
1374266202 INFO RandomSeed.c:68 Trying random seed [/dev/urandom] Success
// main.go
package main
func main() {
Foo()
}
// json.go
package main
func Foo() {
}
import random
def isPrime(n):
#print 'is ',n,' prime?'
# make sure n is a positive integer
n = abs(int(n))
# 0 and 1 are not primes
if n < 2:
#print 'no'
return False
// Get http://acme.com/software/bigint/
// Then change Makefile to point CC to emcc.
// make
// Emscripten compile with the following line:
// emcc bigint.a -O2 -o bigint.html -s EXPORTED_FUNCTIONS="['_str_to_bi_base', '_bi_mod_power', '_bi_int_mod', '_bi_copy', '_bi_initialize', '_bi_int_divide', '_bi_compare', '_int_to_bi', '_digit_to_char']"
// Now go to bigint.html & run the following code:
var bi_initialize = Module.cwrap('bi_initialize', null, [])
var str_to_bi_base = Module.cwrap('str_to_bi_base', 'number', ['string', 'number'])
var bi_int_mod = Module.cwrap('bi_int_mod', 'number', ['number', 'number'])
@jaekwon
jaekwon / gist:7575612
Created November 21, 2013 03:21
simple routing
//////////// ROUTER
//////////// ROUTER
$(function() {
window.onhashchange = function() {
if (location.hash) {
gotoRoute((location.path||'')+location.hash, false);
} else {
gotoRoute(location.path||'', false);
}