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
/* | |
Solution to the Array Iteration Problem @ http://blog.jazzychad.net/2012/08/01/array-iteration-problem.html | |
--- | |
add1 - increments items in an array matching specified value | |
param: arr - array of integers to manipulate | |
param: val - integer, value to increment |
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
var hasClass = function(el, c){ | |
return new RegExp("(\\s|^)" + c + "(\\s|$)", "g").test(el.className); | |
} | |
var addClass = function(el, c){ | |
if(!this.hasClass(el, c)) el.className += " " + c; | |
} | |
var removeClass = function(el, c){ | |
el.className = el.className.replace(new RegExp("(\\s|^)" + c + "(\\s|$)", "g"), " ").trim(); |
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
curl -X POST -F outputFormat=ttf -F fontFile=@./icons.svg www.freefontconverter.com > icons.ttf |
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
var padNumber = function(n, d){ | |
if(!d || d <= (n+"").length) | |
return n+""; | |
return (0).toPrecision(d - (n+"").length).replace(".", "")+n; | |
} | |
padNumber(1.234, 6); // Returns "000001.234" | |
padNumber(1.234, 10); // Returns "01.234" |
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
var minimalAjax = function(url, callback){ | |
var xmlHTTP = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MicrosoftXMLHTTP"); | |
xmlHTTP.onreadystatechange = function(){ | |
if(this.readyState == 4 && this.status == 200) | |
callback(this.responseText); | |
} | |
xmlHTTP.open("GET", url, true); | |
xmlHTTP.send(); |
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
// Reverse words in a string | |
var reverseWords = function(sentence){ | |
var words = sentence.split(" ").reverse(); // Split the sentence into an array of words and reverse it | |
var string = ""; | |
for(word in words) | |
string += (word > 0 ? " " : "") + words[word]; // Concatenate each word to the output and add spaces where required | |
return string; | |
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
curl -XPUT -HContent-Type:application/json https://user:[email protected]/_config/vhosts/subdomain.host.com -d '"/database/_design/app/_rewrite"' |
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
'"' + words.join('","') + '"' |
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
python -m SimpleHTTPServer |
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
grep -oh something ./some.file | wc -w |
OlderNewer