Skip to content

Instantly share code, notes, and snippets.

[
{
"actor": {
"avatar_url": "https://avatars.githubusercontent.com/u/10810283?",
"display_login": "direwolf-github",
"gravatar_id": "",
"id": 10810283,
"login": "direwolf-github",
"url": "https://api.github.com/users/direwolf-github"
},
@rnystrom
rnystrom / gist:7a0f4d39bf9e1320953be1e99d0e0bf8
Created April 4, 2017 01:01
IGListKit sample debug dump
(lldb) po [IGListDebugger dump]
IGListAdapter 0x7ff4c0933100:
Updater type: IGListAdapterUpdater
Data source: <IGTestDelegateDataSource: 0x7ff4c0916ee0>
Collection view delegate: (null)
Scroll view delegate: (null)
Is in update block: No
View controller: (null)
Registered cell classes:
{(
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=10000
bindkey -v
# End of lines configured by zsh-newuser-install
fpath=(/usr/local/share/zsh-completions $fpath)
# The following lines were added by compinstall
// iterate newResultsArray in ascending order
// if na[i] == oa[j] and na[i+1] == oa[j+1], assign them to the opposite index+1
// pass 4 is for ascending and 5 descending, block covers logic for both
void (^pass4And5Block)(BOOL, vector<IGListRecord>&, vector<IGListRecord>&) = ^(BOOL ascending, vector<IGListRecord> &newResults, vector<IGListRecord> &oldResults) {
const NSInteger offset = ascending ? 1 : -1;
for (NSInteger i = ascending ? 0 : newCount - 1;
(ascending && i < newCount - 1) || (!ascending && i > 0);
ascending ? i++ : i--) {
// don't check block moves for new elements
// iterate newResultsArray in ascending order
// if na[i] == oa[j] and na[i+1] == oa[j+1], assign them to the opposite index+1
// pass 4 is for ascending and 5 descending, block covers logic for both
void (^pass4And5Block)(BOOL, vector<IGListRecord>&, vector<IGListRecord>&) = ^(BOOL ascending, vector<IGListRecord> &newResults, vector<IGListRecord> &oldResults) {
const NSInteger offset = ascending ? 1 : -1;
for (NSInteger i = ascending ? 0 : newCount - 1;
(ascending && i < newCount - 1) || (!ascending && i > 0);
ascending ? i++ : i--) {
// don't check block moves for new elements
@rnystrom
rnystrom / RN3DTouchGestureRecognizer.swift
Last active February 3, 2018 22:58
RN3DTouchGestureRecognizer
//
// RN3DTouchGestureRecognizer.swift
//
// Created by Ryan Nystrom on 10/10/15.
// Copyright © 2015 Ryan Nystrom. All rights reserved.
//
import UIKit.UIGestureRecognizerSubclass
class RN3DTouchGestureRecognizer: UIGestureRecognizer {
@rnystrom
rnystrom / iOS @3x assets script
Created November 26, 2014 01:52
Save this shell script to generate @2x and 1x PNG assets for your apps. Requires Imagemagick (http://www.imagemagick.org/). These will probably look shitty and blurred.
#!/bin/sh
# Example usage
# cd into directory that has @3x images
# ./whatever-you-name-this.sh
# Remember to chmod +x the script
resize () {
ls *@3x.png | awk '{print("convert "$1" -filter box -resize '$1' "$1)}' | sed 's/@3x/'$2'/2' | /bin/sh
}
func showScheme(sender: ScalingPageControl) {
performSegueWithIdentifier(SegueIdentifier.PresentSchemeSegue.rawValue/* :( */, sender: pageControl)
}
@rnystrom
rnystrom / :(
Created November 3, 2014 16:37
A friendly challenge to anyone w/ functional chops to improve this function. No holds barred: op overloading, enum/struct/class, everything-is-a-singleton... go for it! The only rule is no forced unwrapping (e.g. !).
import Foundation
import ImageIO
func datesFromImagesInDir(dir: String) -> [NSDate] {
let fm = NSFileManager.defaultManager()
var error: NSError?
let df = NSDateFormatter()
df.dateFormat = "yyyy:MM:dd HH:mm:ss"
- (NSManagedObjectContext *)managedObjectContext {
if (! _managedObjectContext) {
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Moviedo" withExtension:@"momd"];
NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
_managedObjectContext.persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
NSURL *storeURL = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject] URLByAppendingPathComponent:@"Moviedo.sqlite"];
NSDictionary *options = @{