miércoles, 3 de diciembre de 2014

Keep going with BeagleBone Black - Small Midi Piano

Looks like I'm on fire these days -;) I got somehow the plan of building new things on the BeagleBone Black as fast and often as I can...better way to learn for sure -:)

This time I have made a small Midi Piano...and excuse my total lack of Piano skills -:(


For this I used Python, AdaFruit_BBIO, PyGame and Timidity++.

Greetings,

Blag.
Development Culture.

martes, 2 de diciembre de 2014

DYI Simon Says - Using BeagleBone Black

Today...I was thinking what else could I built using the BeagleBone Black...and what came out was...making a Simon Says game! -:D


For this I simply used Python and AdaFruit_BBIO -:)

Of course...I need to add music and put a new color LED -;)

Greetings,

Blag.
Development Culture.

My first BeagleBone Black Project

As you may know...I started with the BeagleBone Black, almost a month ago...and of course...I have a project done already -;)

Sorry for the crappy quality of the video...but I shot it with my IPhone and uploaded to YouTube...


As you can see...it will play the Happy Birthday song while lighting the LEDs simulating a keyboard...not way cool...but it was a really good start for me -:)

I used Python, AdaFruit_BBIO, PyGame and Pyknon.

Greetings,

Blag.
Development Culture.

martes, 11 de noviembre de 2014

Starting up with the BeagleBone Black

I have always been a software guy...always immersed in programming and cool projects...but a couple of days ago I start playing with my first electronics toy...a BeagleBone Black...

I got myself The Ultimate BeagleBone Black Development Kit from Amazon which is really good to get you started...the only problem is that it comes with an PTBB-170B breadboard which is really small and doesn't really come with the ground and positive rails...so I have no clue how to use it...yet -:(



Good thing is...I work at the d-shop in SAP Labs Palo Alto...so we have plenty of regular and extra big breadboards -;)

Anyway...I started building up my first simple projects and using Adafruit BBIO on Python to code...which is really nice -:)





Of course...I still have a very long to go...but I have a couple ideas on my mind that could become really nice projects...let's see what becomes on my first adventure on electronics -;)

Greetings,

Blag.
Development Culture.

miércoles, 5 de noviembre de 2014

Web scrapping with Go and PhatomJS

Some time ago I wrote a blog called Web scrapping with Julia and PhantomJS...then I wrote another blog called Web scrapping with Haskell and PhantomJS...

This time...it's Go's time -;)

The concept is the same...we create a PhantomJS script that will read a "user" Twitter page and get the hashtags of the first 5 pages...here's the PhantomJS script...

Hashtags.js
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 = "http://www.twitter.com/" + userid;

webpage.open(profileUrl, function(status) {
 if (status === 'fail') {
  console.error('webpage did not open successfully');
  phantom.exit(1);
 }
 var i = 0,
 top,
 queryFn = function() {
  return document.body.scrollHeight;
 };
 setInterval(function() {
  top = webpage.evaluate(queryFn);
  i++;
   
  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"]');
    forEach.call(tweets, function(el) {
     twitter.push(el.innerText);
    });
    return twitter;
   });

   twitter.forEach(function(t) {
    console.log(t);
   });

   phantom.exit();
  }
}, 3000);
});

If we run the script we're going to see the following output...


Now...what I want to do with this information...is to send it to Go...and get the most used hashtags...so I will summarize them and then get rid of the ones that only appear less than 5 times...

Let's see the Go code...

TwitterHashtags.go
package main

import ( "os/exec"
  "strings" 
  "fmt" )

func main() {
 cmd := exec.Command("phantomjs","--ssl-protocol=any","Hashtags.js", "Blag")
 out, err := cmd.Output()
 if err != nil {
  println(err.Error())
  return
 }
 
 Tweets := strings.Split(string(out), "\n")
 charmap := make(map[string]int)
 for _, value := range Tweets {
  if value != "" {
   charmap[value] += 1
  }
 }
 
 for key, value := range charmap {
  if value >= 5 {
   fmt.Print("(", key, ", ")
   fmt.Println(value, ")")
  }
 }
}

The only problem with this script is that there's not an easy way to sort a map[string]int...so I will simply leave it like that -:)

Here's the result...


If someone knows an easy way to sort this...please let me know -:)

Greetings,

Blag.
Development Culture.

miércoles, 29 de octubre de 2014

LED is my new Hello World - Go Time

As I keep learning Go, I'm learning more commands...so...as usual...here's my take on LED Numbers...maybe not the best code ever...but it works -:)

LED.go
package main

import ( "fmt"
   "strconv" 
   "strings" )

func main() {
 fmt.Print("Enter a number: ")
 var num int
 var list []string
 var line1, line2, line3 string
 fmt.Scanf("%d", &num)
 numList := strings.Split(strconv.Itoa(num), "")
 romans := map[string]string {
  "0" : " _  ,| | ,|_| ",
  "1" : "  ,| ,| ",
  "2" : " _  , _| ,|_  ",
  "3" : "_  ,_| ,_| ",
  "4" : "    ,|_| ,  | ",
  "5" : " _  ,|_  , _| ",
  "6" : " _  ,|_  ,|_| ",
  "7" : "_   , |  , |  ",
  "8" : " _  ,|_| ,|_| ",
  "9" : " _  ,|_| , _| ",
 }
 for _, value := range numList {
  list = strings.Split(romans[value],",")
  line1 += list[0]
  line2 += list[1]
  line3 += list[2]
 }
 fmt.Println(line1)
 fmt.Println(line2)
 fmt.Println(line3)
}

Here are the screenshots...



Greetings,

Blag.
Development Culture.

Mi first post on Go

As Go is gaining some popularity...I decided to give it a try...and sure...the fact that Ken Thompson is one of the three main designers of the language helped as well -:P

In order to learn I'm reading the book An Introduction to Programming in Go so expect a book review soon...



Now...my first impression of Go is that is basically C/C++ without the makeup...meaning...take out some nasty and weird features and you have yourself the Go programming language...

Go is supposed to be compiled, concurrent, imperative and structured.

Anyway...C++ was one of the first languages I ever learned so learning Go feels like going back home for a while...

For sure...the best way to learn a new language is to code something...so again I start by building something simple like the Fibonacci number generator based on Haskell code from another post...

Fibonacci.go
package main

import ( "fmt"
   "strconv" )

func main() {
 fmt.Print("Enter a number: ")
 var num int
 fmt.Scanf("%d", &num)
 fmt.Print(fib(num, 0, 1))
}

func fib(num int, a int, b int) string{
 var result string
 if a > 0 && num > 1 {
  result += strconv.Itoa(a+b) + " " + fib(num-1, a+b, a)
 } else if a == 0 {
  result = strconv.Itoa(a) + " " + strconv.Itoa(b) + 
                             " " + strconv.Itoa(a+b) + 
                             " " + fib(num-1, a+b, b)
 }
 return result
}

When we run it...we're going to see this -:)



Greetings,

Blag.
Development Culture.

How to Design Programs - Book Review

I just finished reading How to Design Programs, a book meant for beginners that want to get into the wonderful world of programming...and for that they use Scheme and DrScheme (which is now called Racket).



Of course, they don't focus on Scheme but on the design principles of programming...which makes this one a really important book.

The book itself is pretty big...with 565 pages...

There's a lot of really nice examples ranging from really basic to somehow complex, so there's a good learning curve attached to it.

Using Scheme as a starting point for learning programming is in my opinion a really smart choice...the syntax might be kind of weird sometimes but the good thing is that there are not so many keywords so learning it it's not a hard task...



Even if you have experience in programming...this book is really helpful and it goes beyond the simple act of programming as it teaches you how to design, build and test your application...making it more robust and less error prone...

If you have the chance...read this book...you will not regret it -;)

Greetings,

Blag.
Development Culture.

lunes, 27 de octubre de 2014

LeapTV - Game System Review

I have always love LeapFrog so when I read that we're planning to release a brand new gaming console...I couldn't stop myself from pre-ordering it -;)

LeapTV is in my opinion...a mix between Education, Wii and XBox Kinnect...just enough to keep our little ones engaged, exercised, happy and practice their school skills...


The console comes with a control and a Kinnect like sensor...but no cartrige games...however...it includes a "Pet Play World" game when you register it online...it's a nice game where you need to pick a pet and take care of him/her -;)

Of course...I couldn't left my daughter with just one included game...so I bought a couple more -:)


Kart Racing Supercharged is a "Mario Kart" like game where the kids needs to solve some math questions in order to get better equipment for their cars...

Sports! includes nine games like Super Goallie, Skateboarding and Bowling...and here kids needs to use their addition, subtraction, patterns and shapes skills...


The un-boxing and setup was of course pretty easy and the controller is wireless...


This picture is from the "Pet Play World" game...


And here's the skateboarding game on Sports!


Kart Racing Supercharged is really nice too -;)


I can say...LeapFrog and LeapTV haven't disappoint me at all...this is a great gaming console for little kids and they will open their App Store soon...so the fun will never end -;)

Greetings,

Blag.
Development Culture.

jueves, 16 de octubre de 2014

Realm of Racket - Book Review

I just finished reading Realm of Racket a book about Racket -:)


The book has 316 pages...so it's a big book...

It starts with the basics of Rackets but very quickly jumps into creating games with Racket...which is something really cool...specially if you want to build games with Racket...

The book comes with some nice and funny comic strips telling us the story of Chad and how using Racket he manage to solve some interesting challenges...

One thing that I didn't like too much about the book...is that I believe that some games are too long and even complex which kind of defeat the purpose of being a beginners book...

Anyway...the book comes with a lot of useful information and will make you be right on track with your Racket learning -;)

You will learn about Recusion, Lambdas, Loops, GameUI and Networking...





Racket is a powerful but strange programming language...so this book will help you to get more comfortable...

If you want to learn Racket in a fun way and built some nice games in the process...then this book is for you -:)

Greetings,

Blag.
Development Culture.