Skip to content

Instantly share code, notes, and snippets.

View jbinto's full-sized avatar

Jesse Buchanan jbinto

View GitHub Profile
@jbinto
jbinto / gist:9663989
Created March 20, 2014 13:43
thinkster.io chapter 4 fixes - Firebase not installed, JS files not included

While walking through Thinkster.io'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
jbinto / getTitle.js
Created January 13, 2016 07:04
Get title of remote (HTML) URL via jQuery
const getTitle = (url, callback) => {
$.get(`https://crossorigin.me/${url}`, (data) => {
const html = $.parseHTML(data);
const bogus = $('<bogus>').append(html);
const title = bogus.find('title').text();
callback(title);
});
};
var urls = [
@jbinto
jbinto / istanbul-report.diff
Created January 9, 2016 01:59
Diff: istanbul initial report vs re-run report
--- coverage/lcov.info 2016-01-08 20:51:59.000000000 -0500
+++ coverage/rerun/lcov.info 2016-01-08 20:44:13.000000000 -0500
@@ -1,26 +1,29 @@
TN:
-SF:src/constants.js
+SF:/Users/jbinto/dev/thirtyone-server/src/constants.js
FNF:0
FNH:0
-DA:1,1
-LF:1
@jbinto
jbinto / heroku.log
Created May 1, 2013 13:15
Heroku H12 request timeouts, PG::Error SSL SYSCALL error: EOF detected
2013-05-01T00:56:21.278781+00:00 app[web.1]: Started GET "/register" for 204.93.223.151 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 host=www.puckpicks.ca fwd="204.93.223.151" 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
jbinto / gist:5421013
Created April 19, 2013 15:13
Procs vs Lambdas
# You can return from a lambda, and it will behave as expected.
write_two_words = lambda { |x, y| return "#{x} #{y}" }
puts write_two_words.call("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 = Proc.new { |x, y| return "#{x} #{y}" }
puts write_two_words.call("hi", "there")
@jbinto
jbinto / gist:5301893
Last active December 15, 2015 18:09
A practical example of closures in JavaScript: creating custom loggers.
function getLogger(prefix) {
return function(message) {
console.log(prefix + ": " + message);
}
}
// Video component
(function() {
log = getLogger("video");
log("initialized");
@jbinto
jbinto / gist:5254785
Created March 27, 2013 14:51
Setting factory_girl as the fixtures replacement. Add to your Rails config/application.rb file.
# So we can run "rails generate" from the command line to create factories
config.generators do |g|
g.fixture_replacement :factory_girl
end
@jbinto
jbinto / gist:5142953
Created March 12, 2013 13:44
Demonstrates the concept of class variables vs. instance variables in Ruby.
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."
end
def Dog.description=(new_description)
@@description = new_description
@jbinto
jbinto / index.html
Created November 27, 2015 21:56 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/wuwezo
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-0.14.3.min.js"></script>
<script src="https://fb.me/react-dom-0.14.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.4/redux.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
@jbinto
jbinto / fix_pythonpath.sh
Last active August 29, 2015 14:10
ansible, dopy, homebrew, python, pip, PYTHON_PATH madness
# situation:
# * Installed python+pip from homebrew.
# * Installed ansible from homebrew, then un/reinstalled with pip+git (requirements.txt)
# * Ansible cannot see `dopy` module installed via requirements.txt.
# solution:
# see https://github.com/jlund/streisand/issues/12
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth