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 <stdlib.h> | |
#import <malloc/malloc.h> | |
#define SLOW 1 | |
int main(int argc, const char * argv[]) { | |
#if SLOW | |
int sizes[] = { 256032, 512032, 1024032, 1792032 }; | |
for (int ii = 0; ii < 10000; ii++) { |
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
/* | |
Shell version: | |
paste -d , oldoutput.txt output.txt | awk -F "," '{printf "%s %s %s %f\n", $2, $8, $16, $8 / $16}' | sort -k4 | egrep -v "(1\.0|0\.9[1-9])" | |
*/ | |
import Foundation | |
// "paste -d , oldfile.txt newfile.txt" | |
let paths = CommandLine.arguments[1...2].map(URL.init(fileURLWithPath:)) |
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
func g(_ x: inout Int) { | |
x = x * x | |
} | |
func f() { | |
var computed:Int { | |
get { return 5 } | |
set { print(newValue) } | |
} | |
g(&computed) |
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
//compile with "clang -framework Foundation -arch i386 failbuzz.m -o FizzBuzz" | |
//Yes, it only works in 32 bit | |
//No, I can't fix it to work correctly past 12 without coming up with a new implementation strategy, | |
//or compiling a new CoreFoundation that caches more CFNumbers (…I did do that to be sure it worked though) | |
#import <Foundation/Foundation.h> | |
#import <libgen.h> | |
static void setup(const char * argv[]) { | |
for (int i = 1; i <= 100; i++) { |
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
//Given this: | |
NSArray *objects = @[@1, @2, @3] | |
//These are equivalent in behavior | |
NSNumber *first = [objects objectAtIndex:0] | |
NSNumber *second = (NSNumber *)CFArrayGetValueAtIndex(objects, 0) | |
//But is the code that runs the same? Not so much… in the first one we do… | |
objc_msgSend(objects, <selector reference>, 0) | |
-> http://sealiesoftware.com/msg/x86-mavericks.html |
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 | |
/* | |
set(char *key, char *domain, char *user, char *host, char *container, char *value) | |
*/ | |
CFPreferences$target:::set { | |
printf("Set request at %Y ( key: %s, domain: %s, user:%s, host: %s, container: %s, value: %s)\n", walltimestamp, copyinstr(arg0), copyinstr(arg1), copyinstr(arg2), copyinstr(arg3), copyinstr(arg4), copyinstr(arg5)); | |
ustack(); | |
printf("\n\n\n"); | |
} |
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 <time.h> | |
#import <os/lock.h> | |
#define ITERS 2000 | |
#define NSEC_PER_ITER(time) (((double)time * (double)NSEC_PER_SEC) / (double)ITERS) | |
#define TEST(body, name) do {\ | |
start = [NSDate date];\ | |
for (int i = 0; i < ITERS; i++) {\ |
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 |
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; | |
} |
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 |