Skip to content

Instantly share code, notes, and snippets.

@bobbrez
bobbrez / keybase.md
Created April 1, 2014 19:58
keybase.md

Keybase proof

I hereby claim:

  • I am bobbrez on github.
  • I am bobbrez (https://keybase.io/bobbrez) on keybase.
  • I have a public key whose fingerprint is 71AA E2C8 2FE0 DD07 9197 10BF 5658 1DDF C278 1BCC

To claim this, I am signing this object:

@bobbrez
bobbrez / sample.rb
Created August 19, 2014 21:47
Redis RPOPZADD for Ruby
require 'redis'
class Redis
REDIS_RPOPZADD = "
local value = redis.call('zrange', KEYS[1], -1, -1)[1]
local score = redis.call('zscore', KEYS[1], value)
redis.call('zremrangebyrank', KEYS[1], -1, -1)
redis.call('zadd', KEYS[2], score, value)
return { value, score }"
def rpopzadd(source, dest)
@bobbrez
bobbrez / plan.md
Last active August 29, 2015 14:06
Sidekiq Dynamic Priorities

Purpose

SDP will add the ability to use queues with a scored priority using the SortedSet functionality in Redis. This will allow projects to add jobs to a dynamic queue with a numeric priority score. Jobs will then be processed from highest priority to the lowest. If a job is added with the highest priority, it will then be the next job to get pulled from the queue.

This will transparently augment the functionality in Sidekiq and will only provide additive functionality.

Example

As an example, a dynamic priority queue exists with workers Alpha and Beta. At time(0) the queue exists but workers have not pulled any jobs yet:

@bobbrez
bobbrez / .bashrc
Created April 12, 2011 01:25 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
ActiveRecord::Schema.define(:version => 20110514135759) do
create_table "beers", :force => true do |t|
t.string "name"
t.string "brewery"
t.float "abv"
t.text "description"
t.string "image_url"
t.datetime "created_at"
t.datetime "updated_at"
@bobbrez
bobbrez / gist:993344
Created May 26, 2011 15:15
MySQL on OS X using Homebrew

Change Permissions

You'll need to change the permissions for /usr/local for your local user.

sudo chown -R whoami /usr/local

Homebrew

The easiest way to get everything setup is to use Homebrew. To do this, you'll need to first install XCode from the standard XCode from Apple Developer site. Afterwards you can just install Homebrew though its normal installation

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

@bobbrez
bobbrez / address.rb
Created September 28, 2011 19:24 — forked from galiat/gist:1248941
class Address < ActiveRecord::Base
belongs_to :contact
validates_presence_of :street, :town
end
@bobbrez
bobbrez / .gitconfig
Created October 24, 2011 00:16
My GitConfig
[user]
name = Bob Breznak
email = bob@where.com
[alias]
co = checkout
st = status
ci = commit
com = commit
di = diff
@bobbrez
bobbrez / gist:2228387
Created March 28, 2012 17:20
Javascript Question

So you have a document like this:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <textarea id="myText"></textarea>
  </body>
</html>
@bobbrez
bobbrez / json-table.rb
Last active December 14, 2015 15:58
Simple script to read json and output a table.
#!/usr/bin/env ruby
require 'rubygems'
require 'terminal-table'
require 'json'
require 'hashie'
require 'csv'
data = Hashie::Mash.new JSON.parse(ARGF.read)
CSV.open('uvr.csv', 'w') do |csv|