Skip to content

Instantly share code, notes, and snippets.

View rfdickerson's full-sized avatar
:octocat:
Reticulating splines

Robert F. Dickerson rfdickerson

:octocat:
Reticulating splines
View GitHub Profile
@rfdickerson
rfdickerson / SpeechToTextTests.swift
Created December 16, 2015 22:29
Example of using AVAudioRecorder
func testRecording() {
let recordExpectation = expectationWithDescription("Record")
let recordSettings = [
// AVFormatIDKey: NSNumber(unsignedInt:kAudioFormatLinearPCM),
AVNumberOfChannelsKey: 1,
AVSampleRateKey : 16000.0
]
@rfdickerson
rfdickerson / swift-c-tutorial.md
Last active February 11, 2016 16:39
Swift and C integration

Swift C-bindings Tutorial

##Creating a static library:

Suppose you have a project with the following structure:

.
+-- CAwesome
| +-- awesome.h
@rfdickerson
rfdickerson / install-swift-test-linux.md
Last active March 2, 2016 15:39
Installation instructions for a SNAPHOT with XCTest support
  1. Install the latest snapshot:

wget https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a/swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a-ubuntu15.10.tar.gz

  1. Set an environment variable pointing to your snapshot

export SWIFT_PATH=/home/rfdickerson/linux-swift-testing/swift-DEVELOPMENT-SNAPSHOT-2016-02-25-a-ubuntu15.10

  1. Download Swift Package Manager repository:
Run with -swift build --configuration release -Xcc -fblocks -Xcc -I$BUILD_DIR/.apt/usr/include -Xlinker -L$BUILD_DIR/.apt/usr/lib -Xlinker -rpath,$BUILD_DIR/.apt/usr/lib | indent
-----> Building Package
Cloning https://github.com/IBM-Swift/Kitura.git
Resolved version: 0.6.0
Cloning https://github.com/IBM-Swift/Kitura-net.git
Resolved version: 0.6.0
Cloning https://github.com/IBM-Swift/Kitura-sys.git
Resolved version: 0.6.0
Cloning https://github.com/IBM-Swift/LoggerAPI.git
indirect enum STree {
case Leaf
case Node (STree, AnyObject, STree)
}
let s = STree.Node(.Node(.Leaf, 3, .Leaf), 5, .Leaf)
func search(tree: STree, toFind: AnyObject) {
switch tree {
case .Leaf: return
typealias Byte = UInt8
let size: Int = 100000
var simpleData = [Byte](repeating: 3, count: size)
var dataCompressed = [Byte](repeating: 6, count: size)
simpleData[3] = 2
simpleData[4] = 1
@rfdickerson
rfdickerson / pthreads.swift
Last active December 15, 2017 03:17
Example of Forking a thread in Swift
import Foundation
func sayHello2() {
//sleep(5)
print("Hello!")
}
#if false
public func pthread_create(
make[2]: Entering directory '/home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src'
/home/rfdickerson/swift-toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a-ubuntu15.10/usr/bin/swiftc -frontend -c /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Block.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Data.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Dispatch.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/IO.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Private.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Queue.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Source.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Time.swift /home/rfdickerson/swift-toolchains/swift-corelibs-libdispatch/src/swift/Wrapper.swift -primary-file /home/rfdickerson/swift-toolchains/swift
@rfdickerson
rfdickerson / todolist-api.swift
Last active August 5, 2016 19:29
TodoList with Swift 3
import Foundation
infix operator |> { associativity left precedence 140 }
func |> <S,T> (value: S, f: (S) -> T) -> T{
return f(value)
}
enum SuccessOrFail<T> {
case success(T)
case failure(Error)
@rfdickerson
rfdickerson / TodoModel.swift
Created August 6, 2016 18:19
TodoList models
//: Playground - noun: a place where people can play
import UIKit
struct JSON { }
struct ZewoMySQL {
func execute(sqlStatement: String) {}
}