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 overlay = { | |
el: false, | |
class: 'overlay', | |
show: function(clickCallback) { | |
this.el.show() | |
if (clickCallback && typeof clickCallback == "function") { | |
this.el.off('click').click(clickCallback) | |
} | |
}, | |
hide: function() { |
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() { | |
$.fn.toggleFullscreen = function() { | |
var elem = this[0]; | |
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { | |
if (elem.requestFullscreen) { | |
elem.requestFullscreen(); | |
} else if (elem.msRequestFullscreen) { | |
elem.msRequestFullscreen(); | |
} else if (elem.mozRequestFullScreen) { | |
elem.mozRequestFullScreen(); |
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 | |
function convert_spreadsheet_rows_to_sql($table_name, $row_mappings = array(), $rows = array(), $start_row = 2) { | |
$mappings = array(); | |
$fields = array(); | |
foreach ($row_mappings as $ind => $field) { | |
if ($field) { | |
$mappings[] = $ind; | |
$fields[] = $field; | |
} | |
} |
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 scrollLock = { | |
scrollTop: 0, | |
lock: function(scrollTop) { | |
if (typeof scrollTop == "number") { | |
this.scrollTop = scrollTop; | |
} | |
$(window).on("scroll", this.onScroll); | |
}, | |
unlock: function() { | |
$(window).off("scroll", this.onScroll); |
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 json, os.path | |
def json_load(filepath): | |
return json.load(open(filepath)) | |
def valid_filenames(filenames): | |
return map(os.path.realpath, filter(os.path.exists, filenames)) | |
def merge(*dicts): | |
res = {} |
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
#!/bin/sh | |
command="${*}" | |
printf "Initialized REPL for `%s`\n" "$command" | |
printf "%s> " "$command" | |
read -r input | |
while [ "$input" != "" ]; | |
do | |
eval "$command $input" | |
printf "%s> " "$command" |
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 | |
function export_variables_to_js($vars = array(), $parent = "window") { | |
$js_vars = array(); | |
foreach ($vars as $key => $val) { | |
$key = json_encode($key); | |
$val = json_encode($val); | |
if ($parent) { | |
$js_vars[] = "$parent[$key] = $val"; | |
} else { |
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 | |
function make_select($name, $options, $selected = "", $additional_attrs = "") { | |
$res = "<select"; | |
if ($name) { | |
$res .= " name='$name'"; | |
} | |
if ($additional_attrs) { | |
$res .= " $additional_attrs"; | |
} |
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 | |
function replace_template_strings($template, $data = array(), $beginning_regex = '\{\{', $end_regex = '\}\}') { | |
return preg_replace_callback('/' . $beginning_regex . '(\w+)' . $end_regex . '/', function($match) use ($data) { | |
return empty($data[$match[1]]) ? "" : $data[$match[1]]; | |
}, $template); | |
} |
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 getOptions(len) { | |
return Array(len).join().split(",").map(function(c, i) { | |
return i; | |
}); | |
} | |
function getStep(i, len) { | |
return factorial(len) / len * i; | |
} | |
function to(order) { |