Skip to content

Instantly share code, notes, and snippets.

@greyspot09
greyspot09 / shuffle.swift
Created April 25, 2017 02:32 — forked from natecook1000/shuffle.swift
Shuffle/shuffled functions & Array extensions
// (c) 2014 Nate Cook, licensed under the MIT license
//
// Fisher-Yates shuffle as top-level functions and array extension methods
/// Shuffle the elements of `list`.
func shuffle<C: MutableCollectionType where C.Index == Int>(inout list: C) {
let c = count(list)
for i in 0..<(c - 1) {
let j = Int(arc4random_uniform(UInt32(c - i))) + i
swap(&list[i], &list[j])
import Foundation
/// A generic Cocoa-Style completion handler
typealias CompletionHandler<T> = (T?, Error?) -> Void
/// A generic result type that returns a value or an error
enum Result<T> { case success(T), error(Error), uninitialized }
/// Provides syncronous access to results returned by
/// asynchronous processes with completion handlers
@greyspot09
greyspot09 / ATS.plist
Created March 16, 2017 13:43 — forked from onevcat/ATS.plist
Fuck off ATS
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
@greyspot09
greyspot09 / git-branch-rules.md
Created December 22, 2016 09:27 — forked from imty42/git-branch-rules.md
git 分支规范

主分支 master

  • master 为主分支,要保护它的稳定性,随时可用来上线。
  • 我们不应该直接在 master 分支上直接提交代码,而是从其它分支的合并。

开发分支 develop

  • develop 为开发分支,一般包含正在开发的所有新特性,用于测试环境部署和测试。
  • 我们不应该直接在 develop 分支上直接提交代码,也不应该把未经测试的代码合并进来,应该尽量保持测试环境干净可用。
  • 当 develop 太“脏”以至于不能继续测试之后,可以考虑重新从 master 拉取一次。
//:
//: UIView Animation Syntax Sugar
//:
//: Created by Andyy Hope on 18/08/2016.
//: Twitter: @andyyhope
//: Medium: Andyy Hope, https://medium.com/@AndyyHope
import UIKit
extension UIView {
public struct Singleton {
// Use a reference type for state
private class SingletonState {
// Where possible, provide explicit initial
// state values that do not depend on custom
// initializers
var value: Int = 0
}
private var _state = SingletonState()
import UIKit
func pushDraw(in context: UIGraphicsImageRendererContext,
applying actions: () -> Void)
{
context.cgContext.saveGState()
actions()
context.cgContext.restoreGState()
}

Videos

@greyspot09
greyspot09 / LICENSE
Created June 21, 2016 08:45 — forked from chriseidhof/LICENSE
A tiny networking library
Copyright 2015 Chris Eidhof
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE