Skip to content

Instantly share code, notes, and snippets.

View glaurent's full-sized avatar

Guillaume Laurent glaurent

View GitHub Profile
@fabiogiolito
fabiogiolito / FacebookReactions.swift
Last active August 11, 2022 15:25
Recreating Facebook Reactions with SwiftUI. Demo Video: https://twitter.com/fabiogiolito/status/1142226669471748096
//
// FacebookReactions.swift
//
// Created by Fabio Giolito on 10/06/2019.
// Follow me: https://twitter.com/fabiogiolito
//
import SwiftUI
struct FacebookReactions : View {
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@eleev
eleev / UIImage+SolidColor.swift
Created March 24, 2017 11:18
Extension for creating UIImage from a UIColor. Swift 3
extension UIImage {
convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
let rect = CGRect(origin: .zero, size: size)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
color.setFill()
UIRectFill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
guard let cgImage = image?.cgImage else { return nil }
@JanJastrow
JanJastrow / backup_tumblr.sh
Created April 8, 2016 14:07 — forked from doersino/backup_tumblr.sh
Simple way of backing up one or multiple Tumblr blogs to date-prefixed folders; downloads and removes required software (except Python) automatically. http://neondust.tumblr.com/post/97723922505/simple-tumblr-backup-script-for-mac-os-x-and-linux
#!/bin/bash
# http://neondust.tumblr.com/post/97723922505/simple-tumblr-backup-script-for-mac-os-x-and-linux
# https://gist.github.com/doersino/7e3e5db591e42bf543e1
# BLOGS is a space-separated list of the blogs you want to backup. You can omit
# the ".tumblr.com" part if you want.
BLOGS="neondust.tumblr.com aufgeloest.tumblr.com hejlisten.tumblr.com"
# OUT is the directory where the backups will be stored. For each blog, a date-
# prefixed subdirectory will be created here.
@tahmidsadik
tahmidsadik / purgeAndroid.txt
Created September 19, 2015 18:47
How to completely remove Android Studio from Mac OS X
How to Completely Remove Android Studio
Execute these commands from the terminal
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
@robotconscience
robotconscience / SelectAudioOutput.mm
Created April 8, 2015 15:07
Set CoreAudio ouput device for your app
// change this to a recognizeable piece of your audio output
// e.g. setAudioOutput("AirPlay"); or setAudioOutput("VoilaDevice");
// returns true on success / false on beef
// as always, all thanks to StackOverflow for the amazing
// enumerate devices script:
// http://stackoverflow.com/questions/1983984/how-to-get-audio-device-uid-to-pass-into-nssounds-setplaybackdeviceidentifier
// Note: if you change "kAudioDevicePropertyScopeOutput" to "kAudioObjectPropertyScopeGlobal" in line 62,
// you can set the output for your whole system...
@staltz
staltz / introrx.md
Last active April 29, 2024 09:25
The introduction to Reactive Programming you've been missing
@HeshamMegid
HeshamMegid / AddressBookManager.h
Last active February 1, 2023 11:28
Lookup a contact name/photo using phone number in ABAddressBook
#import <Foundation/Foundation.h>
#import "Contact.h"
@interface AddressBookManager : NSObject
+ (NSString *)nameForContactWithPhoneNumber:(NSString *)phoneNumber;
+ (UIImage *)photoForContactWithPhoneNumber:(NSString *)phoneNumber;
@end