Skip to content

Instantly share code, notes, and snippets.

View aciidgh's full-sized avatar

Ankit Aggarwal aciidgh

View GitHub Profile
@aciidgh
aciidgh / MenuCustomAnimationDelegate.h
Created November 18, 2015 09:15
Dropdown menu animation
//
// MenuCustomAnimationDelegate.h
//
//
// Created by Ankit Aggarwal on 25/05/15.
// Copyright (c) 2015 Ankit Aggarwal. All rights reserved.
//
#import <UIKit/UIKit.h>
@aciidgh
aciidgh / XCPlaygroundPage.playground
Created December 4, 2015 20:56
Use of unresolved identifier 'XCPlaygroundPage'
//: Playground - noun: a place where people can play
import UIKit
import XCPlayground
class VC: UIViewController {
let newView = UIView()
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
@aciidgh
aciidgh / swift-build-output
Created December 6, 2015 16:24
Swift build -v output
/Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain/usr/bin/swiftc -module-name SimpleGetClient -incremental -emit-dependencies -emit-module -emit-module-path /Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/.build/debug/SimpleGetClient.swiftmodule -output-file-map /Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/.build/debug/SimpleGetClient.o/SimpleGetClient/output-file-map.json -parse-as-library -c /Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/Packages/SimpleGetClient-1.0.0/Sources/GetClient.swift -I /Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/.build/debug -j8 -Onone -g -target x86_64-apple-macosx10.10 -enable-testing -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I /usr/local/include
/bin/sh -c "rm -f '/Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/.build/debug/SimpleGetClient.a'; ar cr '/Users/aciid/mycode/swift/GetClient/SwiftGetClientDemo/.build/debug/SimpleGetClient.a' '/Users/a
@aciidgh
aciidgh / CSwift.swift
Created December 14, 2015 19:37
Swift ++ operator
prefix func ++(inout x: Int) -> Int {
x = x + 1
return x
}
postfix func ++(inout x: Int) -> Int {
let oldX = x
x = x + 1
return oldX
}
let ib = hoedown_buffer_new(1024);
hoedown_buffer_puts(ib, "#file\n##dsdsd\n`hello`");
let renderer = hoedown_html_renderer_new(hoedown_html_flags(0), 0);
let ob = hoedown_buffer_new(1024);
let document = hoedown_document_new(renderer, hoedown_extensions(0), 16);
hoedown_document_render(document, ob, ib.memory.data, ib.memory.size);
let outputData = ob.memory.data
let outputSize = ob.memory.size
let str = String.fromCString(UnsafePointer<CChar>(outputData))!
if let userLibPaths = getenv("DYLD_LIBRARY_PATH") {
userLibPaths.characters.split{$0 == ":"}.forEach {
let path = String($0)
if path.isDirectory {
args += ["-L\(path)"]
}
}
}
@aciidgh
aciidgh / trim.swift
Last active December 28, 2015 18:04 — forked from erica/trim.swift
extension String {
func trimBackTo(boundary: Character) -> String {
if isEmpty {return ""}
if self[endIndex.predecessor()] == boundary { return "" }
return characters.split(boundary).map(String.init).last!
}
func trimUpTo(boundary: Character) -> String {
if isEmpty { return "" }
@aciidgh
aciidgh / CustomCollection.swift
Last active December 30, 2015 19:53
Learning Sequence and Generators
struct Stack<T> {
private var store = [T]()
mutating func push(anObject: T) {
store.append(anObject)
}
mutating func pop() -> T? {
let lastItem = store.last
struct LazyStore<Key: Hashable, Value> {
private var store: [Key : Value] = [:]
let builderClosure: Key -> Value?
init(builderClosure: Key -> Value?) {
self.builderClosure = builderClosure
}
@aciidgh
aciidgh / SwiftStack.swift
Created January 2, 2016 15:59
A generic stack in swift
protocol StackType {
typealias Element
mutating func push(element: Element)
mutating func pop() -> Element?
}
final class BufferStorage<Element> {
private var ptr: UnsafeMutablePointer<Element>
private let capacity: Int