Skip to content

Instantly share code, notes, and snippets.

View spnkr's full-sized avatar

Will Jessop spnkr

  • New York, NY
View GitHub Profile
@iwasrobbed
iwasrobbed / gist:5528897
Last active June 5, 2020 20:34
UICollectionView w/ NSFetchedResultsController & NSBlockOperation. Idea originated from Blake Watters (https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController/issues/13)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
@owenkellogg
owenkellogg / rubymotion_location_bubblewrap.rb
Created May 16, 2013 23:26
rubymotion get location with bubble wrap
BW::Location.get(distance_filter: 10, desired_accuracy: :nearest_ten_meters) do |result|
geocoder = CLGeocoder.alloc.init
geocoder.reverseGeocodeLocation result[:to], completionHandler: lambda {|location, x|
alert = UIAlertView.alloc.init
alert.message = "#{location[0].locality} : #{location[0].postalCode}"
alert.show
}
end
@michelson
michelson / picker_with_search_row.rb
Last active January 1, 2016 17:18
Formotion Picker with search bar
module Formotion
module RowType
class PickerWithSearchRow < PickerRow
include RowType::ItemsMapper
def after_build(cell)
super
@items_for_search = items
keyboardDoneButtonView = UIToolbar.new
keyboardDoneButtonView.barStyle = UIBarStyleBlack
@protrolium
protrolium / YouTube API — getting video thumbnail
Created February 5, 2014 19:57
YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
@hebertialmeida
hebertialmeida / gist:9234391
Last active February 15, 2019 05:16
Resize UIView to fit subviews
- (void)resizeToFitSubviews:(UIView *)view
{
float w, h;
for (UIView *v in view.subviews) {
float fw = v.frame.origin.x + v.frame.size.width;
float fh = v.frame.origin.y + v.frame.size.height;
w = MAX(fw, w);
h = MAX(fh, h);
}
@Bodacious
Bodacious / app_delegate.rb
Created April 1, 2014 20:00
Rubymotion developers often seem to shy away from using getter methods for instance variables. Instead, they're defined all over the place - as you'd see more in Objective-C.
# This is the approach I see most commonly in Rubymotion code examples.
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@mainViewController = MainViewController.alloc.init
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame)
@window.rootViewController = mainViewController
@window.makeKeyAndVisible
true
end
#import <AddressBook/AddressBook.h>
#import <Accounts/Accounts.h>
#import <Social/Social.h>
@interface ContactsDiscovery()
@property (nonatomic, retain) ACAccountStore* accounts;
@property (nonatomic, retain) ACAccountType* faceBookAccountType;
@property (nonatomic, retain) ACAccount* faceBookAccount;
@property (nonatomic, retain) id addressBook;
@end
@alanzeino
alanzeino / lldb-debugging.md
Last active April 30, 2025 19:32
LLDB debugging with examples

LLDB Debugging Cheat Sheet

Commands

LLDB Commands

LLDB comes with a great set of commands for powerful debugging.

help

Your starting point for anything. Type help to get a list of all commands, plus any user installed ones. Type 'help for more information on a command. Type help to get help for a specific option in a command too.

@m1entus
m1entus / CoreDataContextObserver.swift
Last active July 3, 2021 18:08
CoreDataContextObserver
//
// CoreDataContextWatcher.swift
// ContextWatcher
//
// Created by Michal Zaborowski on 10.05.2016.
// Copyright © 2016 Inspace Labs Sp z o. o. Spółka Komandytowa. All rights reserved.
//
import Foundation
import CoreData

Sublime Text 3 configuration

subl config

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Custom color schemes