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 collections import deque | |
class Node(object): | |
left = None | |
right = None | |
value = None | |
def __init__(self, left, right, value): | |
self.left = left | |
self.right = right |
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 programming problems every software developer should be able to solve in | |
under an hour. | |
Given an array of integers find the largest integer they can be combined to | |
form. | |
for instance [50, 2, 1, 9, 62] would yield the answer 9625021 | |
""" |
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 dateutil.parser import parse | |
from pytz import utc | |
datestr = 'Fri, 24 Apr 2015 14:49:32 -0400' | |
dt = parse(datestr) | |
utc_dt = dt.astimezone(utc) | |
final = utc_dt.replace(tzinfo=None) |
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 collections import namedtuple | |
from wtforms import Form, IntegerField, FieldList, FormField, TextField | |
from werkzeug.datastructures import MultiDict | |
Prediction = namedtuple('Prediction', ['id']) | |
predictions = [Prediction(id=1), Prediction(id=2)] | |
class PredictionForm(Form): | |
id = IntegerField() |
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
print [for num in ['33','14','96'] if set(num).intersection(set(['0','2','3','5','6','8','9']))] |
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
s = set(['0','2','3','5','6','8','9']) | |
l = ['33', '14', '19'] | |
# as loop | |
for num in l: | |
charset = set(num) | |
if charset.intersection(s): | |
print num | |
# as comprehension |
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
# | |
# Wide-open CORS config for nginx | |
# | |
location / { | |
if ($request_method = 'OPTIONS') { | |
add_header 'Access-Control-Allow-Origin' '*'; | |
# |
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
<!-- Sample Site http://nsfyn55.fortune.site.s3-website-us-east-1.amazonaws.com/ --> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html"; charset="UTF-8"/> | |
<title>Page Title</title> | |
<link rel="stylesheet" type="text/css" href="test.css"> | |
<link rel="stylesheet" type="text/css" href="dhtmlxslider.css"> | |
<script type="text/javascript" src="d3.js"></script> | |
<script type="text/javascript" src="dhtmlxcommon.js"></script> | |
<script type="text/javascript" src="dhtmlxslider.js"></script> |
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
def create_list(n): | |
l = [] | |
for x in range(2,n+1): | |
l.append(x) | |
return l | |
def get_remove_factors(start, n, inc): | |
s = set() | |
for i in range(start, n+1, inc): | |
if i > start: |
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
def tick(world): | |
output_world = world.copy() | |
if len(world) <= 2: | |
return set() | |
for cell in world: | |
if len(get_live_neighbors(cell, world)) < 2: | |
output_world.remove(cell) |