Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Coding!

Andrew Crookston acrookston

👨‍💻
Coding!
Block or report user

Report or block acrookston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 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 Oct 14, 2019
A Swifty version of an AsyncOperation which solves two common problems I ran into. (see comment below for issues addressed)
View AsyncOperation.swift
//
// AsyncOperation.swift
// Slopes
//
import Foundation
class AsyncOperation: Operation {
private let stateLock = NSLock()
private var observers: [NSKeyValueObservation] = [NSKeyValueObservation]()
View Decode Array<Any> and Dictionary<String, Any> Swift
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 Dec 15, 2017
Prune local tracking branches that have been removed upstream. Place file in your path (perhaps `~/bin` or `~/scripts`).
View git-prunelocal
#!/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
View pngbai.sh
#!/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 Nov 25, 2010
My haml version of the html 5 boiler plate code
View hamlhtml5boilerplate.html.haml
!!! 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 Oct 1, 2010
Snow Leopard, Homebrew, Git, RVM, Ruby, Passenger, Apache, MySQL, Memcached and ImageMagick
View Rails 2 Environment
# 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
You can’t perform that action at this time.