Skip to content

Instantly share code, notes, and snippets.

View justincampbell's full-sized avatar
🌯
🍩

Justin Campbell justincampbell

🌯
🍩
View GitHub Profile
# table_stats User
# table_stats User, :email, :name
def table_stats(model, *fields)
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
fields = model.send :column_names if fields.empty?
model_count = model.send(:count)
[
[%w[c r u d], Widget],
].each do |tuple|
permissions = tuple[0].map!(&:to_sym)
model = tuple[1]
permissions.map! do |permission|
case permission
when :c then :create
when :r then :read
@justincampbell
justincampbell / PhillyETE 2012 Day 1.md
Created April 10, 2012 21:08
PhillyETE 2012 Notes

todo

Storm Threequal js vs ruby

Keynote

The E myth Org chart for yourself

QFD = ideas into actionable items

@justincampbell
justincampbell / README.md
Created May 1, 2012 23:21
Capistrano Notifier Require Test

Capistrano Notifier Require Test

@justincampbell
justincampbell / lookup.rb
Created May 9, 2012 11:24
Method vs Variable lookup in Ruby
# Variable before method
a = "A variable"
def a; "A method"; end
puts a # A variable
# Method before variable
def b; "B method"; end
b = "B variable"
class Bicycle < ActiveRecord::Base
validate_presence_of :tire_quantity
def ride
pedal
brake
end
end
@justincampbell
justincampbell / attr_test.rb
Created May 21, 2012 19:55
attr_accessor test for RubyMotion 1.5
(main)> class AttrTest
(main)> attr_accessor :accessor
(main)> attr_reader :reader
(main)> attr_writer :writer
(main)>
(main)> def initialize(accessor, reader, writer)
(main)> @accessor = accessor
(main)> @reader = reader
(main)> @writer = writer
(main)> end
@justincampbell
justincampbell / tmux.md
Created July 13, 2012 21:01
Testing tmux

tmux

Install

brew install tmux

tmux starts a new session

Use

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Popcorn</title>
<style type="text/css">
body {
background: white url(popcorn.gif) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
@justincampbell
justincampbell / sio-redis-load-test.coffee
Created August 2, 2012 20:59
Socket.IO + Redis load test
redis = require("redis").createClient()
io = require("socket.io-client")
RESULT_COUNT = process.argv[2]
DATA_LENGTH = process.argv[3]
channel = "channel#{Math.floor(Math.random() * 1024)}"
results = []
console.log channel