Skip to content

Instantly share code, notes, and snippets.

View vprtwn's full-sized avatar
🌀
𓊍

Ben Guo vprtwn

🌀
𓊍
View GitHub Profile
@vprtwn
vprtwn / Spotify.xml
Created April 10, 2015 03:51
/Applications/Spotify.app/Contents/Resources/Spotify.sdef
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="Dictionary">
<suite name="Spotify Suite" code="spfy" description="Spotify specific classes.">
<enumeration name="ePlS" code="ePlS">
<enumerator name="stopped" code="kPSS">
<cocoa integer-value="0"/>
</enumerator>
<enumerator name="playing" code="kPSP">
<cocoa integer-value="1"/>
import Cocoa
protocol Pet {
var name : String { get }
func renamed(newName: String) -> Self
}
struct Fish : Pet {
let name : String
func renamed(newName: String) -> Fish {
@vprtwn
vprtwn / enumFrom.swift
Last active August 29, 2015 14:24
enumFrom
protocol StringDecodable {
init?(string: String)
}
extension Dictionary where Key: JSONKey, Value: AnyObject {
/// Converts a string to an enum value
func enumFrom<T: StringDecodable>(key: Key, _ enumType: T.Type) -> T? {
if let s = self[key] as? String {
return enumType.init(string: s)
}
// before
func formattedAddress() -> String {
let lines:NSMutableArray = NSMutableArray(capacity: 4)
let zipStateCityArgs:NSMutableArray = NSMutableArray(capacity: 3)
let zip = self.stringValueForKeyPath("address_zip")
let city = self.stringValueForKeyPath("address_city")
let state = self.stringValueForKeyPath("address_state")
for arg in [zip, city, state] {
//
// PFTrendsViewModel.m
// SUM
//
// Created by Ben Guo on 11/26/14.
// Copyright (c) 2014 Project Florida. All rights reserved.
//
#import "PFTestUtilities.h"
#import "PFTrendsViewModel.h"