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 / my_attributed_text_view.rb
Created August 29, 2012 03:21
A hack to use DTAttributedTextContentView for multiple column text.
class MYAttributedTextView <DTAttributedTextContentView
def layoutFrame
layout_frame = super
rect = layout_frame.frame
rect = UIEdgeInsetsInsetRect(self.bounds, edgeInsets)
new_frame = DTCoreTextLayoutFrame.alloc.initWithFrame(rect, layouter:self.layouter)
new_frame
end
end
@eyeplum
eyeplum / CVDisplayLink
Last active December 20, 2015 17:59
CVDisplayLink based animator example.
@eyeplum
eyeplum / rycooder.swift
Last active August 29, 2015 14:13
RyCooder - Command Line Music Player written in Swift
import Foundation
import AVFoundation
// AudioPlayer Class Definition
class AudioPlayer: NSObject {
private let runLoop: NSRunLoop = NSRunLoop.currentRunLoop()
private let stdinHandle: NSFileHandle = NSFileHandle.fileHandleWithStandardInput()
private let items: [AVPlayerItem]!
private var queuePlayer: AVQueuePlayer!
@eyeplum
eyeplum / lumiere.rs
Last active October 19, 2015 09:21
A talk about WWDC15 at Liulishuo House-warming Party
// Trying to build a Rust version here
extern crate rustc_serialize;
use std::io;
use std::env;
use std::path::Path;
use std::fs::File;
use std::io::Read;
use std::vec;
@eyeplum
eyeplum / GIF-Screencast-OSX.md
Created December 8, 2015 08:24 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@eyeplum
eyeplum / Dockerfile
Last active March 7, 2016 17:05
Dockerfile for building latest Open Source Swift container
FROM ubuntu:15.10
# Latest Swift Development Snapshot
ENV SWIFT_BRANCH development
ENV SWIFT_VERSION swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a
ENV SWIFT_PLATFORM ubuntu15.10
# Install Dependencies
RUN apt-get update && \
apt-get install -y \
@eyeplum
eyeplum / drawRect.swift
Created March 7, 2016 16:15
Simple command to draw a rect.
/*
Tested on OS X 10.11 and Ubuntu 15.10
Exmaple: `$ drawRect 4 3` should output this:
┌──┐
│ │
└──┘
*/
// MARK: - Data Structures
@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()
@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 / 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