Skip to content

Instantly share code, notes, and snippets.

View arfon's full-sized avatar
:shipit:

Arfon Smith arfon

:shipit:
View GitHub Profile
@arfon
arfon / instance.rb
Created January 7, 2013 03:15
Instance keys
# http://aws.amazon.com/ec2/pricing/pricing-on-demand-instances.json
class Instance
def key_for_type(type)
type_translations = {
'm1.small' => ['stdODI', 'sm'],
'm1.medium' => ['stdODI', 'med'],
'm1.large' => ['stdODI', 'lg'],
'm1.xlarge' => ['stdODI', 'xl'],
@arfon
arfon / rebuild_cache.rb
Last active December 11, 2015 12:38
Ouroboros User seen cache rebuilder
projects = Project.all
projects.each do |project|
puts "Working with #{project.name}"
index = 0
project_total = Recent.where(:project_id => project.id).count
user_ids = Recent.where(:project_id => Project.first.id).distinct('user.id')
user_ids.each do |user_id|
user = User.find(user_id)
project_user = user.for_project(project)
@arfon
arfon / gmail_ruby_labels.rb
Created April 4, 2013 12:10
GMail labels
require 'gmail'
label = 'MY LABLE'
gmail = Gmail.connect('USERNAME', 'PASSWORD')
gmail.mailbox(label).emails.each do |email|
mailbox = email.sender.first.mailbox
host = email.sender.first.host
puts "#{mailbox}@#{host}"
end
@arfon
arfon / snapshot_serengeti.rb
Last active December 16, 2015 18:21
Snapshot Serengeti classifcation
{"subject_ids"=>[BSON::ObjectId('50dcb441a2fc8e37890dafe8')],
"annotations"=>
[{"species"=>"wildebeest",
"count"=>"3",
"behavior"=>["eating"],
"babies"=>"false",
"search"=>""},
{"agent"=>
"Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0"},
{"started"=>"Tue, 05 Feb 2013 18:54:39 GMT"}],
@arfon
arfon / travis.yml
Created May 8, 2013 12:02
Ouroboros Travis
language: ruby
rvm:
- "1.9.3-p392"
before_install:
- wget https://github.com/zooniverse/redis/archive/zdiffstore.tar.gz
- tar -xvzf zdiffstore.tar.gz
branches:
only:
def self.next_original_for_user(user)
recents = joins(:classifications).where(:classifications => { :zooniverse_user_id => user.id }).select('subjects.id').all
if recents.any?
where(['id NOT IN (?)', recents]).first
else
first
end
end
class BatDetectiveSubject < Subject
include SubjectSelector
include SubjectSelector::Unique
end
@arfon
arfon / gist:6082984
Created July 25, 2013 19:31
HCOMP demonstration
The Zooniverse (zooniverse.org) began in 2007 with the launch of Galaxy Zoo, a project in which more than 175,000 people provided shape analyses of more than 1 million galaxy images sourced from the Sloan Digital Sky Survey. These galaxy 'classifications', some 60 million in total, have subsequently been used to produce more than 50 peer-reviewed publications based not only on the original research goals of the project but also because of serendipitous discoveries made by the volunteer community.
Based upon the success of Galaxy Zoo the team have gone on to develop more than 25 web-based citizen science projects, all with a strong research focus in a range of subjects from astronomy to zoology where human-based analysis still exceeds that of machine intelligence. Over the past 6 years Zooniverse projects have collected more than 300 million data analyses from over 1 million volunteers providing fantastically rich datasets for not only the individuals working to produce research from their projects but also
@arfon
arfon / badass_applescriptin.scpt
Last active December 21, 2015 09:28
Oh yeah, bet you never knew you could do this on your Mac
tell application "Google Chrome" to activate
tell application "System Events"
keystroke "F" using {command down, shift down}
end tell
delay 10
tell application "System Events" to key code 126
@arfon
arfon / Published Article.json
Created October 16, 2013 10:56
Figshare article response
// curl -v http://api.figshare.com/v1/articles/821210
{
"count": 1,
"items": [{
"article_id": 821210,
"title": "Fidgit fileset test",
"figshare_url": "http://figshare.com/articles/Fidgit_fileset_test/821210",
"views": 40,
"downloads": 0,