Skip to content

Instantly share code, notes, and snippets.

View sgoodwin's full-sized avatar

Samuel Goodwin sgoodwin

View GitHub Profile
@timonus
timonus / programmatic-dynamic-images.m
Last active January 1, 2024 12:08
Programmatically create iOS 13 dynamic images
- (UIImage *)dynamicImage
{
UITraitCollection *const baseTraitCollection = /* an existing trait collection */;
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]];
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]];
__block UIImage *lightImage;
[lightTraitCollection performAsCurrentTraitCollection:^{
lightImage = /* draw image */;
@brentsimmons
brentsimmons / declarative_code.markdown
Last active April 30, 2019 14:16
A draft of a blog post that will never be published.

THIS IS A BLOG POST DRAFT THAT I WILL NEVER PUBLISH

INSTEAD I PLAN TO DO A SERIES OF SMALLER BLOG POSTS ON THE SUBJECT

The Objective-C Runtime and Declarative Programming

I write new code in Swift. It’s fun and I like it.

@beny
beny / gist:8313959
Last active March 14, 2022 11:41
Xcode tips

Core Data

  • -com.apple.CoreData.SQLDebug 1-3 - print all SQL queries called by Core Data
    • -com.apple.CoreData.Logging.stderr 1-3 - needed alongside with the SQLDebug from iOS 10+ because of new logging system, more on that in changelog
  • -com.apple.CoreData.SyntaxtColoredLogging YES - probably syntax colored logging (not tried)
  • -com.apple.CoreData.SQLiteDebugSynchronous 1 - preference controls some aspects of the SQLite store. See the "Configuring a SQLite Store's Save Behavior" section of the Core Data Programming Guide for details
  • -com.apple.CoreData.SQLiteIntegrityCheck 1 - the SQLite store does extra integrity checking
  • -com.apple.CoreData.MigrationDebug 1 - Core Data will log information about exceptional cases as it migrates data
  • -com.apple.CoreData.ThreadingDebug - preference enables assertions to enforce Core Data's multi-threading policy. It is a number, where incre
@bolot
bolot / gist:3812249
Created October 1, 2012 14:50
Simulate memory warning in iOS
[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
@tlrobinson
tlrobinson / LICENSE.txt
Created October 2, 2011 08:56
Extremely simple lexer, parser, compiler, and interpreter for a prefix notation calculator.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Tom Robinson <http://tlrobinson.net/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@kisom
kisom / configfile.c
Created September 18, 2011 17:19
C function to split a buffer into a char ** containing each line.
/*
* written by kyle isom <coder@kyleisom.net>
* license: isc / public domain dual license
* one of the functions i wrote for the lurker project
* (https://github.com/kisom/lurker) project
*
* from twitter (@kyleisom):
* '"so a char * goes to a char ** where each char * in the char ** is a line
* in the first char *" - me explaining my C algorithm to @qb1t'
*/
@skabber
skabber / build_ota.sh
Created September 12, 2011 19:49
Xcode Build OTA
#!/bin/sh
# This script was written by Jay Graves for the 360iDev Conference.
# You can find the full slides available at http://skabber.com/
# This script requires Xcode and s3cmd http://s3tools.org/s3cmd
# You will need your own Amazon S3 account to upload files.
# Put your distribution certificates and keys in the System Keychain
# otherwise you will need to use security unlock-keychain
TARGET=GroupA
PlistBuddy=/usr/libexec/PlistBuddy
@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@sebastiandeutsch
sebastiandeutsch / deploy.rb
Created July 13, 2011 21:10
deploy.rb for node.js
set :stages, %w(production staging)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
set :application, "imgly-tracking"
set :domain, "node.9elements.com"
set :user, "imgly-tracking"
set :repository, "git@github.com:9elements/imgly-tracking.git"
set :use_sudo, false