Skip to content

Instantly share code, notes, and snippets.

View eyeplum's full-sized avatar
👀
U+1F440 EYES

Yan Li eyeplum

👀
U+1F440 EYES
  • Auckland, New Zealand
View GitHub Profile
@eyeplum
eyeplum / unihan_data_properties.regex
Last active April 11, 2018 00:37
Regex for capturing Unihan database properties
# See: https://regex101.com/r/pIx6E8/10
(?xm)^ # every line
U\+([[:xdigit:]]{4,6}) # [1]codepoint
\t # separator
(k[a-zA-Z0-9_]+) # [2]field key
\t # separator
(.*) # [3]field value
@eyeplum
eyeplum / rust.out
Last active January 8, 2018 20:34
Swift and Rust Static Linked ELF
#####
# on a machine with Rust installed
#####
$ ldd ./target/debug/hello
linux-vdso.so.1 (0x00007ffefb7f4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9e6e25b000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9e6e053000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9e6de36000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9e6dc1f000)
@eyeplum
eyeplum / slides.swift
Created September 13, 2017 21:59
cocoa-for-ios-dev
import TruffautSupport
let layerHosting = """
/* Layer Backed View */
view.wantsLayer = true
// this view is now a layer-backed view
// the layer hierarchy is considered private and
// should NEVER be modified (add or remove sublayers)
/* Layer Hosting View */
- (void)drawRect:(NSRect)rect
{
// Drawing code here.
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
NSAttributedString *str = [[NSAttributedString alloc ]
initWithString:@"学习 Core Text. Learning Core Text. 中华人民共和国。"
attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Adobe Song Std" size:24.0f], (NSString *)kCTFontAttributeName, [NSNumber numberWithBool:YES], (NSString *)kCTVerticalFormsAttributeName, nil]];
CFAttributedStringRef attrString = (CFAttributedStringRef)str;
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attrString);
@eyeplum
eyeplum / ios-static.sh
Last active September 27, 2021 03:56
Build Google Protobuf C++ Runtime for iOS
#!/bin/bash
## Environments
# Exit the build pass if any command returns a non-zero value
#set -o errexit
# Echo commands
set -x
@eyeplum
eyeplum / .gitignore
Created January 10, 2017 14:46 — forked from BennettSmith/.gitignore
Google Protobuf v2.6.0 Build Script for iOS
protobuf
protobuf-2.6.0
protobuf-2.6.1
protobuf-master
@eyeplum
eyeplum / assertion_failure.log
Last active October 8, 2016 11:20
clang 3.9.0 assertion failure when compiling swift on Ubuntu 15.10
[1/49] Compiling /swift.org/build/Ninja-ReleaseAssert/swift-linux-x86_64/stdlib/public/core/linux/x86_64/Swift.o
FAILED: cd /swift.org/build/Ninja-ReleaseAssert/swift-linux-x86_64/stdlib/public/core && /usr/local/bin/cmake -E make_directory /swift.org/build/Ninja-ReleaseAssert/swift-linux-x86_64/stdlib/public/core/linux/x86_64 && /usr/local/bin/cmake -E make_directory /swift.org/build/Ninja-ReleaseAssert/swift-linux-x86_64/./lib/swift/linux/x86_64 && /swift.org/swift/utils/line-directive /swift.org/swift/stdlib/public/core/Algorithm.swift /swift.org/swift/stdlib/public/core/ArrayBody.swift /swift.org/swift/stdlib/public/core/ArrayBuffer.swift /swift.org/swift/stdlib/public/core/ArrayBufferProtocol.swift /swift.org/swift/stdlib/public/core/ArrayCast.swift /swift.org/build/Ninja-ReleaseAssert/swift-linux-x86_64/stdlib/public/core/8/Arrays.swift /swift.org/swift/stdlib/public/core/ArrayType.swift /swift.org/swift/stdlib/public/core/Assert.swift /swift.org/swift/stdlib/public/core/AssertCommon.swift /swift.org/sw
@eyeplum
eyeplum / Makefile
Created July 2, 2016 06:35
Working with Swift.org
.PHONY: docker
.PHONY: build
.PHONY: test
docker:
docker run -it \
-v /Users/eyeplum/Projects/swift.org/:/swift.org \
eyeplum/swift-foundation-dev \
/bin/bash
@eyeplum
eyeplum / output.log
Last active May 26, 2016 08:54
LLVM crashed when building swift-corelibs-foundation on Ubuntu 14.04
[84/269] CompileC: CoreFoundation/NumberDate.subproj/CFBigNumber.c
FAILED: mkdir -p `dirname ../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/CoreFoundation/NumberDate.subproj/CFBigNumber.c.o`; /swift.org/build/Ninja-DebugAssert/llvm-linux-x86_64/bin/clang -fcolor-diagnostics -fdollars-in-identifiers -fblocks -fobjc-runtime=macosx-10.11 -fintegrated-as -fPIC --target=x86_64-linux-gnu -g -O0 -Ibootstrap/common/usr/include -Ibootstrap/common/usr/local/include -Ibootstrap/x86_64-linux-gnu/usr/include -Ibootstrap/x86_64-linux-gnu/usr/local/include -I../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation -I../build/Ninja-DebugAssert/foundation-linux-x86_64 -I../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/usr/lib/swift -I../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/usr/lib/swift/CoreFoundation -I../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/usr/lib/swift/CoreFoundation -I../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/usr/lib/swi
@eyeplum
eyeplum / CVDisplayLinkOutputCallback.swift
Last active October 30, 2023 04:17
CVDisplayLinkOutputCallback in Swift
private func createDisplayLink() {
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink)
guard let displayLink = displayLink else {
return
}
let callback: CVDisplayLinkOutputCallback = { (_, _, _, _, _, userInfo) -> CVReturn in
let myView = Unmanaged<MyView>.fromOpaque(COpaquePointer(userInfo)).takeUnretainedValue()
dispatch_async(dispatch_get_main_queue()) {
myView.update()