As easy as 1, 2, 3!
Updated:
- Aug, 08, 2022 update configdocs for npm 8+
- Jul 27, 2021 add private scopes
- Jul 22, 2021 add dist tags
- Jun 20, 2021 update for --access=public
- Sep 07, 2020 update docs for npm version
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby | 
| var util = require('util') | |
| function hook_stdout(callback) { | |
| var old_write = process.stdout.write | |
| process.stdout.write = (function(write) { | |
| return function(string, encoding, fd) { | |
| write.apply(process.stdout, arguments) | |
| callback(string, encoding, fd) | |
| } | 
| IO.popen('ant run') do |io| | |
| while (line = io.gets) do | |
| puts line | |
| end | |
| end | 
| exports.ext = function () { | |
| var extTypes = { | |
| "3gp" : "video/3gpp" | |
| , "a" : "application/octet-stream" | |
| , "ai" : "application/postscript" | |
| , "aif" : "audio/x-aiff" | |
| , "aiff" : "audio/x-aiff" | |
| , "asc" : "application/pgp-signature" | |
| , "asf" : "video/x-ms-asf" | |
| , "asm" : "text/x-asm" | 
| (env)~/env pip install pycurl | |
| Downloading/unpacking pycurl | |
| Downloading pycurl-7.19.0.tar.gz (71Kb): 71Kb downloaded | |
| Running setup.py egg_info for package pycurl | |
| sh: curl-config: not found | |
| Traceback (most recent call last): | |
| File "<string>", line 14, in <module> | |
| File "/home/eric/env/build/pycurl/setup.py", line 90, in <module> | |
| raise Exception, ("`%s' not found -- please install the libcurl development files" % CURL_CONFIG) | |
| Exception: `curl-config' not found -- please install the libcurl development files | 
| // see http://d.hatena.ne.jp/ashigeru/20090113/1231855642 | |
| var calc = { | |
| add: function (node) { | |
| return visit(this, node.l) + visit(this, node.r); | |
| }, | |
| sub: function (node) { | |
| return visit(this, node.l) - visit(this, node.r); | |
| }, | |
| val: function (node) { | 
| // Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp. | |
| // Captures within lookbehind are not included in match results. Lazy | |
| // repetition in lookbehind may lead to unexpected results. | |
| (function (XRegExp) { | |
| function prepareLb(lb) { | |
| // Allow mode modifier before lookbehind | |
| var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb); | |
| return { | 
| / A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails | |
| / Useful when using tools like LiveReload http://livereload.com/ | |
| / but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials) | |
| / It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973 | |
| / Check out the Jade version https://gist.github.com/2593727 | |
| %html | |
| %body | |
| %header | |
| = Haml::Engine.new(File.read('/path/to/your/partial.haml')).render | 
| var p1 = { | |
| x: 20, | |
| y: 20 | |
| }; | |
| var p2 = { | |
| x: 40, | |
| y: 40 | |
| }; |