Skip to content

Instantly share code, notes, and snippets.

View owensd's full-sized avatar

David Owens II owensd

View GitHub Profile
@owensd
owensd / gist:7661970
Created November 26, 2013 17:00
AppleScript to open Safari with the data:text/html;base64 information.
tell application "Safari"
activate
tell window 1
open location "data:text/html;base64,PGI+aGVsbG8hPC9iPg=="
end tell
end tell
- (void)testLoopOneMillionTimes
{
__block int count = 0;
[self measureBlock:^{
for (int i = 0; i < 1000000; ++i) {
count++;
}
}];
}
func testLoopOneMillionTimesA() {
var count = 0
self.measureBlock() {
count = 0
for _ in 0..1000000 {
++count
}
}
}
func testAppendInt() {
var array : Int[] = []
self.measureBlock() {
for (var i = 0; i < 1_000_000; ++i) {
array.append(i)
}
}
}
- (void)testAppendInt
{
NSMutableArray *array = [[NSMutableArray alloc] init];
[self measureBlock:^{
for (int i = 0; i < 1000000; ++i) {
[array addObject:@(i)];
}
}];
}
if (myDelegate != nil) {
if ([myDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) {
[myDelegate scrollViewDidScroll:myScrollView];
}
}
{
"stat": "ok",
"blogs": {
"blog": [
{
"id" : 73,
"name" : "Bloxus test",
"needspassword" : false,
"url" : "http://remote.bloxus.com/"
},
if ([json isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = json[@"blogs"];
if ([dict isKindOfClass:[NSDictionary class]]) {
NSArray *blogs = dict[@"blogs"][@"blog"];
if ([blogs isKindOfClass:[NSArray class]]) {
for (NSDictionary *blog in blogs) {
if ([blog isKindOfClass:[NSDictionary class]]) {
NSLog(@"Blog ID: %@", blog[@"id"]);
NSLog(@"Blog Name: %@", blog[@"name"]);
NSLog(@"Blog Needs Password: %@", blog[@"needspassword"]);
if let dict = json as? NSDictionary {
if let blogs = dict["blogs"] as? Dictionary<String, AnyObject> {
if let blogItems : AnyObject = blogs["blog"] {
if let collection = blogItems as? Array<AnyObject> {
for blog : AnyObject in collection {
if let blogInfo = blog as? Dictionary<String, AnyObject> {
let id : AnyObject? = blogInfo["id"]
let name : AnyObject? = blogInfo["name"]
let needspassword : AnyObject? = blogInfo["needspassword"]
let url : AnyObject? = blogInfo["url"]
var json = [
"stat": "ok",
"blogs": [
"blog": [
[
"id" : 73,
"name" : "Bloxus test",
"needspassword" : true,
"url" : "http://remote.bloxus.com/"
],