View pointless swift benchmarks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Test | |
{ | |
func testing2(var x : Int) -> Int | |
{ | |
if x % 3 == 0 { | |
x += 10 | |
} | |
x++ |
View syncs.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -q -s | |
/* | |
CFPreferencesServer$target:::request { | |
printf("REQUEST from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", | |
arg0, | |
walltimestamp, | |
arg1 != NULL ? copyinstr(arg1) : "(NULL)", | |
arg2 != NULL ? copyinstr(arg2) : "(NULL)", | |
arg3 != NULL ? copyinstr(arg3) : "(NULL)", | |
arg4 != NULL ? copyinstr(arg4) : "(NULL)", |
View Controller.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Controller.h" | |
#define ENABLE_INLINE | |
#ifdef ENABLE_INLINE | |
#define INLINE static inline | |
#else | |
#define INLINE | |
#endif | |
static inline int INDEX(char letter) { |
View stringbench.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func measure(work:Void->Void) { | |
let start = NSDate() | |
for _ in 0..<100000 { | |
work() | |
} | |
let elapsed = -(start.timeIntervalSinceNow) | |
print(elapsed) | |
} |
View sillykeys.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
static const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
NSString *badKey(int idx) { | |
char *buffer = malloc(4096); | |
memset(buffer, 'A', 4096 * sizeof(char)); | |
//NSString hashes the beginning, middle, and end of long strings, so we want our keys to differ only in other places. | |
//-isEqual: also compares from front to back, so to exaggerate the problem, I placed the differences in the keys about 3/4 of the way through the string | |
buffer[3072] = alphabet[arc4random_uniform(52)]; |
View rootclasskvo.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
NS_ROOT_CLASS | |
@interface KVOTest | |
@end | |
@implementation KVOTest |
View Chicken thighs and brown butter pan sauce tortellini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As seen here: https://twitter.com/Catfish_Man/status/721914376664408064 | |
Loosely based on http://inhousecook.blogspot.com/2013/09/paprika-chicken-and-ravioli-with-brown.html | |
Preheat oven to 375F | |
Chop off a hunk of onion - we had half of one left, so I took about 3/4" off the center, plus a bit more when that looked skimpy | |
In an oven-safe pan (I used a big cast iron one) saute the onion over medium-low heat in a few tablespoons of unsalted butter until it's brown and translucent |
View feb2017donations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We're a group of tech employees (@Catfish_Man, @jnadeau, @numist, @jauricchio, and @daagaak) interested in making sure | |
as many people as possible survive the current state of US politics. For each dollar we donate, our employer | |
will donate two. We're pooling our resources to do the same for you, so for each dollar you donate to the | |
orgs below, we'll also donate one dollar to those orgs, and our employer will donate two: quadruple your donation! | |
We have $45k set aside for this, so we'll keep matching donations until we've matched that much or 72 hours have passed. | |
You can send me a tweet/DM (@Catfish_Man) with a screenshot of evidence that you donated (receipt page, whatever works, we're not picky). | |
Southern Poverty Law Center | |
Council on American-Islamic Relations |
View samplecache.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static id cachedObject; | |
static NSLock *lock; | |
id getCachedObject() { | |
[lock lock]; | |
id result = [cachedObject retain]; | |
[lock unlock]; | |
return result; | |
} |
View tweetstorm.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by David Smith on 5/29/17. | |
// Copyright © 2017 Unseen University. All rights reserved. | |
// | |
// Localization- and encoding-safe solution to Coraline Ada's challenge here: https://twitter.com/CoralineAda/status/869204799027372032 | |
// Very lightly tested. Probably contains bugs. | |
import Foundation | |
func tweetStorm(input uncanonicalizedInput:String, handle:String?) -> [String] { | |
let input = uncanonicalizedInput.precomposedStringWithCanonicalMapping //twitter requires NFC |
OlderNewer