Skip to content

Instantly share code, notes, and snippets.

View peterellisjones's full-sized avatar

Peter Jones peterellisjones

View GitHub Profile
@peterellisjones
peterellisjones / gist:288992fcf2e1e70df003
Created January 29, 2015 14:07
Unit testing external library calls in Meteor
# example class / prototype to test on the client
class ClientThing
clientFoo: ->
Meteor.call 'serverFoo', 'bar'
# client-side test
describe 'ClientThing', ->
clientThing = new ClientThing()
describe '#clientFoo', ->
it 'calls serverFoo with "bar"', (test) ->
@peterellisjones
peterellisjones / go.go
Last active August 29, 2015 14:07
Line 19 Compiles with Go 1.3.3
package main
import "fmt"
type poolJSON struct {
Clusters []clusterJSON `json:"clusters"`
}
type clusterJSON struct {
InstanceID string `json:"instance_id"`
@peterellisjones
peterellisjones / gist:426ced0eb025e00d0a94
Last active August 29, 2015 14:06
Create random arithmetic operations using numbers between 0 and 20
# returns a random operation that
# result in n. eg:
# randomOperation(20) => [4, '*', 5]
# randomOperation(10) => [20, '/', 2]
class RandomOperationGenerator
def initialize(min = 0, max = 20)
raise "min must be less than max" unless min < max
@min = min
@max = max
end
package main
import "fmt"
func binarySearchRec(elem int, array []int, accesses int) (bool, int) {
accesses += 1
if len(array) == 0 {
return false, accesses
} else if len(array) == 1 {