Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
sangheestyle / seller.py
Created February 12, 2017 20:40
Chapter 6, Breath-first search (From Grokking Algorithm)
from collections import deque
def is_person_seller(person):
return True if person.endswith('m') else False
def search(graph, start_point, search_function):
search_queue = deque()
search_queue.extend(graph[start_point])
@sangheestyle
sangheestyle / gradebook.py
Created January 30, 2017 05:16
Item 22: Prefer Helper Classes Over Bookkeeping with Dictionaries and Tuples from Effective Python written by Brett Slatkin
# This code is from
# Item 22: Prefer Helper Classes Over Bookkeeping with
# Dictionaries and Tuples
# from Effective Python written by Brett Slatkin
# 2015
import collections
Grade = collections.namedtuple('Grade', ('score', 'weight'))
@sangheestyle
sangheestyle / Wash+sell+model+-+take+2.ipynb
Created January 1, 2017 23:44
Practicing wash sell model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sangheestyle
sangheestyle / build_vendored.sh
Last active December 7, 2016 05:50
Create python dependency directory for using scikit-learn on AWS lambda Raw
#!/bin/bash
set -ex
set -o pipefail
yum update -y
yum install -y \
atlas-sse3-devel \
blas-devel \
gcc \
gcc-c++ \
# python
Python 2.7.12 (default, Sep  1 2016, 22:14:00) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy.distutils.system_info as si
>>> si.get_info('atlas')
ATLAS version 3.8.4 built by mockbuild on Sat Jul  7 07:38:30 UTC 2012:
   UNAME    : Linux gobi-build-31003.sea31.amazon.com 2.6.18-164.el5az00 #1 SMP Tue Sep 15 14:19:07 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
   INSTFLG  : -1 0 -a 1
@sangheestyle
sangheestyle / test.py
Created December 4, 2016 01:09
invoke aws lambda from another lambda
from __future__ import unicode_literals
import base64
from datetime import datetime, timedelta
import random
import string
import json
import zlib
from concurrent.futures import ThreadPoolExecutor, as_completed
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# fourFn.py
#
# Make the original fourFn.py simple to understand how it works.
#
# Original source code:
# http://pyparsing.wikispaces.com/file/view/fourFn.py/30154950/fourFn.py
import math
import operator
from pyparsing import Literal, CaselessLiteral, Word, Combine, \
def repeat(object, times=None):
# repeat(10, 3) --> 10 10 10
if times is None:
while True:
yield object
else:
for i in range(times):
yield object
@sangheestyle
sangheestyle / May 26, PyParsing.ipynb
Created June 1, 2016 21:54
Practicing simple query parser with pyparsing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.