Skip to content

Instantly share code, notes, and snippets.

View bhuga's full-sized avatar

Ben Lavender bhuga

View GitHub Profile
@bhuga
bhuga / bug.rb
Created November 13, 2017 17:32
is this a ruby bug or am i misunderstanding something? fails on 2.4.1p111
# without a default for x
def foo(x, keyword: :b)
puts x
puts keyword
end
foo({x: 1})
#{:x=>1}
#b
# Description:
# Words of wisdom from @pengwynn
#
# Commands:
# hubot wynn me
# hubot wynnage me
# hubot wynning
wynnsdom = [
"You'll find that most touchdowns are actually scored by utility infielders."
@bhuga
bhuga / git-pr
Created January 8, 2015 16:47
git pr command
#!/bin/sh
#/ Usage: git pr [<branch>]
#/ Open the pull request page for <branch>, or the current branch if not
#/ specified. Lands on the new pull request page when no PR exists yet.
#/ The branch must already be pushed
# Based on script from @rtomayko
set -e
# usage message
@bhuga
bhuga / keybase.md
Created March 25, 2014 21:46
keybase.md

Keybase proof

I hereby claim:

  • I am bhuga on github.
  • I am bhuga (https://keybase.io/bhuga) on keybase.
  • I have a public key whose fingerprint is 73A5 ACF2 703C 88E3 A25B 8D88 4E78 3A18 06B9 07E8

To claim this, I am signing this object:

@bhuga
bhuga / gist:9631068
Created March 18, 2014 22:21
heroku available fonts
Path: /usr/lib/ImageMagick-6.5.7/config/type-ghostscript.xml
Font: AvantGarde-Book
family: AvantGarde
style: Normal
stretch: Normal
weight: 400
glyphs: /usr/share/fonts/type1/gsfonts/a010013l.pfb
Font: AvantGarde-BookOblique
family: AvantGarde
style: Oblique
@bhuga
bhuga / anything.rb
Last active August 29, 2015 13:57
Sane sawyer inspect for octokit
class Sawyer::Resource
def to_attrs
hash = self.attrs.clone
hash.keys.each do |k|
if hash[k].is_a?(Sawyer::Resource)
hash[k] = hash[k].to_attrs
end
end
hash
end
@bhuga
bhuga / hybrid_authenticatable.rb
Created November 9, 2012 22:23 — forked from spullen/devise_create_user.rb
HybridAuthenticatable 2
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :username, :null => false, :default => ""
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
@bhuga
bhuga / attribute_filter.rb
Created March 4, 2012 19:55 — forked from dpickett/attribute_filter.rb
attribute filter concept for mass assignment
class User < ActiveRecord::Base
protection_strategy :whitelist do
only :first_name, :last_name, :login, :password, :password_confirmation
end
protection_strategy :blacklist do
except :encrypted_password
end
end
u = User.new({protected_attribute: "blah", first_name: "John"}, filter: :whitelist)
@bhuga
bhuga / Guardfile
Created February 3, 2012 19:26
Can't believe this one took me so long to figure out.
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('Gemfile.lock')
watch('spec/spec_helper.rb')
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch(%r{^spec/support/.+\.rb$})
watch(%r{^spec/factories/.+\.rb$})
# watch(%r{^spec/factories/.+\.rb$}) # Uncomment when you have a large amount of factories
$ ->
class window.Chat extends Backbone.Model
class window.ChatList extends Backbone.Collection
model: Chat
window.chats = new ChatList
class window.ChatView extends Backbone.View
tagName: 'li'