This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
| /** | |
| * Watcher leaks for jQuery | |
| * RubaXa <trash@rubaxa.org> | |
| * MIT Licensed. | |
| * | |
| * API: | |
| * $.leaks.get(); | |
| * $.leaks.watch(); | |
| * $.leaks.unwatch(); | |
| * $.leaks.remove(); |
| /** | |
| * jQuery extension, add support `scrollstart` and `scrollend` events. | |
| * | |
| * @author RubaXa <trash@rubaxa.org> | |
| * @github https://gist.github.com/RubaXa/5568964 | |
| * @license MIT | |
| * | |
| * | |
| * @settings | |
| * $.special.scrollend.delay = 300; // default ms |
| $ = jQuery | |
| queues = {} | |
| running = false | |
| queue = (name) -> | |
| name = 'default' if name is true | |
| queues[name] or= [] | |
| next = (name) -> |
| /** | |
| * @author RubaXa <trash@rubaxa.org> | |
| * @license MIT | |
| */ | |
| (function () { | |
| "use strict"; | |
| function _then(promise, method, callback) { | |
| return function () { |
| /** | |
| * User Timing polyfill (http://www.w3.org/TR/user-timing/) | |
| * @author RubaXa <trash@rubaxa.org> | |
| */ | |
| (function (window){ | |
| var | |
| startOffset = Date.now ? Date.now() : +(new Date) | |
| , performance = window.performance || {} | |
| , _entries = [] |
| var _hasOwn = Object.prototype.hasOwnProperty; | |
| var _toString = Object.prototype.toString; | |
| var _hasGOPD = typeof Object.getOwnPropertyDescriptor === 'function'; | |
| var _hasDP = typeof Object.defineProperty === 'function'; | |
| function _getOwnPropertyDescriptor(obj, prop) { | |
| if ( _hasGOPD ) { | |
| return Object.getOwnPropertyDescriptor(obj, prop) | |
| } | |
| else { |
| /** | |
| * Микро обертка для выполенения XHR-запросов | |
| * @namepace window.xhr | |
| * @example | |
| * xhr.load('/path/to', {type: 'POST'}, function (err, xhr) { | |
| * // ... | |
| * }); | |
| */ | |
| (function (global) { | |
| 'use strict'; |
| // 1. var | |
| var name = 'name'; | |
| var i, length; | |
| var j = 0; | |
| // 2. var | |
| var name = 'name'; | |
| var i; | |
| var j = 0; | |
| var length; |
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.