Skip to content

Instantly share code, notes, and snippets.

View vukcevich's full-sized avatar

Marijan Vukcevich vukcevich

  • Huntington Beach, California
View GitHub Profile
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@vukcevich
vukcevich / migrator.rb
Created February 28, 2017 00:02 — forked from davidahouse/migrator.rb
Run the Swift 3 migrator for a project manually from the command line rather than letting Xcode do it
require 'find'
require 'pp'
swift_file_paths = []
Find.find('./') do |path|
if path =~ /.*\.swift$/ and !path.start_with? "./Carthage"
swift_file_paths << path
cmd = "xcrun swift-update -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -target arm64-apple-ios9 #{path} > convert.swift"
system cmd
@vukcevich
vukcevich / uiimage_check.sh
Created February 1, 2017 16:30 — forked from vdugnist/uiimage_check.sh
Check if UIImage exists in assets
#!/bin/bash
function show_code {
ERROR_LOCATION=$(grep -Ron "\[UIImage imageNamed:\s*@\"$1\"\s*\]" $PROJECT_NAME)
if [[ -z $ERROR_LOCATION ]]; then
ERROR_LOCATION=$(grep -Ron "UIImage(named\:\s*\"$1\"\s*)" $PROJECT_NAME)
fi
ERROR_LOCATION=$(echo $ERROR_LOCATION | cut -d ':' -f 1,2)
echo "$ERROR_LOCATION: error: Missing imageset with name $1"
}
@vukcevich
vukcevich / EnvoyMatrixCountElementsAroundBlock
Created January 19, 2017 22:42 — forked from dautermann/EnvoyMatrixCountElementsAroundBlock
Write a Swift playground that takes an n x n grid of integers. Each integer can be either 1 or 0. The playground then outputs an n x n grid where each block indicates the number of 1's around that block.
// Copyright © 2016 Envoy. All rights reserved.
/*
Write a Swift playground that takes an n x n grid of integers. Each integer can be either 1 or 0.
The playground then outputs an n x n grid where each block indicates the number of 1's around that block, (excluding the block itself) . For Block 0 on row 0, surrounding blocks are (0,1) (1,0) and (1,1). Similary for block (1,1) all the blocks around it are to be counted as surrounding blocks.
Requirements:
// Returns `URL?`
public enum SocketEndPoint: String {
case eventSocket = "http://nowhere.com/events"
case liveSocket = "http://nowhere.com/live"
public var url: URL? {
return URL(string: self.rawValue)
}
}
@vukcevich
vukcevich / IntExtensions.swift
Created December 22, 2016 05:13 — forked from tanner0101/IntExtensions.swift
Convert an arbitrary length byte array into a Swift Int
/**
IntExtensions.swift
Convert an arbitrary length byte array into a Swift Int
<https://gist.github.com/tannernelson/e720877bf7700138eb99>
*/
extension Int {
static func fromByteArray(bytes: [UInt8]) -> Int {
@vukcevich
vukcevich / convert_double_to_nsdata.swift
Created December 21, 2016 22:48 — forked from key/convert_double_to_nsdata.swift
Convert `Double` value to `NSData` in Swift
var x: Double = 0.99043125417
var length = sizeof(Double) // -> 8
var x_data = NSData(bytes: &x, length: length)
var buffer = [UInt8](count: sizeof(Double), repeatedValue: 0x00)
x_data.getBytes(&buffer, length: buffer.count)
print(buffer) // -> "[210, 21, 179, 226, 156, 177, 239, 63]\n"
@vukcevich
vukcevich / endian-conversion-cheat-sheet.swift
Created December 21, 2016 21:33 — forked from DevAndArtist/endian-conversion-cheat-sheet.swift
A cheat sheet for byte conversion of number types in Swift 3.0
func _convertToBytes<T>(_ value: T, withCapacity capacity: Int) -> [UInt8] {
var mutableValue = value
return withUnsafePointer(to: &mutableValue) {
return $0.withMemoryRebound(to: UInt8.self, capacity: capacity) {
return Array(UnsafeBufferPointer(start: $0, count: capacity))
}
}
@vukcevich
vukcevich / HTSDReachability.swift
Created December 7, 2015 16:39 — forked from UjwalManjunath/HTSDReachability.swift
IOS Reachability: Swift 2.0
import UIKit
import SystemConfiguration
public let ReachabilityChangedNotification = "ReachabilityChangedNotification"
class HTSDReachabiltiy: NSObject {
typealias NetworkReachable = (HTSDReachabiltiy) -> ()
typealias NetworkUnreachable = (HTSDReachabiltiy) -> ()
enum NetworkStatus: CustomStringConvertible {
import Cocoa
// Note: use of enumeration var in generic is instadeath
// Note: use of static var in generic is not yet supported
public protocol EnumConvertible: Hashable {
init?(hashValue hash: Int)
static func countMembers() -> Int
static func members() -> [Self]
}