This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
// | |
// Example of Using AVAudioPlayer | |
// to play a buffer of (synthesized) audio samples from memory | |
// by converting a [Float] buffer into an in-memory WAV file | |
// | |
// Copyright © 2019 Ronald H Nicholson Jr. All rights reserved. | |
// (re)Distribution permitted under the 3-clause New BSD license. | |
// | |
import Foundation |
// Taken from http://PSPDFKit.com. This snippet is under public domain. | |
#define UIKitVersionNumber_iOS_7_0 0xB57 | |
BOOL PSPDFIsUIKitFlatMode(void) { | |
static BOOL isUIKitFlatMode = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
} |
// | |
// ToneOutputUnit.swift | |
// | |
// This is a Swift 3 class (which should be instantiated as a singleton object) | |
// that can play a single tone of arbitrary tone and frequency on iOS devices | |
// using run-time sinewave synthesis and the Audio Unit v3 API with RemoteIO. | |
// | |
// Created by Ronald Nicholson rhn@nicholson.com on 2/20/2016. | |
// revised 2016-Sep-08 for Swift 3 | |
// http://www.nicholson.com/rhn/ |
// Restify Server CheatSheet. | |
// More about the API: http://mcavage.me/node-restify/#server-api | |
// Install restify with npm install restify | |
// 1.1. Creating a Server. | |
// http://mcavage.me/node-restify/#Creating-a-Server | |
var restify = require('restify'); |
I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!
Install FFmpeg
Install ImageMagick
// Created by Vasily Ulianov on 09.02.17, updated in 2019. | |
// License: MIT | |
import Foundation | |
/// Subclass of `Operation` that adds support of asynchronous operations. | |
/// 1. Call `super.main()` when override `main` method. | |
/// 2. When operation is finished or cancelled set `state = .finished` or `finish()` | |
open class AsynchronousOperation: Operation { | |
public override var isAsynchronous: Bool { |
Note: the original location of this article is on my blog, however, it is posted here too for better readability.
In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.
1. Open Terminal | |
2. cd to your Xcode project | |
3. Execute the following when inside your target project: | |
find . -name "*.swift" -print0 | xargs -0 wc -l |
CFRunLoopSource
is cool. It lets you build behavior similar to the mechanisms that drive setNeedsLayout
and setNeedsDisplay
in UIKit.
I found myself in need of something like this a couple of times. It's great to know that no matter how many times I say I need to update something, I will get a single callback at the end of the run loop that gives me a chance to perform my work.
Here is a little Swift wrapper that makes the API easier to deal with.