Skip to content

Instantly share code, notes, and snippets.

extension UIImage {
func blurred(radius: CGFloat) -> UIImage {
let ciContext = CIContext(options: nil)
guard let cgImage = cgImage else { return self }
let inputImage = CIImage(cgImage: cgImage)
guard let ciFilter = CIFilter(name: "CIGaussianBlur") else { return self }
ciFilter.setValue(inputImage, forKey: kCIInputImageKey)
ciFilter.setValue(radius, forKey: "inputRadius")
guard let resultImage = ciFilter.value(forKey: kCIOutputImageKey) as? CIImage else { return self }
enum Zodiac: String {
case aries, taurus, gemini, cancer, leo, virgo, libra, scorpio, sagittarius, capricorn, aquarius, pisces
}
extension Zodiac {
var dateRangeString: String {
let df = DateFormatter()
df.dateFormat = "MMM d"
let from = df.string(from: dateRange.lowerBound)
let to = df.string(from: dateRange.upperBound)
extension UIImage {
func darkened() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
defer { UIGraphicsEndImageContext() }
guard let ctx = UIGraphicsGetCurrentContext(), let cgImage = cgImage else {
return nil
}
// flip the image, or result appears flipped
import Foundation
// Caveats (specify fixes alongside)
// * Promise { throw E.dummy } is interpreted as `Promise<() throws -> Void>` of all things
// * Promise(E.dummy) is interpreted as `Promise<E>`
// Remarks:
// * We typically use `.pending()` to reduce nested insanities in your backtraces
#!/bin/bash
#
# Faster toolchain build: skips as much as possible.
#
# To use this toolchain from the command line:"
# export TOOLCHAINS=$(whoami)
#
# we build to the same prefix every time (instead of building
# to a versioned prefix) because every time the prefix changes
# *everything* rebuilds.
@mxcl
mxcl / Lockfile.md
Last active March 13, 2016 12:39 — forked from ankitspd/Lockfile.md
Lock file proposal

Dependency Locking with the Swift Package Manager

Introduction

In a vibrant packaging ecosystem, dependencies update continuously with bug-fixes and feature improvements. When working against a collection of dependencies, especially in a team, it is vital to lock the graph and update it so that all team members receive the exact same graph at the same time.

The typical flow for this in dependency management is to create and use a dependency “Lockfile”.

Motivation

firstly {
NSURLSession.GET(url)
}.then { (dict: NSDictionary) in
//…
}.catch { (err: Error.JSONError) in
// The token `JSONError` is defined in PromiseKit
}.catch { (err: Error.HTTPError) in
switch err.statusCode {
case 400: //…
//…
import Darwin //.C.stdlib
// updated for Swift 2.0 beta4
private func merge<T: Comparable>(a: ArraySlice<T>, _ b: ArraySlice<T>, mergeInto acc: ArraySlice<T> = []) -> ArraySlice<T> {
guard let aF = a.first, bF = b.first else {
return acc + a + b
}
return aF < bF
? merge(dropFirst(a), b, mergeInto: acc + [aF])
{
"name": "XMPPFramework",
"version": "3.6.4",
"platforms": {
"ios": "5.0",
"osx": "10.7"
},
"license": {
"type": "BSD",
"file": "copying.txt"
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
float y = scrollView.contentOffset.y;
////// parallax
CGAffineTransform transform;
BOOL clip = YES;
y -= 320;
if (y < -320) {
float const required_scale = y / -320;