Skip to content

Instantly share code, notes, and snippets.

Avatar
🥝
Working...

Maksym Bilan maximbilan

🥝
Working...
View GitHub Profile
View NSSecureCodingValueTransformer.swift
import Foundation
public protocol ValueTransforming: NSSecureCoding {
static var valueTransformerName: NSValueTransformerName { get }
}
public class NSSecureCodingValueTransformer<T: NSObject & ValueTransforming>: ValueTransformer {
public override class func transformedValueClass() -> AnyClass { T.self }
public override class func allowsReverseTransformation() -> Bool { true }
@sieroshtan
sieroshtan / ibm_speech_to_text.py
Created Jul 28, 2015
Simple example using Speech To Text API of IBM's Bluemix platform in python
View ibm_speech_to_text.py
# https://console.ng.bluemix.net/catalog/speech-to-text/
# pip requests module required
import requests
url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/recognize'
username = '<username>'
password = '<password>'
headers={'Content-Type': 'audio/wav'}
@kristopherjohnson
kristopherjohnson / methodNames.swift
Last active Jan 15, 2021
Get method names for an Objective-C class in Swift
View methodNames.swift
import Foundation
/// Given pointer to first element of a C array, invoke a function for each element
func enumerateCArray<T>(array: UnsafePointer<T>, count: UInt32, f: (UInt32, T) -> ()) {
var ptr = array
for i in 0..<count {
f(i, ptr.memory)
ptr = ptr.successor()
}
}
@cromandini
cromandini / universal-framework.sh
Last active Feb 23, 2021 — forked from cconway25/gist:7ff167c6f98da33c5352
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
View universal-framework.sh
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@armstrongnate
armstrongnate / basic-auth.swift
Created Jul 20, 2014
HTTP Basic Authentication using NSURLSession in swift
View basic-auth.swift
import Foundation
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = "username@gmail.com:password"
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
@fwal
fwal / gist:3864958
Created Oct 10, 2012 — forked from adamgit/gist:3705459
Automatically create cross-platform (simulator + device) static libraries for Objective C / iPhone / iPad
View gist:3864958
#
# c.f. StackOverflow question/answer here: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.5
#
# Latest Change:
# - The "copy headers" section now respects the build setting for the location of the public headers
# - Opens the directory with the universal library after build (Can be annoying)
#
# Purpose:
@adamgit
adamgit / gist:3705459
Last active Sep 28, 2020
Automatically create cross-platform (simulator + device) static libraries for Objective C / iPhone / iPad
View gist:3705459
##########################################
#
# c.f. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.82
#
# Latest Change:
# - MORE tweaks to get the iOS 10+ and 9- working
# - Support iOS 10+
# - Corrected typo for iOS 1-10+ (thanks @stuikomma)