Skip to content

Instantly share code, notes, and snippets.

View danielt1263's full-sized avatar

Daniel Tartaglia danielt1263

View GitHub Profile
@kristopherjohnson
kristopherjohnson / NSData_hexadecimalString.swift
Last active July 14, 2018 12:44
Convert NSData bytes to hexadecimal string
import Foundation
extension NSData {
/// Return hexadecimal string representation of NSData bytes
@objc(kdj_hexadecimalString)
public var hexadecimalString: NSString {
var bytes = [UInt8](count: length, repeatedValue: 0)
getBytes(&bytes, length: length)
@interface KeyBoardSizeView : UIView
@property (nonatomic,weak) NSLayoutConstraint* heightConstraint;
@end
@Revolucent
Revolucent / BitwiseOptions.swift
Last active September 22, 2018 12:46
BitwiseOptions implementation for Swift
//
// BitwiseOptions.swift
//
// Created by Gregory Higley on 11/24/14.
// Copyright (c) 2014 Prosumma LLC. All rights reserved.
//
// 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
@mzaks
mzaks / debounce.swift
Last active March 4, 2019 09:47
Swift debounce function based GCD
import Foundation
/**
Creates and returns a new debounced version of the passed block which will postpone its execution until after wait seconds have elapsed since the last time it was invoked.
It is like a bouncer at a discotheque. He will act only after you shut up for some time.
This technique is important if you have action wich should fire on update, however the updates are to frequent.
Inspired by debounce function from underscore.js ( http://underscorejs.org/#debounce )
*/
public func dispatch_debounce_block(wait : NSTimeInterval, queue : dispatch_queue_t = dispatch_get_main_queue(), block : dispatch_block_t) -> dispatch_block_t {
@maxchuquimia
maxchuquimia / NSAttributedStringConcatenation.swift
Last active May 24, 2019 14:38
Concatenate NSAttributedString in Swift without your code wrapping over multiple lines. Also adding images to attributed strings is supported!
func +(lhs: NSAttributedString, rhs: NSAttributedString) -> NSAttributedString {
let a = lhs.mutableCopy() as! NSMutableAttributedString
let b = rhs.mutableCopy() as! NSMutableAttributedString
a.appendAttributedString(b)
return a.copy() as! NSAttributedString
}
@insidegui
insidegui / WebCacheCleaner.swift
Created September 14, 2016 23:12
Clear WKWebView's cookies and website data storage, very useful during development.
import Foundation
import WebKit
final class WebCacheCleaner {
class func clean() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("[WebCacheCleaner] All cookies deleted")
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
// ObservableBuffer.swift
//
// Created by Daniel Tartaglia
// Copyright © 2019 Daniel Tartaglia. MIT License.
import RxSwift
extension ObservableType {
/**
//
// PaginationNetworkLogic.swift
//
// Created by Daniel Tartaglia on 4/9/17.
// Copyright © 2019 Daniel Tartaglia. MIT License
//
import RxSwift
struct PaginationUISource {
//
// EmitWhile.swift
//
// Created by Daniel Tartaglia on 09/06/2018.
// Copyright © 2021 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift