Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aantix's full-sized avatar

Jim Jones aantix

View GitHub Profile
@aantix
aantix / allow_webrtc_video.reg
Created May 19, 2014 14:29
Allow webrtc video policy under http for Chrome (Windows)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome]
"AudioCaptureAllowed"=dword:00000001
"VideoCaptureAllowed"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\AudioCaptureAllowedUrls]
"1"="http://[*.]fiveaskfive.com/"
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\VideoCaptureAllowedUrls]
@aantix
aantix / seed_model_hash_dump.rb
Created January 1, 2011 02:34
Display model data in hash form for create -- Useful in dumping old Rails model data (for seeds.rb)
model = Object::const_get(ARGV[0])
rows = model.find(:all)
# Any columns you don't want output, list here as symbols
# e.g. BLACKLIST = [:user_id, :workout_id]
BLACKLIST = []
# Any columns that you'd like to rename on the output, list in this hash
# e.g. TRANSFORM = {:percentOfMax => :percent_of_max}
TRANSFORM = {}
@aantix
aantix / pre-commit
Created January 11, 2011 22:21
Checks to see if there are any uncommitted files and alerts the git user that they need to add or ignore before proceeding.
#!/bin/sh
#
# .git/hooks/pre-commit
#
if git status -u | grep '^# Untracked files:$'
then
echo 'Files need to be either added ( git add .) or ignored (edit the .gitignore file) before a commit can be made.'
exit 1
fi
@aantix
aantix / factories_from_db.rb
Created January 16, 2011 12:14
Takes a seeded model and dumps out the data in a format that can be used for testing factories
# 523 : ~/Projects/runfatboy2 $ rails runner ~/factories_from_db.rb Exercise 1 2 3
#
# Factory.define :exercise_incline press do |r|
# r.name 'Incline Press'
# r.url 'http://video.google.com/googleplayer.swf?docId=-5762262560903802111&hl=en'
# r.verb 'Lift'
# r.measurement_type_id 3
# r.exercise_type_id 1
# r.user_id 2
# r.start_weight 0.8
@aantix
aantix / turk_import_to_excel.rb
Created January 19, 2011 02:51
Imports the data for a specific Mechanical Turk HIT (by title) and stores the data in an excel spreadsheet.
# turk_import_to_excel.rb hit_title file_output.xls sandbox=false dispose_hit=false
# ruby turk_import_to_excel.rb 'Find resources to help the disabled/underprivileged people of San Francisco, CA' /tmp/output.xls false false
#
# 255 char limitation for spreadsheet cell : http://blog.eastfacesoftware.com/2008/01/14/ruby-spreadsheet-excel-gem-255-character-limit/
#
require 'rubygems'
require 'rturk'
require "spreadsheet/excel"
@aantix
aantix / sync.rb
Created January 19, 2011 21:38
RSyncs all svn changed files to a remote VM volume. Useful when you want to test changes on a remote VM, but not necessarily commit them to the SVN trunk.
#!/usr/bin/env ruby
ignore_patterns = ["db/","test","log","reports","server","vendor/","Gemfile","tmp",".idea","config/",".DS_Store", ".xml", '.zip']
ignore_statuses = ['!','D','?']
changed_files = (`svn status`).split("\n").collect do |e|
p = e.split(/\s+/)
ignore_statuses.include?(p[0]) ? nil : p[p.size - 1]
end.compact
@aantix
aantix / download_images.rb
Created November 7, 2011 01:16
Download all images for a given web page
require 'nokogiri'
require 'open-uri'
require 'uri'
require 'pathname'
pages = ['http://images.google.com/search?tbm=isch&hl=en&source=hp&q=dogs',
'http://images.google.com/search?tbm=isch&hl=en&source=hp&q=cats',
'http://images.google.com/search?tbm=isch&hl=en&source=hp&q=hats']
pages.each do |page|
@aantix
aantix / gist:1596047
Created January 11, 2012 18:30
Open Letter to Mechanical Turk: Please improve the externalSubmit interface

Sharon, just to introduce myself. My name is Jim Jones, I’m a senior software engineer at Zvents (recently acquired by StubHub). We’re located in San Mateo, CA.

I am the author of the Ruby/Mechanical Turk integration gem, Turkee ( http://www.github.com/aantix/turkee ).

Recently I’ve run into an issue with the platform’s externalSubmit interface. I’ve posted the specifics here :
https://forums.aws.amazon.com/thread.jspa?threadID=84581&tstart=0

My frustration lays with the fact that there is no way to accurately debug issues that arise with posting to the externalSubmit interface. All I receive is an ambiguous “Your request was not completed successfully”. This isn’t the first time I’ve run into this ambiguous error message.

Further complicating the issue, the above issue appeared to be inconsistent on my day-to-day debugging. One day it appeared to be length dependent, the next day those same

@aantix
aantix / clean_pop3.rb
Created January 13, 2012 23:54
Clean Pop3 Account
require 'net/pop'
Net::POP3.start(ARGV.shift, 110,
ARGV.shift, ARGV.shift) do |pop|
if pop.mails.empty?
puts 'No mail.'
else
puts "Deleting #{pop.mails.size} mails."
i = 0
pop.each_mail do |m| # or "pop.mails.each ..."
@aantix
aantix / extract_emails_names.rb
Created April 11, 2012 16:50
Extract Names and Emails Address
# http://zadasnotes.blogspot.ca/2012/04/extracting-names-and-email-addresses.html
# first last <email1@example.com>
# {:name => "First Last", :email => "email1@example.com"}
# john.smith@example.com
# {:name => "John Smith", :email => "john.smith@example.com"}
# mary@example.com
# {:name => "Mary", :email => "mary@example.com"}
def names_and_emails_from_multiple_addresses(emails)
addresses = emails.split(',')