Skip to content

Instantly share code, notes, and snippets.

View justinvanwinkle's full-sized avatar

Justin Van Winkle justinvanwinkle

View GitHub Profile
def test_method(method):
start_time = time.time()
result = method()
assert len(result) == 68888890, 'Method work no good: %s != 68888890' % len(result)
end_time = time.time()
print method.func_name, end_time - start_time
def naive_way():
#!/usr/bin/env python
import time
data = range(10000000)
def test_method(method):
start_time = time.time()
result = method()
assert len(result) == 68888890, 'Method work no good: %s != 68888890' % len(result)
end_time = time.time()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from cStringIO import StringIO
from UserString import MutableString
data = xrange(100000)
def test_join_way():
return ''.join([str(x) for x in data])
"#detail-bullets td.bucket div.content li" | {
kind := /([ \w]+):/
value := /: (.+)/
}
description = .".content #postBodyPS p"
"#ASIN" {
asin = value
from __future__ import division
import random
import sys
import re
from math import floor
from math import ceil
from collections import defaultdict
_tokenize = re.compile(r'((?:\w{1,20}\'\w+)|(?:\w{1,20})|(?:[.,]))')
bad_attrs = ('__class__', '__doc__', '__init__', '__new__',
'__getattr__', '__getattribute__', '__subclasshook__',
'__str__', '__repr__', '__hash__', '__setattr__')
good_attrs = ('append',)
def get_ops(o):
ops = [x for x in dir(o) if
(x.startswith('__') and x not in bad_attrs) or
type
TPerson = object of TObject
name*: string
age: int
TStudent = object of TPerson
student_id: int
var
student: TStudent
@justinvanwinkle
justinvanwinkle / gist:6410445
Created September 2, 2013 08:21
Methods defined in closures for fast local performance.
class Closer(object):
def __init__(self):
methods = self.fixup_methods()
for name, method in methods.iteritems():
setattr(self, name, method)
def _inner__(self):
return locals()
def fixup_methods(self):
09 19:22:30
m218176vaps2036.att.target.com, WCS01 </<built-in function Comment>> <title> KitchenAid Stamped Set - Black (16 Pc)
href="http://Img2.targetimg2.com/wcsstore/TargetSAS/11_05_2013_06_55/css/Globalperf_2_ie_minified.css
http://Img3.targetimg3.com/wcsstore/TargetSAS/11_05_2013_06_55/
http://imgsvc.target.com/wcsstore/TargetSAS/11_05_2013_06_55/
http://Img1.targetimg1.com/wcsstore/TargetSAS/11_05_2013_06_55/images/spinner-small.gif
<a> Load Complete Content
12417854",
12417854
4133
for(i = 0; i < BUCKET_A_SIZE; ++i) { bucket_A[i] = 0; }
for(i = 0; i < BUCKET_B_SIZE; ++i) { bucket_B[i] = 0; }
/* Count the number of occurrences of the first one or two characters of each
type A, B and B* suffix. Moreover, store the beginning position of all
type B* suffixes into the array SA. */
for(i = n - 1, m = n, c0 = T[n - 1]; 0 <= i;) {
/* type A suffix. */
do { ++BUCKET_A(c1 = c0); } while((0 <= --i) && ((c0 = T[i]) >= c1));
if(0 <= i) {