2017-05-20

Tinkerboard

Finally my Asus tinkerboard arrived.

Buy Tinker Board 2 GB, Cortex-A17 Quad-core

Is it awesome?
not sure yet...

Yes, it packs more power than raspberry pi, but it falls behind in so many things

The software is basically inexistent
You get a standar linux and nothing more


With no further ado, lets get it going.

step 1: ssh to it

ssh linaro@your_ip
pwd: linaro

step 2: install go

wget https://storage.googleapis.com/golang/go1.8.1.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.8.1.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin


... aaaaaaannnd I am out of space :'(


something is not right here, I have a 32gb sd card,
I run fdisk and check that indeed my partition is 29gb
but somehow my /root is locked to 2gb

well, anyway, lost a day playing around with that,
in the end formatted my sd card before loading the image
and it works.


2015-04-22

did I run my migrations?

Today I had an error message driving me crazy:
`method_missing': undefined method `export_format' for XXX model

You see, our model is a gem itself, because it is shared by several projects.

When we have something in the schema that is not in  the database, that is the error we get.



Now, I knew this error from previous executions, but my model was in synch with the DB.

I tried to comment out all my changes, without luck.



Until I realized. This error was in my specs.

I had run the rake db:migrate, but not RACK_ENG=test



In this situation I was happy I fixed the issue, but at the same time extremely angry I wasted 1h with that



Mental note: run both friggin migrations together in the future!



This might help:

alias migrate='rake db:migrate; rake db:migrate RAILS_ENV=test'



thanks to Eumir for this post


2014-10-02

Go, go, go!



C is fast, but boring,
Ruby is slow, but fun.
Go is right in between

Let's start with the fun bits:
- You don't import just a file, you import a repository.
Reading import "github.com/tiagodll/golib" is beautiful, that alone gets me excited about go.

- Returning multiple values. Yes, finally!
You can set resp, err := MyFunction()
- Ditching the ;. I never got the reason for it, maybe it is because I learned programming with VB, but to me it just doesn't make sense.

Now to the boring
- The name. Seems like nothing, but having a language called go makes google searches useless unless you use golang.
- Not having try/catch. It sucks. Although returning value, error makes up for it quite well.
- Having any not used lib/variable as an error instead of warning. It is ok when you have a final version, but that is really annoying while development phase.
And the worst of all: 
- the insane amount of extra lines to assign a variable such as
temp := MyType{id:123}
GetValueFromMongo(&temp)
Printf("%v", temp)
Instead of a simple
puts get_value_from_mongo(123).to_s

and the grey area
- Not having classes. I like the idea of having all static methods (unless it is really about the object they are in), but not having classes could have some issues, specially because of inheritance.

Regardless, this is my current language of choice.
But this is just the beginning. 
Let's see next what go is all about.

2014-09-02

Back in purple, well... that is the elixir's main color, right?

One of my favorite hobbies is to learn new technologies. This means almost anything. I like Languages, patterns, databases, and sometimes even hardware stuff (even though I am very bad at that)

That being said, from time to time I decide to revisit and adopt or abandon that technology.

This time is about Elixir. but not just about elixir, I realised that to properly learn elixir, Erlang is required.
No, you don't have to use Erlang code, but it is more about the programming style (and a bit about the libraries too).

So why to learn that?

Simple..


Not only that, every time you learn a new paradigm, you bring good knowledge to yours. So learning Erlang might bring you some good improvements even in java. 
But seriously, it is 2014... leave java where it belongs: in the past!

2014-09-01

Database evolution

"Someday your little database will grow up. When it hits the teenage years - about two in human years - it will get moody, sullen, and resentful. In the worst case, it will start undermining the whole system (and it will probably complain that nobody understands it, too)."
 Release it
Release It - Michael T. Nygard

2014-08-10

Dart + start + polymer = ?

So as I said in my <a href="/2014/07/yeah-about-that.html">Dart, what do we think about it?</a> post, it is an interesting language to look into. It is lacking good libraries, but a problem can also be seen as an opportunity: it is a great time build your own.

Back to the topic, because of the pub system it is very easy to have dart + start <b>or</b> dart + polymer, but not as easy to have both.

There is a teeny-tiny detail it took me a couple of days to realize, but let me save this to the end of the post.

Start is simple, lets begin with that.
first, the pubspec

<code file="pubspec.yaml">
name: onemore
description: A sample Polymer application
dependencies:
  polymer: '>=0.11.0'
  start: any
transformers:
- polymer:
    entry_points: web/index.html
</code>


Then all you need to do is to import the package and create a server side dart file to start it.
In this example I am only serving static files, it would be just as easy to handle dynamic content with the get(url).
<code file="app.dart">
import 'package:start/start.dart';

main(args) {
  start(port: 3000).then((Server app) { app.static('build/web', jail: false); });
}
</code>

Done, you have a web server running in http://localhost:3000 as soon as you run this code.

Now, the polymer part
to have a custom element we need 3 files: the dart, the html and the hosting html file.
this custom element expects a String list, and publish (sends to the client) both lst and plist.
<code file="elementlist.dart">
import 'package:polymer/polymer.dart';
import 'dart:convert';

@CustomTag('element-list')
class ElementsList extends PolymerElement {
  @published String list;
  @published List plist;

  ElementsList.created() : super.created(){
    try{
      plist = JSON.decode(list);
      plist.add({"id":"test"});
    }catch(e){
      print(e.toString());
    }
    polymerCreated();
  }
}
</code>

Here in the html we can use mustache style expressions
<code file="elementlist.html">
<link rel="import" href="packages/polymer/polymer.html">
<polymer-element name="element-list" attributes="list">
  <template>
    <div>the list: {{ list }}</div>
    <ul>
      <template repeat="{{elmt in plist}}">
        <li>{{elmt["id"]}}</li>
      </template>
      </ul>
  </template>
  <script type="application/dart" src="elementlist.dart"></script>
</polymer-element>
</code>

and then your index file you just have to add some references and include the custom element element-list.
<code file="index.html">
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sample app</title>
    <script src="packages/web_components/platform.js"></script>
    <script src="packages/web_components/dart_support.js"></script>
    <!-- import the click-counter -->
    <link rel="import" href="elementlist.html">
    <script type="application/dart">export 'package:polymer/init.dart';</script>
    <script src="packages/browser/dart.js"></script>
  </head>
  <body unresolved touch-action="auto">
    before list<br>
    ---------------------<br>
    <element-list id="the_list" list='[{"id":1},{"id":2},{"id":3}]'></element-list>
    ---------------------<br>
  </body>
</html>
</code>

Now, let me explain the little detail that made me lose so much time: start is just serving the folder specified above. The problem is that all the polymer javascript is generated in the build, and stored there. So our start must serve that folder instead.
to do that, all we have to do is to change the web to build/web in the start method:
app.static('build/web', jail: false);

That is all folks, hope you enjoy it.

2014-07-24

Dart, what do we think about it?


yeah, about that...

Google's attempt to improve on Javascript and get a server-side language at the same time.
I have always wanted something else to thrive over javascript, and tried many good options like coffeescript or opal. Most of them are really good and easy to use as long as everything is correct.
Sadly that is not what happens. The bug fixing is a vital phase of software development, and in this is the problem with all the languages that compile to javascript.
Fixing the code is already hard enough as it is, imagine if you have to debug an auto-generated code in a language you possibly don't master.
For this reason I never adopted any of those for my development projects, and that is why dart quickly got my attention when they announced the dart VM embedded in chrome (ok, it is dartium, a branch of chromium but still counts).

Not just that, it is also a very flexible language where types are recommended but not enforced.
syntax is a bit outdated, they opted for the java style to make developers feel comfortable. With languages like ruby and python getting more and more users everyday I am not sure it was the best decision.
Although I have to agree, every developer feels familiar to a language with all the semi colons, curly brackets shenanigans that resembles java.

They have also done a good job in their package system, the pub. It feels just the same as using ruby gems.

Dart start is quite close to Sinatra, it is still lacking the template rendering, but it s a good start (pun unintended)

IDE. Ah, the IDE... why always Eclipse google?
It is so bad, rebuilds workspace every other minute, hangs all the time.
In fact, it hangs so much, my most used terminal command is "killall dart".
Seriously, why Eclipse again?

Overall it is good and I hope it works out.
Being a google product, I believe it will be forced upon us like google+ anyway, so why not to make the best of it and enjoy all the benefits?