Skip to content

Instantly share code, notes, and snippets.

View wvdk's full-sized avatar

Wes van der Klomp wvdk

View GitHub Profile
func progression(from: Double, to: Double, numberOfItems: Int) -> [Double] {
let delta = (to - from) / Double(numberOfItems)
var results: [Double] = []
for _ in 0..<numberOfItems {
let lastItem = results.last ?? from
let numberToAppend = lastItem + delta
@wvdk
wvdk / prettyVersionNumber
Created April 27, 2017 00:16
Get the version number from info plist and return nicely formatted
var prettyVersionNumber: String {
get {
if let infoDictionary = Bundle.main.infoDictionary {
if let versionNumber = infoDictionary["CFBundleShortVersionString"] as? String,
let buildNumber = infoDictionary["CFBundleVersion"] as? String {
return "\(versionNumber) (\(buildNumber))"
}
}
@wvdk
wvdk / UIApplication+isRunningOnSimulator.swift
Last active August 15, 2017 15:37
if UIApplication.isRunningOnSimulator.swift { ... } else { ... }
//
// UIApplication+isRunningOnSimulator.swift
// MusicMind
//
// Created by Wesley Van der Klomp on 5/11/17.
// https://gist.github.com/wvdk/e3dd57620c53f338978e6d5d022d3672
// Thanks to http://stackoverflow.com/a/30284266/6407050
//
import Foundation
@wvdk
wvdk / FileManager+simpleSaveAndRead.swift
Last active August 15, 2017 15:39
Makes saving strings to disk a little easier. Works in playgrounds.
//
// Created by wvdk on 2/10/17.
// Copyright © 2017 Wesley Van der Klomp. All rights reserved.
//
// https://gist.github.com/wvdk/46dbc3b88a0924e5815e7e68933e31ec
//
// For macOS
//
import Foundation
@wvdk
wvdk / UILabel+setTextWhileKeepingAttributes.swift
Last active March 1, 2020 11:48
Extension for changing text on a UILabel with an attributed string. With this method you can style in interface builder and easily change the text in code without losing attributes.
//
// Created by WVDK on 2/10/17.
// Copyright © 2017 Wesley Van der Klomp. All rights reserved.
//
// https://gist.github.com/wvdk/e8992e82b04e626a862dbb991e4cbe9c
//
import UIKit
extension UILabel {
# export PS1="úÙ¯‘ \[\033[38m\]\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.match(/^\*.*/).to_s || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "
#alias ls='ls -a -l -G -h -p -T'
alias ls='ls -A -h -p'
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit -m'