Skip to content

Instantly share code, notes, and snippets.

JP Simard jpsim

Block or report user

Report or block jpsim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jpsim
jpsim / FB6395442.md
Created Jul 24, 2019
FB6395442: Running 'xcodebuild archive' on a SwiftPM product produces different results than an equivalent .xcodeproj
View FB6395442.md

An Xcode project generates the following archive:

$ tree Yams-macosx.xcarchive
Yams-macosx.xcarchive
├── Info.plist
├── Products
│   └── Library
│       └── Frameworks
│           └── Yams.framework
@jpsim
jpsim / LineEndsFind.mm
Created Apr 22, 2018 — forked from iosdevzone/LineEndsFind.mm
A function to find the offsets of newlines ('\n') in UTF-16 encoded string. Try as I might, I cannot get a Swift version within an order of magnitude of the C++ version. Both routines must return arrays of the same size and with equal elements.
View LineEndsFind.mm
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <iostream>
#import <vector> // Needed for gist to compile.
#pragma mark - Pure Implementation Functions
const static unichar kUTF16Newline = (unichar)'\n'; // old naming habits die hard!
/**
* Calculates an array of line end "positions" for a given string.
* The equivalent Swift function was `(String) -> [Int]` or `(NSString) -> [Int]`
*
@jpsim
jpsim / jazzy_linux.md
Last active May 30, 2019
Jazzy Linux
View jazzy_linux.md

Running jazzy from a fresh Ubuntu machine:

Create a brand new Ubuntu machine

$ doctl compute droplet create jazzy --size 16gb \
    --image ubuntu-16-10-x64 --region sfo1
$ doctl compute ssh jazzy

Install Swift

@jpsim
jpsim / swift_dev_linux.md
Created Dec 14, 2017
Build & run a subset of Swift tests on Linux
View swift_dev_linux.md

Build & run a subset of Swift tests on Linux

# Spin up a beefy Digital Ocean droplet
doctl compute droplet create swift-dev --size m-224gb --image ubuntu-16-10-x64 --region sfo2 --ssh-keys XXXXXXX
doctl compute ssh swift-dev
# Install dependencies
apt-get update
apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev tzdata
# Clone & build Swift
@jpsim
jpsim / 31302382.md
Last active May 30, 2019
File attachments for rdar://31302382
View 31302382.md
@jpsim
jpsim / README.md
Last active Jan 18, 2018
Generate Swift docs on Linux with Jazzy and SourceKitten
View README.md
View keybase.md

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 Jun 4, 2016
TranslatedString Realm Model
View TranslatedString.swift
// 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 Apr 15, 2016
optional enum switch compiler issue
View switch.swift
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 Nov 14, 2015
Realm.write() valid syntax
View realm_write_syntax.swift
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
You can’t perform that action at this time.