Skip to content

Instantly share code, notes, and snippets.

View tinomen's full-sized avatar

Jake Mallory tinomen

  • Salt Lake City, UT
View GitHub Profile
@tinomen
tinomen / install_riak_with_homebrew.bash
Created April 14, 2011 22:49
riak needs erlang R13b04 and homebrew now defaults to R14
# first install erlang using the R13b04 formula
brew install https://github.com/mxcl/homebrew/raw/810d52f4a386ea9e2b837030120ffd69cad73722/Library/Formula/erlang.rb
# now you are free to install riak
brew install riak
@tinomen
tinomen / registry_test.rb
Created April 9, 2011 02:01
Service Locator Pattern - remove the explicit references to external class names. *** I had it in my head to write something that would provide the basics of the service locator pattern. While this will provide all services without error it still leaves t
puts __FILE__
require "../service_locator.rb"
require "test/unit"
class TestServiceRegistry < Test::Unit::TestCase
def test_registry
reg = Service::Registry.new
assert_not_nil(reg)
assert_nil(reg[:bob])
@tinomen
tinomen / a_couchdb_recipe_for_ey.txt
Created March 30, 2011 00:29
Altered couchdb recipe for use on EngineYard with chef-solo 0.6
I had to alter the recipe for couchdb available on opscode.com to work on engine yard. (http://community.opscode.com/cookbooks/couchdb)
1. EY still uses chef-solo 0.6 which requires the attributes file to be changed. trial and error found a working solution
2. EY is on gentoo and the service commands hang. Changed recipe to use the typical init.d path. Updated the init.d script.
3. added couchdb.yml template to add file to app_server:/data/[app_name]/shared/config
FYI I commented out the reference to the erlang recipe for now as we've added the erlang package to the entire environment.
@tinomen
tinomen / client.rb
Created January 26, 2011 01:43
demo for urug on msgpack and 0mq
require 'Date'
class Client
attr_accessor :from, :msg
attr_reader :at, :diff
def initialize
@at = Time.now
end
@tinomen
tinomen / msgpack_example.rb
Created January 19, 2011 01:27
log client for simple rpc logger using MessagePack
require 'msgpack'
require 'msgpack/rpc'
class Logr
attr_accessor :client
def initialize(ip)
@client = MessagePack::RPC::Client.new(ip, 9090)
end
@tinomen
tinomen / r3-templates-logrotate.rb
Created October 23, 2010 05:00
setup logger to rotate
#----------------------------------------------------------------------------
# Rotate log files (50 files max at 1MB each)
#----------------------------------------------------------------------------
log_path = '#{Rails.root}/log/#{Rails.env}.log'
gsub_file 'config/application.rb', /(< Rails::Application.*)/ , "\\1\n config.logger =
Logger.new(\"#{log_path}\", 50, 1048576)"
@tinomen
tinomen / r3-templates-js-framework.rb
Created October 23, 2010 04:59
choose javascript framework
#----------------------------------------------------------------------------
# Choose Javascript Framework
#----------------------------------------------------------------------------
run 'mkdir public/uploads && chmod 777 public/uploads'
run 'mkdir public/ui'
ask_js = ask("\r\n\r\nWhat javascript framework do you want to use?\r\n\r\n(1) Prototype\r\n(2) jQuery\r\n(3) MooTools\r\n(4) RightJS")
if ["1", "2", "3", "4"].include?(ask_db_type)
@prototype = (ask_db_type=="1")
@jquery = (ask_db_type=="2")
#----------------------------------------------------------------------------
# Git Setup
#----------------------------------------------------------------------------
file '.gitignore', <<-FILE
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
public/uploads/*
@tinomen
tinomen / curl-client.bash
Created September 10, 2010 22:00
riak-sinatra-test-session.bash
$ curl -X PUT -v -F value=@bauhaus.jpg http://localhost:9292/test/bauhaus.jpg
* About to connect() to localhost port 9292 (#0)
* Trying ::1... Connection refused
* Trying fe80::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 9292 (#0)
> PUT /test/bauhaus.jpg HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-apple-darwin10.4.0) libcurl/7.21.0 OpenSSL/1.0.0a zlib/1.2.5 libidn/1.19
> Host: localhost:9292
> Accept: */*
//Add the following category to CPToolbar
@implementation CPToolbar (selectables)
- (CPToolbar)initWithSelector:(CPString)anId forWindow:(CPWindow)aWindow
{
if(self = [self initWithIdentifier:anId])
{
var mainBundle = [CPBundle mainBundle],
image = [[CPImage alloc] initWithContentsOfFile:[mainBundle pathForResource:@"selected.png"]