If you're building an Elixir DSL that has this form:
some_macro "title" do
some "functions"
that "are"
called "one"
after "another"
but "build"
a "structure"
If you're building an Elixir DSL that has this form:
some_macro "title" do
some "functions"
that "are"
called "one"
after "another"
but "build"
a "structure"
@function short-prefix($prefix) { | |
@if $prefix == 'margin' { | |
@return 'm'; | |
} | |
@elseif $prefix == 'padding' { | |
@return 'p'; | |
} | |
} | |
@function short-direction($direction) { |
let router = Ember.getOwner(this).lookup('router:main') | |
let queryParams = router.currentState.routerJsState.queryParams; |
import Ember from 'ember'; | |
const EachRecordComponent = Ember.Component.extend({ | |
tagName: '', | |
savedRecords: Ember.computed.filterBy('records', 'isNew', false) | |
}); |
has_many :tokens, as: :tokenable, dependent: :destroy |
#if DEBUG | |
func dLog(message: AnyObject, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
NSLog("%@", "[\(filename):\(line)] \(function) - \(message)") | |
} | |
func uLog(message: AnyObject, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
let message = NSString(format: "%@", "\(function) - \(message)") as String | |
let alertView = UIAlertView(title: "[\(filename):\(line)]", message: message, delegate:nil, cancelButtonTitle:"OK") | |
alertView.show() | |
} |
So dumb. If you're trying to use boundingRectForGlyphRange…
or lineFragmentRectForGlyphAtIndex…
on a UITextView's
NSLayoutManager, you will get slightly wrong coordinates if the text is longer than a few thousand characters.
…until you:
textView.layoutManager.allowsNonContiguousLayout = false
Then it works perfectly.
import UIKit | |
extension UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
assert(red >= 0 && red <= 255, "Invalid red component") | |
assert(green >= 0 && green <= 255, "Invalid green component") | |
assert(blue >= 0 && blue <= 255, "Invalid blue component") | |
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0) | |
} |
import Foundation | |
public class Promise<T> { | |
public typealias PromiseSuccessBlock = (result: T) -> Void | |
public typealias PromiseFailureBlock = (error: NSError?) -> Void | |
public typealias PromiseAlwaysBlock = () -> Void | |
private(set) var successBlocks = [PromiseSuccessBlock]() | |
private(set) var failureBlocks = [PromiseFailureBlock]() |
// | |
// Q.swift | |
// Created by Adam Kirk on 6/6/15. | |
// | |
import Foundation | |
public typealias QBlock = () -> Void | |
func serialQueueWithName(name: String) -> NSOperationQueue { |