Skip to content

Instantly share code, notes, and snippets.

View acrookston's full-sized avatar
👨‍💻
Coding!

Andrew Crookston acrookston

👨‍💻
Coding!
View GitHub Profile
@nicklockwood
nicklockwood / Withable.swift
Created January 28, 2019 12:06
Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@parrots
parrots / AsyncOperation.swift
Last active May 17, 2021 10:44
A Swifty version of an AsyncOperation which solves two common problems I ran into. (see comment below for issues addressed)
//
// AsyncOperation.swift
// Slopes
//
import Foundation
class AsyncOperation: Operation {
private let stateLock = NSLock()
private var observers: [NSKeyValueObservation] = [NSKeyValueObservation]()
import Foundation
// Inspired by https://gist.github.com/mbuchetics/c9bc6c22033014aa0c550d3b4324411a
struct JSONCodingKeys: CodingKey {
var stringValue: String
init?(stringValue: String) {
self.stringValue = stringValue
}
@leshill
leshill / git-prunelocal
Last active May 25, 2023 07:00
Prune local tracking branches that have been removed upstream. Place file in your path (perhaps `~/bin` or `~/scripts`).
#!/bin/bash
#
# Prune local tracking branches that have been removed upstream.
# Your remote tracking branches can be removed automatically by setting `fetch.prune` to true or running `git fetch -prune`.
# Another command to clean up your remote tracking branches is `git remote prune <remote>`.
#
# Author: @leshill
# https://gist.github.com/leshill/9a1088a17f94cef24831
if [[ $# = 1 && $1 == '-n' ]]; then
#!/bin/sh
## Packages:
# brew install pngcrush
# brew install optipng
# brew install advancemame
# brew install https://raw.github.com/adamv/homebrew-alt/23f9084410476da1fcaf946f24f4dde47fe888ea/non-free/pngout.rb
function usage {
echo "Usage: $0 infile outfile"
@neiled
neiled / hamlhtml5boilerplate.html.haml
Created November 25, 2010 23:20
My haml version of the html 5 boiler plate code
!!! 5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%head
%meta{:charset => "utf-8"}/
/
Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame
@laserlemon
laserlemon / Rails 2 Environment
Created October 1, 2010 12:11
Snow Leopard, Homebrew, Git, RVM, Ruby, Passenger, Apache, MySQL, Memcached and ImageMagick
# 2010-10-01
#
# Mac OS X 10.6.3
# Homebrew 0.7
# Xcode 3.2.4
# Git 1.7.3.1
# RVM 1.0.12
# Ruby 1.8.7, 1.9.2
# Passenger 2.2.15
# MySQL 5.1.49