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
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 https://github.com/antillas21/ajax-datatables-rails
app.get '/things'
controller = ThingsController.new
controller.request = app.request
controller.params = ActionController::Parameters.new({search: 'Thing Name'})
datatable = ThingDatatable.new(controller.view_context)
datatable.send(:data)
View params.rb
# This is what my params looks like
{:group_id=>86,
:payer_id=>1982,
:account_type=>"standard",
:sms_credit_price_ex_tax=>"0.025",
:auto_purchase_sms_credits_amount=>1000,
:setup_invoice=>true,
:locale=>"en-GB",
:timezone=>"London",
@benmacleod
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 'https://rubygems.org'
gem 'rails'
# etc, etc.
gem 'rack-cors', require: 'rack/cors'
View account.rb
class Account
has_many :payment_methods
end
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
dummy.should_receive(:destroy)
delete :destroy, id: 99
end
end
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))
end
View gist:7003283
class Contact < ActiveResource::Base
self.site = 'http://localhost:3000/service/v1/'
self.user = (a = Account.find(1)).users.first.email
self.password = a.web_service_key
end
c = Contact.find 1
View gist:6985047
def password=(password)
Rails.logger.debug "Called password=#{password}"
super(password)
end
You can’t perform that action at this time.