Skip to content

Instantly share code, notes, and snippets.

💭
??

Josscii Josscii

💭
??
Block or report user

Report or block Josscii

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View with.swift
@discardableResult
public func with<T>(_ value: T, _ builder: (T) -> Void) -> T {
builder(value)
return value
}
@discardableResult
public func with<T>(_ value: T, _ builder: (T) throws -> Void ) rethrows -> T {
try builder(value)
return value
View UIControlClosure.swift
extension UIControl {
/// Typealias for UIControl closure.
public typealias UIControlTargetClosure = (UIControl) -> ()
private class UIControlClosureWrapper: NSObject {
let closure: UIControlTargetClosure
init(_ closure: @escaping UIControlTargetClosure) {
self.closure = closure
}
@ksm
ksm / UIBarButtonItem+Closure.swift
Last active Sep 13, 2019 — forked from BeauNouvelle/UIBarButtonItem Closure 1.swift
Slightly improved version of Beau Nouvelle's UIBarButtonItem closure extension. I hid all the helper classes within the extension and made them private, so as not to pollute the global namespace. Original article: https://medium.com/@BeauNouvelle/adding-a-closure-to-uibarbuttonitem-24dfc217fe72
View UIBarButtonItem+Closure.swift
import Foundation
import UIKit
public extension UIBarButtonItem {
public typealias TargetClosure = (UIBarButtonItem) -> ()
public convenience init(title: String?, style: UIBarButtonItem.Style = .plain, closure: @escaping TargetClosure) {
self.init(title: title, style: style, target: nil, action: nil)
targetClosure = closure
@ZAYDEK
ZAYDEK / bookmark.min.js
Last active Nov 8, 2019
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
View bookmark.min.js
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();
@onevcat
onevcat / Delegate.swift
Created Mar 20, 2018
An auto-weak delegate for handle modern delegate pattern.
View Delegate.swift
class Delegate<Input, Output> {
private var block: ((Input) -> Output?)?
func delegate<T: AnyObject>(on target: T, block: ((T, Input) -> Output)?) {
self.block = { [weak target] input in
guard let target = target else { return nil }
return block?(target, input)
}
}
func call(_ input: Input) -> Output? {
@saitjr
saitjr / symbolicatecrash
Last active Oct 21, 2018
Advance version of symbolicatecrash
View symbolicatecrash
#!/usr/bin/perl -w
#
# This script parses a crashdump file and attempts to resolve addresses into function names.
#
# It finds symbol-rich binaries by:
# a) searching in Spotlight to find .dSYM files by UUID, then finding the executable from there.
# That finds the symbols for binaries that a developer has built with "DWARF with dSYM File".
# b) searching in various SDK directories.
#
# Copyright (c) 2008-2015 Apple Inc. All Rights Reserved.
@kean
kean / AutoRetry.swift
Last active Oct 23, 2019
Smart Auto Retry using RxSwift
View AutoRetry.swift
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import RxSwift
import RxCocoa
extension ObservableType {
@rproenca
rproenca / Clipboard.js
Last active Oct 25, 2019
Copy text to clipboard using Javascript. It works on Safari (iOS) and other browsers.
View Clipboard.js
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
View MKMapView+ZoomLevel.swift
//
// MKMapView+ZoomLevel.swift
// Monizze
//
// Created by Dylan Gyesbreghs on 23/06/2017.
// Copyright © 2017 DGyesbreghs. All rights reserved.
// https://oleb.net/blog/2010/05/set-the-zoom-level-of-mkmapview/
//
import MapKit
You can’t perform that action at this time.