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(){ | |
var event_names = { | |
"click" : "" , | |
"tweet" : "", | |
"retweet" : "source_tweet_id", | |
"follow" : "screen_name", | |
"favorite" : "tweet_id" | |
}; | |
for(var event_name in event_names) |
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
Number.prototype.timeLeft = function(){ | |
var days = Math.floor(this / 86400); | |
var hours = Math.floor((this - (days * 86400)) / 3600); | |
var minutes = Math.floor((this - ((hours * 3600) + (days * 86400))) / 60); | |
var seconds = this - ((days * 86400) + (hours * 3600) + (minutes * 60)); |
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
// Test monad laws. | |
// Monad laws are described in http://www.haskell.org/haskellwiki/Monad_Laws | |
test("return a >>= f should be equivalent to f a", function() { | |
var f = function(a) { return Maybe.return(a * 3); }; | |
var lhs = Maybe.return(5).bind(f); | |
var rhs = f(5); | |
deepEqual(lhs, rhs, "equivalent"); | |
}); |
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
-- Inspired by http://nedbatchelder.com/blog/201301/stupid_languages.html | |
-- which describes how the Javascript array.map function seems weird | |
-- and also http://blog.sigfpe.com/2008/03/comonadic-arrays.html | |
-- which describes the comonad for arrays | |
import Data.Array | |
import Data.Char | |
class Functor w => Comonad w where | |
(=>>) :: w a -> (w a -> b) -> w 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
<?php | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
$plugin_info = array( | |
'pi_name' => 'URL Encode', | |
'pi_version' => '1.1', | |
'pi_author' => 'Airtype Studio / BSD', | |
'pi_author_url' => 'http://www.airtypestudio.com/', | |
'pi_description' => 'Runs urlencode on a string of text.', |
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
<?php | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
$plugin_info = array( | |
'pi_name' => 'URL Encode', | |
'pi_version' => '1.1', | |
'pi_author' => 'Airtype Studio / BSD', | |
'pi_author_url' => 'http://www.airtypestudio.com/', | |
'pi_description' => 'Runs urlencode on a string of text.', |
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
console.log("\033[39mRunning tests…"); | |
function assertEquals(actual, expected, description) { | |
if(typeof actual === "undefined") { | |
console.error("\033[31m" + description + " not implemented\033[39m"); | |
} else { | |
if(actual !== expected) { | |
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m"); | |
} else { | |
console.log(description + " \033[32m ok\033[39m"); | |
} |
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
const IdModule = { | |
fmap: (fn) => (x) => fn(x), | |
} | |
const ConstModule = { | |
fmap: (fn) => (x) => 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
const lineLens = lens(split('\n'), join('\n')); | |
const mapLines = curry((fn, str) => | |
over(lineLens, map(fn), str)); | |
const adjustLine = curry((fn, n, str) => | |
over(lineLens, adjust(fn, n), str)) | |
mapLines(toUpper, 'foo\nbar') // => 'FOO\nBAR' | |
adjustLine(toUpper, 0, 'foo\nbar') // => 'FOO\nbar" |
OlderNewer