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
def algo(env) | |
data_raw = open('http://spreadsheets.google.com/tq?key=0AsTunpthKrMxdEp5R1loYjBBcVhNQWVEc1BUZmZ1QUE&pub=1') | |
data = data_raw.read | |
data = data.split('(')[1].split(")")[0] | |
data = data.gsub("'", '"') | |
data = data.gsub(/([a-z]+):/, '"\1":') | |
result = JSON.parse(data) |
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 "open-uri" | |
require "json" | |
class RuteoApp | |
def batman(env) | |
[200, {"Content-Type" => "text/plain"}, "El Guason"] | |
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
func centerMapWithCoords(coordsArr:[CLLocationCoordinate2D]){ | |
var zoomRect:MKMapRect = MKMapRectNull; | |
for coord:CLLocationCoordinate2D in coordsArr { | |
var annotationPoint: MKMapPoint = MKMapPointForCoordinate(coord) | |
var pointRect:MKMapRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0) | |
zoomRect = MKMapRectUnion(zoomRect, pointRect) | |
} | |
mapView.setVisibleMapRect(zoomRect, edgePadding:UIEdgeInsetsMake(150, 30, 30, 30), animated:false) |
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
func setupBackButton(){ | |
var count: Int? = navigationController?.viewControllers.count | |
if count > 0 && navigationItem.leftBarButtonItem == nil{ | |
if !(navigationController?.viewControllers.first === self) { | |
self.navigationItem.leftBarButtonItem = HSAppearance.barButtonWithTitle("BACK", image:UIImage(named:"ArrowLeft"), target: self, action: "HSBackAction:") | |
} | |
} | |
} | |
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
class func getAddressFromCoords(coords:CLLocationCoordinate2D, complete:(location:Location?, error:NSError?)->()){ | |
var url = "http://maps.googleapis.com/maps/api/geocode/json" | |
var str = String(format: "%f",coords.latitude) + "," + String(format:"%f",coords.longitude) | |
var params = ["latlng":str, "sensor":true] | |
AFHTTPRequestOperationManager().GET(url, parameters: params, success: { (operation:AFHTTPRequestOperation!, response:AnyObject!) -> Void in | |
let json:JSON = JSON(response) | |
var loc = Location(dictionary: json) |
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
post_install do |installer| | |
installer.pods_project.targets.each do |target| | |
target.build_configurations.each do |config| | |
config.build_settings['SWIFT_VERSION'] = '3.0' | |
end | |
end | |
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
//transform array from objectMapper parsing to Realm List | |
public class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType { | |
public typealias Object = List<T> | |
public typealias JSON = Array<Any> | |
public init(){ | |
} | |
public func transformFromJSON(_ value: Any?) -> List<T>? { | |
let result = List<T>() |
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 ObjectMapper | |
import RealmSwift | |
open class BaristaISO8601DateTransform: TransformType { | |
public typealias Object = Date | |
public typealias JSON = String | |
let dateFormatter: DateFormatter = DateFormatter() | |
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
public extension UIView { | |
/** | |
Convert current view to image | |
:returns: return the image | |
*/ | |
public func convertToImage() -> UIImage { | |
UIGraphicsBeginImageContext(self.bounds.size); | |
self.layer.render(in: UIGraphicsGetCurrentContext()!) | |
let viewImage = UIGraphicsGetImageFromCurrentImageContext() |
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
func formatFrom(_ value:String) -> (dateString:String?, dateFormat:String?) { | |
var regexString = "\\A(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})" // Mandatory - YYYY-MM-DDTHH:mm | |
regexString = regexString + ":?(\\d{2})?" // Optional - :ss | |
regexString = regexString + "[.]?(\\d{1,6})?" // Optional - .nnnnnn | |
regexString = regexString + "([+-])?(\\d{2})?:?(\\d{2})?|Z" // Optional -[+-]hh:mm or Z | |
regexString = regexString + "\\z" | |
let regex: NSRegularExpression? | |
var matchesResult: [NSTextCheckingResult]? |
OlderNewer