Skip to content

Instantly share code, notes, and snippets.

View BrianTheCoder's full-sized avatar

Brian Smith BrianTheCoder

View GitHub Profile
class Google
def self.geocode(address)
puts "address: #{address}"
@resp = client.get do |req|
req.url 'geocode/json'
req.params[:address] = address
req.params[:sensor] = false
end
@address = @resp.body['results'].first
{
Bundler could not find compatible versions for gem "money":
In Gemfile:
spree_stock_email (>= 0) ruby depends on
money (< 6.0.0) ruby
spree_stock_email (>= 0) ruby depends on
money (6.0.0)
@BrianTheCoder
BrianTheCoder / gist:6645990
Created September 21, 2013 01:11
broken seed demo
def foo
puts 'bar'
end
puts 'test'
foo
rake spree_auth:admin:create --trace
-----
Create the admin user (press enter for defaults).
Email [spree@example.com]:
Password [spree123]:
There was some problems with persisting new admin user:
Email can't be blank
Email can't be blank
@BrianTheCoder
BrianTheCoder / gist:6591244
Created September 17, 2013 07:50
Is there a way to have rubygems continue on past an error like this?
Updating activeadmin
ERROR: While executing gem ... (Gem::ImpossibleDependenciesError)
rails-4.0.0 requires activerecord (= 4.0.0) but it conflicted:
Activated activerecord-4.0.0 instead of (~> 3.1) via:
meta_search-1.1.3, activeadmin-0.6.0
@BrianTheCoder
BrianTheCoder / locu.rb
Last active December 14, 2015 17:39
Locu API client
module Porter
class Locu
# http://dev.locu.com/documentation/
DEFAULTS = {api_key: ENV['LOCU']}
class << self
%w(venue menu_item).each do |section|
define_method :"#{section}_search", ->(params = {}){ get("#{section}/search/", params) }
define_method :"#{section}_insight", ->(params = {}){ get("#{section}/insight/", params) }
define_method :"#{section}_info", ->(id){ get("#{section}/#{id}/") }
Scaffold is nice, but as you move forward you'll find yourself customizing too much. Use slim for markup, sass for styling, and coffeescript for behavior. There's niceities like inherited_resources for defining the default crud in a controller, and are usually even faster to develop with. The greatest thing about ruby on rails is how easy it is to write tests. Its a core convention of the framework. From my (limited) python experience, I have not seen such an adherence to test or the ease to do so.
request = require 'request'
keys = require('../config/keys.json')[process.env.NODE_ENV|| 'development']
exports.nearby = (options, callback)->
params =
term: options.query
offset: options.offset
ll: "#{options.lat},#{options.lng}"
console.log keys.yelp
@BrianTheCoder
BrianTheCoder / errorhandling.js
Created October 10, 2012 17:38
errorhandling
// Lovely simple-to-read code:
function handleDelete(request, response) {
getBlogByGuid(request.url.query.guid, function gotBlog(err, blog) {
deleteDocumentById(blog.id, function deletedBlog(err, status) {
// Deleted OK
response.writeHead(200);
response.end('Blog Deleted');
})
});
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets