Skip to content

Instantly share code, notes, and snippets.

View bschwartz's full-sized avatar

Brendan Schwartz bschwartz

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bschwartz on github.
  • I am brendanschwartz (https://keybase.io/brendanschwartz) on keybase.
  • I have a public key whose fingerprint is 92F6 2F9A 12AC 4855 8BDF 6567 0E25 A3D0 2002 85B4

To claim this, I am signing this object:

@bschwartz
bschwartz / multitopic.rb
Created November 11, 2014 13:52
Consume from multiple topics into a single queue
require 'nsq'
require 'thread'
queue = Queue.new
consumer_for_topic1 = Nsq::Consumer.new(
topic: 'topic1',
channel: 'multi-topic-consumer',
queue: queue
)
@bschwartz
bschwartz / full-scrub.js
Created November 6, 2014 18:15
Scrub all query params with FreshURL
FreshUrl.waitsFor(function(){freshUrl.allReady()}).then(function(){
// This will fire once all analytics platforms are ready
// Scrub everything in the query string, not just utm_*
window.history.replaceState({}, '', window.location.pathname + window.location.hash);
});
#
# Put this in a directory and create a `Gemfile` with this in it:
#
# source 'https://rubygems.org'
# gem 'nsq-cluster'
# gem 'nsq-ruby'
#
# Then run `bundle install` to install the require gems.
# Then run this like so: `ruby fin-failer.rb`
#
silent !mkdir -p ~/.vim/swap
silent !mkdir -p ~/.vim/backups
set directory=~/.vim/swap//
set backupdir=~/.vim/backups
@bschwartz
bschwartz / random_maker.rb
Created January 27, 2012 17:34
How Wistia names its video encoding workers
module RandomMaker
ADJECTIVES = %w(red blue yellow fuschia orange teal smokey the a some greyest lovely hyped
another justa speedy quick fast worldly scholarly slow sloth-like understated overestimated
leftover worthless optimistic friendly venerable quixotic lowkey shiny glowing hot cold tepid
lukewarm fairweather winning elusive secret ancient ruined rare unique extra thebest my-greatest
string-like towering confused insulant brave cowardly cycling rolling uncle aunt nostalgic
beastly slanted enchanted top-notch grade-a primo grand creepy)
NOUNS = %w(cadillac smith carl fish sticks car mechanic smoothie art cabbage screen kiwi yam
@bschwartz
bschwartz / list_view
Created June 16, 2011 21:29 — forked from joelbschwartz/list_view
cooktwice list view
--------------- the page ------------------
<li class="recipe">
<a href="#" class="star"/>
<h3><%= "Chile-Braised Pork Shoulder Tacos" %></h3>
<p class="details"><%= "Added by you, shared with 3 others, edited by 2 others, 5 comments" %></p>
<p class="source"><%= "Bon Apetit" %></li>
<div class="actions">
<a href="#" class="share">Share</a>
</div>
<html>
<head>
</head>
<body style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
<div id="wistia_253852" width="438" height="320">Almost there...</div>
<script src="http://embed.wistia.com/embeds/v.js" charset="ISO-8859-1"></script>
<script>
Wistia.VideoEmbed('wistia_253852',438,320,{videoUrl:'http://embed.wistia.com/deliveries/f429e644d5d0f46bd36496d4caab604379382ce5.bin',stillUrl:'http://embed.wistia.com/deliveries/0a87e488223ac510058dad6ec742d9e8b4b50fe1.bin',distilleryUrl:'http://distillery.wistia.com/x',accountKey:'wistia-production_3176',mediaId:'wistia-production_253852',mediaDuration:44.78,autoPlay:true});
var v = document.getElementById('wistia_253852');v.load();v.play();
#!/usr/bin/env ruby
#
# Send your exact HTTP request back to you in the response body.
# Useful for debugging.
#
require 'proxymachine'
proxy do |data|
@bschwartz
bschwartz / vswap.wistia-tracker.js
Created May 6, 2010 16:06
Track Wistia videos using Vertster
/*
* Tracks a video's play progress via Vertster
*
* Usage:
*
* Vswap.trackWistiaVideo(560, 'wistia_123', 63.0);
*
* Note: This currently only works with a Wistia video embed but could be easily adapted to
* work with YouTube or other video players.
*/