Skip to content

Instantly share code, notes, and snippets.

@trydionel
trydionel / app.rb
Created February 27, 2010 21:17
Lightning-Quick Redis Viewer
require 'rubygems'
require 'haml'
require 'sinatra'
require 'redis'
helpers do
def redis
@redis ||= Redis.new
end
end
class SuperClass
def run
return "foo"
end
end
class SubClass < SuperClass
def run
super
return "bar"
ruby-1.8.7-p302 :001 > require 'builder'
=> true
ruby-1.8.7-p302 :002 > xm = Builder::XmlMarkup.new; nil
=> nil
ruby-1.8.7-p302 :003 > xm.title('foo'); nil
=> nil
ruby-1.8.7-p302 :004 > puts xm.target!
<title>foo</title>
=> nil
@trydionel
trydionel / gist:1959381
Created March 2, 2012 16:11
$.serializeJSON()
// Rails-style JSON serialization. e.g., Given a form:
//
// <input type="text" name="foo[bar][]" value="qux" />
// <input type="text" name="foo[bar][]" value="quux" />
//
// $("form").serializeJSON() will serialize to
//
// { foo: { bar: [ "qux", "quux" ] } }
//
$.fn.serializeJSON = function() {
@trydionel
trydionel / asset_check.rb
Created March 14, 2012 17:12
Finds and prints unused assets
#!/usr/bin/env ruby
paths = ARGV
paths.each do |path|
Dir["#{path}/*"].each do |file|
asset = File.basename(file)
search = `ack -ai1 --ignore-dir=tmp --ignore-dir=log #{asset}`.strip
if search.length.zero?
ext = File.extname(asset)
@trydionel
trydionel / email.txt
Created June 27, 2012 14:05
JustHost insanity
Jeff Tucker
9:04 AM (1 hour ago)
to support, billing
You do realize I'm no longer a customer of yours, right? You've freaked me out with these
emails 4-5 times over the last month -- 2 new billing emails (with a zero balance,
thankfully) and a few warnings that my non-existant server is being moved. This is
terrible -- you're going out of your way to ensure I'll never be a customer again. Please
stop contacting me.

Keybase proof

I hereby claim:

  • I am trydionel on github.
  • I am trydionel (https://keybase.io/trydionel) on keybase.
  • I have a public key ASAqp_aOZqcmAe0F12Mvs7kjsW8ly1MaSbxkQY6XnRIFWgo

To claim this, I am signing this object:

@trydionel
trydionel / backbone.rails.js
Created November 28, 2010 16:47
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.