Posts

TECH-COFFEE - Webpack - How to set up a Dev Server

//English Hi guys, this will be my third Tech Coffee! Yay! and I want to share with you something really amazing: How to set up a Dev Server using Webpack...I really like this feature, because now, I don't need some tool like Gulp or Grunt to set up a Server with Livereload, because Webpack give us that feature too! I'm pretty excited with this, so, give it a look... //Español Hola chavos, este es mi tercer Tech Coffee! Si! y hoy quiero compartirles algo que para mi es realmente impresionante: Como setear un Sev Server usando Webpack...Yo en serio adoro esta funcionalidad, porque asi ya no necesito una herramienta como Gulp o Grunt para lanzar un servidor con el Livereload o algo asi, solo necesito Webpack...asi que, por favor chequenlo:

How to mock properly the services in AngularJS

Image
//English As you may know, there's a lot of posts about how to create unit tests in AngularJS, you can find a lot of results in Google, but after a long time working with Angular I found that those posts are incomplete! why? simple, they tell you how to test controllers but each post I read tell you to inject the needed services, this is wrong because what happen if the service is incomplete or maybe someone introduce a bug on the latest commit? then that unit test will fail and it will fail not because the functionality to test is failing, it will fail because a dependency that we can mock... Let's take this controller as example: Loading... https://gist.github.com/3672831a21169e9deac9.git As you can see, the controler will fetch the new values from the server, following the good practices that Ajax call will be stored in a factory or service, so the controller will do what a controller should do: just be the "glue" between the view and the model :) N...

NICE NODE MODULES! - Rest Facade

//English Hi guys, yesterday I was playing a little bit with a module that I saw on Twitter : Rest Facade ! Basically this module abstracts the process of consuming REST endpoints! I don't need to explain you too much about it, because its documentation is pretty much straight forward, please see below the code of the examples that I did: Loading... https://gist.github.com/92db9047ca5d8d07ae44.git As you can see, even if you don't read the documentation, you can understand pretty well the code. To see this example working, you can go to my c9 , the same code is there, you just need to run it as we normally do on node =D. NOTE : You can check the same code on my Github Well guys, if you have doubts, please let me know, I'm going to do my best to answer :) //Español Hola! ayer estuve jugando un poco con un nuevo modulo que vi en Twitter : Rest Facade ! Basicamente este modulo encapsula el proceso de consumir REST APIs La verdad es que no necesito e...

Webpack Overview

Image
//English Hi guys, since the last weeks I've been trying something different than the usual, you may know that I love gulpJS, but I found a new "task-runner": Webpack! <!-- WTF is Webpack? --> To be honest, Webpack isn't a "task-runner", It's a module bundler. What this means is that Webpack takes your src code and transforms it into one single file which has all your src code organized as you have but improving the repeating calls, requires, imports, etc. Why is this important? well the heavier your files are, the more time it takes to download and render your website. Webpack is meant to be a single module bundler for all your Web Apps. This means that you only need Webpack, not anything else, for instance: You have an SPA that needs Angular to work but instead of using purely JS, you decide to use coffeescript, then you can use gulp and create a task called: bundle-js and add the proper pipes, right? Well with Webpack, this process i...

Node JS - Error Handling

Image
//English Hi Guys, today I want to talk about the Error Handling on NodeJS, so far there's no way to handle the errors properly on Node. There are certain techniques, I'm going to touch on a couple of them in this post, but these techniques are unstable for now. But they still work, maybe in future releases Joyent will change these specifications or at least some of them. <!-- Bad way or the way we used to do it... --> Usually we catch the error on the process of our application, we do something like this: 1 2 3 process . on ( 'uncaughtException' , function ( err ){ //Let's handle the error... }) But, what are we doing wrong? We are following what Joyent says, If something unexpected happens, we should catch it and handle the error properly...The problem here is that we are catching the error at the process level, so if you have some async process running in background and one of them throws an error, it will break the entire applicati...

Currying - JavaScript

//English <!-- What is currying? --> Currying is when you break a complex function into a serie of functions. It means that if you have a function that takes 2 arguments, you can break it into 2, each one will receive one parameter, something like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 //Complex Function function greetingsComplex(msg,name){ console.log(msg + ', ' + name); } //Simple Function function greetingsEasy(msg){ return function (name){ console.log(msg + ', ' + name); } } greetingsComplex( 'Hello' , 'Carlos' ); greetingsComplex( 'Hello' , 'Ulises' ); greetingsComplex( 'Hello' , 'Hector' ); var greetings = greetingsEasy( 'Hello' ); greetings( 'Carlos' ); greetings( 'Ulises' ); greetings( 'Hector' ); As you can see above, it's easier to understand the easiest way t...

JUST FOR FUN - Space Invaders purely JS/CSS

//English Hi guys, today I want to share with you something that I did during my leisure time: Space Invaders with Javascript! Please feel free to see it in action on my plunker . //Español Hola chavos, hoy quiero compartir con ustedes algo que realize en mi tiempo de ocio: Space Invaders con Javascript! Por favor vayan a verlo en acción y diviértanse en mi plunker .