Skip to content

Instantly share code, notes, and snippets.

View JKring's full-sized avatar

jake kring JKring

View GitHub Profile
@JKring
JKring / rectify_prescreen_payments.rb
Created May 8, 2013 00:36
this was to rectify mislabeled prescreen payments
misc_writers = Hash.new(0)
adj_writers = []
b.finished_jobs.each do |f|
p = Payment.where("prescreened_jobs.#{ f.id }" => {"$ne" => nil }).first
if p
unless p.prescreened_jobs[f.id.to_s] == 15
if p.paid
current_p = Payment.current(p.writer)
adding = (15 - p.prescreened_jobs[f.id.to_s])
current_p.misc += adding
@JKring
JKring / wtfoneflare.rb
Last active December 17, 2015 04:29
GIST OF TEH DAY
b.finished_jobs.where(id: { "$nin" => ids }).each do |j|
d = j.document
puts "scripted.com/documents/show/#{ d.id }"
d.save_file("Cleaned Up")
@new_c = []
d.content.each do |c|
begin
c.gsub!("\n", " ")
c.strip!
@splitup = c.split(">")
@JKring
JKring / issue.py
Created May 10, 2013 21:07
import issue
Traceback (most recent call last):
File "starter.py", line 31, in <module>
seed()
File "starter.py", line 25, in seed
flat_docs = load_flat_docs('jobs.txt')
File "starter.py", line 14, in load_flat_docs
return [ruby_to_python(doc) for doc in open(filename).readlines()]
File "starter.py", line 10, in ruby_to_python
python_dict = eval(sub)
File "<string>", line 1
@JKring
JKring / scrollwatcher.js
Created May 15, 2013 23:25
fun scrolly time
var BUFFER = $(window).height() - $("#box").height();
$(window).scroll(function(){
$(window).scrollTop() > BUFFER ? $("#box").hide() : $("#box").show();
});
@JKring
JKring / json.sh
Created May 23, 2013 22:14
trying to update json
Jakes-MacBook-Pro:Scripted jakekring$ bundle install
Fetching gem metadata from http://rubygems.org/.......
You have requested:
json ~> 1.7.7
The bundle currently has json locked at 1.5.5.
Try running `bundle update json`
Jakes-MacBook-Pro:Scripted jakekring$ bundle update json
Fetching gem metadata from http://rubygems.org/.......
Bundler could not find compatible versions for gem "json":
@JKring
JKring / too_long.rb
Created May 30, 2013 02:32
long query
query = {:per_page=>15, :page=>1, :blacklisted=>false, :not_team_ids=>["5090770bd6841267b10004b4"], :search_terms=>nil, :sort=>[:team_scores_5090770bd6841267b10004b4_num_overall, :desc]}
solrquery = Writer.search do
all_of do
without(:removed).equal_to(true)
without(:blacklisted).equal_to(true) if query[:blacklisted] == false
with(:has_photo).equal_to(true) if query[:has_photo]
with(:team_ids).any_of(query[:team_ids]) if query[:team_ids]
without(:team_ids).any_of(query[:not_team_ids]) if query[:not_team_ids]
with(:group_ids).any_of([query[:group_ids]]) if query[:group_ids]
end
@JKring
JKring / revs.rb
Created May 31, 2013 22:12
document.revs
[
["Initial Draft", "First draft of first piece of content==========abc123==========First draft of second piece of content"],
["Second Draft", "Second draft of first piece of content==========abc123==========Second draft of second piece of content"],
["Final Draft", "Final draft of first piece of content==========abc123==========Final draft of second piece of content"]
]
## On BuyerEmailer
# Now we don't have to call it in every method...
sendgrid_category 'buyer'
# This is the hash that connects preference levels to emails
@@preference_levels = {
claimed: "important"
}
@JKring
JKring / payday.rb
Created June 27, 2013 23:02
payday logic
def is_payday?(t)
return true if (t.end_of_month.saturday? || t.end_of_month.sunday?) && t.friday?
return true if [13, 14].include?(t.day) && t.friday?
return true if (t.end_of_month == t.midnight || t.day == 15) && !(t.saturday? || t.sunday?)
return false
end
@time = DateTime.now
100.times do |i|
t = @time.advance(days: i)
@JKring
JKring / gist:6116618
Created July 30, 2013 20:29
migrating team ids
id_map = {
"soon-to-be-deleted-team-id" => "replacement-team-id",
"other-soon-to-be-deleted-team-id" => "other-replacement-team-id"
}
id_map.each_pair do |old_id, new_id|
old_id = BSON::ObjectId(old_id)
new_id = BSON::ObjectId(new_id)
classes = [BlogPost, Business, Job, FinishedJob, PitchSet, TempJob]
classes.each do |cl|