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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 arr = [1,1,1,2,3,4,5,3,3,3,4,5,6,3,2,4,6]; | |
// first work out the mean | |
var mean = arr.reduce(function (p, c) { | |
return p + c; | |
}) / arr.length; | |
// now the stanard deviation | |
var standardDeviation = Math.sqrt(arr.map(function (l) { | |
return Math.pow(l - mean, 2); |
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
/** | |
* Omit keys from an object by an Array | |
* | |
* @param Object Obj The original object | |
* @param [[string, ....] The array of blacklisted keys | |
* | |
* @returns a clone of the obj with the keys removed | |
*/ | |
var deepOmit = function (obj) { | |
var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1)); |
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
// ==UserScript== | |
// @name TweetDeck Instagram | |
// @description Adds instagram to Tweetdeck | |
// @include https://tweetdeck.twitter.com/* | |
// @include chrome-extension://hbdpomandigafcibbmofojjchbcdagbl/* | |
// @version 0.1 | |
// ==/UserScript== | |
var func = 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
$callback = $_GET['callback']; | |
$posts = []; | |
if (have_posts()) { | |
while(have_posts()) { | |
array_push(the_post()); | |
} | |
} | |
print $callback . '(' . json_encode($posts) . ')'; |
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
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, | |
unused:true, curly:true, browser:true, indent:4, maxerr:50, globalstrict:false */ | |
/** | |
* Will fetch the Twitter embed object | |
* | |
* See https://dev.twitter.com/docs/embedded-tweets for more information | |
* | |
* @param {Int} id Twitter status ID | |
* @param {Function} callback The callback function when this is successful |
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
Object.prototype.clone = function () { | |
var obj = {}; | |
for (var prop in this) { | |
obj[prop] = this[prop]; | |
} | |
return obj; | |
}; |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2281636/hack.sh | sh | |
# |
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
setInterval(function() { | |
if (element.style.visibility != 'hidden') { | |
element.style.visibility = 'hidden'; | |
} else { | |
element.style.visibility = 'visible'; | |
} | |
}, 1000); |
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
/** | |
* Will give you the object from a set of arrays | |
* | |
* If you wanted to retrieve the object window.frames.url when you only have a array of string parts ['frames', 'url'] | |
*/ | |
function crawl(obj, keys) { | |
var key = keys.shift(); | |
return keys.length == 0 ? obj[key] : crawl(obj[key], keys); | |
} |
NewerOlder