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 I have no clue how to use it...yet -:(

Good thing is...I work at the d-shop in SAP Labs Palo 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 -;)


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'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's the PhantomJS script...

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 the script we're going to see the following output...

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

Let's see the Go code...

package main

import ( "os/exec"
  "fmt" )

func main() {
 cmd := exec.Command("phantomjs","--ssl-protocol=any","Hashtags.js", "Blag")
 out, err := cmd.Output()
 if err != nil {
 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] I will simply leave it like that -:)

Here's the result...

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


Development Culture.