(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.
(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.
| # Thanks to http://makandracards.com/makandra/1431-resque-+-god-+-capistrano for an idea and v2 version. | |
| namespace :god do | |
| def god_is_running | |
| capture(:bundle, "exec god status > /dev/null 2>&1 || echo 'god not running'") != 'god not running' | |
| end | |
| # Must be executed within SSHKit context | |
| def config_file | |
| "#{release_path}/config/god.rb" |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>PageView Grid</title> | |
| <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script> | |
| <script> | |
| var Keen=Keen||{configure:function(e){this._cf=e},addEvent:function(e,t,n,i){this._eq=this._eq||[],this._eq.push([e,t,n,i])},setGlobalProperties:function(e){this._gp=e},onChartsReady:function(e){this._ocrq=this._ocrq||[],this._ocrq.push(e)}};(function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://":"http://")+"dc8na2hxrj29i.cloudfront.net/code/keen-2.1.0-min.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})(); | |
| Keen.configure({ | |
| projectId: "<your-projectId>", |
| class Point | |
| constructor: (@x = 0, @y = 0) -> | |
| if isNaN(@x) or isNaN(@y) | |
| throw new Error('Invalid coords') | |
| add: (point) -> | |
| @x += point.x | |
| @y += point.y | |
| subtract: (point) -> |
| class A | |
| class << self | |
| def add(ele) | |
| @array ||= [] | |
| @array << ele | |
| end | |
| def array | |
| @array ||= [] | |
| end |
| Ruby 1.9.3-p392 | |
| =========================================================== | |
| All memory used before 1st run - 7 MB | |
| Memory consumed by 1st run of eat_up_memory - 445 MB | |
| All memory used before 2nd run - 452 MB | |
| Memory consumed by 2nd run of eat_up_memory - 20 MB | |
| All memory used before 3rd run - 472 MB | |
| Memory consumed by 3rd run of eat_up_memory - 5 MB | |
| Memory used before explicit GC.start - 478 MB | |
| Memory used after explicit GC.start - 284 MB |
| gifify() { | |
| if [[ -n "$1" ]]; then | |
| if [[ $2 == '--good' ]]; then | |
| ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
| time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
| rm out-static*.png | |
| else | |
| ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
| fi | |
| else |
| data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script> |