Skip to content

Instantly share code, notes, and snippets.

@aodhol
aodhol / CTTelephonyNetworkInfo+ConnectionClassifier.h
Last active July 27, 2016 17:30
Classifier of Radio Access Technologies
#import "CTTelephonyNetworkInfo+ConnectionClassifier.h"
@implementation CTTelephonyNetworkInfo (ConnectionClassifier)
// Naive implementation.
- (BOOL)isFast:(NSString*)radioAccessTechnology {
if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
return NO;
} else if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
#!/bin/sh
# Shell file to run X3D-Edit 3.2
# First make sure we're running 1.6, will bomb if not
source `dirname $0`/javaVersionCheck.sh
# Memory settings for X3D-Edit 3.2: see ReadmeX3D-EditMemorySettings.txt
# The default settings for a zipped app exist in x3deditor32/etc/x3deditor32.conf
# The stack (-Xss2m) setting is under evaluation and may need
# increasing because of recursive routines in XML and XSLT processing.
NSDictionary *rabbits = @{@"name": @"Bugs", @"color":@"#777"};
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:rabbits
options:NSJSONWritingPrettyPrinted
error:&error];
NSLog(@"Pretty Printed JSON:%@", [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
// Returns true if array contains a String matching the specified regular expression pattern
extension SequenceType where Generator.Element == String {
func matches(pattern: String) -> Bool {
for item in self {
if (item.rangeOfString(pattern, options: .RegularExpressionSearch) != nil) {
return true
}
}
return false
}
import Mapbox
// MGLPointAnnotation subclass
class MyCustomPointAnnotation: MGLPointAnnotation {
var willUseImage: Bool = false
}
class MyCustomPointAnnotationView: MGLAnnotationView {
static let reuseIdentifier = String(describing: MyCustomPointAnnotationView.self)
import UIKit
class Animal: Codable {
var say: String?
private enum CodingKeys : String, CodingKey {
case say
}