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
import Prelude hiding (foldl) | |
data Moody a = Happy a | Depressed a | |
deriving Show | |
foo (Happy a) = Happy (a + 1) | |
foo (Depressed a) = Depressed (a - 1) | |
foldl :: (b -> a -> b) -> b -> [a] -> b |
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
### Redirects controller: | |
class RedirectsController < ApplicationController | |
def create | |
redirect_to "http://www.google.com" | |
end | |
end | |
### Routes |
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
var format = function() { | |
var args = Array.prototype.slice.call(arguments); | |
var fmt = args[0]; | |
var vals = args.slice(1); | |
return fmt.replace(/(?:^|([^{]))\{(\d+)\}/g, function(_, pref, i) { | |
pref = pref || ''; | |
return pref + vals[i]; | |
}).replace(/{{|}}/g, function(s) { | |
return s[0]; | |
}); |
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
require 'sinatra/base' | |
require 'pp' | |
class HttpDebug < Sinatra::Base | |
set :port, ARGV[0] || 8001 | |
set :logging, false | |
[:get, :put, :post, :patch, :delete, :head, :link, :unlink, :options].each do |method| | |
send(method, '*') 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 f(x) { | |
return Math.round(1 / (0.5 * Math.sqrt(Math.PI)) * Math.pow(Math.E, (-Math.pow(x%3, 2)/Math.pow(0.1,2))) | |
+ 1 / (0.27 * Math.sqrt(Math.PI)) * Math.pow(Math.E, (-Math.pow(x%5, 2)/Math.pow(0.1,2)))); | |
} | |
var text = ["%", "Fizz", "Buzz", "FizzBuzz"]; | |
for(var x = 1; x <= 100; ++x) { | |
console.log(text[f(x)].replace('%', x)); | |
} |
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
# The best result I got so far is 72.9% , which is | |
# close enough for most real word uses. | |
Defs = { | |
fizz: 0, | |
buzz: 1, | |
fizzbuzz: 2, | |
neither: 3 | |
} | |
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
var r20 = /%20/g, | |
rbracket = /\[\]$/, | |
rCRLF = /\r?\n/g, | |
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, | |
rsubmittable = /^(?:input|select|textarea|keygen)/i, | |
rIdentifier = /^[$A-Z_][0-9A-Z_$]*$/i; | |
jQuery.fn.extend({ | |
serialize: function() { | |
return jQuery.param( this.serializeArray() ); |
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
/* ... */ | |
class TilemapIterator | |
{ | |
private var tilemap:FlxTilemap; | |
private var curX:Int; | |
private var curY:Int; | |
private var endX:Int; | |
private var endY:Int; | |
public function new(tilemap:FlxTilemap, x1:Int, y1:Int, x2:Int, y2:Int) |
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
//for that guy on #javascript | |
function paddedNumber(n, places) | |
{ | |
var strn = n.toString(); | |
var zerosToAdd = places-strn.length; | |
if(places !== undefined && zerosToAdd > 0) | |
while(zerosToAdd--) | |
strn = "0"+strn; | |
return strn; | |
} |
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 swap(f) | |
{ | |
return function(a, b) | |
{ | |
return f(b, a); | |
}; | |
} | |
function ArgPos(i) |
NewerOlder