method PageHeaderHelper
def page_header(title, subtitle = nil, &contents)
PageHeader.new(self, title, subtitle, &contents)
end
class PageHeader
attr_reader :context, :title, :subtitle
def initialize(context, title, subtitle = nil)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ChronicAttribute | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def chronic(*attrs) | |
attrs.each do |attr| | |
define_method "#{attr}=" do |value| | |
if value.is_a? String | |
with_utc do | |
self[attr] = Chronic.parse(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Analyzer | |
class << self | |
include ActionView::Helpers::NumberHelper | |
end | |
CACHE_NAMESPACE = "analyzer" | |
CACHE_LIFESPAN = 10.minutes | |
class_attribute :items_to_analyze |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FieldsetWithSubtext | |
def fieldset_with_subtext(main_text, subtext, options = {}, &block) | |
View.new(self, main_text, subtext, options, &block) | |
end | |
class View | |
attr_reader :context, :main_text, :subtext, :options, :block | |
def initialize(context, main_text, subtext, options = {}, &block) | |
@context = context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instructions: | |
// 1. Visit https://clients.uber.com/#!/dashboard | |
// 2. Click the "Show all trips" link | |
// 3. Paste the following into the console | |
// 4. Gasp in horror as you see how much money you've spent on Uber | |
_($("td.num:contains($)")).map(function (el) { return $(el).text().substring(1) }).map(Number).reduce(function(memo, num) { return memo + num; }) |
The following document outlines a basic design for implementing single sign-on in a service-oriented architecture with many user-facing apps. I have posted it here hoping to get feedback, so don't be afraid to fork and/or comment with your thoughts.
The design relies on two main components in addition to the user-facing servers (apps) and app-facing servers (services):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Provides a helper method for controllers who need to query a nested resource. | |
# Implements per-request in-memory caching for nested resources as well as | |
# support for controllers that are also accessed without being nested. | |
module NestedResource | |
DEFAULT_OPTIONS = { | |
optional: false, | |
class_name: nil, | |
param: nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backbone.View.register = (role) -> | |
$ => new @(el: element).render() for element in $("@" + role) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Stolen from Joshua Clayton of thoughtbot: | |
# http://robots.thoughtbot.com/post/19398560514/how-to-copy-and-paste-with-tmux-on-mac-os-x | |
PATH=/usr/local/bin:$PATH | |
while true; do | |
if test -n "`tmux showb 2> /dev/null`"; then | |
tmux saveb - | pbcopy && tmux deleteb |