Skip to content

Instantly share code, notes, and snippets.

@brookskindle
brookskindle / ramblings!~
Created January 31, 2013 03:30
push vs push -u
git push -u github master
is way better than
git push github master.
-u allows you to push your master branch to github with more ease in the future:
from then on, just type
git push
and as long as you're on your master branch, it will automatically push your master branch to github!
@brookskindle
brookskindle / arraySize.c
Created February 1, 2013 00:42
quick way to find the size of an array in C
#include <stdio.h>
int main(void)
{
int arr[] = {45, 69, 27, 3, 99, -1, 0, 948, 34, 46};
int size = 0;
size = sizeof(arr) / sizeof(int);
printf("Size: %d.", size);
@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
@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 / 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

Pre-class Exercises

What is the difference between the following two lines?

num = 4
num == 4

Given the following code:

@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.
@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 / 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 / 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