Skip to content

Instantly share code, notes, and snippets.

View tylerhunt's full-sized avatar

Tyler Hunt tylerhunt

View GitHub Profile
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@sco
sco / gist:832414
Created February 17, 2011 19:13
Simple chronologic example
# Get an instance of the Chronologic client
chronologic = Chronologic::Client.new
# Cache metadata for users, spots, etc.
chronologic.object(:user_1, {:name => 'Scott Raymond'})
chronologic.object(:user_2, {:name => 'Josh Williams'})
chronologic.object(:spot_1, {:name => 'Gowalla HQ'})
# Create subscriptions when one user follows another, etc.
chronologic.subscribe(:user_2_friends, :user_1)
@twbell
twbell / factual_local_mappings.json
Created June 29, 2011 21:56
Provides a machine-readable mapping between Factual's Global Local Schema and country-specific attributes, denotes which attributes are supported within a specific country, and provides a country-to-table lookup
{
"countries": {
"ar": {
"country": "Argentina",
"table": "PfldJg",
"attributes": {
"factual_id": {
"supported": true,
"mapping": "Factual ID"
},
@mbleigh
mbleigh / gist:1081663
Created July 14, 2011 00:58
Notes from converting my AppleTV into a media server and NAS.

AppleTV as Headless Media NAS

I don't use my AppleTV and I've had a 500GB external HD sitting around that isn't really getting use either. I thought I'd make use of both of these things and see if I could turn my AppleTV into a NAS device that would also allow for BitTorrent downloading and act as a transcoding DLNA MediaServer that I could access from my Xbox 360 and/or PS3.

Feature List

@nickawalsh
nickawalsh / gist:2923581
Created June 13, 2012 11:41
Pseudo Caret
/* Sample usage: +caret(bottom, 8px, #000); */
=caret($side, $size, $color)
$opposite: opposite-position($side)
+stretch(50%,auto,auto,50%)
border: $size solid transparent
border-#{$opposite}: $size solid $color
border-#{$side}: 0
content: ''
display: block
@steveklabnik
steveklabnik / _comment.html.erb
Created October 9, 2012 06:05
Presenters in Rails?
<article>
<header>
<h3><%= comment.author %></h3>
</header>
<%= comment.body %>
</article>
@geeksam
geeksam / gist:3875462
Created October 11, 2012 21:02
Roles in Ruby
class Role < Module
IncompleteInterface = Class.new(RuntimeError)
def included(receiver)
missing_methods = @public_api.map(&:to_sym) - receiver.public_instance_methods.map(&:to_sym)
unless missing_methods.empty?
raise IncompleteInterface,
"#{receiver} must implement these methods: #{missing_methods.inspect}"
end
@krisleech
krisleech / 01-trips_controller.rb
Created February 13, 2013 22:35
Using focused_controller to provide service object with hooks for callbacks
class TripsController < ApplicationController
class Action < ApplicationController::Action
end
class New < Action
expose(:trip) { Trip.new(params[:trip]) }
end
class Create < New
def call
@skwp
skwp / watch_listing.rb
Last active December 15, 2015 18:09
Hexagonal extraction of a controller action from reverb.com, showing reuse between controller and Grape/Roar based API. This is sample code stripped down to the essentials and is not guaranteed to work as-is :)
class Reverb::Actions::WatchListing
def self.watch(user, product, listener)
if product.owner?(user)
listener.failure(I18n.t('flash.watchlist.error_own'))
else
Reverb::Analytics.track(user, :watch_product) # FIXME, this doesn't belong here
user.user_watch_products.create(:product_id => product.id)
listener.success
end
end
@chris-zwickilton
chris-zwickilton / gist:6625578
Last active December 23, 2015 10:59
A flavor of Hexagonal Rails with factory created use cases
class UsersController < ApplicationController
def create
create_user = UserUseCaseFactory.create_user(Responder.new(self)
create_user.do(params[:email], params[:password[)
end
class Responder < SimpleDelegator
def success(user)
render json: UserSerializer.new(user)