Skip to content

Instantly share code, notes, and snippets.

View michelleboisson's full-sized avatar

Michelle Boisson michelleboisson

View GitHub Profile
@michelleboisson
michelleboisson / home.html
Created February 29, 2012 15:20
Selecting Options in dropdown menu from request.body
<form method="post">
<dl>
<% for(i=0; i<=itemTypes.length-1; i++) { %>
<dt><input type="checkbox" name="itemChoices" value="<%= itemTypes[i].itemTypeName %>"/> <strong><%= itemTypes[i].itemTypeName %></strong></dt>
<dd>Dominence Points: <%= itemTypes[i].domPts %><dd>
<dd>Picture: <%= itemTypes[i].picture %><dd>
<select>
<% for (r=rooms.length-1; r>=0; r--) { %>
<option value="<%= rooms[r].name %>"><%= rooms[r].name %></option>
<% } %>
@michelleboisson
michelleboisson / assign1.R
Created September 12, 2012 22:06
Data without Borders - Assignment 1
#Read in the data, save it to variable 'data'
data = read.csv("http://www.jakeporway.com/teaching/data/snf_11_2011_1.csv", header=TRUE, as.is=TRUE)
#How many women were stopped?
sum(data$sex == "F")
#[1] 3927
#What percentage of the stops is this?
sum(data$sex == "F") / length(data$sex) * 100
#[1] 6.760316
@michelleboisson
michelleboisson / data-without-borders-hw2-part1.R
Created September 18, 2012 21:21
Data without Borders - Assignment 2
# Write code to return the percentage of people who were frisked for each
# race. In other words, count up the number of people who were frisked for a given race
# divided by the number of people of that race stopped. Which race leads to the highest
# percentage of frisks? Which one the lowest?
#read in the data
snf <- read.csv("http://www.jakeporway.com/teaching/data/snf_2.csv", as.is=TRUE)
#race1 is black
race1.in.total = table(snf$race ==1)
@michelleboisson
michelleboisson / libya_tweets-pt1.r
Created September 26, 2012 22:55
Data Without Borders - Assignment 3
#How many unique users have more than 100000 followers? What are their screen names?
tweets <- read.csv("/Users/michelleboisson/Documents/ITP/* Data without Borders/hw3/libya_tweets.csv", as.is=TRUE)
unique(tweets$screen_name[which(as.numeric(tweets$followers) >= 100000)])
# [1] "detikcom" "DonLemonCNN" "HuffingtonPost" "Dputamadre" "WorldRss" "AlMasryAlYoum"
# [7] "theobscurant" "fadjroeL" "TPO_Hisself" "CAPAMAG" "TwittyAlgeria" "foxandfriends"
# [13] "PranayGupte"
@michelleboisson
michelleboisson / behavior-data.csv
Created September 30, 2012 20:37
Behavior Experiment
video time person behavior id real_time
1 5:00 girl in white hoodie stretched shoulders 1 12:35:00
1 8:00 sean arms up stretch 2 12:38:00
1 9:30 guy in green shirt infront of sean arms up stretch 3 12:39:30
1 13:31 sean stretched back 2 12:43:31
1 15:38 plaids shirt guy brisk back bend 4 12:45:38
1 16:01 guy in green shirt in front of sean brisk back bend 3 12:46:01
1 17:57 girl in white hoodie wrist stretch 1 12:47:57
1 19:43 girl in white hoodie wrist stretch 1 12:49:43
1 20:48 guy in green hands behind neck stretch 3 12:50:48
@michelleboisson
michelleboisson / behavior_exp.ino
Created October 3, 2012 23:10
Arduino Servo and light sensor
#include <Servo.h> // include the servo library
Servo servoMotor; // creates an instance of the servo object to control a servo
int servoPin = 2; // Control pin for servo motor
int pos = 0; // variable to store the servo position
int now, previousTime, interval = 0;
//for smoothing of values
@michelleboisson
michelleboisson / Lets-Get-Political.R
Created October 23, 2012 03:05
Data Without Borders - Assignment 6 (really 4)
# Let’s breakdown our tweets around a certain topic. How about, oh, say, Iran?
# So how do we pull tweets out that have a certain word in them?
# grep() to the rescue! If you’ve used the grep function on the command-line, this
# should look familiar. grep() takes as arguments a phrase you’re searching for, a
# set of text to look through, and optional arguments about how to search. It will
# then return the row numbers of any rows that match your search. To pull out Iran
# tweets, we can use the code:
iran.tweets <- tweets[grep(“iran”, ignore.case=TRUE, tweets$text), ]
@michelleboisson
michelleboisson / mapping-crime.R
Created November 6, 2012 22:24
Data Without Borders - Assignment 7
# CRIME MAPPING
#We’ve done some basic analysis of our Stop and Frisk data this semester, looking at
#basic statistics (e.g. number of stops by race or most common crimes by race) and
#timeseries information. We haven’t yet touched geography though. Let’s spend this
#week’s assignment answering the question: Where are Stop n Frisks happening in New
#York?
snf = read.csv("/Users/michelleboisson/Documents/ITP/* Data without Borders/snf_3.csv", as.is=TRUE)
geo = read.csv("/Users/michelleboisson/Documents/ITP/* Data without Borders/geo.csv", as.is=TRUE)
@michelleboisson
michelleboisson / homework8.R
Created November 15, 2012 03:56
Data Without Borders - Assignment 8
#Describing Distributions
snf = read.csv("http://jakeporway.com/teaching/data/snf_4.csv", head=T, as.is=T)
#Make a “height” column for your data that is the total number of inches tall each person is.
heights = apply(snf,1, function(x) { as.numeric(x['feet'])*12 + as.numeric(x['inches']) })
snf$fullheight = heights
mean(heights)
#[1] 68.57884
@michelleboisson
michelleboisson / IPCameraControl-Android.pde
Created November 20, 2012 01:34
Controlling an IP camera with an Android device
/**
* <p>This uses the Ketai Sensor Library for Android: http://ketaiMotion.org</p>
*
*
*/
import ketai.sensors.*;
KetaiSensor sensor;