Skip to content

Instantly share code, notes, and snippets.

View spnkr's full-sized avatar

Will Jessop spnkr

  • New York, NY
View GitHub Profile
@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
@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
@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
@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;
@fphilipe
fphilipe / gist:4058176
Created November 12, 2012 08:35
Obfuscated ids
module Base62
BASE_CHARS = '0SKVnQFHhGs9qo7p8cRW54duMYNXTCErx2tDmwO3kabfUB1elLvjiIgyJAZ6Pz'.split('')
BASE = BASE_CHARS.length
BASE_ENCODED_MIN_LENGTH = 1
def self.decode(number)
# assure string
number = number.to_s.reverse.split('')
decoded = 0
@Bodacious
Bodacious / app_delegate.rb
Created October 22, 2012 17:11
Simple Rubymotion app with UIAlertView
class MyController < UIViewController
def viewDidLoad
self.view.backgroundColor = UIColor.whiteColor
alert.show
end
# ==============
# = Properties =
# ==============
@Bodacious
Bodacious / Rakefile
Created August 23, 2012 11:19
my Rakefile for lastest Rubymotion app
$:.unshift("/Library/RubyMotion/lib")
require File.join(File.dirname(__FILE__), 'version')
require 'motion/project'
require 'bundler'
Bundler.require
@seanlilmateus
seanlilmateus / gist:3187192
Last active March 5, 2021 07:17
How to use Obj-C with MacRuby/Rubymotion

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = ExampleViewController.alloc.init
@window.makeKeyAndVisible
true
end
end
@Bodacious
Bodacious / README.md
Created June 28, 2012 13:16
A handy helper for showing loading cells in iOS Apps with Rubymotion