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
// strip-unit function courtest of Karl Merkli http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/ | |
@function strip-unit($num) { | |
@return $num / ($num * 0 + 1); | |
} | |
// $size arg is the desired font size in pixels (e.g. @include font-size(16px);) | |
// Requires a $base-font-size variable be set and used like so: | |
// | |
// $base-font-size: 16px; | |
// |
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 php | |
<?php | |
// OSA Script command line template | |
$osascriptTpl = 'osascript -e "tell application \"Safari\" to add reading list item \"%s\""'; | |
// Read in export file from Pocket app | |
$pocketList = file_get_contents("{$_ENV['HOME']}/Downloads/ril_export.html"); | |
// Get the ul that contains my unread list |
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 lambdafy(callable $funcname) { | |
return function() use ($funcname) { | |
return call_user_func_array($funcname, func_get_args()); | |
}; | |
} |
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 lambdafy($funcname) { | |
if (function_exists($funcname)) { | |
return function() use ($funcname) { | |
return call_user_func_array($funcname, func_get_args()); | |
}; | |
} | |
throw new ErrorException('Catchable fatal error: Argument 1 passed to lambdafy() must be callable, string given', E_RECOVERABLE_ERROR); | |
} |
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
// Requires testers.js for existy() and isRealNaN() | |
/** | |
* Maybe Monad (chainable, failure tolerant) | |
* | |
* Maybe(value, failOn).bind(function(value) { return value * value; }).value() | |
*/ | |
var Maybe = function Maybe(val) { | |
if (!(this instanceof Maybe)) { | |
return new Maybe(val); |
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 existy(val) { | |
return val !== undefined && val !== null && !isRealNaN(val); | |
} | |
function toClass(obj) { | |
return Object.prototype.toString.call(obj); | |
} | |
function isMaker(type) { | |
return function(val) { |
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
// Requires tester.js for isFunction() | |
function not(val) { | |
return !(value); | |
} | |
function unbind(fn) { | |
return function() { | |
return fn.apply(arguments[0], Array.prototype.slice.call(arguments, 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
// Requires utils.misc.js for unbind() and testers.js for existy() | |
var slice = unbind(Array.prototype.slice); | |
function toList(arr) { | |
return existy(arr) ? slice(arr) : []; | |
} | |
function nth(index, list) { | |
return list[index]; |
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
// Requires utils.list.js for first() and rest() | |
function map(callback, list) { | |
if (!list.length) return []; | |
else return [callback(first(list))].concat(map(callback, rest(list))); | |
} | |
function filter(predicate, list) { | |
if (!list.length) return []; | |
else return (predicate(first(list)) ? [first(list)] : []).concat(filter(predicate, rest(list))); |
OlderNewer