Skip to content

Instantly share code, notes, and snippets.

View xavierjurado's full-sized avatar

Xavier Jurado xavierjurado

View GitHub Profile
class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
let htmlString = """
<a style="text-decoration:none; font-weight:bold;" href="https://verse.me/en/faq">How Verse takes care of your money</a>
"""
let textView = ExternalLinkTextView(htmlString: htmlString)
view.addSubview(textView)
@xavierjurado
xavierjurado / NSMutableAttributedString.swift
Created May 16, 2018 12:57
Adds a link to a URL for a specified text/range
extension NSMutableAttributedString {
/**
Transforms the given text into a tappable link
- parameters:
- url: the destination url
- text: the substring that should be made tappable
- attributes: optional dictionary of parameters to customize the link's appearance
*/
@xavierjurado
xavierjurado / ViewController.m
Created November 7, 2015 14:25
On how MKAnnotationView works with autolayout
//
// ViewController.m
// AnnotationHell
//
// Created by Xavier Jurado on 07/11/15.
// Copyright © 2015 Xavier Jurado. All rights reserved.
//
#import <MapKit/MapKit.h>
#import <Masonry/Masonry.h>
@xavierjurado
xavierjurado / file.m
Created November 21, 2013 15:33
Helper function to calculate the region needed to show a number of POIs
// Helper function to calculate the region needed to show a number of POIs
MKCoordinateRegion RegionForAnnotations (NSArray *records)
{
MKCoordinateRegion region;
// center the map arround our records
// @see https://devforums.apple.com/message/48525#48525
double minLatitude = [[records valueForKeyPath:@"@min.latitude"] doubleValue];
double maxLatitude = [[records valueForKeyPath:@"@max.latitude"] doubleValue];
@xavierjurado
xavierjurado / gist:3138813
Created July 18, 2012 20:53
Gitlab Gmail configuration

Gitlab Gmail configuration

In Gitlab 2.6 you must edit the following files in order to send messages through a Gmail account (also applicable to Google Apps accounts).

config/environments/production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
@xavierjurado
xavierjurado / gist:3121573
Created July 16, 2012 08:39
Batch convert iPhone optimized PNG images to standard PNG images
find <path_to_source_directory> -name "*.png" -exec /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -d /tmp -q -revert-iphone-optimizations {} \;