Skip to content

Instantly share code, notes, and snippets.

View mxcl's full-sized avatar

Max Howell mxcl

View GitHub Profile
# This is more "Ruby", and I agree that I don't necessarily agree with
# all the syntax choices. The else condition isn't required as the
# function returns nil if no other code paths executed. You could argue
# that, that is a regression waiting to happen though.
def just_one_kind_of_response? item, controller
case controller
when 'actions'
item.comments.blank? or item.suggestions.blank? or detail.comments.blank?
when 'thoughts'
// Trying to write a function that does some select/map magic with easy error handling
let cities = [[
"name": "Geneva",
"population": 184538
],[
"name": "Bern",
"population": 123154
], [
"name": "Zurich",
import Darwin //.C.stdlib
// updated for Swift 2.0 beta4
private func merge<T: Comparable>(a: ArraySlice<T>, _ b: ArraySlice<T>, mergeInto acc: ArraySlice<T> = []) -> ArraySlice<T> {
guard let aF = a.first, bF = b.first else {
return acc + a + b
}
return aF < bF
? merge(dropFirst(a), b, mergeInto: acc + [aF])
@mxcl
mxcl / Lockfile.md
Last active March 13, 2016 12:39 — forked from aciidgh/Lockfile.md
Lock file proposal

Dependency Locking with the Swift Package Manager

Introduction

In a vibrant packaging ecosystem, dependencies update continuously with bug-fixes and feature improvements. When working against a collection of dependencies, especially in a team, it is vital to lock the graph and update it so that all team members receive the exact same graph at the same time.

The typical flow for this in dependency management is to create and use a dependency “Lockfile”.

Motivation

@mxcl
mxcl / tea-rfc1.md
Last active February 20, 2023 13:36 — forked from mfts/tea-rfc1.md
RFC: Dependency Manager Install Location

Motivation

One of the core benefits of tea: it's relocatable. tea does not pollute your system environment, everything gets "installed" in a relocatable folder ~/.tea.

tea can also install languages like node and ruby and it's dependency managers, npm and gem, respectively. However, these language dependency managers install packages to global directories like ~/.npm and ~/.gem. Tools from these ecosystems expect to find packages in these locations.

In this RFC, we would love to hear feedback from the community.