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 get_products_of_all_ints_except_at_index(arr) { | |
var numbersBeforeIndex = []; | |
var numbersAfterIndex = []; | |
for (var i = 0; i < arr.length; i++) { | |
numbersBeforeIndex[i] = arr.slice(0, i); | |
if (numbersBeforeIndex[i].length) { | |
numbersBeforeIndex[i] = numbersBeforeIndex[i].reduce(function (a, b) { |
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 kittenizeAllImages() { | |
var images = document.getElementsByTagName('img'); | |
for (var i = 0; !!images[i]; i++) { | |
if (!! images[i].dataset.notChecked) | |
continue; | |
checkImage(images[i]); | |
} | |
} |
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
extension Int { | |
func isPrime() -> Bool { | |
if (self == 1) { return false } | |
if (self == 2) { return true } | |
var sqr = Int(sqrt(Float(self))) + 1 | |
for i in 2...sqr { | |
if self % i == 0 { | |
return false | |
} |
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
#!/bin/bash | |
# Connects to a MySQL database to dump data in batches. | |
# Great for dumping large datasets. | |
LIMIT=1000000 | |
OFFSET=0 | |
MAX_ROWS=1000000000 | |
# This loops until it has read MAX_ROWS |
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
#!/bin/bash | |
# | |
# Watchdog watches a process passed in as the first argument waits until | |
# it finishes and then sends a text message to the number provided. | |
# | |
PID=$1 | |
NUMBER=$2 | |
MESSAGE=$3 |
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
/** | |
* Detect if a browser supports a CSS feature. | |
* Courtesy of Stack Overflow. | |
* http://stackoverflow.com/questions/10888211/detect-support-for-transition-with-javascript | |
* | |
*/ | |
function detectCSSFeature(featurename){ | |
var feature = false, | |
domPrefixes = 'Webkit Moz ms O'.split(' '), | |
elm = document.createElement('div'), |
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
// Add toUSDateString to global Date object, prints Mon/Day/Year | |
Date.prototype.toUSDateString = function () { | |
return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear(); | |
}; | |
(new Date()).toUSDateString(); // "MM/DD/YYYY" |
NewerOlder