Skip to content

Instantly share code, notes, and snippets.

View joshk's full-sized avatar
🥸

Josh Kalderimis joshk

🥸
  • Valued
  • Wellington, NZ
  • 18:11 (UTC +02:00)
View GitHub Profile
module UnicornPowers
def fire_super_ray_beam
ray_beam_power
end
def ray_beam_power
"pow"
end
end
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
module ActionView
# = Action View Lookup Context
#
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. The LookupContext is also responsible to
# generate a key, given to view paths, used in the resolver cache lookup. Since
# this key is generated just once during the request, it speeds up all cache accesses.
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