Skip to content

Instantly share code, notes, and snippets.

@wallace
wallace / irc.conf
Created February 14, 2013 01:19
An example server section from my weechat irc.conf configuration file, ~/.weechat/irc.conf. /help server will give you the commands to setup an IRC server.
[server]
freenode.addresses = "chat.freenode.net/6667"
freenode.proxy
freenode.ipv6
freenode.ssl
freenode.ssl_cert
freenode.ssl_priorities
freenode.ssl_dhkey_size
freenode.ssl_verify
freenode.password
@wallace
wallace / debugger session
Last active December 12, 2015 02:08
Example of saving debugger session using https://github.com/cldwalker/debugger.
(rdb:1) help save
save [FILE]
Saves current debugger state to FILE as a script file.
This includes breakpoints, catchpoints, display expressions and some settings.
If no filename is given, we will fabricate one.
Use the 'source' command in another debug session to restore them.
(rdb:1) help source
source FILE executes a file containing debugger commands
(rdb:1)
@wallace
wallace / app.js
Created October 11, 2012 14:43
Grabbed from the socket.io examples
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(80);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
class LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :order
validates :price, :quantity, numericality: true
validates :product_id, :order_id, presence: true
end
class Order < ActiveRecord::Base
has_many :line_items
validates :total_price, numericality: true
before_create :apply_returning_customer_discount, if: lambda { |order| order.returning_customer? }
def apply_returning_customer_discount
self.total_price = self.total_price * 0.9
end
class Product < ActiveRecord::Base
validates :price, numericality: true
end
~ 1.9.3-p194 $ cd Documents/projects/activeadmin-xlsx/
~/Documents/projects/activeadmin-xlsx (wip) 1.9.3-p194 $ be rake
/Users/jonathanwallace/.rbenv/versions/1.9.3-p194/bin/ruby -S rspec ./spec/lib/active_admin/xlsx/settings_spec.rb
ActiveAdmin requires meta_search >= 1.1.0.pre and sass-rails ~> 3.1.0.rc to work with rails >= 3.1.0
Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
Mocha deprecation warning: If you're integrating with another test library, you should probably require 'mocha_standalone' instead of 'mocha'
F
Failures:
root@wallaces-desktop:/home/kristina/Downloads# apt-get remove scratch
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
scratch
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 46.7 MB disk space will be freed.
Do you want to continue [Y/n]? Y
@wallace
wallace / sample_lonely_job.rb
Created June 15, 2012 18:44
Sample Lonely Job implementation
class ImportJob
extend Resque::Plugins::LonelyJob
def self.enqueue(account_id, import_id)
# All enqueued resque jobs have the same payload
Resque.enqueue(ImportJob, account_id)
# but we drop the import_id into an account specific
# redis list that we use when actually processing jobs to preserve job order
enqueue_payload(account_id, import_id)
# Extracted from https://github.com/wallace/resque-lonely_job/blob/master/lib/resque-lonely_job.rb#L12-L16
# Overwrite this method to uniquely identify which mutex should be used
# for a resque worker.
def redis_key(*args)
"lonely_job:#{@queue}"
end