Skip to content

Instantly share code, notes, and snippets.

Honza Dvorsky czechboy0

Block or report user

Report or block czechboy0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View kdybyste.md

Keybase proof

I hereby claim:

  • I am czechboy0 on github.
  • I am honzadvorsky (https://keybase.io/honzadvorsky) on keybase.
  • I have a public key ASDrO2xgsCJ5xuHgLnr4TfUqgexRE33AOzRyvLE080gOWwo

To claim this, I am signing this object:

View swiftenv-install.sh
#!/usr/bin/env bash
# Automatically installs swiftenv and run's swiftenv install.
# This script was designed for usage in CI systems.
git clone --depth 1 https://github.com/kylef/swiftenv.git ~/.swiftenv
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH"
if [ -f ".swift-version" ] || [ -n "$SWIFT_VERSION" ]; then
swiftenv install -s
@czechboy0
czechboy0 / reviews.sh
Last active Sep 16, 2016
Fetch iTunes App reviews
View reviews.sh
# you find the app id of an app by calling the following API and parse the JSON
QUERY="swiftkey"
curl -X "GET" "https://itunes.apple.com/search?term=$QUERY&country=us&entity=software"
# this is how you fetch the page 3 of the app with ID 911813648 (SwiftKey)
# you'd probably want to write a script and start fetching from page 1 up until you get 404 back
PAGE=3
APPID=911813648
curl -X "GET" "https://itunes.apple.com/us/rss/customerreviews/page=$PAGE/id=$APPID/sortby=mostrecent/json?urlDesc=%2Fcustomerreviews%2Fid%3D$APPID%2FsortBy%3DmostRecent%2Fjson"
@czechboy0
czechboy0 / add_swap.sh
Last active Sep 6, 2016
Add 4 GB swapspace on Ubuntu 14.04
View add_swap.sh
# based on https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# run with eval "$(curl -sL https://gist.githubusercontent.com/czechboy0/ba249dc375dd6335f30f7acd593aa193/raw/add_swap.sh)"
echo "Starting with swap table:"
sudo swapon -s
echo "Available space:"
df -h
echo "Creating a 4GB swap file"
View extension-dictionary.swift
import Foundation
extension Collection where Iterator.Element == (key: String, value: FileWrapper) {
func hello() -> String {
return "world"
}
}
let dict: [String: FileWrapper] = [:]
print(dict.hello())
View gist:517b22041c0eeb33f723bb66933882e4
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
View swift-self-build
#!/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.
@czechboy0
czechboy0 / contents.md
Last active Mar 4, 2016
We need to talk about JSON "parsers".
View contents.md

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.

View redis-local-install.sh
#!/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 / After
Last active Jan 26, 2016
CryptoSwift 0.2.2 compilation times
View After
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
You can’t perform that action at this time.