Skip to content

Instantly share code, notes, and snippets.

View jacksonwillis's full-sized avatar

Jackson Willis jacksonwillis

  • Madison, Wisconsin
View GitHub Profile
@jacksonwillis
jacksonwillis / dag.txt
Created August 7, 2012 03:19
dog test page
== PRINTER TEST PAGE = 1/1 ==
;\
|' \
_ ; : ;
/ `-. /: : |
| ,-.`-. ,': : |
\ : `. `. ,'-. : |
\ ; ; `-.__,' `-.|
\ ; ; ::: ,::'`:. `.
@jacksonwillis
jacksonwillis / y.coffee
Created June 3, 2012 07:59
y combinator
B = (f) -> (g) -> (h) -> f (g h)
M = (f) -> f f
K = (f) -> (g) f
Y = (f) -> M (B f) M
(function () {
var root = this,
previousDollar = root["$"];
var $ = function (it) {
return document.getElementById(it);
};
root.baobob = root["$"] = $;
@jacksonwillis
jacksonwillis / tbtm.coffee
Created June 1, 2012 19:06
TwoByTwoMatrix
class TwoByTwoMatrix
constructor: ([[@a, @b], [@c, @d]]) ->
toString: -> "[#{@a} #{@b}\n #{@c} #{@d}]"
determinant: -> (@a * @d) - (@b * @c)
inverse: ->
D = @determinant()
new TwoByTwoMatrix [[@d/D, -@b/D], [-@c/D, @a/D]]
alert new TwoByTwoMatrix([[1, 2], [3, 4]]).inverse().toString()
@jacksonwillis
jacksonwillis / lol.html
Created May 31, 2012 15:56
click here 4 fun!! (siezure warning)
<a href="data:text/html,plain;%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3EOMG!%3C%2Ftitle%3E%3Cscript%3Ewindow.onload%3Dfunction()%7BsetInterval(function()%7Bvar%20a%3Ddocument.body.style%3Ba.background%3D%22%23%22%2Bc(0%2C16777215).toString(16)%3Ba.fontSize%3Dc(10%2C100)%2B%22px%22%3Ba.padding%3Dc(10%2C125)%2B%22px%22%3Bvar%20b%3Dc(5%2C10)%3Bfor(var%20d%3D%22A%22%2Ca%3D0%3Ba%3Cb%3B%2B%2Ba)d%2B%3D%22A%22%3Bdocument.body.innerHTML%3Dd%7D%2C50)%7D%3Bfunction%20c(a%2Cb)%7Breturn%20a%2BMath.floor(Math.random()*(b-a))%7D%3B%3C%2Fscript%3E%3Cbody%20style%3Dcolor%3Awhite%3E">click here 4 fun!!</a>
@jacksonwillis
jacksonwillis / timing.coffee
Created May 18, 2012 19:07
Coffeescript Idiomatic Timing Events
inAbout = (n) -> new ->
@milliseconds = (f) -> setTimeout f, n
@seconds = (f) -> setTimeout f, n * 1000
every = (n) -> new ->
@milliseconds = (f) -> setInterval f, n
@seconds = (f) -> setInterval f, n * 1000
console.log "starting!"
inAbout(3).seconds ->
@jacksonwillis
jacksonwillis / vector.coffee
Created May 11, 2012 18:33
CoffeeScript Vector Math
Number::toRadians = -> (@ * Math.PI) / 180
Number::toDegrees = -> (@ * 180) / Math.PI
Array::product = -> @reduce (a, e) -> a * e
Array::sum = -> @reduce (a, e) -> a + e
Array::zip = (args...) -> ((args...) ->
longest = args.reduce ((a, b) -> (if a.length > b.length then a else b)), []
longest.map (_, i) -> args.map (array) -> array[i])(@, args...)
@jacksonwillis
jacksonwillis / range.js
Created April 28, 2012 00:06
Recursive Javascript range function
/* recursive version
*/
var M = function (f) { return f(f); } // Mockingbird function
range = M(function (f) {
return function (min, max) {
return min === max ? [min] : [min].concat(f(f)(min + 1, max));
}
});
/* SEMICOLON2.js
Copyright 2012 Jack Willis */
(function () { return ;;; }).call(this);
Number.prototype.superfactorial = function() {
var a, e, d, b, c;
d = 1;
for(a = b = 2;2 <= this ? b <= this : b >= this;a = 2 <= this ? ++b : --b) {
for(e = c = 2;2 <= a ? c <= a : c >= a;e = 2 <= a ? ++c : --c) {
d *= e
}
}
return d
};