Skip to content

Instantly share code, notes, and snippets.

Ben MacLeod benmacleod

Block or report user

Report or block benmacleod

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nuvola.log
Master: [DEBUG Nuvola] master.vala:111: Compositing mode disabled because of WebKitGTK < 2.13.4
Master: [DEBUG Gtk] Connecting to session manager
Master: [DEBUG DioriteGtk] DesktopShell.vala:96: Shell: compiz (null), CSD 0, appmenu 1, menubar 0
Master: [DEBUG Nuvola] WebAppRegistry.vala:169: Found web app Test at /usr/share/nuvolaplayer3/web_apps/test, version 1.0
Master: [DEBUG Nuvola] WebAppRegistry.vala:169: Found web app 8tracks at /usr/share/nuvolaplayer3/web_apps/8tracks, version 5.1
Master: [DEBUG Nuvola] WebAppRegistry.vala:169: Found web app Amazon Cloud Player at /usr/share/nuvolaplayer3/web_apps/amazon_cloud_player, version 5.1
Master: [DEBUG Nuvola] WebAppRegistry.vala:169: Found web app Bandcamp at /usr/share/nuvolaplayer3/web_apps/bandcamp, version 2.1
Master: [DEBUG Nuvola] WebAppRegistry.vala:169: Found web app Deezer at /usr/share/nuvolaplayer3/web_apps/deezer, version 2.4
Master: [DEBUG
benmacleod / debug_ajax_datatable.rb
Last active Apr 13, 2016
Debug an AJAX Datatable from the Rails 4 console
View debug_ajax_datatable.rb
# Using a datatable as per
app.get '/things'
controller =
controller.request = app.request
controller.params ={search: 'Thing Name'})
datatable =
View params.rb
# This is what my params looks like
benmacleod / Gemfile
Last active Aug 29, 2015
Adding CORS support to a Ruby on Rails app working with a Squawkbox editor session
View Gemfile
source ''
gem 'rails'
# etc, etc.
gem 'rack-cors', require: 'rack/cors'
View account.rb
class Account
has_many :payment_methods
View dummies_controller_spec.rb
describe 'DELETE #destroy' do
let(:dummy) { mock('Dummy') }
it "should find the object with the given ID and destroy it" do
# set the expectations about the interactions
Dummy.should_receive(:find).with(99).and_return dummy
delete :destroy, id: 99
View _form.rb
<%= simple_form_for @item do |i| %>
<%= i.input :name %>
<%= i.input :description %>
<%= i.input :price %>
<%= i.input :zip %>
<%= i.input :weight %>
<%= i.input :volume %>
<%= i.simple_fields_for :item_images do |image| %>
<% image.input :image, as: :file %>
<% end %>
View comment..rb
def self.create_from_parent(parent_type, parent_id, comment_params, current_account)
parent = parent_type.safe_constantize
raise ActiveRecord::RecordNotFound unless parent && (parent.reflect_on_association(:comments).klass == self)
parent.find(parent_id).comments.create(comment_params.merge(account: current_account))
View gist:7003283
class Contact < ActiveResource::Base = 'http://localhost:3000/service/v1/'
self.user = (a = Account.find(1))
self.password = a.web_service_key
c = Contact.find 1
View gist:6985047
def password=(password)
Rails.logger.debug "Called password=#{password}"
You can’t perform that action at this time.