Skip to content

Instantly share code, notes, and snippets.

View klauslanza's full-sized avatar

Klaus Lanzarini klauslanza

  • Brescia
View GitHub Profile
@jamztang
jamztang / LICENSE
Created January 6, 2012 18:48
Creating a placeholder UIImage dynamically with color
Copyright (c) 2013 Jamz Tang <jamz@jamztang.com>
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
@sgergely
sgergely / gist:3793166
Created September 27, 2012 09:43
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active June 26, 2019 16:41
Objective-C Uncrustify Config
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment
@xhruso00
xhruso00 / BlackAndWhiteThreshold.metal
Last active February 27, 2021 21:12
Black & White monochrome 1bit threshold filter. Uses modern 10.15 approach with protocols and metal and half data type. To use simply call [CIFilter blackAndWhiteThresholdFilter]; (add -fcikernel to "Other metal compiler flags" and add -cikernel for User-defined MTTLINKER_FLAGS . Enable fast math in build settings section metal. Targeting earlie…
#include <metal_stdlib>
using namespace metal;
//https://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_palettes
//https://en.wikipedia.org/wiki/Relative_luminance
//https://en.wikipedia.org/wiki/Grayscale
constant float3 kRec709Luma = float3(0.2126, 0.7152, 0.0722);
constant float3 kRec601Luma = float3(0.299 , 0.587 , 0.114);
//constant float3 kRec2100Luma = float3(0.2627, 0.6780, 0.0593);
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active June 20, 2024 17:13
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@santoshrajan
santoshrajan / JSONStringify.swift
Created October 12, 2014 05:36
JSON Stringify in Swift
// Author - Santosh Rajan
import Foundation
let jsonObject: [AnyObject] = [
["name": "John", "age": 21],
["name": "Bob", "age": 35],
]
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String {
@bwhiteley
bwhiteley / gist:049e4bede49e71a6d2e2
Last active March 17, 2024 13:10
Initialize Swift subclass of UIView, designed in .xib
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet private var contentView:UIView?
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
self.commonInit()
import Foundation
public class CredentialHelper {
// MARK: Init
private var host: String
private var protectionSpace: NSURLProtectionSpace
public init(host: String) {
self.host = host
protectionSpace = NSURLProtectionSpace(host: host, port: 0, `protocol`: "http", realm: nil, authenticationMethod: nil)
@gonzalezreal
gonzalezreal / ios-cell-registration-swift.md
Last active March 13, 2024 15:18
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@thefotes
thefotes / localized.swift
Created January 17, 2016 13:33
Cleaner localized strings with Swift protocols and enums.
import Foundation
// Localized string struct that has single static method which accepts a `Localizeable` value.
struct LocalizedString {
// Usage: LocalizedString.localizedStringForValue(NavBarTitle.Home)
static func localizedStringForValue<T: Localizeable>(localizeableValue: T) -> String {
return NSLocalizedString(localizeableValue.localizedString, comment: localizeableValue.localizedStringComment)