Skip to content

Instantly share code, notes, and snippets.

View Fishrock123's full-sized avatar
💭
#freepalestine #blacklivesmatter #acab drop ICE you cowards

Jeremiah Senkpiel Fishrock123

💭
#freepalestine #blacklivesmatter #acab drop ICE you cowards
View GitHub Profile
for(var i=0; i<10; i++) {
try {
var z = 0;
break;
}
catch(e) {
console.log(e);
}
finally {
console.log('gosh, finally');
class Module
# Takes symbols representing instance methods defined in the module.
# Returns a new anonymous module with only those instance methods defined.
def slice(*methods)
src = self
Module.new do
methods.each do |sym|
define_method(sym, src.instance_method(sym))
end
end
@ircubic
ircubic / gist:dd3f2ebd729182e22796
Created June 7, 2014 16:17
Odd array behavior
func doThing(var array:Array<Int>) -> Array<Int> {
array[0] = array[0]*2
array.append(array[1]*2)
return array
}
let originalArray = [1, 2, 4]
let otherArray = doThing(originalArray)
println(originalArray) // [4, 2, 4]
println(otherArray) // [4, 2, 4, 4]
extension String {
subscript (r: Range<Int>) -> String {
let indexRange = Range(start: advance(self.startIndex, r.startIndex), end: advance(self.startIndex, r.endIndex))
return self[indexRange]
}
}
println("Foo"[1..2])
func async(queue: dispatch_queue_t, f: () -> Void) {
dispatch_async(queue, f)
}
func async(f: () -> Void) {
async(dispatch_get_main_queue(), f)
}
async {
println("Hello")
class ModelGenerator {
var modelOutput:IndentableOutput = IndentableOutput()
var childModels:ModelGenerator[] = []
var output:String {
get {
return modelOutput.output
}
}
class BasicUser {
var age:NSNumber
var clearances:AnyObject[]
var exempt:NSNumber
var name:String
var address:BasicUserAddress
init(json:NSDictionary) {
age = json.objectForKey("age") as NSNumber
clearances = []
for v:AnyObject in (json.objectForKey("clearances") as NSArray) {
@bmeck
bmeck / partial_application.js
Last active August 29, 2015 14:10
simple tagged template functions
let tee = (a) => {console.log(String(a)); return a}
// our applicator
let $_ = (n) => {
let args = new Array(n);
for (let i = 1; i <= n; i++) {
args[i-1] = `$${i}`
}
return (raw, ...values) =>
Function(...args.concat(tee('return ' + raw.reduce(
@indexzero
indexzero / README.md
Last active August 29, 2015 14:12
Myo C++ Header files. Who wants to write a node binding for this?

The state of Myo bindings in Node.js

... any takers? Comment on this gist! The discussion all started from a Tweet:

Who's going to be the first to write a wrapper for the @thalmic #myo C++ library? Latest headers: https://gist.github.com/indexzero/60d1224f0082f0d16f14

As pointed out by @c4milo there are a number of libraries that exist, but from first glance they all have deficiencies:

@max-mapper
max-mapper / times.log
Created April 4, 2015 00:25
request require load times (on iojs 1.5.1)
total: 209ms
17ms ./node_modules/qs/index.js
12ms ./node_modules/tough-cookie/lib/store.js
12ms ./node_modules/har-validator/src/error.js
11ms ./node_modules/tunnel-agent/index.js
9ms ./node_modules/tough-cookie/lib/pubsuffix.js
8ms ./request.js
6ms ./lib/oauth.js
5ms ./node_modules/hawk/lib/server.js
5ms ./node_modules/bl/bl.js