Skip to content

Instantly share code, notes, and snippets.

View AmitaiB's full-sized avatar

Amitai Blickstein AmitaiB

View GitHub Profile
@AmitaiB
AmitaiB / .gitignore
Last active August 29, 2015 14:25 — forked from octocat/.gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
-(void)geocodeMe {
CLGeocoder *geocoder = [CLGeocoder new];
[geocoder geocodeAddressString:@"" completionHandler:^(NSArray *placemarks, NSError *error) {
/**
* deprecated sample error message
*/
if (error)
{
// [self.latitudeTextField setText:@"Not found"];
// [self.longitudeTextField setText:@"Not found"];
@AmitaiB
AmitaiB / UIImage+FromURL.m
Last active August 29, 2015 14:28
shortens getting a UIImage from the string of a URL
#import <UIKit/UIKit.h>
@interface UIImage (FromURL)
+(UIImage*)imageWithContentsOfURLString:(NSString*)URLString;
@end
//*************************************
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}
@AmitaiB
AmitaiB / NSAttributedString+HTML.swift
Last active April 23, 2019 10:21
Extends String to created NSAttributedStrings, and vice versa, for many encoding types, including HTML and RTF.
//
// NSAttributedString+HTML.swift
//
// Created by Amitai Blickstein on 6/22/16.
// Copyright © 2016 Amitai Blickstein, LLC. All rights reserved.
//
import UIKit
////////////////////////
@AmitaiB
AmitaiB / OptionalLiteralType.swift
Created September 28, 2016 17:52
Provides failable initializers for X-Literals, e.g., `String(suspectedString) // returns a String optional`, just like `String(5) // returns a String, "5"`
/*
Instead of, say:
if let definitelyAString = perhapsAString as? String { // yadda... }
We now have:
String(perhapsAString) // returns a String? (an optional)
*/
protocol OptionalLiteralType {
@AmitaiB
AmitaiB / snake_cased.swift
Last active March 30, 2018 03:39
Turns CamelCase and lamaCase strings into snakecase aka underscorecase (Swift 3.0)
// Swift 3.0
// snake_cased
import Foundation
extension String {
mutating func snake_cased() {
self = self.snake_case()
}
func snake_case() -> String {
@AmitaiB
AmitaiB / llamaCamelCased.swift
Last active June 1, 2021 21:34
CamelCase - CamelCased and llamaCase - llamaCased extensions to String in Swift 3.0
import UIKit
// Swift 3.0
// Helper
public extension Character {
public var stringValue: String { return String(self) }
}
extension String {
// MARK: - CamelCase
@AmitaiB
AmitaiB / SwiftXOR.swift
Created November 17, 2016 04:41
Swift 3 Logical XOR Operator
precedencegroup BooleanPrecedence { associativity: left }
infix operator ^^ : BooleanPrecedence
/**
Swift Logical XOR operator
```
true ^^ true // false
true ^^ false // true
false ^^ true // true
false ^^ false // false
```
@AmitaiB
AmitaiB / UITableViewCellStyle+PlainEnglishNames.swift
Created November 28, 2016 19:12
Replaces the opaque styles 'value1' and 'value2' with 'rightDetail' and 'leftDetail' respectively.
//
// UITableViewCellExtensions.swift
// HealthBucks
//
// Created by Amitai Blickstein on 11/28/16.
// Copyright © 2016 Amitai Blickstein, LLC. All rights reserved.
//
import UIKit