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 vm = require('vm'), | |
Contextify = require('contextify'), | |
code = 'var square = n * n;', | |
fn = new Function('n', code), | |
script = vm.createScript(code); | |
n = 5; | |
benchmark = function(title, funk) { | |
var end, i, start, spins = 10000; |
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
import importlib | |
from multiprocessing import Pool | |
from django.test.simple import DjangoTestSuiteRunner | |
from django.conf import settings | |
__doc__ = """ | |
In settings.py do this: | |
JUXD_FILENAME = '/Code/project/junit.xml' |
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 strict'; | |
var domain = require('domain'); | |
var userMethod = 'handler'; | |
var userCodeWrapper = function(userCode) { | |
return '\ | |
"use strict";\n\ | |
' + userCode + '\n\ | |
try {\n\ |
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
class DisconnectCacheCloseSignal(object): | |
""" Add me to your settings.MIDDLEWARE_CLASSES """ | |
def process_response(self, request, response): | |
from django.core.cache import caches, close_caches | |
signals.request_finished.disconnect(caches['default'].close) | |
signals.request_finished.disconnect(close_caches) | |
return response |
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
[ | |
{ | |
"id": "222dcd03aed943a8676dc80e2427a40d", | |
"title": "The Headquarters", | |
"lat": 37.387617, | |
"long": -122.036132 | |
}, | |
{ | |
"id": "a102c4a959dfe7efdd3a4e112bee0407", | |
"title": "A Sweet Beach", |
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
[ | |
{ | |
"id": 6, | |
"name": "banana" | |
}, | |
{ | |
"id": 5, | |
"name": "burrito" | |
}, | |
{ |
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
#!/bin/bash | |
# This is modifed from https://gist.github.com/caiguanhao/4528926 | |
# This is an improved script of pngfix.sh (https://gist.github.com/404909) | |
# which can also crush/shrink/optimize/losslessly compress JPEGs and GIFs. | |
# It is recommended you backup your image files before executing this script. | |
# Operation will be skipped if output file is bigger in size. | |
# | |
# use chmod +x crushimg.sh to make it executable and then ./crushimg.sh to run, or | |
# bash ./crushimg.sh to run it directly | |
# |
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
import itertools | |
import math | |
def tokenize_keyboard(board): | |
return [list(row.strip()) for row in board] | |
def invert_grid(grid): | |
out = {} | |
for row_i, row in enumerate(grid): | |
for col_i, cell in enumerate(row): |
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
""" | |
users if active or not on a given day plus counts of events | |
""" | |
import os | |
import csv | |
from collections import defaultdict | |
from collections import Counter | |
UFILE = 'data/users.csv' |
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
package main | |
import ( | |
"fmt" | |
) | |
func decorator(f func(s string)) func(s string) { | |
return func(s string) { | |
fmt.Println("Started") |