Skip to content

Instantly share code, notes, and snippets.

View dnedrow's full-sized avatar

David Nedrow dnedrow

View GitHub Profile
@dnedrow
dnedrow / leverageuserappfolder.md
Last active February 23, 2026 02:11
Leveraging an Applications folder in the user's home on macOS

Leveraging a User Applications Folder on macOS

The Why

A macOS user does not necessarily have the ability to install applications in the system /Applications folder. This often is because they are not an administrator on their machine. However, they can install applications in their own user folder. This is typically /Users/<username>/Applications.

The How

If a /Users//Applications folder does not exist, the user should

@dnedrow
dnedrow / TouchIDsudo.md
Created November 9, 2021 00:15
Enable TouchID auth for sudo in macOS

Add the following line

auth       sufficient     pam_tid.so

immediately after

auth       sufficient     pam_smartcard.so

in the /private/etc/pam.d/sudo file.

import AudioToolbox.AudioServices
extension SystemSoundID {
static let vibrate = SystemSoundID(kSystemSoundID_Vibrate) // 4095
static let peek = SystemSoundID(1519)
static let pop = SystemSoundID(1520)
static let cancelled = SystemSoundID(1521)
static let tryAgain = SystemSoundID(1102)
static let failed = SystemSoundID(1107)
}
@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
}
@ari
ari / build.gradle
Last active August 17, 2019 22:18
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
@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 {
@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
@jstn
jstn / RandomNumbers.swift
Last active May 5, 2023 03:26
generate random numbers for 64-bit types while mitigating modulo bias
/*
`arc4random_uniform` is very useful but limited to `UInt32`.
This defines a generic version of `arc4random` for any type
expressible by an integer literal, and extends some numeric
types with a `random` method that mitigates for modulo bias
in the same manner as `arc4random`.
`lower` is inclusive and `upper` is exclusive, thus: