Skip to content

Instantly share code, notes, and snippets.

@evanemolo
evanemolo / gist:11380480
Last active August 29, 2015 14:00
Perka - generate a visitor
# Customer Check-in Script
import requests
def init():
checkin_type = raw_input('Enter 1 for "points" or 2 for "punches": ')
new_customer_data = create_customer()
if checkin_type == '1':
checkin_customer('points', new_customer_data)
@evanemolo
evanemolo / gist:2405864
Created April 17, 2012 13:08
Tweet Count Web App
var express = require('express');
var ejs = require('ejs'); //embedded javascript template engine
var app = express.createServer(express.logger());
var mongoose = require('mongoose'); // include Mongoose MongoDB library
var schema = mongoose.Schema;
var requestURL = require('request');
@evanemolo
evanemolo / twitter-stepper.pde
Created April 25, 2012 19:37
twitter-stepper
//Twitter-Stepper Test
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
#include <Stepper.h>
#define STEPS 200
// MAC address and server DNS:
@evanemolo
evanemolo / ard-interval-test.ino
Created May 1, 2012 00:46
arduino interval test code
//Twitter-Stepper Test
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
#include <Stepper.h>
#define STEPS 200
// interval declarations
@evanemolo
evanemolo / DWB-Assignment-WK2
Created September 19, 2012 18:09
Data Without Borders—Week 2 Assignment
snf <- read.csv("http://www.jakeporway.com/teaching/data/snf_2.csv", as.is=TRUE)
# Part 1
# Write code to return the percentage of people who were frisked for each race.
race.code = c(-1,1,2,3,4,5,6)
for(i in race.code) {
@evanemolo
evanemolo / DWB-race-top-crimes.R
Created September 20, 2012 15:37
DWB-race-top-crimes
snf <- read.csv("http://www.jakeporway.com/teaching/data/snf_2.csv", as.is=TRUE)
crime.abbr = substr(snf$crime.suspected, 1, 3)
snf$crime.abbr = crime.abbr
race.code = c(-1,1,2,3,4,5,6)
for(i in race.code) {
# create subset
which.race = which(snf$race == i)
@evanemolo
evanemolo / race-top-crime-answer.R
Created September 20, 2012 15:44
race-top-crime-answer
[1] "racecode -1 results:"
subset.race.crime.abbr
FEL MIS CPW
566 229 202
[1] "racecode 1 results:"
subset.race.crime.abbr
FEL MIS CPW
10744 4487 4009
[1] "racecode 2 results:"
subset.race.crime.abbr
@evanemolo
evanemolo / Obese-discrimination-arrests.R
Created September 20, 2012 15:54
Obese-discrimination-arrests
snf <- read.csv("http://www.jakeporway.com/teaching/data/snf_2.csv", as.is=TRUE)
# First create a subset of the data only consisting of “good” weights and heights.
clean.subset = snf[snf$height > 40 & snf$weight > 90 & snf$weight < 400, ]
# Add a BMI variable to our dataset, where BMI is computed as (weight)*703/(height*height).
bmi = (clean.subset$weight)*703/(clean.subset$height*clean.subset$height)
# What percentage of people with BMI’s greater than or equal to 30 who were stopped were
# ultimately arrested?
obese.subset = clean.subset[bmi >= 30, ]
obese.arrested.subset = which(obese.subset$arrested == 1)
@evanemolo
evanemolo / .bashrc
Created September 29, 2012 16:09
.bashrc-boilerplate
# custom command prompt
export PS1="\W > "
# bash aliases
alias la='ls -la'
alias lah='ls -lah'
alias move='mv -i'
alias rename='mv'
alias remove='rm -i'
alias rmdir='rm -rf'
@evanemolo
evanemolo / list-compare.R
Created September 29, 2012 20:21
Comparing lists in R
# Write code to find the 5 most popular words used in the descriptions of our users
# use strsplit to seperate the words in the description
split.description = strsplit(tweets$description, split = "[^a-zA-Z0-9]+")
# use unlist() to turn the list into a vector
split.description = unlist(strsplit(tweets$description, split = "[^a-zA-Z0-9]+"))
# use tolower() to convert all words to lower case to reduce duplicates
split.description = tolower(unlist(strsplit(tweets$description, split = "[^a-zA-Z0-9]+")))
# count the number of occurances of each word, and pull the top five
rev(sort(table(split.description)))[1:5]