Skip to content

Instantly share code, notes, and snippets.

View vanpelt's full-sized avatar
🤓
nerd

Chris Van Pelt (CVP) vanpelt

🤓
nerd
View GitHub Profile
class FakeApp < Sinatra::Base
set :raise_errors, false
set :show_exceptions, false
set :dump_errors, false
#set :logging, true
post '/start' do
secret_key = "your secret"
payload = JSON.parse(params[:payload])
if(Digest::SHA1.hexdigest(params[:payload]+secret_key) == params[:signature])
window.addEvent('domready', function(){
$$('.address')[0].getParent('form').addEvent('submit', function(e){
var bad = $$('.address').some(function(a){
if(a.retrieve('verified') != a.get('value')) {
return a.fireEvent('blur')
} else {
return false
}
})
if(bad)
require 'rubygems'
require 'httparty'
require 'cgi'
units = Unit.all(:job_id => 1111, :golden => true).to_a
units.each do |u|
#Where u is an instance of Unit...
q = u.data["full_address_gold"].join(" ")
res = HTTParty.get("http://maps.google.com/maps/geo?q=#{CGI.escape(q)}&ue=utf8&sensor=false&key=ABQIAAAAo7WZCzZIkSblHMg0GJ-AwRTO9bHCf1xwbKWofRtvGHi3UueLXRRlU_wLzBzvBmEBRO_34kWbmaAngQ")
p = res["Placemark"]
require 'rubygems'
require 'httparty'
require 'cgi'
#Where u is an instance of Unit...
q = u.data["full_address_gold"].join(" ")
res = HTTParty.get("http://maps.google.com/maps/geo?q=#{CGI.escape(q)}&ue=utf8&sensor=false&key=ABQIAAAAo7WZCzZIkSblHMg0GJ-AwRTO9bHCf1xwbKWofRtvGHi3UueLXRRlU_wLzBzvBmEBRO_34kWbmaAngQ")
p = res["Placemark"]
if p && p.length == 1 && p[0]["AddressDetails"]["Accuracy"] > 6
u.data["full_address_gold"] = p[0]["address"]
module Extension
def self.included(base)
base.extend ClassMethods
end
def rad
"rad"
end
module ClassMethods
#If override is set
def self.reject(jid, wid, max = nil)
q = Unit.all('judgments.job_id' => jid, 'judgments.worker_id' => wid, 'judgments.tainted' => false).to_a
job = Job.get(jid)
Judgment.all(:job_id => jid, :worker_id => wid).update!(:tainted => true)
q.each do |u|
AggregateJudgment.reset_unit(u.id)
u.rejudge!(job.judgments_per_unit)
end
worker = Worker.get(wid)
require 'rubygems'
require 'httparty'
module HTTParty
class Request
def handle_response(response)
case response
when Net::HTTPRedirection
options[:limit] -= 1
require 'httparty'
class CrowdFlower
include HTTParty
base_uri "https://crowdflower.com/jobs/"
def initialize(key = nil)
key ||= YOUR_KEY
self.class.default_params(:key => key)
end
{"_tainted"=>
[nil, true, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],
"title"=>"",
"orig_gold_rel"=>
["3", "2", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],
"_ids"=>
[523581,
523675,
524097,
524476,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
body {
font:13px/1.231 "Helvetica Neue",arial,clean,sans-serif;
*font-size:small;
*font:x-small;
overflow:hidden;