Skip to content

Instantly share code, notes, and snippets.

View czechboy0's full-sized avatar

Honza Dvorsky czechboy0

View GitHub Profile
@czechboy0
czechboy0 / gist:11358741
Last active August 29, 2015 14:00
Clang is confused in a block with no return value by @Try{}
int main(int argc, const char * argv[])
{
id (^iReturnStuff)() = ^id() {
@try{} @finally{}
//if you comment out line 4, Clang will not compile this.
//if you leave it like this, Clang will compile and run this, even though
//there's no value being returned.
//is there something special in @try{} that turns off compiler errors?
};
return 0;
@czechboy0
czechboy0 / SwiftTerminalScript.swift
Last active March 5, 2021 01:33
Run Terminal Scripts from your Mac app
//
// Script.swift
// Buildasaur
//
// Created by Honza Dvorsky on 12/05/15.
// Copyright (c) 2015 Honza Dvorsky. All rights reserved.
//
import Foundation
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Contains a unique string that identifies your daemon to launchd.
This key is required. -->
<key>Label</key>
<string>com.gocongress.backup</string>
@czechboy0
czechboy0 / fastlane_provision_lane.rb
Created October 20, 2015 18:35
Example: Fastlane provision lane for Xcode Server
lane :provision do
ENV['SIGH_APP_IDENTIFIER'] = 'com.honzadvorsky.XCSTutorialProject1'
ENV['SIGH_OUTPUT_PATH'] = './ProvisioningProfiles'
ENV['SIGH_USERNAME'] = "#{ENV['USER']}@icloud.com"
ENV['SIGH_SKIP_CERTIFICATE_VERIFICATION'] = 'true' # https://github.com/KrauseFx/sigh/issues/141
ENV['FL_PROJECT_PROVISIONING_PROJECT_PATH'] = 'XCSTutorialProject1.xcodeproj'
ENV['FL_PROJECT_PROVISIONING_PROFILE_TARGET_FILTER'] = '^XCSTutorialProject1$' # exact match in regex, we don't want e.g. XCSTutorialProject1Tests
@czechboy0
czechboy0 / After
Last active January 26, 2016 12:34
CryptoSwift 0.2.2 compilation times
229.9ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/AES.swift:215:18 private final func decryptBlock(block: [UInt8]) -> [UInt8]?
206.1ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/AES.swift:297:18 private final func expandKeyInv(key: [UInt8], variant: AESVariant) -> [[UInt32]]
124.6ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/SHA2.swift:116:10 final func calculate32() -> [UInt8]
115.3ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/SHA1.swift:19:10 final func calculate() -> [UInt8]
77.4ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/ChaCha20.swift:49:24 private final func wordToByte(input: [UInt32]) -> [UInt8]?
76.9ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/SHA2.swift:198:10 final func calculate64() -> [UInt8]
75.7ms /Users/honzadvorsky/Documents/CryptoSwift/Sources/CryptoSwift/Poly1305.swift:263:18 private final func blocks(context: Context, m: [UInt8], startPos: Int = default) -> Int
72.6ms /Users
#!/bin/bash
# Installs the latest stable Redis version in a local directory
if [ -d ~/.redis-stable ]; then
echo "redis is already installed, ignoring..."
else
echo "Installing the latest Redis stable from source"
curl -O http://download.redis.io/redis-stable.tar.gz > /dev/null 2>&1
@czechboy0
czechboy0 / contents.md
Last active March 4, 2016 22:46
We need to talk about JSON "parsers".

We need to talk about JSON "parsers"

For the sake of a vibrant Swift community, we need to call things what they are. And what they aren't.

I recently wrote a JSON parser to accomodate for the lack of NSJSONSerialization on Linux. When searching for an existing one, I was caught by all these libraries which called themselves JSON parsers, but were in fact just wrapping calls to an actual underlying parser (usually NSJSONSerialization). They only provided convenience functions for unwrap values from dictionaries and mapping data to objects.

Those libraries are JSON-to-object mapping libraries. Those are JSON convenience function libraries.

#!/bin/bash
#
# Faster toolchain build: skips as much as possible.
#
# To use this toolchain from the command line:"
# export TOOLCHAINS=$(whoami)
#
# we build to the same prefix every time (instead of building
# to a versioned prefix) because every time the prefix changes
# *everything* rebuilds.
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
import Foundation
extension Collection where Iterator.Element == (key: String, value: FileWrapper) {
func hello() -> String {
return "world"
}
}
let dict: [String: FileWrapper] = [:]
print(dict.hello())