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
package main | |
import ( | |
"os" | |
"text/template" | |
) | |
type Person struct { | |
Name string | |
} |
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
package main | |
import "fmt" | |
type User struct { | |
FirstName, LastName string | |
} | |
func (user *User) Name() string { | |
return fmt.Sprintf("%s %s", user.FirstName, user.LastName) |
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 UIKit | |
class CustomView: UIView { | |
let text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiu |
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
let label = UILabel() | |
let string = "by " as NSString | |
let attributedText = NSMutableAttributedString(string: string, attributes: [ | |
NSFontAttributeName: UIFont(name: "HelveticaNeue-Medium", size: 13)!, | |
NSForegroundColorAttributeName: UIColor(white: 0.2, alpha: 1) | |
]) | |
attributedText.setAttributes([ |
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 UIKit | |
class TitleView: UIView { | |
lazy var avatar: UIImageView = { | |
let view = UIImageView() | |
view.setTranslatesAutoresizingMaskIntoConstraints(false) | |
view.layer.cornerRadius = 5 | |
view.layer.masksToBounds = true |
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
let HTMLString: NSString = "<p>Hello, World!</p>" | |
let text = NSAttributedString(data: HTMLString.dataUsingEncoding(NSUnicodeStringEncoding), options: [ | |
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType | |
], documentAttributes: nil, error: nil)?.string // {Some "Hello, World!\n" | |
label.text = text | |
label.font = UIFont.boldSystemFontOfSize(14) |
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 longPress(cell: TableViewCell, recognizer: UILongPressGestureRecognizer) { | |
let location = recognizer.locationInView(tableView) | |
let indexPath = tableView.indexPathForCell(cell) | |
switch recognizer.state { | |
case .Began: | |
sourceIndexPath = indexPath | |
// Take a snapshot of the selected row using helper method. | |
snapshot = customSnapshotFromView(cell) |
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
// | |
// BackgroundView.swift | |
// Quiz | |
// | |
// Created by Damien D on 09/09/2014. | |
// Copyright (c) 2014 Damien D. All rights reserved. | |
// | |
import UIKit |
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 UIKit | |
class PlayViewController: UIViewController { | |
var label: UILabel? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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 Expert < ActiveRecord::Base | |
include Notifiable | |
has_many :trackings do | |
def recent | |
where('created_at >= ?', proxy_association.owner.notified_at) | |
end | |
end | |
end |