Skip to content

Instantly share code, notes, and snippets.

View shakemno's full-sized avatar

Manolis Pahlke shakemno

View GitHub Profile
@shakemno
shakemno / Fireworks.swift
Created May 2, 2019 19:31 — forked from victorchee/Fireworks.swift
Fireworks effect by emitter.
let emitterLayer = CAEmitterLayer()
emitterLayer.frame = navigationView.bounds
emitterLayer.renderMode = .additive
emitterLayer.emitterMode = .outline
emitterLayer.emitterShape = .line
emitterLayer.emitterSize = CGSize(width: 50, height: 0)
emitterLayer.emitterPosition = CGPoint(x: navigationView.bounds.width / 2, y: navigationView.bounds.height)
emitterLayer.velocity = 1
emitterLayer.seed = (arc4random() % 100) + 1
navigationView.layer.insertSublayer(emitterLayer, at: 0)
@shakemno
shakemno / introrx.md
Created July 4, 2019 22:15 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
var backgroundColor: [UInt8] = [0, 0, 0, 0]
let GaussianBlurKernel: [Int16] =
[ 1, 4, 6, 4, 1,
4, 16, 24, 16, 4,
6, 24, 36, 24, 6,
4, 16, 24, 16, 4,
1, 4, 6, 4, 1
]
@shakemno
shakemno / UIImage+ImageEffects.swift
Created July 26, 2019 21:45 — forked from devonc/UIImage+ImageEffects.swift
Image Effect Category in Swift
import Accelerate
import UIKit
public extension UIImage {
public func applyLightEffect() -> UIImage? {
return applyBlur(radius: 30, tintColor: UIColor(white: 1, alpha: 0.3))
}
public func applyExtraLightEffect() -> UIImage? {
return applyBlur(radius: 20, tintColor: UIColor(white: 0.97, alpha: 0.82))
@shakemno
shakemno / vImageFastBlur.c
Created July 29, 2019 13:55 — forked from jmenter/vImageFastBlur.c
C Function to create a blurred CGimageRef (supply an image and a blur radius). Uses vImage Accelerate Framework for Mac OS X/iOS 5+ and is VERY fast.
// Assumes ARGB8888
CGImageRef CGImageCreateBlurredImage(CGImageRef inImage, NSUInteger blurRadius)
{
if (!inImage) { return NULL; }
uint32_t radius = (blurRadius % 2) ? (uint32_t)blurRadius : (uint32_t)++blurRadius;
vImage_Error error;
vImage_CGImageFormat imageFormat = {(uint32_t)CGImageGetBitsPerComponent(inImage), (uint32_t)CGImageGetBitsPerPixel(inImage), CGImageGetColorSpace(inImage), CGImageGetBitmapInfo(inImage), 0, NULL, kCGRenderingIntentDefault};
vImage_Buffer source;
@shakemno
shakemno / _command_runner.sh
Created September 29, 2019 22:02 — forked from Timothee/_command_runner.sh
This function lets you easily create series of commands into a single call # It will print each successive command, run it and, as long as it returned # with code 0, continue to the next step. # If any step fails, it will stop and let you pick it back up after you fix the # issues.
#!/usr/bin/env bash
# This function lets you easily create series of commands into a single call
# It will print each successive command, run it and, as long as it returned
# with code 0, continue to the next step.
# If any step fails, it will stop and let you pick it back up after you fix the
# issues.
#
# Example of script using this function:
# !/usr/bin/env bash
@shakemno
shakemno / UILabel+Debug.swift
Created October 22, 2019 08:23 — forked from BjornRuud/UILabel+Debug.swift
Debug mode for UILabel that can optionally show bounds, ascender, descender, x height, cap height, baseline and leading.
import UIKit
struct UILabelDebugOptions: OptionSet {
let rawValue: Int
static let bounds = UILabelDebugOptions(rawValue: 1 << 0)
static let ascender = UILabelDebugOptions(rawValue: 1 << 1)
static let descender = UILabelDebugOptions(rawValue: 1 << 2)
static let xHeight = UILabelDebugOptions(rawValue: 1 << 3)
static let capHeight = UILabelDebugOptions(rawValue: 1 << 4)
@shakemno
shakemno / UILabel+Debug.swift
Created October 22, 2019 08:23 — forked from BjornRuud/UILabel+Debug.swift
Debug mode for UILabel that can optionally show bounds, ascender, descender, x height, cap height, baseline and leading.
import UIKit
struct UILabelDebugOptions: OptionSet {
let rawValue: Int
static let bounds = UILabelDebugOptions(rawValue: 1 << 0)
static let ascender = UILabelDebugOptions(rawValue: 1 << 1)
static let descender = UILabelDebugOptions(rawValue: 1 << 2)
static let xHeight = UILabelDebugOptions(rawValue: 1 << 3)
static let capHeight = UILabelDebugOptions(rawValue: 1 << 4)
@shakemno
shakemno / WorkUnitExecutor.swift
Created October 23, 2019 20:36 — forked from deze333/WorkUnitExecutor.swift
Multi-thread to single-thread synchronized executor pattern in Swift (playground)
// Multi to single thread execution
// Credits go to https://www.reddit.com/r/swift/comments/7ijbt0/whats_a_good_way_to_make_sync_calls_from_swift_to/dr4iwxr/
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3000)) {
print("Done")
PlaygroundPage.current.finishExecution()