Skip to content

Instantly share code, notes, and snippets.

@rweald
rweald / mongo_tweet_health_spike.rb
Created October 26, 2011 04:12
A simple script that grabs some health related tweets and stores them in mongodb
require 'mongo'
require 'tweetstream'
db = Mongo::Connection.new("dbh13.mongolab.com", "27137").db("ch-diabetes-demo")
auth = db.authenticate("surfandcode", "irNwHfB3udTEpk9z")
collection = db.collection("diabetic_tweets")
stream = TweetStream::Client.new("commithealth", "SDSF202e")
@rweald
rweald / install_macvim.sh
Created January 11, 2012 05:46
A very basic shell script to install MacVim and setup a custom configuration
#!/bin/bash
echo "removing old versions installed by homebrew"
brew remove macvim
rm /usr/local/bin/mvim
echo "Downloading MacVim Application"
cd ~/Downloads
curl -L "https://github.com/downloads/b4winckler/macvim/MacVim-snapshot-64.tbz" -o macvim.tbz
require 'aws-sdk'
require 'uuid'
require 'pry'
uuid = UUID.new
dynamo_db = AWS::DynamoDB.new(:access_key_id => "AKIAJLGFC545YHHWOD3A", :secret_access_key => "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")
dynamo_db.tables.each { |t| puts t.name }
tweets_db = dynamo_db.tables["tweets"]
@rweald
rweald / build.sbt
Created March 24, 2012 18:22 — forked from mumoshu/build.sbt
DES and AES encryption in Scala
name := "DES and AES encryption in Scala"
version := "1.0"
scalaVersion := "2.9.1"
libraryDependencies += "commons-codec" % "commons-codec" % "1.6"
@rweald
rweald / gist:3151173
Created July 20, 2012 14:59 — forked from igrigorik/gist:3148848
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
@rweald
rweald / ruby-on-mountain-lion.md
Created August 13, 2012 02:28
Getting Ruby Up and Running on OSX Mountain Lion
  • Install the latest version of xcode from the App Store

  • Install the xcode command line tools. How To Guide

  • XCode no longer ships with gcc-4.2 as a separate executable as gcc is version 4.2. Therefore you need to symlink it so that ruby can find gcc-4.2.

    sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
    
@rweald
rweald / spoof_mac_address.rb
Created August 27, 2012 17:20
Little Ruby script to spoof a mac address
#!/usr/bin/env ruby
puts "Please Enter Your MAC Address: "
mac = gets
mac = mac.strip
`sudo /bin/bash -lc "sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z && sudo ifconfig en0 ether #{mac}"`
puts "Congratulations you now have #{mac} as your MAC address"
@rweald
rweald / denominator-snippet.rb
Created August 29, 2012 17:50
Code Snippets for Simple Linear Regression Using Ruby Blog Post
denominator = @xs.reduce(0) do |sum, x|
sum + ((x - x_mean) ** 2)
end
@rweald
rweald / sample-video-view-data.csv
Created August 29, 2012 18:00
Simple Linear Regression Using Ruby Blog Post DataSet
Days Online Number of Views
1 5500.0
2 45000.0
3 27500.0
4 38000.0
5 38500.0
6 17000.0
7 37500.0
8 55000.0
9 63500.0
@rweald
rweald / simple-linear-regression.rb
Created August 29, 2012 19:13
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))