viernes, 8 de agosto de 2014

Bioinformatics with R Cookbook - Book Review

I just finished reading Bioinformatics with R here's my review -:)

I was excited to read this book, because it's been a while since I read any R book...but...I gotta admit...this is not my kind of I discovered that obviously I had minus one experience in Bioinformatics...

The book is not short but not long either...340 pages...and it's full of recipes...

It starts with a basic introduction to R, which should be appreciated by newbies...but for more season developers that just can be skipped out...

The are chapters dedicated to Sequence Analysis, Protein Structure Analysis and even Machine Learning in Bioinformatics...

Of course there's a lot of new packages that are used for the recipes and well as many interesting graphics...

If you have some knowledge of Bioinformatics...then you should for sure get this book...if you're can buy it anyway...even if you don't understand is still a book about R and it's full of interesting you might end learning a bunch of new things -;)

The recipes are well explained and the result is always shown...which is good so we can know exactly what to expect...


Development Culture.

miércoles, 6 de agosto de 2014

Decimal to Romans - Erlang Style

As I keep going with my Erlang enlightenment...I decided to try to make a Decimal to Roman Numbers I have done with other programming languages in the past...and it wasn't that easy -:)

First...there's no such thing as associative arrays in can only assign variables once...on top of that there's no loops...but...who cares...functional programming is cool -;)

Of code might be have done better...but...I'm learning...and by coding I learn that's fine with me...

Here's why I wrote -;)


showRomans(Number) when is_integer(Number) ->

showRomans(0,_,Acc) ->
showRomans(Number,Counter,Acc) ->
 case Number >= element(Counter,?DECIMALS) of 
  true -> showRomans(Number - element(Counter,?DECIMALS),
         Counter,Acc ++ make_roman(element(Counter,?DECIMALS)));
  false -> showRomans(Number,Counter + 1,Acc)
make_roman(1) -> "I";make_roman(4) -> "IV";make_roman(5) -> "V";
make_roman(9) -> "IX";make_roman(10) -> "X";make_roman(40) -> "XL";
make_roman(50) -> "L";make_roman(90) -> "XC";make_roman(100) -> "C";
make_roman(400) -> "CD";make_roman(500) -> "D";make_roman(900) -> "CM";
make_roman(1000) -> "M".

When we execute it...we can see that it works nicely -;)

As you can see...Erlang is all about functions, recursion, accumulators and a new way of thinking -:)


Development Culture.

lunes, 4 de agosto de 2014

A trip down memory lane - Basic for Macintosh Plus

Many years the good old first computer was a Macintosh Plus...

Of course...back then I didn't have a clue about programming...but...thanks to the wonderful world of the Internet I was able to get my hands on a Macintosh Plus Emulator called Mini vMac.

I got it a couple of years ago but barely used today...I wanted to get the feeling of old programming by using...

Yep...Microsoft Basic 2.0 for the Mac...

This is how the environment of the Mini vMac looks like...using MacOS 7.0.1

As I have been using the LED example for many programming languages...I thought it would be a good idea to use it here as well...

The output doesn't look to good...but who cares -;)

Here's the source code in case you're interested -:D

Dim Five$(2)
Dim Six$(2)
Dim Seven$(2)
Dim Eight$(2)
Dim Nine$(2)
Zero$(0) = " _  "
Zero$(1) = "| | "
Zero$(2) = "|_| "
One$(0) = "  "
One$(1) = "| "
One$(2) = "| "
Two$(0) = " _  "
Two$(1) = " _| "
Two$(2) = "|_  "
Three$(0) = "_  "
Three$(1) = "_| "
Three$(2) = "_| "
Four$(0) = "    "
Four$(1) = "|_| "
Four$(2) = "  | "
Five$(0) = " _  "
Five$(1) = "|_  "
Five$(2) = " _| "
Six$(0) = " _  "
Six$(1) = "|_  "
Six$(2) = "|_| "
Seven$(0) = "_  "
Seven$(1) = "  |"
Seven$(2) = "  |"
Eight$(0) = " _  "
Eight$(1) = "|_| "
Eight$(2) = "|_| "
Nine$(0) = " _  "
Nine$(1) = "|_| "
Nine$(2) = " _| "
INPUT "Enter a Number: ", Number$
NumLen = LEN(Number$)
FOR i = 1 to NumLen
Digit$ = MID$(Number$,i,1)
IF Digit$ = "0" THEN line1$ = line1$ + Zero$(0):line2$ = line2$ + Zero$(1):line3$ = line3$+Zero$(2)
IF Digit$ = "1" THEN line1$ = line1$ + One$(0):line2$ = line2$ + One$(1):line3$ = line3$+One$(2)
IF Digit$ = "2" THEN line1$ = line1$ + Two$(0):line2$ = line2$ + Two$(1):line3$ = line3$+Two$(2)
IF Digit$ = "3" THEN line1$ = line1$ + Three$(0):line2$ = line2$ + Three$(1):line3$ = line3$+Three$(2)
IF Digit$ = "4" THEN line1$ = line1$ + Four$(0):line2$ = line2$ + Four$(1):line3$ = line3$+Four$(2)
IF Digit$ = "5" THEN line1$ = line1$ + Five$(0):line2$ = line2$ + Five$(1):line3$ = line3$+Five$(2)
IF Digit$ = "6" THEN line1$ = line1$ + Six$(0):line2$ = line2$ + Six$(1):line3$ = line3$+Six$(2)
IF Digit$ = "7" THEN line1$ = line1$ + Seven$(0):line2$ = line2$ + Seven$(1):line3$ = line3$+Seven$(2)
IF Digit$ = "8" THEN line1$ = line1$ + Eight$(0):line2$ = line2$ + Eight$(1):line3$ = line3$+Eight$(2)
IF Digit$ = "9" THEN line1$ = line1$ + Nine$(0):line2$ = line2$ + Nine$(1):line3$ = line3$+Nine$(2)
PRINT line1$
PRINT line2$
PRINT line3$

The code might not be the most optimal...but what can you expect? It's basic...old basic -:P


Development Culture.

viernes, 1 de agosto de 2014

Learn You Some Erlang for great good! - Book review

Today...just a couple of minutes ago...I finished reading Learn You Some Erlang for great good! and I must say...I'm both joyful and tired -:)

The book is huge...not's "OMFG this book is huge"...with 628 pages...and lots...lots of examples...

This book is so good that it's actually considered part of the Erlang standard documentation...or something like that...or at least...that's how I think it should be considered...

The book starts with the basics of Erlang (the one's that make you brain hurt)...and then keeps moving forward introducing things like Concurrency, Multiprocessing, Supervisors, OTP, Event Handlers and more...much more...

Reading this book will give all the tools and knowledge necessary to start building applications...

If you have never heard of Erlang before and want to give it a try...this is totally the book for you...but...a word of warning...this book is full of content...that it could easily overwhelm you and make your brain hurt even more...

Now that I have finished the book...I think I will constantly come back to re-read some chapters as I need them...gladly...with some many examples it's easy to grasp most of the concepts at least in a slight way...

Of course...I'm still a my next book (with review of course) it's going to be Programming Erlang (Software for a Concurrent World) written by Joe Amstrong (one the creators of Erlang)... can read Learn You Some Erlang for great good! online


Development Culture.

viernes, 25 de julio de 2014

My first post on Erlang

So...a couple of days ago I decided (for the second time) to learn Erlang...but this time...I'm taking it serious -;)

But...what the hell is Erlang? Put it's a multi-paradigm, concurrent and functional programming language...simple, huh?

Erlang is a really nice and beautiful language...but...after this first couple of brain is starting to hurt...I will let you know later why...

Anyway...I'm reading Learn You Some Erlang for Great Good...that can be read online here or bought here. I bought it -;) can expect a nice review as soon as I finish reading it...

As I usually do with new programming languages...I wanted to port something I have done before into Erlang...because for me...that's the best way to learn...

I took the code for an LED Output that I have built for both Python and Julia and ported to the blog here.

Here's the Erlang code...


 when Counter > Long ->
  [io:format("~s",[X]) || X <- Line1], io:format("~n"),
  [io:format("~s",[X]) || X <- Line2], io:format("~n"),
  [io:format("~s",[X]) || X <- Line3], io:format("~n");
 when Counter =< Long ->
      Line1 ++ [element(1,element(1,X)) || {X,Y}<-Lines, Y == element(Counter,list_to_tuple(Digits))],
      Line2 ++ [element(1,element(2,X)) || {X,Y}<-Lines, Y == element(Counter,list_to_tuple(Digits))],
      Line3 ++ [element(1,element(3,X)) || {X,Y}<-Lines, Y == element(Counter,list_to_tuple(Digits))]).

showLED() ->
 io:format("You must enter a number!~n").
showLED(Number) ->
 Lines = [{{{" _  ",1},{"| | ",2},{"|_| ",3}},0},{{{"  ",1},{"| ",2},{"| ",3}},1},
   {{{" _  ",1},{" _| ",2},{"|_  ",3}},2},{{{"_  ",1},{"_| ",2},{"_| ",3}},3},
   {{{"    ",1},{"|_| ",2},{"  | ",3}},4},{{{" _  ",1},{"|_  ",2},{" _| ",3}},5},
   {{{" _  ",1},{"|_  ",2},{"|_| ",3}},6},{{{"_   ",1},{" |  ",2},{" |  ",3}},7},
   {{{" _  ",1},{"|_| ",2},{"|_| ",3}},8},{{{" _  ",1},{"|_| ",2},{" _| ",3}},9}],
 Line1 = "", Line2 = "", Line3 = "", Counter = 1,
 Numbers = integer_to_list(Number),
 Long = length(Numbers),
 Digits = lists:map(fun(X) -> X - 48 end, Numbers),

and here's the output...

So...I'm going to tell you why my brain hurts...and I hope this doesn't make you stay away from really should give Erlang a change -;)

First...Variables are invariable...which means...once A = 1 then A is going to be 1 forever and matter how many times you do A = 2...A is going to keep being 1...and of course you're going to get an error if you do A = 2...because A is it!

Second...No For' While' Do...While's...nothing...just recursion...functions that call themselves...multiple times until something makes them stop...

Third...String...are not strings in Erlang...everything is in the end "A" is 65...

Forth...Object Orientation...doesn't even try good...this is functional programming...forget about classes, methods, attributes, friends, templates...and so on...

Ok...why would you want to learn Erlang after all this non-sense? Easy...because Erlang changes your mindset completely...forgot everything you have ever need to think and do things in a completely different way...but believe me...after a couple of days with're going to be a better developer...that's guaranteed...


Development Culture.

miércoles, 16 de julio de 2014

Web scrapping with Julia and PhatomJS

As I have been reading some PhantomJS books and I'm always looking to develop something nice using Julia...I thought that integrate them would be an awesome idea -;)

I thought about Twitter and the hashtags...wouldn't it be nice to write a PhantomJS script to webscrape Twitter and get all the hashtags that I have used?

For this particular script...I'm taking the hashtags from the first 5 Twitter pages linked to my profile...

var system = require('system');

var webpage = require('webpage').create();
webpage.viewportSize = { width: 1280, height: 800 };
webpage.scrollPosition = { top: 0, left: 0 };

var userid = system.args[1];
var profileUrl = "" + userid;, function(status) {
 if (status === 'fail') {
  console.error('webpage did not open successfully');
 var i = 0,
 queryFn = function() {
  return document.body.scrollHeight;
 setInterval(function() {
  top = webpage.evaluate(queryFn);
  webpage.scrollPosition = { top: top + 1, left: 0 };

  if (i >= 5) {
   var twitter = webpage.evaluate(function () {
    var twitter = [];
    forEach = Array.prototype.forEach;
    var tweets = document.querySelectorAll('[data-query-source="hashtag_click"]');, function(el) {
    return twitter;

   twitter.forEach(function(t) {

}, 3000);

If we run this...we're going to have this output...

Now...what I want to do with this to send it to Julia...and get the most used I will summarize them and then get rid of the ones that only appear once...

Let's see the Julia code...

tweets = readall(`phantomjs Hashtags.js Blag`)
tweets = split(tweets,"\n")
hashtags = Dict()
for hash in tweets
  hashtags[hash] += 1
 catch e
  hashtags[hash] = 1


for (k,v) in hashtags
 println("$k has been mentioned $v times")

When we run this code...we're going to have this output...

I still don't know how to sort Dicts in bear with me -:) looking at the output...we can have my top 3 hashtags -;)

#LeapMotion ==> 14 times
#Flare3D ==> 11 times
#DevHangout ==> 8 times

Hope you like this and see you next time -:)


Development Culture.

PhantomJS Cookbook - Book Review

After reading and blogging about Getting Started with PhantomJS I decided to bought another PhantomJS book...of course -;)

This time...I got PhantomJS Cookbook...

This book is fairly big with 304 pages...and it's really really nice...

Of course...being a "Cookbook"...there's always good and bad things...the bad things are that some of the recipes are boring or too obvious (specially if you already know something about PhantomJS)...and dont' get me wrong on this...I just believe that if you're going to read a "Cookbook" it's because you already have some knowledge and don't really need to be instructed on how to do the most simple always...that's just me...for newbies...those recipes must be really good...

The good things about this that the recipes that are good...are really good...and the recipes that are awesome...are totally awesome! I was really excited and blown away by some of them...

The book covers some CasperJS, Jasmine, Jenkins and more...much more...

Thanks to this book I discovered what HAR is...and how can PhantomJS can help you with it...

Wanna see some Jenkins? Here it is -:)

I gotta say...if you already bought "Getting Started with PhantomJS"...then you need to buy this "Cookbook"'s really cool -;)

Taking screenshots of a webpage using different sizes is also a very nice script...but of course I'm not going to fill this post with images...because after all...PhantomJS is a headless browser, right? -;)


Development Culture.

lunes, 14 de julio de 2014

Getting Started with PhantomJS - Book Review

A couple of days ago I start reading Getting Started with PhantomJS from Packt Publishing. I had heard about PhantomJS in the past but never really use I was really excited about reading the book...

Like all the Getting Started books, this one is kind of short...with 140 pages...but let me tell you...that's more than enough to keep your attention and make a PhatomJS advocate -;)

The book starts with a little introduction and then jumps straight into the code examples...which is something that I always appreciate -:P

The first important example is based on Pinterest but I don't use/like I change the example a little bit to use Twitter instead -;)

Here's the source code in case you're interested...

var system = require('system');
var userid = system.args[1];
var page = require('webpage').create();

var profileUrl = "" + userid;, function(status) {
 if ( status === "success" ) {
  var twitter = page.evaluate(function (uid) {
  var username = document.querySelector('[href="/' + uid + '"]').innerText.trim();
  var numTweets = document.querySelector('[data-nav="tweets"]');
  numTweets = numTweets.attributes[1].value;
  var numFollowing = document.querySelector('[href="/' + uid + '/following"]');
  numFollowing = numFollowing.querySelector('[class="ProfileNav-value"]').innerText;  
  var numFollowers = document.querySelector('[href="/' + uid + '/followers"]');
  numFollowers = numFollowers.querySelector('[class="ProfileNav-value"]').innerText;    
  return {
   name: username,
   tweets: numTweets,
   following: numFollowing,
   followers: numFollowers
}, userid);

console.log( + ' (' + userid + ')' + ' has wrote ' + twitter.tweets + ' and has ' +
      twitter.followers + ' followers and is following ' +
      twitter.following + ' accounts ');


And here's the output...

Cool, huh? For a very first example...I think it's impressive -;)

The book also comes with example on taking webpages screenshots, loading performance, modification of the DOM, working with files and more...

It includes even a small introduction to CasperJS, the perfect companion to PhantomJS.

I would say...just go ahead and buy this book...I totally love it and will read it again just to discover and learn more....PhantomJS is just amazing!


Development Culture.

jueves, 10 de julio de 2014

LED - My first Julia package

So yesterday I was thinking about Julia and how easy people claim package development is...of course...I need to give it a try...

I wanted to start small and I build something useless mostly for fun and learning...

The LED Package simply writes an LED representation of any given number...

julia> Using LED

julia > ShowLED(12345)

   _  _       _  
|  _| _| |_| |_  
| |_  _|   |  _| 

As simple as that...and it took me no more than 5 minutes to get it done...

So, I can confirm now that package development in a piece of cake -:)

If everything was done should be able to do...

julia > Pkg.add("LED")

otherwise...please do...

julia > Pkg.clone("")

Of course...this was just an of course I'm planning to put my mind into the work and come up with some nice and useful packages -;)


Development Culture.

jueves, 3 de julio de 2014

10 years of Pack Publishing!

My good friends at Packt Publishing are turning 10 years old and they are celebrating it with an awesome promotion!

All ebooks and videos for just $10 dollars each...hurry up! This wonderful offer end on July go ahead and grab as many as you can -:D


Development Culture.