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
#!/bin/sh | |
set -e | |
# First we are going to make sure that you understand this is sort of experimental and we will be compiling stuff. | |
# by default CONTINUE will be false | |
CONTINUE=false | |
echo "" | |
echo "You are about to download, compile, and install stuff on your computer." |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* Scroll to the bottom for examples */ | |
typealias WritableObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: WritableKeyPath<O, V>) | |
typealias ReadOnlyObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: KeyPath<O, V>) | |
func bind<O: NSObject, O2: NSObject, V: Equatable>(source: ReadOnlyObjectKeyPath<O, V>, to target: WritableObjectKeyPath<O2, V>) -> NSKeyValueObservation? |
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
actor Downloader { | |
let mainActor : TheMainActor | |
var theList : [URL] = [] | |
init(mainActor: TheMainActor) { self.mainActor = mainActor } | |
actor case .initialized, .ready { | |
actor func setList(list:[String]) -> self.ready? //can only call this from these 2 (initialized and ready) states | |
} | |
actor case .ready { |
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 | |
struct Country { | |
let name: String | |
let capital: String | |
var visited: Bool | |
} | |
extension Country: Equatable { | |
static func == (lhs: Country, rhs: Country) -> Bool { |
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
/// Observes a run loop to detect any stalling or blocking that occurs. | |
/// | |
/// This class is thread-safe. | |
@interface GHRunLoopWatchdog : NSObject | |
/// Initializes the receiver to watch the specified run loop, using a default | |
/// stalling threshold. | |
- (id)initWithRunLoop:(CFRunLoopRef)runLoop; | |
/// Initializes the receiver to detect when the specified run loop blocks for |
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 java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import org.apache.commons.lang.StringUtils; | |
import org.apache.log4j.Logger; |
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
<html> | |
<div class="container"> | |
<div class='picture_container' id='picture1'> | |
<img class='picture' src="http://ecx.images-amazon.com/images/I/31TmE1so1SL.jpg" alt="" /> | |
</div> | |
<div class='picture_container' id='picture2'> | |
<img class='picture' src="http://ecx.images-amazon.com/images/I/615bt5a8zEL.jpg" alt="" /> | |
</div> | |
<div class='picture_container' id='picture3'> | |
<img class='picture' src="http://ecx.images-amazon.com/images/I/41si2LNmptL.jpg" alt="" /> |
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
require "openssl" | |
require "digest" | |
def aes128_encrypt(key, data) | |
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize) | |
aes = OpenSSL::Cipher.new('AES-128-CBC') | |
aes.encrypt | |
aes.key = key | |
aes.update(data) + aes.final | |
end |
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
// | |
// UIDeviceHardware.h | |
// | |
// Used to determine EXACT version of device software is running on. | |
#import <Foundation/Foundation.h> | |
@interface UIDeviceHardware : NSObject | |
- (NSString *) platform; |
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> | |
@interface BNRDiggyDict : NSObject | |
// React to object indexing. Would be nice to have a @protocol for this | |
- (id) objectForKeyedSubscript: (id) key; | |
- (void) setObject: (id) thing forKeyedSubscript: (id<NSCopying>) key; | |
// And for fun, it also can react to scalar indexing. | |
// Returns the N'th key of the top-level collection. |