Skip to content

Instantly share code, notes, and snippets.

View scottdensmore's full-sized avatar

Scott Densmore scottdensmore

View GitHub Profile
# Luke's config for the Zoomer Shell
# Enable colors and change prompt:
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@bradwilson
bradwilson / .bashrc
Last active December 28, 2017 20:26
*nix startup scripts
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\w\a\]$PS1"
;;
@sharplet
sharplet / SimpleNetworkingExample.swift
Created September 14, 2017 21:37
Example Source Code for "A Simple Approach to Thread-Safe Networking in iOS Apps"
import Foundation
import PlaygroundSupport
enum URLResult {
case response(Data, URLResponse)
case error(Error, Data?, URLResponse?)
}
extension URLSession {
@discardableResult
@candostdagdeviren
candostdagdeviren / pre-commit
Last active April 22, 2023 09:32
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
#Path to swiftlint
SWIFT_LINT=/usr/local/bin/swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
count=0
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path
@bradwilson
bradwilson / vs2017.ps1
Last active January 23, 2018 19:05
VS 2017 PowerShell script; if you need invoke-cmdscript, it's here: https://gist.github.com/bradwilson/3fca203370d54304eff1cce21ffc32aa
param(
[string]$edition,
[switch]$noWeb = $false
)
# Try and find a version of Visual Studio in the expected location, since the VS150COMNTOOLS environment variable isn't there any more
$basePath = join-path (join-path ${env:ProgramFiles(x86)} "Microsoft Visual Studio") "2017"
if ((test-path $basePath) -eq $false) {
write-warning "Visual Studio 2017 is not installed."
@aceontech
aceontech / RetainCycleUnitTest.swift
Created March 3, 2017 08:14
Unit test for checking for retain cycles in Swift. Replace `CLASS_YOU_WANT_TO_TEST` with your class name.
func testCleanup() {
// Extend your class inline in order to add closure property `deinitCalled`,
// which indicates when/if your class's deinit() gets called
class ClassUnderTest: CLASS_YOU_WANT_TO_TEST {
var deinitCalled: (() -> Void)?
deinit { deinitCalled?() }
}
// Set up async expectation, which causes the test to wait for `deinitCalled`
1. Use openssl
openssl smime -in /path/to/your.mobileprovision -inform der -verify
2. Use security command
security cms -Di /path/to/your.mobileprovision
//
// FontUtil.swift
// FantasyMovieLeague
//
// Created by Ben Dalziel on 2/17/16.
// Copyright © 2016 Kinetoplay. All rights reserved.
//
import UIKit
//
// ColorUtil.swift
// FantasyMovieLeague
//
// Created by Ben Dalziel on 2/17/16.
// Copyright © 2016 Kinetoplay. All rights reserved.
//
import SwiftHEXColors