This file contains hidden or 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
Number::log = (base)-> Math.log(this)/Math.log(base) | |
Number::pow = (exp)-> Math.pow(this, exp) | |
Number::ceil = -> Math.ceil(this) | |
Number::floor = -> Math.floor(this) | |
Array::first = -> this[0] | |
Array::last = -> this[@length-1] | |
Array::min = -> @sort().first() | |
Array::max = -> @sort().last() | |
Array::minmax = -> sorted = @sort(); [sorted.first(), sorted.last()] |
This file contains hidden or 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
class Array | |
all: (f)-> | |
for e in this | |
return false unless f(e) | |
true | |
any: (f)-> | |
for e in this | |
return true if f(e) | |
false |
This file contains hidden or 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 () { | |
"use strict"; | |
function time_to_seconds(time) { | |
var s = time.attributes.datetime.value.split(":"); | |
return parseInt(s[0] * 3600, 10) + parseInt(s[1] * 60, 10) + parseInt(s[2], 10); | |
} | |
var highlighter = { |
This file contains hidden or 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
$ Number.prototype.divmod = function (n) { return [Math.floor(this / n), this % n]; } | |
=> function (n) { | |
return [Math.floor(this / n), this % n]; | |
} | |
$ typeof 1 | |
=> "number" | |
$ typeof 1.0 | |
=> "number" | |
$ 1.0.divmod | |
=> embedded:16 function (n) { |
This file contains hidden or 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> | |
int main() { | |
int x = 10; | |
while (x --> 0) { // x downto 0 | |
printf("%d ", x); | |
} | |
} |
This file contains hidden or 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
$ grep -i conlang *lesswrong*|field 3|sort|uniq -c | |
4 * | |
1 Betawolf | |
1 c0rw1n | |
3 capisce | |
1 cardboard_box | |
1 catern | |
1 cntarantula | |
1 cntgrational | |
1 cntnamstyle |
This file contains hidden or 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
require 'binding_of_caller' | |
class Tmpl | |
def initialize(&block) | |
@tmpl = block | |
end | |
def render | |
@thebinding = binding.of_caller(1) |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'io/console' | |
thread = Thread.new do | |
$stdin.each_line do |line| | |
print "stdin: #{line}\r" | |
end | |
end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'epitools' | |
class Array | |
def without(letters) | |
grouped = group_by { |letter| letter } | |
letters.each do |letter| |
This file contains hidden or 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
### wxruby ######################### | |
1500 text files. | |
1480 unique files. | |
813 files ignored. | |
http://cloc.sourceforge.net v 1.60 T=4.21 s (172.6 files/s, 16513.3 lines/s) | |
------------------------------------------------------------------------------- | |
Language files blank comment code | |
------------------------------------------------------------------------------- |