Skip to content

Instantly share code, notes, and snippets.

@jonah-williams
jonah-williams / tap.swift
Last active October 31, 2020 14:37
Implementing a Ruby `tap` equivalent in Swift
// I wanted an equivalent to Ruby's `tap` (http://ruby-doc.org/core-2.3.0/Object.html#method-i-tap) in Swift which I could mix into any type to tap into method chains.
// Define the interface we want to provide as a protocol
private protocol Tap {
func tap(block: (Self) -> Void) -> Self
}
// Extend the `Tap` protocol with a default implementation
private extension Tap {
func tap(block: (Self) -> Void) -> Self {
@jonah-williams
jonah-williams / readme.md
Created March 18, 2014 17:49
Default iOS project configuration patterns

iOS Project Template

  1. Install .ruby-version
  2. Install gemfile with pods dependency
  3. Install CocoaPods for dependency management
  4. Install Kiwi pod for unit tests
  5. Install objection pod for IoC
  6. Install KIF pod for acceptance specs
  7. Reorganize file structure; groups match file system folders, split out groups based on features or roles
  8. Define views in nib files by default; designer editable, easier auto-layout configuration, easier localization
@jonah-williams
jonah-williams / circle.yml
Last active May 29, 2019 14:53
Automating deployments to Heroku from CircleCI
test:
override:
- bundle exec rspec spec
deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
timeout: 300

Project

Description: What does this project do and who does it serve?

Project Setup

How do I, as a developer, start working on the project?

  1. What dependencies does it have (where are they expressed) and how do I install them?
  2. How can I see the project working before I change anything?
@jonah-williams
jonah-williams / KWSpec+WaitFor.h
Last active October 7, 2015 01:38
Delay execution of Kiwi specs until an asynchronous process finishes.
#import "KWSpec.h"
@interface KWSpec (WaitFor)
+ (void) waitWithTimeout:(NSTimeInterval)timeout forCondition:(BOOL(^)())conditionalBlock;
@end
@jonah-williams
jonah-williams / build.sh
Created April 30, 2011 17:46
Command line iOS project builds and over-the-air distribution
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
@jonah-williams
jonah-williams / api_docs.rake
Created April 21, 2011 16:19
Instrumenting rspec and using a custom formatter to generate API docs from specs. See http://blog.carbonfive.com/2011/04/21/generating-documentation-from-specs/
require 'rubygems'
require 'rspec/core/rake_task'
namespace :project_name do
namespace :api do
desc 'Generate API request documentation from API specs'
RSpec::Core::RakeTask.new('generate_docs') do |t|
t.pattern = 'spec/controllers/api/**/*_spec.rb'
t.rspec_opts = ["-Ilib/tasks/api_docs", "-rinstrument_specs", "-rapi_formatter", "--format APIFormatter"]
end
#!/bin/sh
~/Applications/UniversalIndentGUI/indenters/uncrustify -l OC -q -c ~/Applications/UniversalIndentGUI/config/uncrustify_obj_c.cfg
#!/usr/bin/env python
import sys, subprocess, re
RX_SUITE_START = re.compile(r"Test Suite '(?P<suitename>\w+)' started at (?P<date>[\d\-]+) (?P<time>[\d\:]+) (?P<tz>[\d\-\+]+)")
RX_SUITE_END = re.compile(r"Test Suite '(?P<suitename>\w+)' finished at (?P<date>[\d\-]+) (?P<time>[\d\:]+) (?P<tz>[\d\-\+]+)")
RX_TEST_START = re.compile(r"Test Case '(?P<testname>[^']+)' started\.")
RX_TEST_END = re.compile(r"Test Case '(?P<testname>[^']+)' passed \((?P<sec>[\d\.]+) seconds\)\.")
RX_TEST_FAIL = re.compile(r"Test Case '(?P<testname>[^']+)' failed \((?P<sec>[\d\.]+) seconds\)\.")
@jonah-williams
jonah-williams / default.rb
Created March 16, 2010 23:36 — forked from ezmobius/default.rb
chef recipe to add delayed_job workers to monit to run them on Engine Yard cloud instances
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
node[:applications].each do |app_name, data|
user = node[:users].first
case node[:instance_role]
when "solo", "app", "app_master"