Skip to content

Instantly share code, notes, and snippets.

View dnedrow's full-sized avatar

David Nedrow dnedrow

View GitHub Profile
@dnedrow
dnedrow / NSObject+ClassName.swift
Last active March 3, 2020 13:27
Extensions to NSObject that return the classname of the object.
//
// Created by Nedrow, David E on 7/20/18.
//
import Foundation
/// Provides extensions to NSObject. This is deliberately not exposed to Objective-C.
// MARK: - NSObject+Extensions
public extension NSObject {
@dnedrow
dnedrow / UIButton+HitTest.swift
Last active March 3, 2020 13:28
Provides a mechanism for setting the size of the touch area for UIButtons
// Created by Nedrow, David E on 2019-05-21.
// See bottom of file for license.
import Foundation
extension UIButton {
/// Overrides hitTest to ensure all buttons have a minimum touch target of 44x44, per Apple guidelines.
override open func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let minimumHitArea = CGSize(width: 44, height: 44)
@dnedrow
dnedrow / UILabel+Kerning.swift
Last active March 3, 2020 13:29
UILabel extensions providing mechanism for adjusting kerning in a label.
// Created by Nedrow, David E on 2019-07-03.
// See bottom of file for license.
import Foundation
// MARK: - Extensions to UILabel
/// This extension to UILabel provides mechanisms for dealing with kerning.
public extension UILabel {
/// This UILabel extension provides a mechanism for getting and setting the kerning.
@dnedrow
dnedrow / UIView+Nibs.swift
Last active March 3, 2020 13:30
UIView extensions related to nib files.
// Created by Nedrow, David E on 7/20/18.
// See bottom of file for license.
// MARK: Nib-related functions.
public extension UIView {
/** Loads instance from nib with the same name. */
func loadNib() -> UIView {
let bundle = Bundle(for: type(of: self))
let nibName = type(of: self).description().components(separatedBy: ".").last!
@dnedrow
dnedrow / UIView+Extensions.swift
Last active February 26, 2020 23:47
Various mechanisms related to view handling and constraints.
//
// Created by Radu Romanov and David Nedrow on 7/20/18.
//
import Foundation
// MARK: View-related functions
public extension UIView {
/// Adds a modal subview
/// - Parameters:
@dnedrow
dnedrow / NSObject+Extensions.swift
Last active March 3, 2020 13:31
Provides various accessibility convenience items
// Created by Nedrow, David E on 7/20/18.
// See bottom of file for license.
import Foundation
/// Provides extensions to NSObject. This is deliberately not exposed to Objective-C.
// MARK: - NSObject+Extensions
public extension NSObject {
/// Uses the given configuration to set the accessibility info for this object.
@dnedrow
dnedrow / rotateawscerts
Last active December 23, 2019 14:44
Amazon Web Services script to rotate SSL/TLS certs
#!/bin/bash
# This is a SLIGHTLY modified version of a script provided by AWS to rotate
# the certificates for RDS.
# The only changes were to add a timestamp to the directory name, and
# create the directory if it didn't already exist.
mydir=/tmp/rdscerts-`date "+%Y%m%d-%H%M%S"`
truststore=${mydir}/rds-truststore.jks
storepassword=changeit
@dnedrow
dnedrow / build.gradle
Created August 17, 2019 22:18 — forked from ari/build.gradle
Docbook gradle build
/*
Copyright 2015 Aristedes Maniatis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@dnedrow
dnedrow / combobuffermeasure
Last active August 13, 2019 02:30
A bash script to measure the performance of `dd` with varying input and output buffer sizes.
#!/usr/bin/env bash
#
#create a file to work with and eat the output
foo="$( dd if=/dev/zero of=/var/tmp/infile count=1175000 2>&1 >/dev/null )"
# Print the CSV header
printf 'ibs,obs,run time,MB/s\n'
# Loop the buffer size for the input
for ibs in 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1M 2M 4M 8M
extension UIStackView {
func removeArrangedSubview(_ view: UIView, shouldRemoveFromSuperview: Bool) {
removeArrangedSubview(view)
if shouldRemoveFromSuperview {
view.removeFromSuperview()
}
}
}