Skip to content

Instantly share code, notes, and snippets.

View below's full-sized avatar
💭
I love feedback on my ARM64 Repo

Alexander von Below below

💭
I love feedback on my ARM64 Repo
View GitHub Profile
@below
below / Optional.swift
Created November 11, 2016 14:44
What the What?
import Foundation
let scheme : String! = "https" // "https"
let host = "example.com" // "example.com"
let urlString = "\(scheme)://\(host)" // "Optional("https")://example.com" // <-- WHAT?
let url = URL(string: urlString) // nil
@below
below / ProtocolPlayground.swift
Created November 8, 2016 13:48
Why does this work if I test for the class, and not for the protocol?
//: Playground - noun: a place where people can play
import Foundation
protocol MyProtocol {
var value: Int! { get set }
}
class MyClass : MyProtocol {
var value : Int!
@below
below / QueryPlayground.swift
Created July 26, 2016 21:18
Why is NSQueryItem not percent escaping "+" in a query?
import UIKit
let comps = NSURLComponents(string: "https://example.com")
comps?.queryItems = [NSURLQueryItem(name: "foobar", value: "foo+bar&something else")]
comps!.URL!
// Actual result:
// https://example.com?foobar=foo+bar%26something%20else
// As per https://tools.ietf.org/html/rfc3986#section-2.1 it
// appears that '+' should be escaped. What am I overlooking?
@below
below / NEHotspotEnum.playground
Created March 3, 2016 09:33
Why is the NEHotspotHelperConfidence not nil if out of bounds?
import UIKit
import NetworkExtension
//: First a classical enum. As documented, it will be nil if initialized with a rawValue outside of bounds
//: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html
enum Foobar : Int {
case foo
case bar
}
@below
below / gist:7419166
Created November 11, 2013 19:44
Also er baut, und dann kommt plötzlich (und ohne Ausführung der Tests):
** TEST SUCCEEDED **
[FOO] $ /bin/bash -xe /var/folders/kx/gv59n06j26n3n1fwxsxctb_m0000gq/T/hudson2864317743272309338.sh
Recording test results
No test report files were found. Configuration error?
Build step 'Publish JUnit test result report' changed build result to FAILURE
Finished: FAILURE`
@below
below / pseudo
Created October 21, 2013 11:19
Total Pseudocode
BOOL compilerSwitch = NO;
#ifdef __FOOCOMPILERDEFINE__
compilerSwitch = YES;
#endif
if (compilerSwitch || [self someOtherActivationLikeInAppPurchaseOrYouNameIt]) {
[MrScott energize];
}
@below
below / gist:3447720
Created August 24, 2012 08:51
Make less do more in OS X Terminal
# Configure less to register the represented file with the terminal.
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
export LESS='-P?n?f'"$(printf '\e]6;%%f\a')"'%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t'
fi
@below
below / gist:1501383
Created December 20, 2011 12:17
Simple Script to set a version number in the Info Plist
# This needs to go into a script build phase prior to "Copying resources"
# Set the version from version.txt
product_version=`cat version.txt`
# Instead of version.txt, you can use whatever your filthy heart desires
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion \"$product_version\"" "$TARGET_BUILD_DIR/$INFOPLIST_PATH"
exit 0
@below
below / gist:cfc8ac57458cce66b137
Created May 14, 2015 10:36
I should admit that I don't regularly work in ruby, so I am pretty stuck here. I am trying to download a https url using NET::HTTP:get, and I get this error. Downloading the URL in curl (even if called from the script) works just fine. What to do?
/Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `connect'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:852:in `start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:583:in `start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:478:in `get_response'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:455:in `get'
from export.rb:4:in `<main>'
@below
below / gist:2b9babcae6aee20c6bae
Created April 8, 2015 10:52
What … gives?
Dyld Error Message:
Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/XYZ
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1004E8000, size=0x0018C000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/Frameworks/libswiftCore.dylib
Dyld Version: 353.12