Skip to content

Instantly share code, notes, and snippets.

@brookskindle
brookskindle / README.md
Last active October 21, 2019 06:03
Queries against the Checkouts by Title dataset that the City of Seattle has. https://data.seattle.gov/Community/Checkouts-by-Title/tmmm-ytt6

Database looks like

$ psql checkouts <<< "\d"
          List of relations
 Schema |   Name    | Type  | Owner  
--------+-----------+-------+--------
 public | checkouts | table | brooks
(1 row)

$ psql checkouts <<< "\d checkouts"
@brookskindle
brookskindle / build_hots_db.py
Created November 20, 2018 03:10
Populate a Postgres table with information from HOTSLogs
#!/usr/bin/env python
"""
Build a heroes of the storm database
"""
import csv
import logging
import time
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, Boolean, create_engine
@brookskindle
brookskindle / fake_census.py
Created May 7, 2018 00:29
Generate fake census data with the `faker` module
from faker import Faker
import pandas as pd
user_factory = Faker()
user_factory.seed(1000)
def get_fake_user():
global user_factory
@brookskindle
brookskindle / trackme.py
Last active February 22, 2018 23:06
What window and workspaces am I focused on throughout the day?
#!/usr/bin/env python3
from collections import namedtuple
import csv
import datetime
import os
import subprocess
import time
WindowInfo = namedtuple("WindowInfo", ["window_name", "window_class"])
@brookskindle
brookskindle / seattle_pet_breakdown.ipynb
Created June 12, 2017 04:37
Breakdown pet locations in Seattle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brookskindle
brookskindle / xkcd style graphs in jupyter.ipynb
Created June 8, 2017 20:11
A simple demonstration on how to make xkcd-styled graphs in Jupyter using Python and Pandas
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Pre-class Exercises

What is the difference between the following two lines?

num = 4
num == 4

Given the following code:

@brookskindle
brookskindle / class.c
Last active December 22, 2015 08:08
class like structures in c
#include <stdio.h>
//define a struct to contain variables and function pointers, much like a class
typedef struct ex {
//declare some variables
int x;
//declare some methods (aka, function pointers)
void (*const p)(void); //let p be a constant pointer
void (*const setX)(struct ex *, int); //must pass self-referential pointer to imitate class scope
@brookskindle
brookskindle / intPal.cpp
Last active December 14, 2015 08:49
Determine if an integer is a palindrome
#include <iostream>
#include <vector>
using namespace std;
bool isPal(int num);
bool isPal(int num)
{
vector<int> val;
@brookskindle
brookskindle / pow.py
Last active December 12, 2015 06:28
Two recursive methods for finding the value of x raised to the nth power. The first method uses the more straight forward approach, but upon inspecting the algorithm, we see that it ends up taking a LOT more recursive calls than power1 does.
def power(x, n):
if (n):
return x * power(x, n - 1)
else:
return 1
def power1(x, n):
if (not n): #0th power
return 1