Skip to content

Instantly share code, notes, and snippets.

@soopa
soopa / last.example.rb
Created June 10, 2015 18:11
Basic Last.rb Example
require "rack"
require "last/endpoints"
require "last/routers"
require "last/middlewares/body_parser_for_json_content_type"
class Router < Last::Routers::Router
get "/accounts", Application::V1::ListAccountsEndpoint
end
class ListAccountsEndpoint < Last::Endpoints::Endpoint
// The variable `delegate` property of `UINavigationController` is defined as `unowned`.
//
// Given a case in which that `delegate` must be retained, is this the best pattern for doing so?
class CustomNavigationController: UINavigationController {
override var delegate: UINavigationControllerDelegate? {
didSet {
self.strongDelegate = delegate
}
@soopa
soopa / reference-api-designs.md
Last active April 22, 2023 10:56
A running list of API designs worth referencing, alphabetized.
@soopa
soopa / airbnb-bookmarklet.js
Created December 29, 2013 01:28
A bookmarklet to calculate an Airbnb stay total (subtotal + Airbnb service fee) and cost per guest and per couple. Example: http://cl.ly/image/2i310X2i1W3H
javascript:(function(){var subtotal=parseInt($('%23subtotal').text().replace(/\$/g,''));var fee=parseInt($('%23service_fee').text().replace(/\$/g,''));var guests=parseInt($('%23number_of_guests').val());var total=subtotal+fee;var total_per_guest=total / guests;var total_per_couple=total_per_guest*2;$('%23show_more_subtotal_info').html("Total: $"+total+"<br>Per Guest/Couple: $"+total_per_guest+" / $"+total_per_couple);})();
@soopa
soopa / screenshot.rb
Created August 23, 2013 21:24
Easy screenshots of websites with Ruby
# Gemfile
# source 'https://rubygems.org'
# gem 'poltergeist', :require => 'capybara/poltergeist'
require 'bundler'; Bundler.require
include Capybara::DSL
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :js_errors => false)
@soopa
soopa / octowalla.rb
Created July 28, 2013 06:16
The ol' Gowalla GitHub Issues Monitor for Campfire, for keepsakes
require 'rubygems'
require 'hashie'
require 'httparty'
require 'json'
module Gowalla
class Issues
include HTTParty