Useful links [Google Docstring Format][http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html]
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
/* | |
Question: I need to access to the web worker's onmessage data somehow | |
*/ | |
var worker = new Worker('worker.js'); | |
var file = { | |
createReadStream: function() { | |
worker.postMessage(options); // some sort of options | |
worker.onmessage = function(e) { |
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
def approximate_exponent(end): | |
denominator = float(end) + 1 | |
for i in xrange(end, 0, -1): | |
denominator = i + i/denominator | |
return 2+1/denominator | |
print approximate_exponent(2) # 2.72727272727 | |
print approximate_exponent(3) # 2.71698113208 |
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
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animatin | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct { | |
int value; | |
struct node *next; | |
} node; | |
node *add_item(node *head, int value) { | |
node *new_node = malloc(sizeof(node)); |
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 asyncChecker(condition, callback, interval) { | |
var checkerInterval = setInterval(function() { | |
if (condition) { | |
clearInterval(checkerInterval); | |
callback(); | |
} | |
}, interval); | |
} |
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
// Implementation | |
function internalizeTextFiles(type, html, callback) { | |
var tagNames = { | |
js: 'script', | |
css: 'style' | |
} | |
var tagName = tagNames[type]; | |
var $html = $(html); | |
var $assets = $html.filter(tagName); | |
var fetchedCounter = 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
def public_fn_with_googley_docstring(name, state=None): | |
"""This function does something. | |
Args: | |
name (str): The name to use. | |
Kwargs: | |
state (bool): Current state to be in. | |
Returns: |
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
sudo apt-get update | |
sudo apt-get install build-essential python-dev | |
sudo apt-get install make wget | |
# Redis | |
wget http://download.redis.io/releases/redis-2.8.14.tar.gz | |
tar xzf redis-2.8.14.tar.gz | |
cd redis-2.8.14 | |
make | |
sudo make install |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
NewerOlder