Skip to content

Instantly share code, notes, and snippets.

View jonstorer's full-sized avatar

Jonathon Storer jonstorer

View GitHub Profile
require 'ruby-progressbar'
module TagTestAccounts
REGEX = /@tfbnw\.net$/
def self.members
Member.where(:email => REGEX)
end
def self.run!
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 = {}
@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
@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 / 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 / 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 / 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 / choose.rb
Created July 5, 2012 18:46
Small script to help rank the values in an array from user input
class Array
CHOOSE_OPTIONS = {'a' => -1, 'b' => 1, 'c' => 0}
def choose
self.sort! do |x, y|
answered = false
begin
puts "Which do you prefer?"
puts " (A) #{x}"
puts " (B) #{y}"
puts " (C) Neither"
@jonstorer
jonstorer / do_while.js
Created March 20, 2012 20:01
do while loops
do {
// stuff;
} while ( test );
def callback
#stuff
session[:lets_redirect_to_here] = "wherever"
redirect_to new_profile_url unless user.profile_complete?
session[:really_redirect_this_time] = true
end