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
/* | |
* @getPersistentVisitorId: Generates a unique visitor ID that is persisted between visits. | |
* | |
* We assume we're in an iframe, so for Safari users we use localStorage, | |
* and for everyone we use local domain cookies. | |
*/ | |
var getPersistentVisitorId = (function() { | |
var key = 'silp_visitorid'; | |
var method = allowsThirdPartyCookies() ? 'cookie' : 'localStorage'; | |
var persistor = { |
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
// We assume that this is running in an iframe which loads a page from a domain | |
// that is specific to where your widget is served from. This means that for | |
// browsers that support 3rd party cookies in iframes, the cookie will be set | |
// on this domain, and for those who don't, localStorage will be used instead. | |
ga('create', 'UA-XXXX-Y', { | |
'storage': 'none', | |
'clientId', getPersistentVisitorId() | |
}); |
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
{ | |
"variables": { | |
"salt_role": "common" | |
}, | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"scripts": [ | |
"scripts/ec2-ephemeral-tmp.sh" | |
], |
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
import bpython | |
import inspect | |
def interact(): | |
""" | |
Just run interace() anywhere in your code, and you'll get a sweet | |
interactive bpython interpreter with access to the scope of where you | |
called it. Great for investigating new API's. | |
""" | |
try: |
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 _ = require('underscore'); | |
function printPrototypeChain(instance, asArray) { | |
var chain = [] | |
while (instance = Object.getPrototypeOf(instance)) { | |
var name = instance.constructor.toString().match(/f.+n (.+)\(/); | |
chain.push(name && name[1]? name[1] : "(anonymous function expression)") | |
} | |
return asArray? chain : chain.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
#!/bin/bash | |
root_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
ssl_dir=$root_dir/ssl | |
mkdir -p $root_dir/ssl | |
echo ">> Generating SSL key and certificate..." | |
rm -rf $ssl_dir/* |
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
/* | |
* | |
* Simple benchmark of `pipe` (https://github.com/wowus/pipe) library | |
* | |
* $ gcc -O3 -pthread -o test pipe.c test.c | |
* $ ./test | |
* Consuming 2000000 items from the queue... | |
* Received 2000000 items in 0.52 seconds, average throughput of 3878081 items/s | |
* | |
*/ |
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
/* | |
* $ gcc -std=c99 -o segfault segfault.c -lpthread | |
* segfault.c: In function ‘thread_fn’: | |
* segfault.c:7:5: warning: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration] | |
* segfault.c:7:17: warning: initialization makes pointer from integer without a cast [enabled by default] | |
* $ ./segfault | |
* Segmentation fault | |
*/ | |
#include <stdio.h> |
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
[user] | |
name = Emil Stenqvist | |
email = [email protected] | |
[branch] | |
autosetuprebase = always | |
[color] | |
diff = auto | |
status = auto |
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
from timeit import timeit | |
def timeit_and_print(stmt, setup='pass', number=100000): | |
t = timeit(stmt, setup=setup) | |
print 'Executed "%s" %d times in %.4f seconds, %.4f ms per call (%d calls per second)' % ( | |
stmt, number, t, 1000 * t / number, int(number / t)) |