Skip to content

Instantly share code, notes, and snippets.

import UIKit
class BlurryVC: UIViewController {
override func loadView() {
view = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
}
}
class ViewController: UIViewController {
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]!, error: NSError!) in
if error == nil {
self.latitudeArray = objects.map{ $0["latitude"]! as Double }
} else {
println(error)
}
}
// Trying to write a function that does some select/map magic with easy error handling
let cities = [[
"name": "Geneva",
"population": 184538
],[
"name": "Bern",
"population": 123154
], [
"name": "Zurich",
enum FizzBuzz {
case fizz
case buzz
case fizzBuzz
case number(Int)
init(rawValue: Int) {
switch (rawValue % 3, rawValue % 5) {
case (0, 0): self = .fizzBuzz
case (0, _): self = .fizz
dispatch_promise(^{
return md5(email);
}).then(^(NSString *md5){
return [NSURLConnection GET:@"http://gravatar.com/%@", md5];
}).then(^(UIImage *gravatarImage){
self.imageView.image = gravatarImage;
});
This file has been truncated, but you can view the full file.
master~/src/YOLOKit$ pod trunk push YOLOKit.podspec --verbose
Validating podspec
> YOLOKit
YOLOKit (9) - Analyzing on OS X platform.
Analyzing dependencies
Fetching external sources
@mxcl
mxcl / simple_socket_client.c
Last active December 16, 2015 18:20
All the examples on the web of socket usage are as complicated as possible, because that is helpful. Thanks morons. Anyway, here's a simple example.
#if _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#if __APPLE__ || _WIN32
#define MSG_NOSIGNAL 0
@mxcl
mxcl / hlink.c
Created November 23, 2012 15:11
#import "MBSQLite.h"
#import <sqlite3.h>
int sqlite3_exec_callback(void *userdata, int argc, char **argv, char **column) {
id aa = (__bridge NSMutableArray *)userdata;
while (argc--)
[aa insertObject:@(argv[argc]) atIndex:0];
return SQLITE_OK;
}
@mxcl
mxcl / asdf.rb
Created September 3, 2012 02:53
#Add before any other code in `bin/brew`
module Kernel
alias_method :old_backtick, :`
alias_method :old_system, :system
def system *args
t = Time.now
old_system *args
puts "#{Time.now - t}: #{args*' '}"
end