Skip to content

Instantly share code, notes, and snippets.

View jonstorer's full-sized avatar

Jonathon Storer jonstorer

View GitHub Profile
@jonstorer
jonstorer / spinejs.html
Created September 7, 2012 02:31
spinejs
<html>
<div id='my-app-id'></div>
<script type="text/javascript">
var MyApp = require("my_app");
$(function(){ new MyApp({ el: $("#my-app-id") }) });
</script>
@jonstorer
jonstorer / cash
Created December 20, 2012 15:51
How much cash our members could cash out
class CountUpCash
COST_OF_TWENTY_FIVE_DOLLAR_GIFT_CARDS = 50000
COST_OF_TEN_DOLLAR_GIFT_CARDS = 20000
DEFAULT_QUERY = { :points.gte => 20000, :banned.in => [ false, nil ] }
attr_accessor :query, :total_number_of_twenty_five_dollar_gift_cards, :total_number_of_ten_dollar_gift_cards
def initialize(query = {})
@query = DEFAULT_QUERY.merge(query)
@jonstorer
jonstorer / gist:4599017
Created January 22, 2013 22:10
This is what I used to get my localizations back when I deleted them from copycopter
select * from versions, (select max(versions.id) as id from versions left outer join localizations on localizations.id = versions.localization_id where localizations.id is null group by versions.localization_id) as x where versions.id = x.id and versions.created_at > to_date('2012-03-18', 'yyyy-mm-dd') and versions.number != 1
@jonstorer
jonstorer / award_challenges.rb
Last active December 16, 2015 07:09
Give the people their points!! Find challenges from labs members and give them their points!!
member_ids = Member.where(:lab => true).only(:_id).map(&:id)
after = Date.parse('10/4/2013').to_time.at_beginning_of_day
before = Award.where(:created_at.gt => after, :brand_id => nil, :points => Game.int_var('challenge_points_for_each_awardable_view'), :reason => 'Someone checked out your Web Share').asc(:created_at).last.created_at
def complete_award(challenge)
challenge.award_and_complete if challenge.unique_views_count >= WebShare.min_challenge_view_count_for_completion
end
def view_awards(challenge)
[challenge.unique_views_count, Challenge.max_awardable_views].min.times{ challenge.award_for_event(:visitor_unique_view) }
@jonstorer
jonstorer / brute.rb
Last active December 17, 2015 10:09
hacker olympics
require 'uri'
require 'net/http'
require 'net/https'
require 'ruby-progressbar'
require 'set'
def add_bad_ip(ip)
File.open('ips.txt', 'a') {|f| f.puts ip }
end
def brand_actions_summary
targeted_brand_actions = targetable_actions
new_brand_actions_by_brand_id = targeted_brand_actions.group_by(&:brand_id)
active_participations = participations.where({
:stage.nin => Participation::Base::NON_ACTIVE_STAGES + Participation::LEGACY_NON_ACTIVE_STAGES
})
active_participations_by_brand_id = {}
expiring_brand_actions_by_brand_id = {}
require 'ruby-progressbar'
module TagTestAccounts
REGEX = /@tfbnw\.net$/
def self.members
Member.where(:email => REGEX)
end
def self.run!
@jonstorer
jonstorer / .gitignore
Last active December 17, 2015 17:19
They seem me trollin' they hatin'
out.log
@jonstorer
jonstorer / win_migrate.rb
Last active December 17, 2015 23:09
Migrate all Win documents to PrizeWin documents
CashstarFulfillment.all.each do |cf|
cf.set(:prize_win_id, cf.win_id)
end
Win.all.each do |win|
win.set(:_type, 'PrizeWin')
end
CashstarFulfillment.all.each do |cf|
cf.unset(:win_id)
@jonstorer
jonstorer / pick.rb
Last active December 18, 2015 02:08
pick crowd winners
class PickCrowdWinners
attr_accessor :crowd_drawing, :ids
def initialize(crowd_drawing)
@crowd_drawing = crowd_drawing
end
def ids
@ids ||= begin
ids = Set.new