Skip to content

Instantly share code, notes, and snippets.

@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 23, 2024 03:59
Swift Concurrency Manifesto
@farktronix
farktronix / gist:da8f3c0ce01a5311364d
Last active August 29, 2015 14:20
Dispatch to a serial queue without deadlocking
static const char *kMyQueueSentinel = "🐔";
- (instancetype)init {
...
_serialQueue = dispatch_queue_crete("com.my.serialqueue", DISPATCH_QUEUE_SERIAL);
dispatch_queue_set_specific(self.serialQueue, kMyQueueSentinel, (void *)1, NULL);
...
}
static inline void _performOnSerialQueue(dispatch_block_t myBlock) {
@farktronix
farktronix / gist:c1032caaeafeb50d823b
Created May 7, 2015 21:04
dispatch_source_type_data_or rocks
_setupQueue = dispatch_queue_create("com.fark.setup", DISPATCH_QUEUE_SERIAL);
_setupSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA_OR, 0, 0, _setupQueue);
dispatch_source_set_event_handler(_setupSource, ^{
[weakSelf _reload];
});
dispatch_resume(_setupSource);
...
- (void)_signalAccountReload {
@farktronix
farktronix / gist:92c3b1a1901eec6c6f2e
Created June 4, 2014 18:04
dispatch_group based state machine
//
// StateMachineExample
//
// Created by Jacob Farkas on 6/4/14.
//
#import <Foundation/Foundation.h>
#define DownloadTempPath "/tmp/tacosXXXXXX"
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@farktronix
farktronix / gist:5241882
Created March 25, 2013 23:34
Replace an iTunes Library with one song. Use at your own risk!
#!/usr/bin/ruby
require 'fileutils'
include FileUtils::Verbose
$rickRollFile="/Volumes/Media/.RickRoll.mp3"
def rickRollDir(sourceDir, destDir)
for filename in Dir.entries(sourceDir)
next if filename=~/\.\.?$/