Skip to content

Instantly share code, notes, and snippets.

View djtech42's full-sized avatar

Dan Turner djtech42

View GitHub Profile
@djtech42
djtech42 / example.swift
Last active June 26, 2017 20:02
Ternary Function for Swift for more readability
var value = 1005
print(ternary(if: value > 1000, then: "big", else: "small")) // OUTPUT: big
value = 5
print(ternary(if: value > 1000, then: "big", else: "small")) // OUTPUT: small
@djtech42
djtech42 / example.swift
Created June 26, 2017 19:57
Swift Safe Unwrap Operators
var value: String? = "test"
value <*> { print($0) } <> { print("value is nil") } // OUTPUT: test
value = nil
value <*> { print($0) } <> { print("value is nil") } // OUTPUT: value is nil
@djtech42
djtech42 / when.swift
Created June 9, 2017 15:08
When/Else { } block from Kotlin in Swift
func when<T, U>(_ value: T, _ cases: [T:U], else elseCaseValue: U) -> U {
if let existingCaseValue = cases[value] {
return existingCaseValue
}
else {
return elseCaseValue
}
}
@djtech42
djtech42 / brew_cask_install_all_apps.sh
Last active May 27, 2017 16:57
My Brew Cask Apps
#!/bin/sh
brew cask install acorn
brew cask install alcatraz
brew cask install alfred
brew cask install anybar
brew cask install appcleaner
brew cask install atom
brew cask install audacity
brew cask install audio-hijack
brew cask install bartender
@djtech42
djtech42 / update.sh
Last active February 20, 2017 06:02
Update Package Managers
#!/bin/sh
# Homebrew (Command Line and GUI)
brew upgrade
brew cask update
# RubyGems
sudo gem update
# Node.js Global
npm update -g
# Bower
bower update
@djtech42
djtech42 / safariHistoryCount.sh
Last active February 20, 2017 05:53
Get Number of Items in Safari History
#!/bin/bash
echo $(ls ~/Library/Caches/Metadata/Safari/History | wc -l) websites in history
@djtech42
djtech42 / safariBookmarks.sh
Last active February 20, 2017 05:53
Get Number of Safari Bookmarks on OS X
#!/bin/bash
echo $(ls ~/Library/Caches/Metadata/Safari/Bookmarks | wc -l) bookmarks
@djtech42
djtech42 / updateDroplet.sh
Created February 20, 2017 05:41
Keep DigitalOcean Dropout Updated
apt-get update && aptitude dist-upgrade -y && apt-get autoremove -y
@djtech42
djtech42 / .gitignore_global
Created January 6, 2017 00:38
Global Git Ignore
*~
# Python
#
*.pyc
*.pyo
# macOS
#
@djtech42
djtech42 / ohMyFish
Last active June 8, 2016 16:47
Oh My Fish Packages and Themes List
agnoster
bang-bang
battery
bobthefish
brew
default
fasd
gem
git-flow
python