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 / 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
@norio-nomura
norio-nomura / HashOfString.swift
Created October 12, 2016 00:30
Hash of Swift String
// The hash algorithm is founded on http://opensource.apple.com//source/CF/CF-1153.18/CFString.c
import Foundation
let first16Char = repeatElement("f", count: 32)
let middle16Char = repeatElement("m", count: 32)
let last16Char = repeatElement("l", count: 32)
let a = (first16Char + ["ab"] + middle16Char + ["ab"] + last16Char).joined()
let b = (first16Char + ["bc"] + middle16Char + ["bc"] + last16Char).joined()
a == b // false
// Foundation
@norio-nomura
norio-nomura / otpauthFromVIPAccess.exp
Last active September 21, 2016 08:23 — forked from p120ph37/VIPAccess.exp
Generate otpauth URL from Symantec's "VIP Access" on OS X that can be used by TOTP Apps such as 1Password.
#!/usr/bin/expect -f
#
# otpauthFromVIPAccess.exp
#
# Generate otpauth scheme url from Symantec VIP Access.
# Usage:
# ./otpauthFromVIPAccess.exp [v]
# If the "v" argument (or any argument) is specified, verbose output
# will be produced on stderr. The otpauth url will be output on stdout.
#