Skip to content

Instantly share code, notes, and snippets.

View zackshapiro's full-sized avatar

Zack Shapiro zackshapiro

View GitHub Profile
extension NSDateFormatter {
convenience init(format: String) {
self.init()
dateFormat = format
}
}
@zackshapiro
zackshapiro / get-fonts.swift
Last active April 23, 2016 14:46 — forked from jbergen/get-fonts
Print font family and font names
for family in UIFont.familyNames() {
print("family: \(family)")
for name in UIFont.fontNamesForFamilyName(family) {
print("name: \(name)")
}
print("")
}
# af-magic.zsh-theme
# Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
# primary prompt
PROMPT='$FG[237]------------------------------------------------------------%{$reset_color%}
$FG[032]%~\
func showStreakIndicator(#today: NSDate, yesterday: NSDate?, tomorrow: NSDate?) -> (top: Bool, bottom: Bool) {
var tuple = (top: false, bottom: false)
let calendar = NSCalendar.currentCalendar()
if yesterday == nil && tomorrow == nil {
tuple.top = true
return tuple
}
@zackshapiro
zackshapiro / gist:b65824847e542d1903d8
Last active August 29, 2015 14:15
How to create a git watcher
# this assumes you have brew installed – http://brew.sh/
# and oh-my-zsh – https://github.com/robbyrussell/oh-my-zsh
# First, create a new zshell script
cd ~/.oh-my-zsh/plugins
mkdir your-plugin
cd your-plugin
# create the empty script doc
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var items: [String] = ["We", "Aenean lacinia bibendum nulla sed consectetur.", "Vestibulum id ligula porta felis euismod semper. Maecenas sed diam eget risus varius blandit sit amet non magna. Sed posuere consectetur est at lobortis. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Etiam porta sem malesuada magna mollis euismod. Sed posuere consectetur est at lobortis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.", "Blah", "one two three", "Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam.", "gum gum gum gum", "Blah", "one two three", "Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam.", "gum gum gum gum", "Blah", "one two three", "Donec sed odio dui. Cras justo odio, d
tom, dick, harry
marge, homer, bart
# /app/models.order.rb
def sell_users_coins
begin
client = user.create_client
balance = user.balance(client)
# some code related to selling the actual bitcoins
# logic, edge case checks, etc.
# /app/models/user.rb
def balance(client)
client.balance.to_f
end
# /app/models/user.rb
# because this code is in user.rb, the user is implied
# because you're in the user model, you can call methods on user without `user.`
# so user.access_token becomes access_token
# contact me [email protected] with questions
def create_client
@tokens = {
access_token: access_token,