Skip to content

Instantly share code, notes, and snippets.

@qwzybug
qwzybug / xcrun.scpt
Last active August 29, 2015 13:55
osascript xcrun.scpt <path to project> <scheme name>
on run argv
set projectPath to item 1 of argv
set projectScheme to item 2 of argv
tell application "Xcode"
open projectPath
activate
tell application "System Events"
tell application process "Xcode"
click menu item "Stop" of menu 1 of menu bar item "Product" of menu bar 1
click menu item projectScheme of menu 1 of menu item "Scheme" of menu 1 of menu bar item "Product" of menu bar 1
#import <Foundation/Foundation.h>
@interface NSMutableDictionary (ValueHolding)
- (void)setDouble:(double)number forKey:(NSString *)key;
- (double)doubleForKey:(NSString *)key;
- (void)setCGFloat:(CGFloat)number forKey:(NSString *)key;
- (CGFloat)CGFloatForKey:(NSString *)key;
#!/usr/bin/ruby1.9.1 -Kw
# -*- coding: utf-8 -*-
# Dijkstra's single-source shortest path algorithm, from https://gist.github.com/roganartu/9407316#file-dijkstra-rb
class Edge
attr_accessor :src, :dst, :length
def initialize(src, dst, length = 1)
@src = src
//
// UIApplication+DisplayedLanguage.m
// Crossfader
//
// Created by Devin Chalmers on 4/14/14.
//
//
#import "UIApplication+DisplayedLanguage.m.h"
@qwzybug
qwzybug / lazy.swift
Created July 9, 2014 21:22
Lazy computed properties in Swift
import Cocoa
class TestClass {
@lazy var lazy: NSDate = {
return NSDate.date()
}()
}
let t = TestClass()
println(t.lazy)
// Playground - noun: a place where people can play
import Foundation
enum LazyVal<T, U> {
case Raw(T)
case Val(U)
case None
}
import UIKit
enum Angle {
case Radians(Double)
case Degrees(Double)
var radians: Double {
switch(self) {
case let .Radians(scalar):
return scalar
func &<T>(x: T, op: T -> T) -> T {
return op(x)
}
func &<T>(x: T, op: T -> ()) -> T {
op(x)
return x
}
attributes.transform3D = CATransform3DIdentity

Keybase proof

I hereby claim:

  • I am qwzybug on github.
  • I am qwzybug (https://keybase.io/qwzybug) on keybase.
  • I have a public key whose fingerprint is 410E E7B4 A821 19CF E0AD 0C9B E1D9 3BEA 9428 91DE

To claim this, I am signing this object:

@qwzybug
qwzybug / swiftchars.txt
Created October 28, 2014 20:28
Were You Aware? that the Swift Character type is 9 bytes large. (And really likes to segfault if you access its memory.)
'a' 61ffffffffffff7f01 UTF8 61
[sunglasses] f09f988effffff7f01 UTF8 F09F988E
[multiply] c397ffffffffff7f01 UTF8 C397