This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
type person struct { | |
nickname string | |
} | |
ppl := []person{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gets an int between min max inclusive very inefficiently, but | |
# only using bash built-ins. More inefficient the smaller the gap | |
# | |
# usage: n=$( bad_random_int 1000 2000 ) | |
bad_random_int() { | |
local min=$1 | |
local max=$2 | |
local n=0 | |
while [[ "$n" -lt "$min" ]] || [[ "$n" -gt "$max" ]]; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Container() { | |
this.call = exports.call.bind(null,this); | |
this._deps = {}; | |
} | |
Container.prototype = { | |
get: function(dep) { | |
return this._deps[dep]; | |
}, | |
put: function(name,thing) { | |
if(typeof name === "object") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's define a type with a method that needs a fair few arguments | |
type Thing struct {} | |
func (c *Thing) Verb(a A,b B,c C,d D) {} | |
// We have things that depend on Thing and we want to test them, so to mock it we'll need to | |
// define an interface and generate a mock | |
type Thinger interface { | |
Verb(a A,b B,c C,d D) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE="github.com/you/thing" | |
FORK="github.com/other/thing" | |
PACKAGE="some-package" | |
CONSTRAINT="aabbcc" | |
dep ensure -add ${SOURCE}/${PACKAGE}:${FORK}.git@${CONSTRAINT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HashConverter | |
class << self | |
def to_underscore hash | |
convert hash, :underscore | |
end | |
def to_camel_case hash | |
convert hash, :camelize, :lower | |
end | |
def convert obj, *method | |
case obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <stdint.h> | |
#include <string.h> | |
/** | |
* So, plan is to store the values for the JS compiler | |
* in a union, nicking Lua's idea. That way immediate | |
* values like numbers live inside the JSValue wrapper, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run on source machine to build and then copy over | |
set -eo pipefail | |
main() { | |
if [[ -z $SKIP_BUILD ]]; then | |
grunt build | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Functor<T> { | |
map(mapper: (x: T) => T): Functor<T>; | |
ret(x: T): Functor<T>; | |
} | |
class Maybe<T> implements Functor<T> { | |
constructor(private value: T) {} | |
private nowt() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cast the strings as any | |
enum StringEnum { | |
a = 'a' as any, | |
b = 'b' as any, | |
} | |
const a = StringEnum.a; | |
const x = 'a'; | |
const y = 1; |