Skip to content

Instantly share code, notes, and snippets.

Jaison Vieira jaisonv

Block or report user

Report or block jaisonv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jaisonv
jaisonv / test_helper.rb
Created May 15, 2015
MiniTest reporters - Rails tests show red and green
View test_helper.rb
require "minitest/reporters"
Minitest::Reporters.use!
@jaisonv
jaisonv / ViewController.m
Last active Aug 29, 2015
Circular ImageView
View ViewController.m
myImageView.layer.cornerRadius = myImageView.frame.size.width / 2;
myImageView.clipsToBounds = YES;
@jaisonv
jaisonv / ViewController.m
Last active Aug 29, 2015
Beautiful border to ImageView
View ViewController.m
myImageView.layer.borderWidth = 3.0f;
myImageView.layer.borderColor = [UIColor whiteColor].CGColor;
@jaisonv
jaisonv / ViewController.m
Last active Aug 29, 2015
Rounded ImageView
View ViewController.m
myImageView.layer.cornerRadius = 10.0f;
@jaisonv
jaisonv / TableViewController.swift
Last active Aug 29, 2015
Resize cell height based on content
View TableViewController.swift
tableView.estimatedRowHeight = 100 // estimated value for cell height
tableView.rowHeight = UITableViewAutomaticDimension
View TableViewController.swift
// first enable "Refreshing" on controller via storyboard
override func viewDidLoad() {
super.viewDidLoad()
// the value for "action" must mach the function's name
refreshControl?.addTarget(self, action: "reloadStuff", forControlEvents: UIControlEvents.ValueChanged)
}
func reloadStuff() {
@jaisonv
jaisonv / ViewController.swift
Created Jul 5, 2015
Go back to the last view controller
View ViewController.swift
navigationController?.popViewControllerAnimated(true)
@jaisonv
jaisonv / RegexExample.swift
Created Oct 2, 2015
Working with regex in Swift
View RegexExample.swift
let text = "Text to get the match"
let regex = NSRegularExpression(pattern: "([^ ]+)", options: nil, error: nil)!
let matches = regex.matchesInString(text, options: nil, range: NSRange(location: 0, length: count(text)))
var substring = ""
for match in matches as! [NSTextCheckingResult] {
// range at index 0 returns the full match
// range at index 1 returns the first capture group
// range at index 2 returns the second capture group and so on...
@jaisonv
jaisonv / Info.plist
Created Jan 19, 2016
Make status bar font white
View Info.plist
View controller-based status bar appearance = NO
Status bar style = UIStatusBarStyleLightContent
@jaisonv
jaisonv / ImageScaled.m
Last active Apr 13, 2016
Scale image based in a width
View ImageScaled.m
-(UIImage *)scaleImage:(UIImage *)image toWidth:(int)width {
// determine the scaling factor to fit the screen width
CGFloat oldWidth = image.size.width;
NSUInteger newWidth = (width - 10);
CGFloat scaleFactor;
if (oldWidth > newWidth)
scaleFactor = oldWidth / newWidth;
else
You can’t perform that action at this time.