Skip to content

Instantly share code, notes, and snippets.

View patr1ck's full-sized avatar
🏫
Retooling...

Patrick B. Gibson patr1ck

🏫
Retooling...
View GitHub Profile
@b3ll
b3ll / MaybeRevolutionary.swift
Created July 3, 2014 23:14
Revolutionizing YES / NO
import Cocoa
var MAYBE: Bool {
get {
return Bool(Int(arc4random_uniform(2)))
}
}
var thisIsTotallyAGoodIdea = MAYBE
@tjw
tjw / readonly-property-analyzer.m
Created March 12, 2015 18:56
20140181: Regression: clang static analyzer emits spurious warning when releasing strong ivar in -dealloc
#import <Foundation/Foundation.h>
/*
clang --analyze readonly-property-analyzer.m
readonly-property-analyzer.m:20:2: warning: Incorrect decrement of the reference count of an object that is not owned at this point by the caller
[_string release];
^~~~~~~~~~~~~~~~~
1 warning generated.
@simonprev
simonprev / gist:3044224
Created July 3, 2012 23:55
Fix my Rdio
1. Open terminal.app
2. Paste this command: defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
(credit: https://twitter.com/defaultswrite/status/220164244954554368)
3. Open Rdio.app
4. Right click and show the inspector panel
5. In the console section, paste this line: $("head").append('<link href="https://s3.amazonaws.com/simon-dev/css/rdio.css" rel="stylesheet" type="text/css">')
@mattt
mattt / nshipster-new-years-2015.md
Created November 25, 2014 19:38
NSHipster New Year's 2015

Season's Greetings, NSHipsters!

As the year winds down, and we take a moment to reflect on our experiences over the past months, one thing is clear: 2014 has been an incredible year professionally for Apple developers. So much has happened in such a short timespan, and yet it's hard to remember our relationship to Objective-C before Swift, or what APIs could have captivated our imagination as much as iOS 8 or WatchKit.

It's an NSHipster tradition to ask you, dear readers, to send in your favorite tips and tricks from the past year for publication over the New Year's holiday. This year, with the deluge of new developments—both from Cupertino and the community at large—there should be no shortage of interesting tidbits to share.

Submit your favorite piece of Swift or Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

If you're wondering about what to post, look to

@iosdevzone
iosdevzone / CommonCryptoHack
Created September 21, 2014 03:14
A shell script to write a dummy CommonCrypto.framework module into the directory where playgrounds look for frameworks.
#!/bin/bash
if [[ $BASH_SOURCE != $0 ]]; then echo "$BASH_SOURCE must be executed, not sourced."; return 255; fi
#
# A script to fool iOS playgrounds into allowing access to CommonCrypto
#
# The script creates a dummy CommonCrypto.framework in the SDK's System
# Framework Library Directory with a module map that points to the
# umbrella header
#
# Usage:
//
// Signal+Extensions.swift
// Khan Academy
//
// Created by Nacho Soto on 10/1/15.
// Copyright © 2015 Khan Academy. All rights reserved.
//
import ReactiveCocoa
Let's Reinvent Modern CPU Caches!
In The Beginning, programs were hard-coded, entered directly with switches. Values would be input, and then results would output,
but couldn't really be stored. We'll draw this like so:
Input -> Fixed Calculations -> Output
An early improvement in generality was the addition of storage (ENIAC eventually gained 100 words of magnetic core memory),
leaving us with something along these lines:

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

@calebd
calebd / ArrayHelpers.swift
Last active November 4, 2022 15:17
Swift Helpers
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
@wearhere
wearhere / keep_current_file_open.sh
Created February 9, 2012 09:34
Keep your current source file open in Xcode after a run completes (a.k.a don't die in main.m)
#! /bin/sh
# On alternate invocations, this script
# saves the path of the source file currently open in Xcode
# and restores the file at that path in Xcode.
#
# By setting Xcode (in Behaviors) to run this script when "Run Starts"
# and when "Run Completes", you can prevent it from switching to main.m
# when a run finishes.
# See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator