Skip to content

Instantly share code, notes, and snippets.

View joshk's full-sized avatar
🥸

Josh Kalderimis joshk

🥸
  • Valued
  • Wellington, NZ
  • 06:34 (UTC +02:00)
View GitHub Profile
MacRubyHTTP.post("https://our.application.url.com", {
:payload => some_json_payload,
:headers => { 'Content-Type' => 'application/json' }) do |lh|
NSLog(lh.inspect)
end
@joshk
joshk / em_deferrable.rb
Created March 6, 2011 18:05
em deferrable faraday adapter
module Faraday
class Adapter
class EMHttpRequest < Faraday::Adapter
self.supports_parallel_requests = true
def self.setup_parallel_manager(options = {})
EMParallelManager.new
end
class EMParallelManager
render: function(username) {
var self = this;
this.repositories.fetch({ success: function() {
var content = this.templates.list({
builds_list_title: "Recent Builds",
repositories: Travis.Collections.Repositories.toJSON()
});
self.el.fadeOut('fast', function() {
@joshk
joshk / habtm_destroy_test.rb
Created February 9, 2011 16:15
Example code for Fix Destroy Arity rails pull request
# Dev with custom destroy taking extra params
class DeveloperWithCustomDestroyMethod < ActiveRecord::Base
self.table_name = 'developers'
has_and_belongs_to_many :projects, :join_table => 'developers_projects', :foreign_key => 'developer_id'
def destroy(options ={})
super
end
end
diff --git a/lib/list.ex b/lib/list.ex
index 75778f7..10d6cf7 100644
--- a/lib/list.ex
+++ b/lib/list.ex
@@ -1,5 +1,13 @@
object List
- def +(another)
+ % Returns a new list with the contents of the
+ % current list and the other list.
+ %
require 'bigdecimal'
class Payment
FEE_PERCENTAGE = BigDecimal.new('2.9')
FEE_SET_AMOUNT = BigDecimal.new('0.15')
attr_reader :amount
def initialize(amount)
@amount = BigDecimal.new(amount.to_s)
def root_binding
binding
end
module Blah
def self.root_binding
@root_binding
end
@joshk
joshk / gist:784304
Created January 18, 2011 11:32
deploy.rb
# - TS related capistrano tasks
require "vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deploy/capistrano"
require 'new_relic/recipes'
set :stages, %w(staging production)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
# Global deployment information
/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/runtime.rb:27:in `setup': You have already activated gemcutter 0.5.0, but your Gemfile requires gemcutter 0.6.1. Consider using bundle exec. (Gem::LoadError)
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/runtime.rb:17:in `setup'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler.rb:95:in `setup'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/cli.rb:292:in `exec'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/task.rb:22:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/task.rb:22:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /o
source :rubygems
gemspec