Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
jbrechtel / does_compile.ts
Created April 28, 2016 18:19
Typescript Structural Typing
class Thing implements IThing {
constructor(private name: string) { }
public doStuff(): string {
return "hello";
}
}
interface IThing {
doStuff(): string
quine.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
quine.rb:1: syntax error, unexpected tI...
^
[0, -30, 30, 0, -30, 30, 0, -30, 30, 0]
[0, -30, 30, 0, -30, 30, 0, -30, 30, 0]
[0, -30, 30, 0, -30, 30, 0, -30, 30, 0]
user system total real
eager_map 0.400000 0.010000 0.410000 ( 0.413597)
lazy_map 1.640000 0.000000 1.640000 ( 1.642215)
composed 0.610000 0.000000 0.610000 ( 0.610857)
m_composed 0.140000 0.000000 0.140000 ( 0.136136)
@jbrechtel
jbrechtel / composition.js
Last active February 26, 2019 15:59
generators?
function mapComp(array, fn) {
var result = [];
for(var i = 0; i < array.length; i++) {
result.push(fn(i));
}
return result;
}
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
<html>
<body>
<div style="color:white">
<a>foo</a>
</div>
</body>
</html>
@jbrechtel
jbrechtel / 0_reuse_code.js
Created June 9, 2014 13:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#mongo 2.4 running with --auth
require 'mongo'
require 'json'
client = Mongo::MongoClient.new('localhost', 27017)
admin = { user: 'admin', pwd: 'password', roles: ['readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin'] }
user = { user: 'app', pwd: 'password', roles: ['readWrite'] }
module James
open System
let strToInt str =
try
Some (Int32.Parse(str))
with
| _ -> None
module james
let rec fib = function
| 0 -> 0
| 1 -> 1
| n -> fib(n - 1) + fib(n - 2)
type Thing =
| Something = 1