Skip to content

Instantly share code, notes, and snippets.

View eugeniobaglieri's full-sized avatar

Eugenio Baglieri eugeniobaglieri

View GitHub Profile
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 29, 2024 14:26
Swift Concurrency Manifesto
@duemunk
duemunk / AsynchronousThrow.swift
Last active February 15, 2017 02:28
An example of how you can use the error handling in Swift 2.0 for an asynchronous API.
typealias EmptyResult = () throws -> ()
typealias AsyncResult = (EmptyResult) -> ()
typealias JsonResult = () throws -> JSON
typealias AsyncJsonResult = (JsonResult) -> ()
class GetResponse {
func main() {
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
@Air-Craft
Air-Craft / iphone_vibrate.m
Created April 26, 2015 13:55
Short custom vibration on iPhone #ios #vibration #private-api
// Headers
#import <AudioToolbox/AudioToolbox.h>
void AudioServicesStopSystemSound(SystemSoundID inSystemSoundID);
void AudioServicesPlaySystemSoundWithVibration(SystemSoundID inSystemSoundID,id arg,NSDictionary* vibratePattern);
// Buzz code
NSArray *vibe = @[ @YES, @10 ]; // ON for 10ms
NSDictionary *dict = @{ @"Intensity": @0.1, @"VibePattern": vibe };
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate,nil,dict);
// Camera permission handling - iOS 8
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted){
if (granted)
{
dispatch_sync(dispatch_get_main_queue(), ^{
// Present camera controller here
});
}
else
{
@ksmandersen
ksmandersen / gist:4d3530eeacd9c41786e5
Created August 4, 2014 09:24
Workaround for: Generic Array DataSource
public class ArrayDataSource<CellType: UIView, ItemType> {
private var items: [ItemType]
private var cellReuseIdentifier: String
private var configureClosure: (CellType, ItemType) -> Void
private var proxy: DataSourceProxy!
private unowned var view: UIView
public init(view: UIView, items: [ItemType], cellReuseIdentifier: String, configureClosure: (CellType, ItemType) -> Void) {
self.items = items
self.cellReuseIdentifier = cellReuseIdentifier
@jacobbubu
jacobbubu / ioslocaleidentifiers.csv
Created February 15, 2012 14:41
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@steipete
steipete / gist:1205760
Created September 9, 2011 08:27
dispatch_reentrant
// checks if already in current queue, prevents deadlock
void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
if (dispatch_get_current_queue() == queue) {
block();
}else {
dispatch_sync(queue, block);
}
}