Skip to content

Instantly share code, notes, and snippets.

@jpsim
jpsim / 31302382.md
Last active May 30, 2019 21:29
File attachments for rdar://31302382
@jpsim
jpsim / README.md
Last active January 18, 2018 11:23
Generate Swift docs on Linux with Jazzy and SourceKitten

Keybase proof

I hereby claim:

  • I am jpsim on github.
  • I am jpsim (https://keybase.io/jpsim) on keybase.
  • I have a public key ASBwmCI1FZ8tNZxDyhrZwx06OrlGAWufb1hQDmLWXD7IWgo

To claim this, I am signing this object:

@jpsim
jpsim / TranslatedString.swift
Created June 4, 2016 20:59
TranslatedString Realm Model
// Example approach for modeling localized strings in Realm
import Foundation
import RealmSwift
enum Locale: String {
case English = "en"
case French = "fr"
}
@jpsim
jpsim / switch.swift
Last active April 15, 2016 22:03
optional enum switch compiler issue
enum MyEnum {
case Case1, Case2
}
let myEnum: MyEnum? = .Case1
// Implicit optional unwrapping
// These first two case statements fail to compile:
//
@jpsim
jpsim / realm_write_syntax.swift
Created November 14, 2015 00:16
Realm.write() valid syntax
import RealmSwift
// Swift's syntax allows for a variety of ways to invoke closures.
// Here are some of them, specifically ways to making write transactions in Realm Swift.
// See https://realm.io/docs/swift/latest/#writes for Realm's docs on write transactions.
do {
let realm = try Realm()
// 1
@jpsim
jpsim / Person.swift
Created July 29, 2015 18:59
Representing an array of strings in Realm
/**
Although this example demonstrates how to store flat arrays of strings
on a Realm model, you can extend this pattern to store anything from
arrays of integers to native Swift enum's. Basically anything that you can
map to a representable type in Realm.
*/
class RealmString : Object {
dynamic var stringValue = ""
}
@jpsim
jpsim / stars_over_time.sql
Last active November 21, 2015 19:06
GitHub Archive Stars Over Time
select created_at
from [githubarchive:month.201401],
[githubarchive:month.201402],
[githubarchive:month.201403],
[githubarchive:month.201404],
[githubarchive:month.201405],
[githubarchive:month.201406],
[githubarchive:month.201407],
[githubarchive:month.201408],
[githubarchive:month.201409],
[
{
"key.substructure" : [
{
"key.namelength" : 7,
"key.runtime_name" : "_TtC8__main__7Ellipse",
"key.name" : "Ellipse",
"key.filepath" : "\/Users\/jp\/Projects\/SwiftGraphics\/SwiftGraphics\/Ellipse.swift",
"key.bodylength" : 907,
"key.nameoffset" : 165,
@jpsim
jpsim / Realm-ObjC.xml
Created January 13, 2015 07:27
SourceKitten 0.3.0 Realm Objective-C Docs
This file has been truncated, but you can view the full file.
<?xml version="1.0"?>
<sourcekitten>
<Other column="12" file="/Users/jp/realm/code/realm-cocoa/Realm/RLMArray.h" line="37">
<Name>RLMArray</Name>
<USR>c:objc(cs)RLMArray</USR>
<Declaration>@interface RLMArray : NSObject &lt;RLMCollection, NSFastEnumeration&gt;
@end</Declaration>
<Abstract>
<Para>RLMArray is the container type in Realm used to define to-many relationships.</Para>