Skip to content

Instantly share code, notes, and snippets.

@23inhouse
23inhouse / swift code-exemplifying-sandy-metz-style-duck-types.gpt3
Last active February 17, 2023 20:14
ChatGPT3 response to "swift code exemplifying sandy metz style duck types"
23inhouse@gmail.com
swift code exemplifying sandy metz style duck types
Sure, here's an example of a Swift code that uses duck typing, in a style similar to that of Sandi Metz:
swift
Copy code
protocol Quackable {
func quack() -> String
}
@23inhouse
23inhouse / add_or_append_to_dictionary.swift
Last active February 11, 2021 21:22
Swift refactoring
// 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 October 23, 2019 13:19
trying to get swift spec to be as awesome as rspec
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 / gist:3594808
Created September 2, 2012 04:18
Customizing simple_form and bootstrap

Customization

<%= f.input :state, :collection => ['SA', 'WA'] %>
<%= f.input :state,
            :as => :radio_buttons,
            :collection => ['SA', 'WA'],
@23inhouse
23inhouse / service-communication.md
Last active April 8, 2016 22:52
Service Communication

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 / Notes
Last active December 27, 2015 10:48
Cache Digests
# cache digest talk
#
# There are 2 hard problems in computer science: caching, naming, and off-by-1 errors
#
# Gemfile
gem 'cache_digests'
@23inhouse
23inhouse / gist:3594973
Created September 2, 2012 05:06
1 more thing

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:3594537
Created September 2, 2012 03:24
Simple form mappings

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 August 31, 2012 02:04
following twitter
require 'mechanize'
require 'csv'
CSV.foreach('wineries.csv', "r") do |row|
puts row.first
end