This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# if 1st param empty... | |
if [ -z "$1" ] | |
then | |
echo "Usage: select-xcode {8|9}" | |
exit | |
fi | |
XCODE8_APP=/Applications/Xcode-8.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyLabel: UILabel { | |
var textWillChange:((_ oldText: String?)->())? = nil | |
var textDidChange:((_ newText: String?)->())? = nil | |
override var text: String? { | |
willSet { | |
if textWillChange != nil { | |
textWillChange!(self.text) | |
} | |
} | |
didSet { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import XCTest | |
/// Basic sanity check that ensures that we are able to retrieve localized strings for all languages | |
/// we support. | |
final class L10NTests: XCTestCase { | |
func testLocalizations() { | |
let locales = ["en", "es", "zh-Hans", "zh-Hant", "fi"] | |
for locale in locales { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let granularity = Calendar.Component.day | |
let comparisonResult = Calendar.current.compare(firstDate, to: secondDate, toGranularity: granularity) | |
// granularity: | |
// .second | |
// .minute | |
// .hour | |
// .day | |
// .month | |
// .year |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
mssql-server-linux: | |
image: microsoft/mssql-server-linux:latest | |
volumes: | |
- mssql-server-linux-data:/var/opt/mssql/data | |
environment: | |
- ACCEPT_EULA=Y | |
- SA_PASSWORD=${SQLSERVER_SA_PASSWORD:-yourStrong(!)Password} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: | |
# IFS=$'\n' find ROOT_SOURCE_FOLDER -name "*.swift" -exec python PATH/TO/migrate.py {} \; | |
import sys | |
import re | |
func = re.compile('func\s+\w+\(') | |
param = re.compile('(?P<indent>\s*)/// -[ ]*[pP]arameter[ ]+(?P<name>\w+)[ ]*:(?P<description>[^\n]+)\n') | |
ret = re.compile('(?P<indent>\s*)/// -[ ]*[rR]eturns[ ]*:(?P<description>[^\n]+)\n') | |
continuation = re.compile('\s*///(?P<description>[^\n]+)') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Adding a header to a single request | |
func doRequestWithHeaders1() { | |
let headers: HTTPHeaders = [ | |
"X-Mashape-Key": MY_API_KEY, | |
"Accept": "application/json" | |
] | |
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers) | |
.responseJSON { response in | |
debugPrint(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func copyDatabaseIfNeeded() { | |
// Move database file from bundle to documents folder | |
let fileManager = FileManager.default | |
let documentsUrl = fileManager.urls(for: .documentDirectory, | |
in: .userDomainMask) | |
guard documentsUrl.count != 0 else { | |
return // Could not find documents URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import config. | |
# You can change the default config with `make cnf="config_special.env" build` | |
cnf ?= config.env | |
include $(cnf) | |
export $(shell sed 's/=.*//' $(cnf)) | |
# import deploy config | |
# You can change the default deploy config with `make cnf="deploy_special.env" release` | |
dpl ?= deploy.env | |
include $(dpl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This compose file mounts an SSH agent socket from the named volume "ssh" into a Ruby container. | |
# The SSH_AUTH_SOCK variable is set so everything just works. | |
app: | |
image: ruby | |
volumes: | |
- ssh:/ssh | |
environment: | |
SSH_AUTH_SOCK: /ssh/auth/sock |