Skip to content

Instantly share code, notes, and snippets.

View norio-nomura's full-sized avatar

Norio Nomura norio-nomura

View GitHub Profile
@norio-nomura
norio-nomura / VerifyUnicodeNormalization.swift
Created March 25, 2017 08:10
APFSでファイル名がUnicode正規化されないことを検証する
let filenames = [
"\u{30D1}\u{30D1}", // パパ
"\u{30CF}\u{309A}\u{30CF}\u{309A}", // パパ
]
let fm = FileManager.default
let baseURL = fm.urls(for: .documentDirectory, in: .userDomainMask)[0]
filenames.forEach { filename in
let url = baseURL.appendingPathComponent(filename)
let fd = fopen(url.path, "w")
@norio-nomura
norio-nomura / README.md
Last active March 24, 2017 05:18
Swift REPL crashes on launch if `~/.lldb/lldb-repl-history` contains emoji. https://bugs.swift.org/browse/SR-4338

Reproducing steps:

  1. launch Swift REPL in terminal
  2. paste enum 🤔 { case 👶🏻, 👴🏻 }
  3. exit Swift REPL
  4. launch Swift REPL again

Actual log:

➜  11:48:39  TOOLCHAINS=org.swift.3020170323a swift
Welcome to Apple Swift version 3.1-dev (LLVM a95654d887, Clang 4a3ce873fe, Swift 3061ba06f8). Type :help for assistance.
@norio-nomura
norio-nomura / README.md
Last active March 24, 2017 14:59
`swift_oss_helper.py` helps debugging Swift Standard Library using source code with Swift Toolchain distributed at swift.org.

swift_oss_helper.py

swift_oss_helper.py helps debugging Swift Standard Library using source code with Swift Toolchain distributed at swift.org.

This helps:

  • Configuring target.source-map setting in lldb for adjusting symbol path lookup to distributed Swift Toolchain snapshots
  • Processing *.swift.gyb without actual building Swift toolchain
  • Generate Symbol Map at ~/Library/Developer/SymbolMap/uuids

Usage

  1. install Swift Toolchain snapshot and symbols from https://swift.org/download/#snapshots
@norio-nomura
norio-nomura / terminal.sh-session
Last active February 15, 2017 00:31
Test using both `: xcode => [" 7.0 ",: run]` and `: xcode => [" 8.0 ",: build]` with `swiftlint.rb`
OS-X-1011:~ norio$ cat /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/swiftlint.rb
class Swiftlint < Formula
desc "Tool to enforce Swift style and conventions"
homepage "https://github.com/realm/SwiftLint"
url "https://github.com/realm/SwiftLint.git",
:tag => "0.16.1",
:revision => "16ca04905c769657c22e3a02435992b41ddfdc52"
head "https://github.com/realm/SwiftLint.git"
bottle do
extension String {
public var unescapeHTMLUsingArrayOfUnichar: String {
var buffer = [unichar](repeating: 0, count: utf16.count)
NSString(string: self).getCharacters(&buffer)
var end = buffer.endIndex
let ampersand = unichar(UInt8(ascii: "&"))
let semicolon = unichar(UInt8(ascii: ";"))
let sharp = unichar(UInt8(ascii: "#"))
let hexPrefixes = ["X", "x"].map { unichar(UInt8(ascii: $0)) }
@norio-nomura
norio-nomura / TestReference2.3.swift
Last active April 28, 2017 11:14
Swift のパラメータで参照カウントがどうなっているのかチェックするコード
class C {}
struct S {
var c = C()
mutating func checkReference() -> Bool {
return isUniquelyReferencedNonObjC(&c)
}
}
func foo(s: S) -> Bool {
Process: swiftlint [32239]
Path: /usr/local/bin/swiftlint
Identifier: swiftlint
Version: 0
Code Type: X86-64 (Native)
Parent Process: zsh [12928]
Responsible: swiftlint [32239]
User ID: 501
Date/Time: 2017-01-01 17:14:58.037 +0900
@norio-nomura
norio-nomura / gist:c2e70fef36d4bfc83062863e07a2da61
Created December 19, 2016 01:21
`make package` on SwiftLint@1654561
➜ 10:01:25 git:(master) ✗ make package
rm -f "SwiftLint.pkg"
rm -rf "/tmp/SwiftLint.dst"
xcodebuild -workspace 'SwiftLint.xcworkspace' -scheme 'swiftlint' DSTROOT=/tmp/SwiftLint.dst OTHER_LDFLAGS=-Wl,-headerpad_max_install_names -configuration Debug clean
Build settings from command line:
DSTROOT = /tmp/SwiftLint.dst
OTHER_LDFLAGS = -Wl,-headerpad_max_install_names
=== CLEAN TARGET SWXMLHash OSX OF PROJECT SWXMLHash WITH CONFIGURATION Debug ===
@norio-nomura
norio-nomura / sourcekitten-NSURLResponse.h.terminal-session
Created December 8, 2016 08:14
sourcekitten doc --objc NSURLResponse.h
$ sourcekitten doc --objc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSURLResponse.h -- -x objective-c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/
[
{
"\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/MacOSX.platform\/Developer\/SDKs\/MacOSX.sdk\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Headers\/NSURLResponse.h" : {
"key.substructure" : [
{
"key.filepath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/MacOSX.platform\/Developer\/SDKs\/MacOSX.sdk\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Headers\/NSURLResponse.h",
"key.doc.file" : "\/Applications\/Xcode.app\/Cont
@norio-nomura
norio-nomura / swift_2016-10-25-180523_norio-nomura-MacBook-Pro.crash
Last active October 25, 2016 09:29
Building `Request.swift` fails by crashing of Swift compiler on Xcode 8.1 GM seed
Process: swift [40046]
Path: /Users/USER/*/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
Identifier: swift
Version: 800.0.58.6
Code Type: X86-64 (Native)
Parent Process: swift [40027]
Responsible: swift [40046]
User ID: 501
Date/Time: 2016-10-25 18:05:22.008 +0900