I hereby claim:
- I am mackross on github.
- I am mackross (https://keybase.io/mackross) on keybase.
- I have a public key ASCwqcO__kOzzSykc-u0HQkuc9PR8aaT8snAZGwypf4mqgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
# RESULTS, feel free to repro yourself | |
# | |
# noLock FAIL | |
# accessShare FAIL | |
# rowShare FAIL | |
# rowExclusive FAIL | |
# shareUpdateExclusive SUCCESS | |
# share FAIL+DEADLOCKS | |
# shareRowExclusive SUCCESS |
// Recursive count array inversions O(n.log(n)) | |
package main | |
import "fmt" | |
func main() { | |
a := []int{2, 1, 4, 3, 6, 5} | |
fmt.Println(a, "has", count(a), "inversions.") | |
} |
// Recursive merge sort O(n.log(n)) | |
package main | |
import "fmt" | |
func main() { | |
a := []int{9, 3, 4, 8, 4, 5, 1, 2, 6, 7, 0, 4} | |
fmt.Printf("%v sorted is %v\n", a, sort(a)) | |
} |
/// like XCTAssertEqual, but handles optional unwrapping | |
public func XCTAssertEqualOptional<T: Any where T: Equatable>(expression1: @autoclosure () -> T?, expression2: @autoclosure () -> T?, _ message: String? = nil, file: String = __FILE__, line: UInt = __LINE__) { | |
if let exp1 = expression1() { | |
if let exp2 = expression2() { | |
XCTAssertEqual(exp1, exp2, message ?? "", file: file, line: line) | |
} else { | |
XCTFail(message ?? "exp1 != nil, exp2 == nil", file: file, line: line) | |
} | |
} else if let exp2 = expression2() { | |
XCTFail(message ?? "exp1 == nil, exp2 != nil", file: file, line: line) |
- (RACSignal *)bindTextfield:(UITextField *)textField target:(id)target keypath:(NSString *)keypath | |
{ | |
textField.text = [target valueForKey:keypath]; | |
RACObservablePropertySubject *textFieldTextProperty = [RACObservablePropertySubject propertyWithTarget:textField keyPath:@keypath(textField,text)]; | |
RACSignal *textFieldEdited = [textField rac_textSignal]; | |
[[textFieldTextProperty binding] bindTo:[[RACObservablePropertySubject propertyWithTarget:target keyPath:keypath] binding]]; | |
[target rac_deriveProperty:keypath from:[textFieldEdited skip:1]]; | |
RACSignal *textValue = [[RACSignal merge:@[ textFieldEdited, textFieldTextProperty ]] distinctUntilChanged]; | |
return textValue; |
git clone https://github.com/mackross/GTKeyboardHelper.git ~/Desktop/DeleteLater && open '~/DeleteLater/Keyboard Helper Demo.xcodeproj' |
- (void)shakeAnimation:(CALayer*)layer | |
{ | |
CGPoint pos = layer.position; | |
static int numberOfShakes = 3; | |
static CGFloat vigourOfShake = 0.055; | |
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; | |
CGMutablePathRef shakePath = CGPathCreateMutable(); | |
CGPathMoveToPoint(shakePath, NULL, pos.x, pos.y); | |
int index; |