Skip to content

Instantly share code, notes, and snippets.

Norio Nomura norio-nomura

Block or report user

Report or block norio-nomura

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
@norio-nomura
norio-nomura / ClassExistencial.asm
Created Aug 2, 2019
swiftc -emit-assembly ClassExistencial.swift|swift demangle>ClassExistencial.asm
View ClassExistencial.asm
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 10, 15 sdk_version 10, 15
.globl _main
.p2align 4, 0x90
_main:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
@norio-nomura
norio-nomura / building-yams-using-xcodebuild-without-xcodeproj.sh-session
Last active Sep 16, 2019
[Xcode 11] Building Yams using `xcodebuild` without `.xcodeproj` with `-destination "name=iPhone 8"`
View building-yams-using-xcodebuild-without-xcodeproj.sh-session
➜ 15:27:26 git clone https://github.com/jpsim/Yams.git
Cloning into 'Yams'...
remote: Enumerating objects: 111, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 3987 (delta 58), reused 71 (delta 31), pack-reused 3876
Receiving objects: 100% (3987/3987), 4.24 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (2313/2313), done.
➜ 15:27:43 cd Yams
➜ 15:27:46 git:(master) rm -rf Yams.xcodeproj
@norio-nomura
norio-nomura / Setup transparent proxy with VMware Fusion.md
Last active Oct 15, 2018
Setup transparent proxy with VMware Fusion
View Setup transparent proxy with VMware Fusion.md

Setup transparent proxy with VMware Fusion

  1. Add network (vmnet3) to VMware Fusion
    1. sudo vi /Library/Preferences/VMware\ Fusion/networking
       answer VNET_1_HOSTONLY_SUBNET 172.16.92.0
       answer VNET_1_VIRTUAL_ADAPTER yes
       answer VNET_1_VIRTUAL_ADAPTER_ADDR 172.16.92.1
      +answer VNET_3_DHCP yes
      +answer VNET_3_DHCP_PARAM_DNS_ADDR 172.16.12.1
      +answer VNET_3_DHCP_PARAM_ROUTERS 172.16.12.1
@norio-nomura
norio-nomura / local.internal.docker.host.bonjour.plist
Created Oct 5, 2018
dns-sd(1)を使い、VMware Fusionのホスト側NATインターフェイス(172.16.241.1)を`host.docker.internal.local`としてアドバタイズする
View local.internal.docker.host.bonjour.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.internal.docker.host.bonjour</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/dns-sd</string>
<string>-P</string>
View httpBodyIsNotSentToTheDomainThatReceivedCookie.swift
import Dispatch
import Foundation
var setCookieRequest = URLRequest(url: URL(string: "http://httpbin.org/cookies/set?freeform=test")!)
let setCookieTask = URLSession.shared.dataTask(with: setCookieRequest) { _, _, error in
guard error == nil else { fatalError("failed to set cookie!") }
var request = URLRequest(url: URL(string: "http://httpbin.org/post")!)
request.httpMethod = "POST"
request.httpBody = "{\"key\":\"value\"}".data(using: .utf8)
@norio-nomura
norio-nomura / terminal.sh-session
Last active Aug 26, 2018
How to use `thread backtrace -e true` in `lldb`.
View terminal.sh-session
$ echo 'import Dispatch; func f() {}; DispatchQueue.global(qos: .default).async { f() }; dispatchMain()'|swiftc -
$ lldb
(lldb) target create main
Current executable set to 'main' (x86_64).
(lldb) b f
Breakpoint 1: 9 locations.
(lldb) process launch -v DYLD_LIBRARY_PATH=/usr/lib/system/introspection -v DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib
Process 33297 launched: '/Users/norio/github/swift-dev/SourceKitten/main' (x86_64)
Process 33297 stopped
* thread #2, queue = 'com.apple.root.default-qos', stop reason = breakpoint 1.1
View request.yml
key.request: source.request.editor.open
key.name: "2178448306979356082"
key.sourcetext: "/* 👨‍👩‍👧‍👦👨‍👩‍👧‍👦👨‍👩‍👧‍👦 */\n`init`(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}"
@norio-nomura
norio-nomura / update-alternatives.terminal.sh-session
Last active Apr 17, 2018
[one-liner] update-alternatives for llvm on ubuntu
View update-alternatives.terminal.sh-session
LLVM_VERSION=`cd /usr/bin; ls llvm-config-*|sed 's/llvm-config-//'` && \
(cd /usr/bin; ls -1 llvm*-$LLVM_VERSION) | sed -e '/llvm-config/d' -e "s/-$LLVM_VERSION//"| \
awk -v LLVM_VERSION=$LLVM_VERSION 'BEGIN{print "update-alternatives --force --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-"LLVM_VERSION" 200 \\"}{print "--slave /usr/bin/"$0, $0, "/usr/bin/"$0"-"LLVM_VERSION" \\" }'|sh
@norio-nomura
norio-nomura / symbolicate-crash.terminal.sh-session
Last active Apr 16, 2018
Symbolicate crash from core on Linux
View symbolicate-crash.terminal.sh-session
$ docker run --privileged -it -v `pwd`:`pwd` -w `pwd` --rm norionomura/swift:41
root@e8fbffcc2ed0:~# ulimit -c unlimited
root@e8fbffcc2ed0:~# echo 'let i: Int? = nil; i!'>main.swift
root@e8fbffcc2ed0:~# swift main.swift
main.swift:1:21: warning: expression of type 'Int' is unused
let i: Int? = nil; i!
~^
Fatal error: Unexpectedly found nil while unwrapping an Optional value
Current stack trace:
0 libswiftCore.so 0x00007fcc7bd96750 _swift_stdlib_reportFatalError + 171
@norio-nomura
norio-nomura / sourcekit-crash.terminal.sh-session
Created Feb 5, 2018
SourceKit crashes with Assertion `(!value || Kind == tok::identifier) && "only identifiers can be escaped identifiers"' failed. on Swift 4.1 for Linux
View sourcekit-crash.terminal.sh-session
$ docker run --privileged -it --rm norionomura/swift:4120180201a
root@ed1c03d3a776:/# git clone https://github.com/realm/SwiftLint.git -b nn-swift-4.1
Cloning into 'SwiftLint'...
remote: Counting objects: 23681, done.
remote: Compressing objects: 100% (165/165), done.
remote: Total 23681 (delta 95), reused 145 (delta 74), pack-reused 23440
Receiving objects: 100% (23681/23681), 6.16 MiB | 1.70 MiB/s, done.
Resolving deltas: 100% (16180/16180), done.
Checking connectivity... done.
root@ed1c03d3a776:/# cd SwiftLint
You can’t perform that action at this time.