Skip to content

Instantly share code, notes, and snippets.

View gregbell's full-sized avatar

Greg Bell gregbell

View GitHub Profile
@gregbell
gregbell / active_admin.rb
Created February 23, 2012 18:11
Example of changing the utility navigation in the layout (Top right of nav bar)
# This assumes you are using that you are using Active Admin from master.
# You can do this with 0.4.2 but you would need to override the HeaderRenderer instead
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# View a list of all the elements you can override
# https://github.com/gregbell/active_admin/blob/master/lib/active_admin/view_factory.rb
config.view_factory.utility_navigation = MyCustomUtilityNav
@gregbell
gregbell / active-admin-run-tests-on-fork.sh
Created February 18, 2012 17:16
Active Admin: run-tests-on-fork
#!/bin/bash
set -e
# Run the script:
# ./active-admin-run-tests-on-fork GITHUBUSERNAME BRANCHNAME
# Change this to wherever you want tests to run
tests_dir=~/code/personal/active_admin_forks
@gregbell
gregbell / batch_review.rb
Created November 23, 2011 17:20 — forked from pcreux/batch_review.rb
Batch gitmine review a bunch of tickets.
#!/user/env ruby
#
# Batch gitmine review a bunch of tickets.
#
# Usage: ruby batch_review.rb 7585 7603 7623 7640 7663 7665
#
ARGV.each do |issue_id|
system("gitmine checkout #{issue_id} && git pull && git diff master...HEAD")
puts "Merge into master?"
@gregbell
gregbell / products.rb
Created September 20, 2011 18:53
Active Admin - Show screen with default content
ActiveAdmin.register Product do
# Will show the default main content...
show do
# Do stuff before
default_main_content
# Do stuff after
end
# ... Or if you want to customize further
@gregbell
gregbell / index.html.erb
Created May 24, 2011 19:24
Arbre components in ERB
<% self.class.send :include, Arbre::HTML %>
<%= panel("Hello"){ h2 @test_assign } %>
<%= panel("Hello World"){ } %>

VersaPay REST API v 0.1

Messages

Response Formats

Add one of the following formats to the end of the url

.json .xml

module HasMoney
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
#
# has_money :default_price
class FormBuilder
attr_reader :calls
def initialize(&block)
@calls = []
@current = @calls
block.call(self)
end
// Assuming jQuery is on the page, this will append the search tweets
// to an element with the id of 'twitter'
$.getJSON("http://search.twitter.com/search.json?q=adobe+sucks&callback=?", function(data){
$.each(data.results, function(i, tweet){
var tweetContent = '<div class="tweet">';
tweetContent += '<p class="tweet-body">' + tweet.text + '</p>';
tweetContent += '<p class="tweet-meta"><a href="http://twitter.com/' + tweet.from_user + '">' + tweet.from_user + '</a> at ' + tweet.created_at + '</p></div>';
$('#twitter').append(tweetContent);
});
})
class Player < ActiveRecord::Base
has_many :game_participations
has_many :games, :through => :game_participations
end
class Game < ActiveRecord::Base
has_many :game_participations
has_many :players, :through => :game_participations
end