Skip to content

Instantly share code, notes, and snippets.

function add() {
var args = [].slice.call(arguments);
var sum = args.reduce(function(a, b){ return a + b; }, 0);
return numify(sum);
function numify(num){
var ret = function(a){
return a === undefined ? numify(num) : numify(a + num);
}
@johnkpaul
johnkpaul / 0.0.58.js
Created September 1, 2014 20:42
Traceur compile in the browser
var compiler = new traceur.Compiler;
compiler.script(content, {experimental: true})
.then(function(result){
var source = result.js;
eval(source);
});
on run {}
activate application "Microsoft Outlook"
tell application "Microsoft Outlook"
set selected folder to folder "Archive"
end tell
tell application "System Events"
keystroke "f" using {option down, command down}
end tell
end run
class SumOfFactors
def initialize(until_num, *divisible_by)
@until_num = until_num
@divisible_by = divisible_by
end
def get_sum
get_range.select(&self.method(:is_disivible_by))
.inject(&self.method(:sum_arr))
var MyApp = {
addPlaceholders: function(props) {
// default configuration
var config = {
'class': 'placeholder' // apply CSS classes to an input displaying a placeholder
};
// if any properties were supplied, apply them to the config object
@johnkpaul
johnkpaul / gist:1044075
Created June 24, 2011 02:04
Add to JavaScript function prototype ability to find source in file
if(typeof _scriptsRecorded == "undefined"){
var scriptBodies = {}
var scripts = document.querySelectorAll("script");
for(var i = 0, len = scripts.length;i<len;i++){
var script = scripts[i];
(function(src){
$.get(src, function(data){
scriptBodies[src] = data;
})
})(script.src)
@johnkpaul
johnkpaul / gist:1087002
Created July 17, 2011 01:21
Implicit conversions in scala
class Mixin(value: Int){
def myCrazyNameOperator(f: Int => Int) : Int = f(value)
}
implicit def toWTF(value: Int) = new Mixin(value);
def double(int: Int) = {2 * int}
def triple(int:Int) = {3 * int}
@johnkpaul
johnkpaul / gist:1556717
Created January 3, 2012 20:19
log all jQuery event triggers to the console
var __temp_trigger = $.fn.trigger;
$.fn.trigger = function(){console.log(arguments, " triggered on element ", this); return __temp_trigger.apply(this,arguments);}
@johnkpaul
johnkpaul / gist:1589927
Created January 10, 2012 16:38
Add elements to bizodo select boxes programatically
var options_to_add = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,"20+"];
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
for(var i=0,len=options_to_add.length;i<len;i++){
$$(".option_add")[0].dispatchEvent(event)
var empty_element = $$(".option_editor_row").filter(function(el){return el.firstChild.value == ""})[0];