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
/* | |
Oddly, the results are not very intuitive. Seems grid_2d_array is fastest in all benchmarks, | |
though I was expecting grid_1d_array or at least grid_2d_lazy_array to win | |
(or maybe even grid_canvas to be surprising, but I was disappointed). | |
Results with size=[1920,1200] (on Chrome, though Firefox is similar): | |
--- grid_canvas (2d canvas treated as small 2d array int storage structure) --- | |
create: 1ms |
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 binary_search = function(a, val, compare_fn) { | |
// Returns (positive) index of element if found (not necessarily the first), | |
// otherwise (negative) negated index of insertion point. | |
var left = 0, right = a.length; | |
// Tight loop optimization | |
if(compare_fn) { | |
while(left < right) { | |
var middle = (left + right) >> 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
class Task(BaseModel): | |
__tablename__ = 'task' | |
id = Column(types.Integer, primary_key=True) | |
time_created = Column(types.DateTime, default=datetime.now, nullable=False) | |
time_updated = Column(types.DateTime, onupdate=datetime.now) | |
time_wait_until = Column(types.DateTime, default=datetime.now, nullable=False) | |
seconds_elapsed = Column(types.Float) |
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 a(n): | |
for i in xrange(n): | |
yield i | |
def b(n): | |
r = [] | |
for i in xrange(n): | |
r.append(i) | |
return r |
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
"""Pylons application test package | |
This package assumes the Pylons environment is already loaded, such as | |
when this script is imported from the `nosetests --with-pylons=test.ini` | |
command. | |
This module initializes the application via ``websetup`` (`paster | |
setup-app`) and provides the base testing objects. | |
""" | |
from unittest import TestCase |
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
"""SQLAlchemy Metadata and Session object""" | |
from sqlalchemy import MetaData, types | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
from datetime import datetime, date | |
__all__ = ['Session', 'metadata', 'BaseModel'] | |
Session = scoped_session(sessionmaker(expire_on_commit=False)) |
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
"""The application's Globals object""" | |
from beaker.cache import CacheManager | |
from beaker.util import parse_cache_config_options | |
from myproject.lib.email import TurboMailer | |
class Globals(object): | |
"""Globals acts as a container for objects available throughout the | |
life of the application |
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.prototype.bind = function(bind) { | |
var self = this; | |
return function () { | |
var args = Array.prototype.slice.call(arguments); | |
return self.apply(bind || null, args); | |
}; | |
}; | |
/** Geometry and vectors **/ |
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 setup(config_file='development.ini'): | |
from socialgrapple.config.environment import load_environment | |
from paste.deploy import loadapp | |
from routes.util import URLGenerator | |
from webtest import TestApp | |
from beaker.session import SessionObject | |
environ = {'HTTP_HOST': 'socialgrapple.com'} | |
wsgiapp = loadapp('config:' + config_file, relative_to='.') | |
config = load_environment(wsgiapp.config['global_conf'], wsgiapp.config['app_conf']) |
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 python | |
# Print all the people you're following on Twitter. | |
import webbrowser | |
import tweepy | |
import sys | |
def main(): | |
# Twolever app | |
consumer_key, consumer_secret = 'd8BVP2w58kwnVxVT3BrrPQ', 'Wuelj9vieJgzpnfqGTxptYBqN9BT3SYHxQnRzeyBbxg' |