Skip to content

Instantly share code, notes, and snippets.

@zooniverse
zooniverse / My app Routes
Created August 13, 2011 20:19 — forked from flockonus/My app Routes
rake routes
rake routes
(in /home/fps/workspace3/peded)
admin_pay_methods GET /admin/pay_methods(.:format) {:action=>"index", :controller=>"admin/pay_methods"}
POST /admin/pay_methods(.:format) {:action=>"create", :controller=>"admin/pay_methods"}
new_admin_pay_method GET /admin/pay_methods/new(.:format) {:action=>"new", :controller=>"admin/pay_methods"}
edit_admin_pay_method GET /admin/pay_methods/:id/edit(.:format) {:action=>"edit", :controller=>"admin/pay_methods"}
admin_pay_method GET /admin/pay_methods/:id(.:format) {:action=>"show", :controller=>"admin/pay_methods"}
PUT /admin/pay_methods/:id(.:format) {:action=>"update", :controller=>"admin/pay_methods"}
DELETE /admin/
@zooniverse
zooniverse / boot.sh
Created April 8, 2011 14:24
Bootstrap Rubygems
#!/bin/bash
sudo apt-get -y install rubygems
sudo gem install crack --source http://rubygems.org
exit
#!/usr/bin/ruby
count = 0
ARGF.each do |line|
count += 1
end
puts "#{count} 'loves' for Justin"
#!/usr/bin/ruby
#!/usr/bin/gem
require 'rubygems'
require 'crack'
ARGF.each do |line|
tweet = line.strip
unless tweet.length == 0
@zooniverse
zooniverse / bieber_finder.php
Created April 8, 2011 14:13
Capture all of the tweets that have the word 'bieber' in them and save them to a file
<?php
$fp = fopen("http://USERNAME:PASSWORD@stream.twitter.com/1/statuses/filter.json?track=bieber","r");
while($data = fgets($fp))
{
$time = date("YmdH");
if ($newTime!=$time)
{
@fclose($fp2);
$fp2 = fopen("{$time}.txt","a");
}
def progress
prog = self.assets.where(:ave_pos => {"$size" => 2} ).sort({ :order => -1}).limit(10).all.collect { |a| a.ave_pos unless a.ave_pos.empty? }
return prog.compact
end
def progress
prog = self.assets.collect { |a| a.ave_pos if !a.ave_pos.empty? }.compact!
# only show the last 10 positions
limited_progress = prog.reverse.slice(0,10)
if prog.empty?
return []
else
return limited_progress
end
# Old
ship.current_voyage.groups.first.zooniverse_users.include?(self)
# New
ship.voyages.first.groups.where(:zooniverse_user_ids => self.id).count == 0 ? false : true
@zooniverse
zooniverse / aws_boot_script.rb
Created January 24, 2011 14:23
Have this file run when your machine boots
#!/home/ec2-user/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
require 'rubygems'
require 'aws/s3'
require 'fileutils'
AWS::S3::Base.establish_connection!(
:access_key_id => 'access_key',
:secret_access_key => 'secret_key'
)
@zooniverse
zooniverse / aws_bundle.rb
Created November 10, 2010 13:45
Git archive and bundle to S3
Capistrano::Configuration.instance(:must_exist).load do
# example execution 'cap bundle_app -s version=HEAD'
desc "Bundle code and push to S3"
task :bundle_app do
puts "Starting Git archive of #{version}"
`git archive -o oldweather.tar #{version}`
`gzip oldweather.tar`
s3_upload
clean_up