Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@benbahrenburg
benbahrenburg / cocoapods-bundle-id
Created May 8, 2018 14:47 — forked from daltonclaybrook/cocoapods-bundle-id
A post install script for CocoaPods that changes the bundle identifier of all pods to the one specified.
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
if config.name == 'BREnterprise'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution: The Carter Group LLC'
config.build_settings['PROVISIONING_PROFILE'] = '${BR_ENTERPRISE_PROVISIONING_PROFILE}'
end
end
end
@benbahrenburg
benbahrenburg / LICENSE
Created November 29, 2017 18:58 — forked from commonsguy/LICENSE
deaar: Convert Android AAR Artifacts Into Library Projects
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
@benbahrenburg
benbahrenburg / Sentimently-output.swift
Last active July 6, 2017 14:13
Sentiment analysis Swift
let sentiment = Sentimently()
print(sentiment.score("Cats are stupid."))
analysisResult(score: -2, comparative: -0.66666666666666663, positive: [], negative: ["stupid"], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "stupid", wordStem: Optional("stupid"))])
print(sentiment.score("Cats are very stupid."))
analysisResult(score: -3, comparative: -0.75, positive: [], negative: ["stupid"], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "very", wordStem: Optional("very")), wordToken(word: "stupid", wordStem: Optional("stupid"))])
print(sentiment.score("Cats are totally amazing!"))
analysisResult(score: 4, comparative: 1.0, positive: ["amazing"], negative: [], wordTokens: [wordToken(word: "cats", wordStem: Optional("cat")), wordToken(word: "are", wordStem: Optional("be")), wordToken(word: "totally", wordStem: Optional("totally")), wordToken(word: "
@benbahrenburg
benbahrenburg / lemmatize.swift
Last active July 6, 2017 14:15
Lemmatize strings
public struct wordToken {
let word: String
let wordStem: String?
init(word: String, wordStem: String?) {
self.word = word
self.wordStem = wordStem
}
}
func lemmatize(_ text: String) -> [wordToken] {
@benbahrenburg
benbahrenburg / fastlane-setBuildNumberOnExtension.rb
Created March 12, 2017 22:18
Fastlane method for updating extension CFBundleVersion
def setBuildNumberOnExtension(build_number)
raise if build_number.nil?
puts "Setting Extension to build number #{build_number}"
sh("/usr/libexec/PlistBuddy -c 'Set CFBundleVersion #{build_number}' ../myWatchApp/Info.plist")
sh("/usr/libexec/PlistBuddy -c 'Set CFBundleVersion #{build_number}' ../myWatchAppExtension/Info.plist")
end
@benbahrenburg
benbahrenburg / fastlane-build.rb
Created March 12, 2017 22:16
Fastlane build using setBuildNumberOnExtension
desc "Create ipa"
lane :build do
increment_build_number
setBuildNumberOnExtension(
get_build_number
)
gym(scheme: "TestApp", workspace: "TestApp.xcworkspace", output_directory: "../../../Builds/TestApp", clean:true, silent: true, export_method: "enterprise")
end
@benbahrenburg
benbahrenburg / UIImageToDataTests.swift
Last active January 26, 2024 19:49
Swift Playground for testing memory associated with converting UIImage to Data
import UIKit
import ImageIO
import MobileCoreServices
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func report_memory() -> UInt64 {
var taskInfo = mach_task_basic_info()
var count = mach_msg_type_number_t(MemoryLayout<mach_task_basic_info>.size)/4
@benbahrenburg
benbahrenburg / Test_JPEGRepresentation_AutoRelease.swift
Created March 5, 2017 23:57
UIImageJPEGRepresentation wrapped in Autorelease Pool Test
func Test_JPEGRepresentation_AutoRelease(iterations: Int, compressionRatio: CGFloat,image: UIImage) {
//Gather the initial information
let startReading = report_memory()
print("Memory at start: \(startReading / 1024 / 1024) mb")
//Loop through the number of test iterations specified
for index in 1...iterations {
if let data = UIImageToDataJPEG2(image: image, compressionRatio: compressionRatio) {
//Sample the length of the first result to make sure we are comparing the same size
if index == 1 {
@benbahrenburg
benbahrenburg / UIImageToDataIO.swift
Created March 5, 2017 23:55
Using ImageIO and Swift to convert a UIImage to Data
func UIImageToDataIO(image: UIImage, compressionRatio: CGFloat, orientation: Int = 1) -> Data? {
return autoreleasepool(invoking: { () -> Data in
let data = NSMutableData()
let options: NSDictionary = [
kCGImagePropertyOrientation: orientation,
kCGImagePropertyHasAlpha: true,
kCGImageDestinationLossyCompressionQuality: compressionRatio
]
let imageDestinationRef = CGImageDestinationCreateWithData(data as CFMutableData, kUTTypeJPEG, 1, nil)!