Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
RoyalIcing / TFFTagging
Created October 5, 2013 05:56
An example of how syncing tags could be made hopefully easier by separating a tag into two objects: - One that is recorded to the database, with a unique identifier. - And one that the are assigned to notes, which then points to a recorded tag.
@protocol TFFTagging
@property (readonly, nonatomic) NSString *name;
@end
// Tags in sidebar UI use TFFRecordedTag
// Tags in notes UI use TFFAttachableTag
// Same interface for what makes a tag, which is its name.
@RoyalIcing
RoyalIcing / gist:9580574
Created March 16, 2014 09:19
Inline SVG in CSS using Compass/SCSS
@mixin searchButtonImage
{
background-image: inline-image('infinitylist/svg/search-icon.svg', unquote('image/svg+xml'));
background-repeat: no-repeat;
}
http://www.adobe.com/digitalimag/pdfs/phscs2ip_colspace.pdf
@RoyalIcing
RoyalIcing / Example.md
Last active August 29, 2015 14:02
PHP burntCheck()

Instead of doing:

$name = !empty($json['name']) ? $json['name'] : null;

just do:

$name = burntCheck($json['name']);
@RoyalIcing
RoyalIcing / example.playground
Created July 13, 2014 09:03
Using enum for getting/setting value and modification date – Inessential · Swift Structs and valueForKey:
import Swift
import Cocoa
// Properties you need as an enum - problem of key value coding is it allows you to type *anything*, typos compile fine.
enum SyncObjectPropertyName {
case Archived
case Title
}
// Protocol shared both for local and server
@RoyalIcing
RoyalIcing / WKUserContentController+bundledScripts
Created April 24, 2015 04:00
Easily add scripts from your bundle to a WKUserContentController. Has optional template replacing, specify a dictionary with `sourceReplacements:`.
// Created by Patrick Smith on 22/04/2015.
// Copyright 2015 Patrick Smith.
// Released under the MIT License http://opensource.org/licenses/MIT
import Cocoa
import WebKit
extension WKUserContentController {
func addBundledUserScript(scriptNameInBundle: String, injectAtStart: Bool = false, injectAtEnd: Bool = false, forMainFrameOnly: Bool = true, sourceReplacements: [String:String]? = nil) {
internal enum FileInfoIdentifier: String {
case DisplayNameAndIcon = "displayNameAndIcon"
case DateModified = "dateModified"
var sortDescriptor: NSSortDescriptor {
switch self {
case .DisplayNameAndIcon:
return NSSortDescriptor(key:NSURLLocalizedNameKey, ascending:true)
case .DateModified:
return NSSortDescriptor(key:NSURLContentModificationDateKey, ascending:false)
@RoyalIcing
RoyalIcing / main.swift
Created July 26, 2015 08:17
Parse & JSON API
protocol ValueStorable {
subscript(key: String) -> AnyObject? { get set }
}
internal protocol ValueStorableUpdater {
init?(fromStorable storable: ValueStorable)
func updateStorable(inout storable: ValueStorable)
}
//: Property Observing
// Swift 1.2
import Cocoa
import XCPlayground
protocol ObjectListenerType {
func objectDidChange<T: AnyObject>(x: T)
}
@RoyalIcing
RoyalIcing / SequenceType+compact.swift
Last active February 1, 2019 16:54
Swift compact() for SequenceType
//: Playground - noun: a place where people can play
import Foundation
protocol OptionalParasite {
typealias WrappedParasite
func toArray() -> [WrappedParasite]
}