Skip to content

Instantly share code, notes, and snippets.

View add_or_append_to_dictionary.swift
// TL;DR: look at this cool thing in swift
let ibsTags = try ibsTagRecords().reduce(into: [Int64: [Int64]]()) {
// this line here
$0[$1.ibsID, default: []].append($1.tagID)
}
// V1 original
@23inhouse
23inhouse / spec.swift
Last active Oct 23, 2019
trying to get swift spec to be as awesome as rspec
View spec.swift
class RawOSMDataTests: QuickSpec {
override func spec() {
context("given a RawOSMData") {
var subject: () -> RawOSMData? = { return nil }
describe(".decode") {
var json: String? = ""
afterEach { json = nil }
beforeEach {
@23inhouse
23inhouse / service-communication.md
Last active Apr 8, 2016
Service Communication
View service-communication.md

Services Communication Design

TL;DR The plan is to use protobuf for the format. Message calls should be made with gRPC when the client wants a response. High level messages should also be published to the bus. Message calls (events) that don't require a response can just be published to the bus.

There are 3 parts to consider:
  • Messaging format
  • Client calls that require a response - RPC
  • Publishing events - BUS

Messaging Format

The message format must be statically typed, binary, good adoption and have RPC integration.

@23inhouse
23inhouse / dev-setup.sh
Last active Aug 29, 2015
New developer setup script
View dev-setup.sh
#!/usr/bin/env bash
set -e
## Developer Environment
# setup
mkdir ~/setup
cd ~/setup
@23inhouse
23inhouse / Notes
Last active Dec 27, 2015
Cache Digests
View Notes
# cache digest talk
#
# There are 2 hard problems in computer science: caching, naming, and off-by-1 errors
#
# Gemfile
gem 'cache_digests'
View gist:3594973

Further customization

bundle open simple_form
<!-- app/view/blogs/_form.html.erb -->

<%= simple_form_for @blog, :html => { :class => 'form-horizontal' } do |f| %>
@23inhouse
23inhouse / gist:3594808
Created Sep 2, 2012
Customizing simple_form and bootstrap
View gist:3594808

Customization

<%= f.input :state, :collection => ['SA', 'WA'] %>
<%= f.input :state,
            :as => :radio_buttons,
            :collection => ['SA', 'WA'],
@23inhouse
23inhouse / gist:3594537
Created Sep 2, 2012
Simple form mappings
View gist:3594537

Config

# config/initializers/simple_form.rb

SimpleForm.setup do |config|
  config.wrappers :default,
                  :class => 'input',
                  :hint_class => 'field_with_hint',
                  :error_class => 'field_with_errors' do |b|
@23inhouse
23inhouse / gist:3547823
Created Aug 31, 2012
following twitter
View gist:3547823
require 'mechanize'
require 'csv'
CSV.foreach('wineries.csv', "r") do |row|
puts row.first
end