background preloader

Node.js

Facebook Twitter

Object Relational Mapping by dresende. Install.

Object Relational Mapping by dresende

Convert JSON string to array of JSON objects in Javascript. Node.js - node js restler result "get" not complete when trying to return result. Getting HTTP Response using restler in Node.js. Danwrong/restler. Restler. An HTTP client library for node.js npm install restler Want to see pretty graphs?

restler

Log in now! Read Me (C) Dan Webb (dan@danwebb.net/@danwrong) 2011, Licensed under the MIT-LICENSE. Node.js - How to post data using node-curl? More Responsive Single-Page Applications With AngularJS & Socket.IO: Creating the Library. Neither HTML nor HTTP were created for dynamic web applications.

More Responsive Single-Page Applications With AngularJS & Socket.IO: Creating the Library

We basically rely on hacks, on top of hacks to give our apps a responsive user interface. AngularJS removes some limitations from HTML, allowing us to create and manage user-interface code easier. Socket.IO, on the other hand helps us send data from the server not only when client requests it, but also when the server needs to. Creating RESTful APIs with Express 4. Real-Time Chat With Node.js' Readline & Socket.io. Node.js has an under-appreciated module in its standard library that is surprisingly useful.

Real-Time Chat With Node.js' Readline & Socket.io

The Readline module does what it says on the box: it reads a line of input from the terminal. This can be used to ask the user a question or two, or to create a prompt at the bottom of the screen. In this tutorial, I intend to show off the capability of Readline and make a real-time CLI chatroom backed by Socket.io. The client will not only send simple messages, but have commands for emotes with /me, private messages with /msg, and allow for nicknames to be changed with /nick. This is probably the simplest usage of Readline: We include the module, create the Readline interface with the standard input and output streams, then ask the user a one-off question. The other functionality that Readline provides is the prompt, which can be customized from its default ">" character and temporarily paused to prevent input.

Let's start with the boring part: dependencies. 7. Control flow in Node.js - Mixu's Node book. In this chapter, I: discuss nested callbacks and control flow in Node introduce three essential async control flow patterns: Series - for running async tasks one at a time Fully parallel - for running async tasks all at the same time Limitedly parallel - for running a limited number of async tasks at the same time walk you through a simple implementation of these control flow patterns and convert the simple implementation into a control flow library that takes callback arguments When you start coding with Node.js, it’s a bit like learning programming the first time.

7. Control flow in Node.js - Mixu's Node book

Since you want everything to be asynchronous, you use a lot of callbacks without really thinking about how you should structure your code. It’s a bit like being overexcited about the if statement, and using it and only it to write complex programs. Tutorial - Getting Started With Node.js, Express, MongoDB. Creating a Simple RESTful Web App with Node.js, Express, and MongoDB. Node.js - Nodejs throwing TypeError('first argument must be a string, Array, or Buffer'); Dresende/node-orm2. Querying MySQL with Node.js. POST to PHP from Node.js. How to Create a Resumable Video Uploader in Node.js.

If you've ever uploaded a considerably large video file, then you know this feeling: you're 90% done, and accidentally refresh the page - having to start all over again.

How to Create a Resumable Video Uploader in Node.js

In this tutorial, I'll demonstrate how to make a video uploader for your site that can resume an interrupted upload, and generate a thumbnail upon completion. Intro To make this uploader resumable, the server needs to keep track of how much a file has already been uploaded, and be able to continue from where it left off. To accomplish this task, we will give full control to the Node.js server to request specific blocks of data, and the HTML form will pickup these requests and send the necessary information to the server. To handle this communication, we'll use Socket.io. This is the basic concept; we will start with the HTML form. Step 1: The HTML I am going to keep the HTML fairly simple; all we need is an input to choose a file, a text box for the name, and a button to begin the upload. Step 2: Making it Work Conclusion. Node.js - NodeJS: How to decode base64 encoded string back to binary? Ios - How to serialize UIImage to JSON?

Ios - post image to server in iphone. Home · LearnBoost/socket.io Wiki. Base64 Encoding / Decoding in Node.js. So how do you encode a string to base64 is Node.js?

Base64 Encoding / Decoding in Node.js

Is there something easy like base64_encode() of PHP's? Node.js 'being' JavaScript, has a more logical approach to encoding strings, instead of having thousands of inconsistently defined global functions. Here is how you encode normal text to base64 in Node.js: var b = new Buffer('JavaScript');var s = b.toString('base64');// SmF2YVNjcmlwdA== And here is how you decode base64 encoded strings: var b = new Buffer('SmF2YVNjcmlwdA==', 'base64')var s = b.toString();// JavaScript If you are interested in the details of how the above examples worked, follow me. The new Buffer() constructor requires a number, array or string as the first parameter, and an optional encoding type as the second parameter.

By passing the second parameter, we tell JavaScript that "the string you see is encoded in this particular format". Once we have the encoded string, we call the toString() method on the string.