Skip to content

Instantly share code, notes, and snippets.

View JKring's full-sized avatar

jake kring JKring

View GitHub Profile
@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"]
]
@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 / 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 / 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 / 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 / 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 / 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
self.loadRev = function(){
console.log("loading rev");
console.log(self.id);
console.log(self.shownRevision().index);
$.get("/documents/load_rev",{
id:self.id,
rev:self.shownRevision().index
},
function(d){
console.dir(d);
@JKring
JKring / export_with_fm.rb
Last active December 16, 2015 07:29
export with format meta
fm = business.format_meta[batch.finished_jobs.first.format_id.to_s]
puts (["Prompt"] + fm).join("\t")
batch.finished_jobs.each do |j|
@out ||= []
j.document.content.each_with_index do |c, i|
if i % fm.size == 0
puts @out.join("\t")
@out = [j.prompts[i / fm.size]]
end
@out << c
# i'm almost certain that if you refactored this
every 1.day, :at => '4:30 am' do
if DateTime.now.end_of_month == DateTime.now
rake "cull_payments"
end
end
every 1.day, :at => '4:30 am' do
if DateTime.now.day == 15