Skip to content

Instantly share code, notes, and snippets.

View shakemno's full-sized avatar

Manolis Pahlke shakemno

View GitHub Profile
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 / UIColor+Blend.swift
Last active August 14, 2019 17:51
Blend/mix UIColor with another color
// https://crunchybagel.com/blend-uicolor-swift-extension/
extension UIColor {
func blend(with: UIColor) -> UIColor {
var orgR: CGFloat = 0, orgG: CGFloat = 0, orgB: CGFloat = 0, orgA: CGFloat = 0
var overR: CGFloat = 0, overG: CGFloat = 0, overB: CGFloat = 0, overA: CGFloat = 0
self.getRed(&orgR, green: &orgG, blue: &orgB, alpha: &orgA)

XCode swift

let docDirPath =
NSSearchPathForDirectoriesInDomains(.documentDirectory,
                                    .userDomainMask, true).first
print(docDirPath)

let docDirUrl =
    FileManager.default.urls(for: .documentDirectory,
 in: .userDomainMask).first
@shakemno
shakemno / quick_nimble_safeguard.sh
Last active September 9, 2019 00:46
XCode build phase script to never miss any 'force' Quick or Nimble test
TAGS="TODO:|FIXME:"
ERRORTAG="ERROR:"
HELPERS="fdescribe|fcontext|fit"
VIOLATIONS=$(find "${SRCROOT}" "./SUBDIRA" "./SUBDIRB" \
\( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number \
--only-matching "($TAGS).*\$|($ERRORTAG).*|($HELPERS).*\$" |\
perl -p -e "s/($TAGS)/ warning: \$1/" |\
perl -p -e "s/($ERRORTAG)/ error: \$1/" |\
perl -p -e "s/($HELPERS)/ error: \$1/")
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
# https://stackoverflow.com/a/57159637
@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)