Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Tamosunas scotttam

View GitHub Profile
@scotttam
scotttam / app_duration_mixpanel.rb
Created Jan 26, 2011
Putting app running time metrics into mixpanel
View app_duration_mixpanel.rb
#If you see 1 on the terminal, that's success. 0 is bad.
require 'rubygems'
require 'base64'
require 'json'
event_hash = {}
event_hash['event'] = "app_time"
event_hash['properties'] = {:token => "4130e0e1bf5ade215e80ebc0b7765b6f", :publisher_id => "1234", :app_id => "5678", :time => Time.now.to_i, :duration => rand(10000)}
@scotttam
scotttam / app_start_time_mixpanel.rb
Created Jan 26, 2011
Recording app start times with mixpanel.rb
View app_start_time_mixpanel.rb
#If you see 1 on the terminal, that's success. 0 is bad.
require 'rubygems'
require 'base64'
require 'json'
event_hash = {}
event_hash['event'] = "app_start"
event_hash['properties'] = {:token => "4130e0e1bf5ade215e80ebc0b7765b6f", :time => Time.now.to_i, :publisher_id => "1234", :app_id => "5678", :start_time => Time.now.to_i}
@scotttam
scotttam / Decrypter.java
Created Mar 17, 2011
encrypt and decrypt with PBKDF2/SHA1 and AES
View Decrypter.java
import javax.crypto.Cipher;
import java.security.spec.KeySpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.SecretKeyFactory;
import java.security.AlgorithmParameters;
import javax.crypto.spec.IvParameterSpec;
public class Decrypter {
@scotttam
scotttam / decrypt.rb
Created Mar 17, 2011
decrypt PBKDF2/SHA1 and AES
View decrypt.rb
require "base64"
require 'openssl'
require 'iconv'
CIPHER = "aes-256-cbc"
#http://www.ruby-doc.org/ruby-1.9/classes/OpenSSL/PKCS5.html
PASSPHRASE = "12345"
IV = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].pack("c*")
@scotttam
scotttam / watch_unicorn.sh
Created Apr 13, 2011
script to watch the unicorns
View watch_unicorn.sh
#!/bin/sh
loop_count=10000
while [ $loop_count -gt 0 ]; do
clear
ls -l /data/server/current
uptime
ps wax --forest | grep [u]nicorn
sleep 1
echo "Refreshing..."
@scotttam
scotttam / tracker.rb
Created May 26, 2011
Pull down the tracker stories
View tracker.rb
begin
require 'pivotal_tracker'
rescue LoadError
puts "This script requires the pivotal-tracker gem: gem install pivotal-tracker"
exit(1)
end
CLIENT_TOKEN = 'GET YER OWN'
PROJECT_ID = 12345
MILESTONE_LABELS = ['m1', 'm2', 'm3', 'm4']
@scotttam
scotttam / pbkdf2_aes.js
Created Aug 16, 2011
Javascript example generating a PBKDF2 key and encrypting/decrypting using AES/256/CBC
View pbkdf2_aes.js
//Requires:
//JQuery
//slowAES (http://code.google.com/p/slowaes/)
//pbkdf2 (1.1) by Parvez Anandam (http://anandam.name/pbkdf2)
//sha1 (2.1a) by Paul Johnston (http://pajhome.org.uk/crypt/md5)
(function(window, document, $, undefined){
$(document).ready(function() {
var startTime = new Date();
View gist:1401441
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git::\1)/'
}
export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\$(parse_git_branch)\[\033[00m\]$\[\033[00m\] "
alias ss='script/rails server'
alias c='script/rails console'
alias start_resque='rake VVERBOSE=1 QUEUE=* environment resque:work --trace'
alias start_ios='cd ~/workspace/katama_server; ruby script/ios_resque_endpoint.rb'
@scotttam
scotttam / gist:1683489
Created Jan 26, 2012
failed iOS compilation
View gist:1683489
cd /var/folders/9n/980qyb090qj5xnbvct2z45rm0000gp/T/4f2176bcb2c2097f8b0001e2/1327593542/IOS
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/Users/scotttam/.rvm/gems/ruby-1.9.2-p180@katama_server_push/bin:/Users/scotttam/.rvm/gems/ruby-1.9.2-p180@global/bin:/Users/scotttam/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/scotttam/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:/Users/scotttam/workspace/users/brightcove/bin:/Applications:/Users/scotttam/ec2/bin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 -x objective-c -arch armv7 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -Os -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -mthumb -miphoneos-version-min=4.0 -iquote /var/folders/9n/980qyb090qj5xnbvct2z45rm0000gp/T/4f2176bcb
View apns_test.rb
require "base64"
require "openssl"
require "socket"
require "yajl" #gem install yajl-ruby
IDENTIFIER = 0
EXPIRY = 0
ENHANCED_COMMAND = 1
DEVICE_TOKEN_SIZE = 32
# DEVICE_TOKEN = Base64.decode64("4DJXVKUhziWwNihDfraFXXZ4RIJK+dCHoiS3awnh0w0=")