Skip to content

Instantly share code, notes, and snippets.


Jesse Buchanan jbinto

View GitHub Profile
jbinto / gist:5142953
Created Mar 12, 2013
Demonstrates the concept of class variables vs. instance variables in Ruby.
View gist:5142953
class Dog
attr_accessor :breed, :color, :description
def Dog.description
# Return @@description, unless it's nil, in that case return a fixed string.
@@description ||= "All dogs are 4 legged animals that bark."
def Dog.description=(new_description)
@@description = new_description
jbinto / gist:5254785
Created Mar 27, 2013
Setting factory_girl as the fixtures replacement. Add to your Rails config/application.rb file.
View gist:5254785
# So we can run "rails generate" from the command line to create factories
config.generators do |g|
g.fixture_replacement :factory_girl
jbinto / gist:5301893
Last active Dec 15, 2015
A practical example of closures in JavaScript: creating custom loggers.
View gist:5301893
function getLogger(prefix) {
return function(message) {
console.log(prefix + ": " + message);
// Video component
(function() {
log = getLogger("video");
jbinto / gist:5421013
Created Apr 19, 2013
Procs vs Lambdas
View gist:5421013
# You can return from a lambda, and it will behave as expected.
write_two_words = lambda { |x, y| return "#{x} #{y}" }
puts"hi", "there") # => hi there
def foo
# If you *explicitly* return from a Proc, you will actually return from the caller.
# Note that if you omit the "return" keyword, it behaves just like a lambda.
write_two_words = { |x, y| return "#{x} #{y}" }
puts"hi", "there")
jbinto / heroku.log
Created May 1, 2013
Heroku H12 request timeouts, PG::Error SSL SYSCALL error: EOF detected
View heroku.log
2013-05-01T00:56:21.278781+00:00 app[web.1]: Started GET "/register" for at 2013-04-30 20:56:21 -0400
2013-05-01T00:56:21.300491+00:00 app[web.1]: Rendered users/new.haml within layouts/application (7.6ms)
2013-05-01T00:56:21.300491+00:00 app[web.1]: Rendered shared/_form_errors.haml (0.1ms)
2013-05-01T00:56:21.300491+00:00 app[web.1]: Rendered layouts/shared/_messages.haml (0.1ms)
2013-05-01T00:56:21.300491+00:00 app[web.1]: Processing by UsersController#new as */*
2013-05-01T00:56:21.300491+00:00 app[web.1]: Rendered layouts/shared/_nav.haml (0.9ms)
2013-05-01T00:56:21.300491+00:00 app[web.1]: Rendered layouts/shared/_carousel.haml (0.4ms)
2013-05-01T00:56:21.300491+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 12.1ms | ActiveRecord: 0.0ms)
2013-05-01T00:56:21.307102+00:00 heroku[router]: at=info method=HEAD path=/register fwd="" dyno=web.1 connect=11ms service=33ms status=200 bytes=0
2013-05-01T00:57:51.101327+00:00 app[web.1]: Started GET "
jbinto / howto-recover-google-authenticator-keys.txt
Created Feb 8, 2014
Recovering Google Authenticator keys from Android device for backup
View howto-recover-google-authenticator-keys.txt
### Last tested February 7 2014 on a Galaxy S3 (d2att) running Cyanogenmod 11 nightly, with Google Authenticator 2.49.
### Device with Google Authenticator must have root.
### Computer requires Android Developer Tools and SQLite 3.
### Connect your device in USB debugging mode.
$ cd /tmp
$ adb root
$ adb pull /data/data/
jbinto / gist:9620922
Created Mar 18, 2014
'yo angular foo' hangs at jpegtran-bin, bower asking a question
View gist:9620922
# See
# Below: output from 'yo angular foo' (or what was left in scrollback buffer)
npm http 200
npm http 200
npm http 200
npm http 200
npm http 200
npm http GET
npm http GET
jbinto / gist:9621435
Created Mar 18, 2014
npm zsh completion broken
View gist:9621435
% npm egrep: empty (sub)expression 1 ↵
jbinto / gist:9663989
Created Mar 20, 2014 chapter 4 fixes - Firebase not installed, JS files not included
View gist:9663989

While walking through's AngularJS tutorial chapter 4 (Three-way data binding with a real-time server), I encountered some problems.

The tutorial advises us to:

  • run bower install angularfire --save
  • add firebase to the list of required modules
  • add a constant FIREBASE_URL to our app

After implementing the posts functionality, I tried it in the browser and got the following error (in Chrome console):

jbinto / gist:9665977
Created Mar 20, 2014
Make Sublime Text not search through JS vendor/generated code (e.g. typical yeoman project)
View gist:9665977

In Preferences.sublime-settings (press CMD + , on OS X), add the following:

"folder_exclude_patterns": [".svn", ".git", ".hg", ".sass-cache", ".tmp", "node_modules", "dist", "bower_components"]