Skip to content

Instantly share code, notes, and snippets.

@brenfrow
brenfrow / sign.js
Last active September 7, 2018 21:09
Query params for authentication
const crypto require('crypto');
const ACCESS_ID = '';
const SECRET_KEY = '';
const EXPIRES = Math.round((new Date()).getTime() / 1000) + 60000; // 60 minutes from now
const signature = crypto
.createHmac('sha1', accessKey)
.update(SECRET_KEY + '\n' + EXPIRES)
.digest('base64');
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@brenfrow
brenfrow / gist:5800025
Created June 17, 2013 20:25
Social Channels for Gaffer
Facebook
Twitter
Google+
WordPress
LinkedIn
Stack Overflow
reddit
SlideShare
Quora
Blogger
campaigns = CampaignIDEnumerator.new(scheduler_queue: ShardCreation.daily_scheduler_queue)
campaigns.each do |campaign_id|
begin
campaign = Campaign.find(campaign_id)
snapshot = campaign.to_packrat_snapshot("mtoken")
date = Date.new(2013, 5, 4)
cycle_id = "index~83"
puts "cycle_id #{cycle_id}; date #{date}"
packrat_cycle = Packrat::CollectionCycle.new(cycle_id, date, Date.today)
Packrat.start_collection(snapshot, packrat_cycle, 'LSAPI')
@brenfrow
brenfrow / rerun_lsap
Last active December 17, 2015 02:19
Rerun LSAPI index
campaigns = CampaignIDEnumerator.new(scheduler_queue: ShardCreation.daily_scheduler_queue)
campaigns.each do |campaign_id|
begin
campaign = Campaign.find(campaign_id)
snapshot = campaign.to_packrat_snapshot("mtoken")
date = Date.new(2013, 5, 4)
cycle_id = "index~83"
puts "cycle_id #{cycle_id}; date #{date}"
packrat_cycle = Packrat::CollectionCycle.new(cycle_id, date, Date.today)
Packrat.start_collection(snapshot, packrat_cycle, 'LSAPI')
@brenfrow
brenfrow / dice_game
Created June 29, 2012 19:33
dice game
# You need to write this method
score = 0
map = {}
#create map of { dice_num => times_rolled }
dice.each do |num|
if map.has_key? num
map[num] += 1
else
map[num] = 1
@brenfrow
brenfrow / triangle.rb
Created June 29, 2012 17:46
triangle
# You need to write the triangle method
class TriangleError < RuntimeError
end
def triangle(x,y,z)
raise TriangleError if has_zero_side? x,y,z
raise TriangleError if has_negitive_side? x,y,z
raise TriangleError if side_too_long? x,y,z
return :equilateral if equilateral? x,y,z
return :isosceles if isoceles? x,y,z