Skip to content

Instantly share code, notes, and snippets.

View norio-nomura's full-sized avatar

Norio Nomura norio-nomura

View GitHub Profile
➜ 8:51:41 git:(master) ✗ echo 'print("Hello, world!")'|DEVELOPER_DIR=/Applications/Xcode-beta.app swiftc - -static-stdlib -emit-bc -o hello_world.bc
➜ 8:51:48 git:(master) ✗ DEVELOPER_DIR=/Applications/Xcode-beta.app LLVM=/usr/local/Cellar/emscripten/1.37.10/libexec/llvm/bin/ emcc hello_world.bc
warning: Linking two modules of different data layouts: '/Users/norio/.emscripten_cache/asmjs/libc.bc' is 'e-p:32:32-i64:64-v128:32:128-n32-S128' whereas 'hello_world.bc' is 'e-m:o-i64:64-f80:128-n8:16:32:64-S128'
warning: Linking two modules of different target triples: /Users/norio/.emscripten_cache/asmjs/libc.bc' is 'asmjs-unknown-emscripten' whereas 'hello_world.bc' is 'x86_64-apple-macosx10.9'
error: Appending variables with different alignment need to be linked!
Traceback (most recent call last):
File "/usr/local/bin/emcc", line 13, in <module>
emcc.run()
@norio-nomura
norio-nomura / URLCodableTest.playground
Created June 12, 2017 15:08 — forked from ken0nek/URLCodableTest.playground
Can not decode an entity which has Optional<URL> property.
//: Playground - noun: a place where people can play
import UIKit
struct URLCodableTest: Codable {
let ou: URL?
let u: URL
enum CodingKeys: String, CodingKey {
case ou
@norio-nomura
norio-nomura / Package@swift-4.swift
Last active May 29, 2017 07:24
v4 manifest for SourceKitten
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "SourceKitten",
dependencies: [
.package(url: "https://github.com/Carthage/Commandant.git", from: "0.12.0"),
.package(url: "https://github.com/drmohundro/SWXMLHash.git", .branch("version-4.0-changes")),
.package(url: "https://github.com/jpsim/Yams.git", .branch("master")),
.package(url: "https://github.com/norio-nomura/Clang_C.git", from: "1.0.0"),
@norio-nomura
norio-nomura / use-generated-xcodeproj-as-dependency.terminal.sh-session
Created May 22, 2017 23:31
`Yams.xcodeproj` generated by `swift package generate-xcodeproj` can't be used as dependency of SourceKitten
➜ 8:25:59 git clone https://github.com/jpsim/SourceKitten.git --recurse-submodules
Cloning into 'SourceKitten'...
remote: Counting objects: 7924, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 7924 (delta 3), reused 7 (delta 2), pack-reused 7908
Receiving objects: 100% (7924/7924), 6.05 MiB | 1.11 MiB/s, done.
Resolving deltas: 100% (5073/5073), done.
Submodule 'Carthage/Checkouts/Commandant' (https://github.com/Carthage/Commandant.git) registered for path 'Carthage/Checkouts/Commandant'
Submodule 'Carthage/Checkouts/Result' (https://github.com/antitypical/Result.git) registered for path 'Carthage/Checkouts/Result'
Submodule 'Carthage/Checkouts/SWXMLHash' (https://github.com/drmohundro/SWXMLHash.git) registered for path 'Carthage/Checkouts/SWXMLHash'
@norio-nomura
norio-nomura / cache.json
Created May 19, 2017 04:23
cache.json after three times execute `.build/debug/swiftlint lint --cache-path .` in workspace of https://github.com/realm/SwiftLint/pull/1530
{
"{\"root\":\"/Users/norio/github/SwiftLint\",\"rules\":{\"closure_spacing\":\"warning\",\"notification_center_detachment\":\"warning\",\"function_parameter_count\":\"warning: 5, error: 8\",\"redundant_discardable_let\":\"warning\",\"closure_parameter_position\":\"warning\",\"function_body_length\":\"warning: 40, error: 100\",\"nesting\":\"(type_level) w: 1, (statement_level) w: 5\",\"first_where\":\"warning\",\"unused_enumerated\":\"warning\",\"valid_ibinspectable\":\"warning\",\"trailing_newline\":\"warning\",\"control_statement\":\"warning\",\"vertical_whitespace\":\"warning, max_empty_lines: 1\",\"for_where\":\"warning\",\"trailing_comma\":\"warning, mandatory_comma: false\",\"closure_end_indentation\":\"warning\",\"generic_type_name\":\"(min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\",\"redundant_nil_coalescing\":\"warning\",\"leading_whitespace\":\"warning\",\"force_cast\":\"error\",\"empty_parentheses_with_trailing_closure\":
@norio-nomura
norio-nomura / build-osx-installer.sh
Created May 15, 2017 01:58
swift/swift-nightly-install からインストーラパッケージを作成
#!/usr/bin/env bash
VERSION=20170501
DARWIN_TOOLCHAIN_APPLICATION_CERT=9E8A538843E364A1C53A4C932648FA4CBC7E5986
DARWIN_BUNDLE_IDENTIFIER=local.swift.$VERSION
DARWIN_INSTALLER_CERT="Developer ID Installer: Norio Nomura (PK9GMQ772L)"
BUNDLE_BASE_NAME=swift-LOCAL-2017-05-01-a
BUNDLE_NAME=$BUNDLE_BASE_NAME.xctoolchain
DARWIN_TOOLCHAIN_INSTALL_LOCATION=/Library/Developer/Toolchains/$BUNDLE_NAME
DARWIN_SCRIPTS=swift/utils/darwin-installer-scripts
/Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/utils/build-script
--ios
--tvos
--watchos
--lldb
--llbuild
--swiftpm
--playgroundlogger
--playgroundsupport
--release-debuginfo
➜ 8:50:54 git:(master) docker run --privileged -it --rm swift-base:16.04
root@1c1012e25424:/# which swift
root@1c1012e25424:/# mkdir -p /opt/swift/swift-3.1.1-with-sourcekit
root@1c1012e25424:/# cd /opt/swift/swift-3.1.1-with-sourcekit
root@1c1012e25424:/opt/swift/swift-3.1.1-with-sourcekit# curl -L https://github.com/norio-nomura/docker-sourcekit-builder/releases/download/311/swift-3.1.1-RELEASE-3f82132-with-sourcekit.tar.gz|tar zxf -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 625 0 625 0 0 692 0 --:--:-- --:--:-- --:--:-- 692
100 352M 100 352M 0 0 2084k 0 0:02:53 0:02:53 --:--:-- 2251k
root@1c1012e25424:/opt/swift/swift-3.1.1-with-sourcekit# export PATH=$PATH:/opt/swift/swift-3.1.1-with-sourcekit/usr/bin/
@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.