In this tutorial we're going to build a set of parser combinators.
We'll answer the above question in 2 steps.
- What is a parser?
- and, what is a parser combinator?
So first question: What is parser?
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
// This class is necessary to support "inset" (required to position placeholder appropriately | |
// in TextView) | |
// | |
class TextField: UITextField | |
{ | |
var inset: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0); | |
override func textRectForBounds(bounds: CGRect) -> CGRect | |
{ | |
return UIEdgeInsetsInsetRect(bounds, inset); |
extension String { | |
var composedCount : Int { | |
var count = 0 | |
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++} | |
return count | |
} | |
} |
import Foundation | |
extension String | |
{ | |
var length: Int { | |
get { | |
return countElements(self) | |
} | |
} | |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
source :rubygems | |
gem "puma" | |
gem "sinatra" |
## Get FFMpeg working on heroku by building binaries using vulcan | |
gem install vulcan | |
vulcan create foo | |
git clone --depth 1 git://source.ffmpeg.org/ffmpeg | |
cd ffmpeg |
An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.
Everything is broken up by tag, but within each the selectors aren't particularly ordered.
I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A
A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:
-webkit-appearance:none;