Skip to content

Instantly share code, notes, and snippets.

View jakekara's full-sized avatar
💾

Jake jakekara

💾
View GitHub Profile
@jakekara
jakekara / coin_flip_sim.py
Created August 9, 2016 00:16
Coin flip simulator to find how many flips are required to produce x consecutive "heads" flips.
# Example of a coin flip simulator
# with a statistical summary
import random, pandas as pd
def flip():
if random.uniform(0.0,1.0) >= 0.5:
return "heads"
return "tails"
// Ratchet.js
// ----------
//
// Pass numbers to Ratchet object using the .add(val) method
// and retrieve the min and max value with .min() and .max()
// Or write custom methods using the .f method used to
// implement the .min() and .max() methods.
// Constructor
// ex: var r = new Ratchet();
@jakekara
jakekara / omg_bears_ct.py
Last active September 9, 2016 22:24
Use Pandas to download html table of bear sightings in CT and save to bears.csv
import pandas as pd
class BearTable():
"""
BearTable() - get a pandas DataFrame() of bear sightings in CT
--------------------------------------------------------------
This is a rolling list of bear sightings maintained by the CT
Department of Energy and Environmental protection. It is

Keybase proof

I hereby claim:

  • I am jakekara on github.
  • I am jakekara (https://keybase.io/jakekara) on keybase.
  • I have a public key whose fingerprint is 0D3D 4A89 09C5 B913 269D 6713 963C E336 3633 EACE

To claim this, I am signing this object:

@jakekara
jakekara / airportstatus.py
Last active December 23, 2016 19:57
get FAA airport status
import requests
def status_url(code):
return "http://services.faa.gov/airport/status/" + code + "?format=application/json"
def get_status(code):
r = requests.get(status_url(code))
if r.status_code != 200:
raise Exception ("Error fetching status for airport " + code+ ": <Status: " + str(r.status_code) + ">")
@jakekara
jakekara / MetaEditor.swift
Created August 15, 2016 22:08
Class for getting and seeing file attributes in Swift
//
// MetaEditor.swift
// Developed for meditor - http://github.com/jakekara/meditor/
// Get and set file attributes
//
// Created by Jake Kara on 8/12/16.
//
import Foundation
@jakekara
jakekara / throttle.js
Created January 16, 2017 20:35
Barebones object for throttling function calls (preventing them from being called too often)
// -----------------------------------
// barebones example of how to throttle a function
// so it doesn't fire too frequently
var THROTTLE = function(){
this.wait = 200;
}
// execute f in this.wait milliseconds. if there's already an f waiting to be called,
// drop it and replace it with this f
<!DOCTYPE html>
<html>
<head>
<!-- Numeral.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.4/numeral.min.js"></script>
<!-- D3js -->
<script src="https://d3js.org/d3.v4.min.js"></script>
<!-- Main style -->
@jakekara
jakekara / Sample execution
Last active March 14, 2017 17:15
print the keys from any level of a json file
Script started on Tue Mar 14 13:11:42 2017
bash-3.2$ ./jsonkeys.py tl_2016_09_tabblock10.json
[u'objects', u'type', u'transform', u'arcs']
bash-3.2$ ./jsonkeys.py tl_2016_09_tabblock10.json:objects
[u'r9c3', u'r5c1', u'r0c2', u'r8c9', u'r8c8', u'r8c7', u'r8c6', u'r8c5', u'r8c4', u'r8c3', u'r8c2', u'r8c1', u'r3c0', u'r2c1', u'r3c2', u'r3c3', u'r3c4', u'r3c5', u'r3c6', u'r3c7', u'r3c8', u'r3c9', u'r2c3', u'r2c2', u'r2c5', u'r2c4', u'r2c7', u'r2c6', u'r1c3', u'r5c8', u'r5c9', u'r0c1', u'r5c2', u'r5c3', u'r0c0', u'r5c6', u'r5c7', u'r5c4', u'r5c5', u'r7c4', u'r7c5', u'r7c6', u'r4c8', u'r6c9', u'r6c8', u'r7c2', u'r7c3', u'r4c3', u'r4c2', u'r6c7', u'r6c2', u'r4c7', u'r4c6', u'r6c3', u'r7c1', u'r4c4', u'r7c7', u'r1c0', u'r4c0', u'r1c1', u'r6c5', u'r6c1', u'r4c9', u'r4c1', u'r6c6', u'r2c8', u'r7c8', u'r2c0', u'r7c9', u'r3c1', u'r1c2', u'r4c5', u'r9c8', u'r9c9', u'r9c6', u'r9c7', u'r9c4', u'r9c5', u'r9c2', u'r6c4', u'r9c1']
bash-3.2$ ./jsonkeys.py tl_2016_09_tabblock10.json:type
<type 'unicode'>
bash-3.2$ ./jsonkeys.p
@jakekara
jakekara / pg_s3_heroku.sh
Last active May 8, 2017 18:33
use an s3 bucket to synch a local postgres DB to a Heroku instance
#
# pg->s3->heroku! - synch a local postgresdb to Heroku using an s3 bucket
#
BUCKET=s3://PUT_YOUR_DBNAME_HERE
LOCALSYNC=s3sync
DUMPNAME=db.dump
APPNAME=PUT_YOUR_APPNAME_HERE
BUCKETURL=https://s3.amazonaws.com/PUT_YOUR_LINK_HERE
LOCAL_DB_UNAME=PUT_YOUR_LOCAL_DB_UNAME_HERE