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 roshHashanah = function(y) { | |
var g = (y % 19) + 1 | |
var n = (Math.floor(y / 100) - Math.floor(y / 400) - 2) + ((765433 / 492480 * ((12 * g) % 19)) + ((y % 4) / 4) - ((313 * y + 89081) / 98496)); | |
var r = Math.floor(n); | |
var m = 9; | |
var h = m; | |
var d = r; | |
if (r > 30) { h = 10; d = r - 30; } | |
var a = Math.floor((14 - h) / 12); | |
var i = y - a; |
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
/*! | |
Original code found here: http://www.dafaweek.com/HebCal/HebCalSampleSource.php | |
Simplifed by Kodie Grantham - http://kodieg.com | |
Hebrew Months: | |
1 - Tishrei | |
2 - Cheshvan | |
3 - Kislev | |
4 - Teves | |
5 - Shevat |
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 matches(str, kw) { | |
var m = []; | |
if (kw.constructor !== Array) { kw = [kw]; } | |
for (var i = 0; i < kw.length; i++) { | |
var f = str.match(new RegExp(kw[i], 'gi')); | |
if (f) { m = m.concat(f); } | |
} | |
return m; |
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 change_url_param($params = null, $url = null) { | |
if (!$url) { $url = '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } | |
$p = parse_url($url); | |
if (isset($p['scheme'])) { $s = $p['scheme'] . '://'; } else { $s = '//'; } | |
if (substr($url, 0, 2) == '//') { $s = '//'; } | |
if (isset($p['host'])) { $h = $p['host']; } else { $h = ''; } | |
if (isset($p['path'])) { $t = $p['path']; } else { $t = '/'; } | |
if (isset($p['query'])) { parse_str($p['query'], $q); } else { $q = array(); } | |
if (isset($p['fragment'])) { $f = '#' . $p['fragment']; } else { $f = ''; } |
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
Template.registerHelper('meteorSettings', function(settings) { | |
var setting = Meteor.settings.public; | |
if (settings) { | |
var eachSetting = settings.split('.'); | |
for (i = 0; i < eachSetting.length; i++) { | |
setting = setting[eachSetting[i]]; | |
} | |
} | |
return setting; | |
}); |
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 csv_to_array($file, $line_length="0", $delimiter=",", $enclosure="\"", $escape="\\") { | |
$csv = array(); | |
$keys = array(); | |
$row = 0; | |
if (($handle = fopen($file, "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, $line_length, $delimiter, $enclosure, $escape)) !== FALSE) { | |
$num = count($data); | |
for ($c=0; $c < $num; $c++) { | |
if ($row == 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
function txtStyle { | |
local color | |
local background | |
local style | |
local output | |
case "$1" in | |
"black") color="30" ;; | |
"red") color="31" ;; | |
"green") color="32" ;; |
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 arraySearch { | |
local i | |
local output | |
local a=("$@") | |
local last_idx=$((${#a[@]} - 1)) | |
local b=${a[last_idx]} | |
unset a[last_idx] | |
for i in "${!a[@]}" ; do | |
if [ "${a[$i]}" == "$b" ]; then |
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
/** | |
* First, add `api.use('ecmascript');` to your package.js files. | |
* packages/project:modules-core/package.js: | |
**/ | |
Package.describe({ | |
name: 'project:modules-core', | |
summary: 'Core package for Modules.', | |
version: '1.0.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
function getVideoMeta(videoUrl, metaType, callback) { | |
var video = document.createElement('video'); | |
video.preload = 'metadata'; | |
video.src = videoUrl; | |
video.addEventListener('loadedmetadata', function() { | |
callback(null, video[metaType]); | |
}); | |
video.addEventListener('error', function(error) { | |
callback(error, video); | |
}); |