Skip to content

Instantly share code, notes, and snippets.

View vukcevich's full-sized avatar

Marijan Vukcevich vukcevich

  • Huntington Beach, California
View GitHub Profile
@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 {
// 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 / 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:
@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 / 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
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 / DependencyInjectionExample.swift
Created March 26, 2019 17:10 — forked from eofster/DependencyInjectionExample.swift
Dependency injection example with tests
import Foundation
import XCTest
//////////////////////////////////////////////////////////////////////
// Preferences
protocol UserDefaults {
func stringForKey(key: String) -> String
}
import CoreData
import UIKit
struct Photo {}
class PhotoDetailViewController: UIViewController {
var photo: Photo!
var context: NSManagedObjectContext!
}
@vukcevich
vukcevich / DataProviding.swift
Created July 30, 2019 18:16 — forked from Frankacy/DataProviding.swift
Swift data provider/presenter
//
// DataProviding.swift
// GenericsDataSource
//
// Created by Frank Courville on 2019-05-09.
// Copyright © 2019 iOS Coach Frank. All rights reserved.
//
import UIKit
# Building FAT librares for XCode 10
set -e
# If we're already inside this script then die
if [ -n "$MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then
exit 0
fi
export MULTIPLATFORM_BUILD_IN_PROGRESS=1