Skip to content

Instantly share code, notes, and snippets.

View Reflejo's full-sized avatar

Martín Conte Mac Donell Reflejo

View GitHub Profile
#!/usr/bin/env osascript
on run argv
if count of argv < 1 then
logEvent("Usage: ./changeVersion iOSVersion(7.1,7.0)")
error number -128
end
set iOSVersion to item 1 of argv
@Reflejo
Reflejo / Options.swift
Last active August 29, 2015 14:13
Simplified version
#!/usr/bin/env xcrun swift -O
struct MyOptions: RawOptionSetType, BooleanType {
var boolValue: Bool { return self.rawValue != 0 }
var rawValue: UInt
init(rawValue value: UInt) {
self.rawValue = value
}
init(nilLiteral: Void) {
struct Foo {
var bar: String = ""
}
class Something {
var foo: Foo = Foo() {
didSet {
println("didSet called")
}
}
@Reflejo
Reflejo / gist:f5addfa6408d521a971f
Created January 26, 2015 19:07
Bezier path creation
func bezierPath(p1: CLLocationCoordinate2D, toPoint p2: CLLocationCoordinate2D, steps: Int = 100)
-> [CLLocationCoordinate2D]
{
let auxiliaryPoint = self.fetchThirdPointByLocations(p1, p2: p2, angle: 90.0)
var targetPoints = [CLLocationCoordinate2D]()
let doubleSteps = Double(steps)
for index in 0 ... steps {
let t = Double(index) / doubleSteps
@Reflejo
Reflejo / gist:63c1c9e7ad4b0916ca7a
Last active August 29, 2015 14:14
NSUserDefaults abstraction
//
// Storage.swift
//
// Created by Martin Conte Mac Donell ([email protected])
//
import Foundation
/**
This struct is the base for Storage Keys. This way we enforce all keys to be in a container to avoid typos
@Reflejo
Reflejo / gist:1f3c553363c712a8e480
Created February 9, 2015 03:35
UIImagePickerController view hierarchy
PLCameraView
PLPreviewView
PLCameraFocusView
UIImageView
PLCropOverlay
OverlayView
PLCropOverlayBottomBar
UIImageView
PLCropOverlayBottomBarButton
UIImageView
$ xcodebuild -workspace 'Test.xcworkspace' -scheme 'Test' -configuration 'Debug' -sdk iphonesimulator -destination 'name=iPhone 6' build
Build settings from command line:
SDKROOT = iphonesimulator8.3
2015-02-10 09:54:05.827 xcodebuild[42416:3126221] DVTAssertions: Warning in /SourceCache/DVTiOSFrameworks/DVTiOSFrameworks-7514.1/DTDeviceKitBase/DTDKRemoteDeviceDataListener.m:79
Details: Running against an old version of MobileDevice; some interaction with proxied devices may be unavailable.
Object: <DTDKRemoteDeviceDataListener: 0x7fcf5cf10c90>
Method: -listenerThreadImplementation
Thread: <NSThread: 0x7fcf5cf09990>{number = 2, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
func test<T>(#something: T) -> T {
return ("abc" as? T) ?? something
}
let str: String? = "abc"
println(test(something: "") == str) // false
println(test(something: "")) // "abc"
@Reflejo
Reflejo / bug.swift
Last active October 11, 2015 01:36
protocol SomeProtocol {
var a: Int { get }
}
struct SomeStruct: SomeProtocol {
var a = 0
}
class SomeClass {
var value: SomeProtocol = SomeStruct() {
import Foundation
let pixels: [[UInt8]] = [
[
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,