Skip to content

Instantly share code, notes, and snippets.

View veryeli's full-sized avatar

Eli Feasley veryeli

  • places
View GitHub Profile
NUM_SHIFTS_PER_DAY_OF_WEEK = {
0: 5,
1: 4,
2: 7,
3: 5,
4: 4,
}
SHIFTNAME = {
0: 'LOW 1',
@veryeli
veryeli / lisp_parser.py
Last active July 16, 2018 00:18
Lisp Parser for Recurse Center Interview
# Parse an abstrat syntax tree from a Lisp expression
def tokenize(expression):
'''Ensures the expression is parsed into words and parentheses.'''
# only tokenize if it's not already tokenized
if type(expression) == list:
return expression
if type(expression) == str:
# put spaces around parentheses so they get tokenized separately
expression = expression.replace('(', ' ( ').replace(')', ' ) ')
@veryeli
veryeli / basic_stats_worked_example.sql
Last active August 29, 2015 14:02
Worked Examples SQL Queries
SELECT top_alternative AS alternative,
ROUND(NTH(500, QUANTILES(ud_points, 1001)), 2) AS median_points,
ROUND(avg(ud_points),2) AS mean_points,
ROUND(NTH(500, QUANTILES(ud_weekly_problem_days, 1001)),2) AS median_weekly_days,
ROUND(avg(ud_weekly_problem_days),2) AS mean_weekly_days,
ROUND(NTH(500, QUANTILES(ud_monthly_problem_seconds/60, 1001)),2) AS median_monthly_minutes,
ROUND(avg(ud_monthly_problem_seconds/60),2) AS mean_monthly_minutes,
ROUND(NTH(500, QUANTILES(ud_monthly_problems_done, 1001)),2) AS median_monthly_problems,
ROUND(avg(ud_monthly_problems_done),2) AS mean_monthly_problems,
ROUND(NTH(500, QUANTILES(percent_mastered, 1001)*100),2) AS median_percent_mastered,
@veryeli
veryeli / Advanced Missions - Completion
Last active August 29, 2015 14:01
Queries for Prereq analysis
SELECT alternative, mission_title, INTEGER(ROUND(NTH(500, QUANTILES(percent_mastered, 1001)) * 100)) as median_pct_mastered,
INTEGER(ROUND(NTH(500, QUANTILES(ud_total_problem_seconds, 1001)) / 60)) as median_problem_minutes,
NTH(500, QUANTILES(ud_age, 1001)) as median_age,
COUNT(1) as N FROM
(SELECT ud_age, ud_total_problem_seconds, mission_title, percent_mastered, alternative FROM [eli.advanced_mission_demos])
GROUP BY alternative, mission_title
order by mission_title, alternative
@veryeli
veryeli / generating script
Last active December 19, 2015 21:49
Covering relationships from topictree
# To run:
# install graphviz commands
# Download topictree from http://www.khanacademy.org/api/v1/topictree
# open ipython or something and run the following script. Save the output
# as, for instance, covers.gv
# run:
# dot covers.gv -T ps > out.ps
# open out.ps
# Make it look better by playing with it and then let me know what you did!
@veryeli
veryeli / gist:3805378
Created September 29, 2012 23:01
Data Model
Patients
age - int
intervention (str, always IV tPA)
patient id: alpha num, 6 - 12 chars
LSN datetime
Triage datetime
MRI datetime
treatment datetime
LSN-triage int (minutes)
LSN-MRI int(minutes)