background preloader

Cloud9 - Your code anywhere, anytime

Cloud9 - Your code anywhere, anytime

The Tapir's Tale: A Not Very Short Introduction To Node.js Node.js is a set of asynchronous libraries, built on top of the Google V8 Javascript Engine. Node is used for server side development in Javascript. Do you feel the rush of the 90's coming through your head. It is not the revival of LiveWire, Node is a different beast. The graph for memory usage is even better. Read more about it at the Web Faction Blog OK, so what's the catch? // Synchronous var result = db.query("select * from T"); // Use result // Asynchronous db.query("select * from T", function (result) { // Use result }); So, all libraries that deal with IO has to be re-implemented with this style of programming. History Node is definitely not the first of its kind. Twisted appeared in Python (2002) and EventMachine in Ruby (2003). This year a couple of newcomers appeared. Goliath, which builds on EventMachine, and uses fibers to allow us to program in an synchronous style even though it is asynchronous under the hood. Get Started When invoked with a script it runs the script. Networking

npm registry npm registry all tags author updated depended on 1 statestream 4push 1 push-node 4sq 2 node-foursquare node-foursquare-2 abstraction 1 simple-dynamo actors 1 actors adventure 1 mingy 2 cryptojs ezcrypto algorithm 2 jshashes random-tools alignment 1 samreader amazon 4 cqs s3ncrypted_proxy simple-dynamo static-plus Amazon 4 bezos hoover mturk mws amd 1 interleave anti-spam 1 defensio api 21 diffbot directvps dnsimple giantbomb-api groupon interstate mollie njive node-prowl nodequote pinboard plumbdb plummet push-node revrise sellmate-utils sphinxapi spotifyapi ubersmith youtube-feeds zootool 5 bezos hoover mturk mws vows-ext api client 1 phonegapbuildapi append 1 append appnotifications archive 1 download arithmetic 1 bigdecimal array 3 RandomSelection arrayemitter clone article 1 diffbot assert 1 node-arse async 4 dive grain junjo relay asyncworkflow 1 drtoms-nodehelpers atom 3 atom-writer atomize feedreader audit 1 audit_couchdb auth 2 lox simple-auth authentication 3 authhmac lox simple-auth automation avectra 1 xfuse aws 2 cqs simple-dynamo db

Express - node web framework Getting started With node installed (download), get your first application started by creating a directory somewhere on your machine: $ mkdir hello-world In this same directory you'll be defining the application "package", which are no different than any other node package. You'll need a package.json file in the directory, with express defined as a dependency. Now that you have a package.json file in this directory you can use npm(1) to install the dependencies, in this case just Express: $ npm install Once npm finishes you'll have a localized Express 3.x dependency in the . $ npm ls hello-world@0.0.1 /private/tmp └─┬ express@3.0.0beta7 ├── commander@0.6.1 ├─┬ connect@2.3.9 │ ├── bytes@0.1.0 │ ├── cookie@0.0.4 │ ├── crc@0.2.0 │ ├── formidable@1.0.11 │ └── qs@0.4.2 ├── cookie@0.0.3 ├── debug@0.7.0 ├── fresh@0.1.0 ├── methods@0.0.1 ├── mkdirp@0.3.3 ├── range-parser@0.0.4 ├─┬ response-send@0.0.1 │ └── crc@0.2.0 └─┬ send@0.0.3 └── mime@1.2.6 Now to create the application itself! Then fire it up!

Yahoo présente un module node.js pour YSlow Aujourd'hui dans l'analyse des performances des pages Webs, il y a deux outils qui sont majoritaires : Google Page Speed et YSlow (de Yahoo). Ces deux outils s'utilisaient soit sur le web ou avec un plugin dans le navigateur. Mais dorénavant, il sera désormais possible d'utiliser YSlow en ligne de commande grâce à la release (en bêta) d'un module node.js... Comme c'est un module node.js, l'installation se fait en deux secondes avec une simple commande grâce à NPM : Une fois l'installation terminée, vous pouvez utiliser le module directement dans votre terminal en fournissant un fichier har ou en intégrant le module YSlow dans une application qui par exemple stockerait des résultats de performances dans une base. Imaginons que je veuille revoir le résultats d'un test que j'avais sauvegardé au format har au cours du mois de juillet. Le résultat de la commande est en JSON (ce qui est parfait pour insérer les données dans une base mongoDB) et contient les informations suivantes :

NoSQL Databases and Node.js In recent years, non-relational DBMSs have reemerged with proponents’ claiming advantages in scalability and simplicity. Many of these DBMSs now exist targeted towards a variety of usage scenarios. They are popularly referred to as NoSQL databases. Authors: Mike Cantelon and TJ Holowaychuk This article is based on “Node.js in Action“, to be published in April 2012. In the early days of the database world, non-relational databases were the norm. Redis Redis is a data store well-suited for handling simple, relatively ephemeral data such as logs, votes, and messages. The most mature and actively developed Redis API module is Matt Ranney’s node_redis module. The following code establishes a connection to a Redis server, using the default TCP/IP port, running on the same host. client.on(‘error’, function (err) { console.log(‘Error ‘ + err); }); Listing 1 shows the storage and retrieval of values in a slightly more complicated data structure: the hash. Big O Notation MongoDB Mongoose Summary

Modules · joyent/node Wiki This page is deprecated. Feel free to add to it, but be advised that it is, at best, a faded relic of Node modules that were written before npm was a dominant force in the Node.js ecosystem. It is not all that useful any more. If you are a newcomer, it can be handy to at least get a starting point. So, this list is long enough to be intimidating, but still only captures a tiny sliver of the Node.js modules you can use with your program. Search for modules with, node-modules, node-toolbox and nipster. The archaic contents of this once-useful page now follow. Adding to this page When you add a framework to this page, have a look at how others have done so, it should be a single item, with a link to the project's source code, and a short description (one line after formatting has been applied). If you see a module without a description, feel free to edit the page and add it in, any contributions are appreciated. Table of contents Modules Web frameworks Routers Static file servers

Node.JS + WebSocket = near real offline/online check « Simple API The problem is well know : the online/offline state is not reliable on many browser, this create a difficult situation for developers who wants to create an offline solution : if you don’t know when the client is online or offline, this became difficult to manage (for example) a local backup before having a new connection. Note : if you already use, you can combine with existing one, because here I only use basic event from (in this case, you only need the client part). With this simple trick on client side and server side, I was able to manage (at +/- 5sec) a good online/offline test : Server : Here I use console from previous page here but if you don’t want, just replace "cs." by "console." Just pass a to this module like this : That’s all, we create in fact a basic (most basic one), ping system from : this system got nothing except connect/disconnect event, which is enough for us in this case. Client : Like this: J'aime chargement…

The Naked Technologist » and Node.js Article Now Available in August JSMag Understanding the node.js event loop So the largest waste with current programming technologies comes from waiting for I/O to complete. There are several ways in which one can deal with the performance impact (from Sam Rushing): The second basis thesis is that thread-per-connection is memory-expensive: [e.g. that graph everyone showns about Apache sucking up memory compared to Nginx] Apache is multithreaded: it spawns a thread per request (or process, it depends on the conf). You can see how that overhead eats up memory as the number of concurrent connections increases and more threads are needed to serve multiple simulataneous clients. Nginx and Node.js are not multithreaded, because threads and processes carry a heavy memory cost. There is no way of making code run in parallel within a single request. If you do that in one request, other requests can be processed just fine while the database is running it's sleep. Of course, on the backend, there are threads and processes for DB access and process execution. E.g. Ed, ed