miércoles, 21 de marzo de 2012

Digging about another project that requires sending messages via D-Bus I decided to make this simple app, that shows a notification of my recent tweets (your) timeline , and with this I can be updated about what's going on twitter while you do your daily tasks ...

It was originally made​only for Linux environments, because in my work I have ubuntu, but then with the help of @dual3nigma decided port to mac and window$ using growl.

The app requires the libnotify library for Linux environments and growl for Mac / Window$, was made with Node.js and the code is available at Github where you will find all the steps to install and use.

/* post */
app.post('/users',function(req,res){
res.write('handler post: /users/ \n');
res.write('parametros en body: \n');
for(key in req.body){
res.write('\t'+key+' : '+req.body[key]+'\n');
}
res.end();
});
/* We can use put to be more semantics, like a RESTful api.
For this be use the middleware methodOverride, this
middleware check for the input _method in the body
(this input could be hidden for don't show to the
end user), and if its present tranform the post in the
_method input value and don't pass this in req.body
*/
app.put('/users',function(req,res){
res.write('handler put: /users/ \n');
res.write('parametros en body: \n');
for(key in req.body){
res.write('\t'+key+' : '+req.body[key]+'\n');
}
res.end();
});
/* delete, as in put we can use methodOverride to be
more semantic
*/
app.delete('/users',function(req,res){
res.write('handler delete: /users/ \n');
res.write('parametros en body: \n');
for(key in req.body){
res.write('\t'+key+' : '+req.body[key]+'\n');
}
res.end();
});

viernes, 9 de marzo de 2012

This series of posts, are related to the previous post node.js apps with real time which explains how to install the necessary components to develop an application with node.js + socket.IO + MongoDB.
But along the way I thought best to start with some basics, and from them be adding complexity until an application (I have not yet defined, hearing ideas...) which makes use of socket.IO for real-time interactions.

Well, let's start with a very basic introduction to Express frameworks.
This framework is widely used and perfectly combines with socket.IO, is very simple to use and brings many things "out of the box" ready to use.

The first thing we do is create the environment where we will develop this demo, we created the directory for this application and within the structure we create the following subdirectories:

They first set the directory / views as a repository of templates, for this we use a variable defined globally node.js runtime is __dirname whose value is a string with the absolute path of the directory of your app.
Then we set to "ejs" as our engine for rendering templates, so remember to install the module via npm (npm install ejs).
The final set is to establish that we will not use a layout file for this example, if we wanted we could have a database file for all of our templates or for use only for some pages.
Then we declare the Middlewares we will use the first express.bodyParser () is used for parsing of the post (either json or not) and you return the result parses the variable accessible via req.body , the following is express.methodOverride () that is important to be declared after express.bodyParser () because it performs a check on the variable req.body , this middleware is useful to override the methods of our forms, just an input field with the hidden attribute, like this:

Then we declare the use of app.router which is simply the middleware that contains all the paths defined, and performs route lookup based on the URL of the current request and the HTTP method.
And finally declare the directory from where we provide our static content express.static (__dirname + '/ public') , this allows us to access our resources (in the directory public ) directly referencing it as , note that there is no need to reference the directory public but directly we refer to directories in there

Well, with this we have our first app using node & Express, the code in this first post is on Github Posts

Yes, I had read the news that they had exploited a vulnerability that allowed update rails attributes inserting a new SSH key for more detail can read these links [0].

Therefore began an audit GitHub SSH key, for it asks that we enter the link listed above ("Please visit https://github.com/settings/ssh/audit/1767330") to approve or reject our key now ... If you have multiple keys as I uploaded to github, since different machines rub shoulders and this means that you must enter each machine and check if the ssh fingerprint is correct or not. Which brings us to what inspired me to write this post, i dont know if everyone knows how to read your fingerprint to validate the github presented to us, if do not know it I leave here a simple explanation.

The first thing to know is where is our public key, which usually is in the path ~/.ssh/ (/home/[user]/.ssh) with the name id_rsa.pub, when you have found this file must run the following command

domingo, 4 de marzo de 2012

This is a small article about how to use node.js as web server to display the results of a query to a MySQL database engine.
The first thing to do is to check is that we have installed the mysql module to run it the following:

jueves, 1 de marzo de 2012

A few days ago I finished a simple application tweetland.com.ar I made in order to learn more about Node.js and MongoDB ... on the road I also came across Socket.IO which is a great library for real time applications.
The first is to prepare the environment. To do this first download node.js (from node.js ), after downloading the installation follows the traditional steps:

./configure
make
make install *

* the last step as root
Once installed, continue with the installation of modules. For this node has npm (which is Node Package Manager) that allows us to install the modules with a single command install npm . Instructions for installing npm are in your home page, also I leave

curl http://npmjs.org/install.sh | sh

At this time we have installed both node.js as its package manager npm. Usually what I usually do is create a directory in my case I call nodeapps as workspace.
Entering the same:

cd "path to nodeapps"

and within it begin to install the modules you require. This is important because when you install the modules npm node_modules create the directory (if not there before), and install the modules in that directory.
This is important because when we do within our code something like:

var sys = require('sys');

node will automatically search the directory sys module within node_modules in the current directory and not finding it will continue with the search recursively upwards, which is always important to remember where you installed the modules that we use.

Before going further make the installation of some modules used, these are express, socket.io, mongoose.

And this is precisely the last module we will use to interact with our database MongoDB, which is an object-oriented database (JSON), high performance and scalable. (in another post I will explain a little more how it works because it is a relatively new and very interesting).
To install you have to download the appropriate version from download , and once discharged, proceed to decompress

Once unpacked and could start the service mongod and start, but I'd rather create the directory structure I will use my base, create two directories for data and logs, the first store the files of the database and the second of logs. I also create the configuration file with which I will start the service, in my case is as follows: