Skip to content

Instantly share code, notes, and snippets.

View jessesquires's full-sized avatar
🏴
free labor

Jesse Squires jessesquires

🏴
free labor
View GitHub Profile
@leemorgan
leemorgan / AutoAssets.md
Last active August 29, 2015 14:25
Xcode build script to generate a Swift file enumerating the project's assets
@juandazapata
juandazapata / mountain_lion_home_brew.md
Created July 26, 2012 15:07
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

After upgrading to Mountain Lion, I got this message when trying to run my local rails server:

Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb
@implementation NSManagedObject (TCCreation)
+ (instancetype)tc_insertIntoContext:(NSManagedObjectContext*)ctx
{
for(NSEntityDescription *desc in [ctx.persistentStoreCoordinator.managedObjectModel entities]) {
if([desc.managedObjectClassName isEqual:NSStringFromClass(self)]) {
return [[self alloc] initWithEntity:desc insertIntoManagedObjectContext:ctx];
}
}
NSAssert(NO, @"This class does not exist in the managed object model for %@", ctx);
return nil;
@airspeedswift
airspeedswift / ProtocolsVsGenerics.swift
Last active November 25, 2015 18:50
Timing the difference between protocols and protocol-constrained generics
import Darwin
import CoreFoundation.CFDate
protocol NumberGeneratorType {
mutating func generateNumber() -> Int
}
struct RandomGenerator: NumberGeneratorType {
func generateNumber() -> Int {
return Int(arc4random_uniform(10))
@jverkoey
jverkoey / NSNotificationCenterExtensions.swift
Last active January 24, 2016 22:19
NSNotificationCenter extension for safe Swift instance method support
/*
Copyright (c) 2011-present, NimbusKit. All rights reserved.
This source code is licensed under the BSD-style license found at http://nimbuskit.info/license
Extracted from NimbusKit: Swift Edition at https://github.com/nimbuskit/swift
*/
extension NSNotificationCenter {
/**
@austinzheng
austinzheng / main.swift
Last active March 7, 2016 20:41
Anonymous class experiment in Swift
import Foundation
protocol SomeDelegateProtocol : class {
func firstFunc() -> String
func secondFunc() -> Bool
func thirdFunc() -> Self
}
class MyClass {
weak var delegate : SomeDelegateProtocol?
@jessesquires
jessesquires / update_xcode_plugins.sh
Last active April 4, 2016 20:35 — forked from neonichu/update_xcode_plugins
Update DVTPlugInCompatibilityUUIDs for installed plugins
#!/bin/sh
# ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2
# ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3
# ID='AABB7188-E14E-4433-AD3B-5CD791EAD9A3' # Xcode 7b5
# ID='7265231C-39B4-402C-89E1-16167C4CC990' #Xcode 7.1.1
ID='F41BD31E-2683-44B8-AE7F-5F09E919790E' # Xcode 7.2
PLIST_BUDDY=/usr/libexec/PlistBuddy
// We're going to try to build a collectionview layout engine that can serve up cells and supplementary views
// in a generic way. I haven't built this all the way to the collection view, and I don't konw what the real
// brief is, so there may be lots of gotchas here that don't work as desired, but it scopes out several ways
// to get a handle on the problem and how I'd at least probably start.
// Ultimately, this requires converting (Model, IndexPath) -> Cell and (Model, IndexPath) -> SupView. I'm
// assuming that's the only feature of these factories.
@orta
orta / _SQL.sql
Last active November 8, 2016 12:12
Top 300 Pods by Application Integrations
SELECT pods.name, stats_metrics.download_total, stats_metrics.download_week, stats_metrics.app_total, stats_metrics.app_week FROM stats_metrics JOIN pods ON stats_metrics.pod_id = pods.id ORDER BY app_total DESC LIMIT 300;
// Photoshop Script to Create iPhone Icons from iTunesArtwork // // WARNING!!! In the rare case that there are name collisions, this script will // overwrite (delete perminently) files in the same folder in which the selected // iTunesArtwork file is located. Therefore, to be safe, before running the // script, it's best to make sure the selected iTuensArtwork file is the only // file in its containing folder. // // Copyright (c) 2010 Matt Di Pasquale // Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and