2013-11-17

MITx and edX update from Prof. Sanjay Sarma

Prof Sanjay Sarma, Director of Digital Learning at MIT, gave a talk on Massive Open Online Courses(MOOCs), at the Indian Institute of Management, Ahmedabad (IIMA) on July 4, 2013.

Here are some of the talk's key points.


2013-10-19

Windows Phone 8 is great!

In the summer I switched to using Windows Phone 8 and Outlook.com using a Lumia 820.
So far I am very satisfied with the phone and the software. Windows Phone provides a great customer experience!

Here is a quick list of positive and negative aspects:

Positive:
- people-centric interface - finally, the contacts are all in one place
- Skype, Facebook, LinkedIn integration
- pin anything to start screen - including the pictures of your friends to keep track of what they're up to
- make notes and share them with PC, Mac and iOS with OneNote with cloud sync
- free Adobe Reader allows PDF comments

Negative:
- interface relies too much on text - a few more icons wouldn't hurt
- too few official apps - Dropbox, etc
- some interface disconnects - for instance, in the SMS menu there is no way to call the person

I recommended the following (paid) apps:

Pocket scanner: Handyscan

RSS Reader: feed me

2013-08-07

The BEST way to learn about the Internet of Things

Today I taught a class about The Internet of Things to the BEST Lisboa students.


Photo credits: Mário Romano

This is the presentation that I made:



This is the pinterest board with some of the cool Internet of Things stuff that I showed in class.

You can find more information about supply chain traceability in the TrakChain PhD project page.

And this is a sneak peek of the great demo that Nuno Correia prepared for the students:


I would also like to thank Link Consulting for sponsoring the demonstration and the people involved, Mário Romano and João Taborda Gonçalves.

Thanks also to Joana, for being there and helping with the people flow! :)

2013-08-02

How to disable Thunderbird mozmsgs

Mozilla Thunderbird has an option to integrate with Mac or Windows email search.
Using this option the emails are no longer stored in the SDB files (many emails in a single file) are stored in multiple and individual files.
This usually results in poor performance, especially if you have many emails.

To disable this option, go to 'Options', 'Advanced', 'General' and unselect the "Allow Windows Search to search message".
You can also unselect the "Enable Global Search and Indexer" option if you do not use the global search.

2013-07-31

How to use Gradle to generate Eclipse files with relative paths to libraries

First, apply the Gradle Eclipse plug-in to your build.gradle file:

apply plugin: 'java'
apply plugin: 'eclipse'

You can now execute the following command to generate the Eclipse configuration files .project and .classpath:

$ gradle eclipse

You can now import and existing project into Eclipse, and enjoy all the correct configurations!

However, in the current Gradle version (1.6), the generated library paths are absolute, for example:

C:/Users/Miguel/.gradle/caches/artifacts-24/filestore/
junit/junit/4.11/source/
28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar

This leads to problems because if you commit these files in source code control, your specific user settings will be imposed on other developers.

One way to avoid this is to use an Eclipse Classpath Variable and customize the Eclipse plug-in output.

eclipse {
    // find gradle cache location
    def gradleCache = null
    for (o in configurations.compile) {
        if (o.toString().indexOf(".gradle") != -1) {
            final def token = "filestore"
            def s = o.toString()
            def idx = s.indexOf(token)
            if (idx != -1) {
                gradleCache = new File(s.substring(0, idx + token.length()))
                break
            }
        }
    }
    assert gradleCache && gradleCache.exists()
    println "GRADLE_CACHE: " + gradleCache

    // replace absolute paths with classpath variable GRADLE_CACHE
    pathVariables 'GRADLE_CACHE': gradleCache

    // make sure GRADLE_CACHE is defined in 
    // Eclipse, Preferences, Java, Build Path, Classpath Variables

}

Note: an alternative solution could use Eclipse workspace Path variables (referred using the ${...} notation) but without DSL support like the pathVariables statement above.

2013-07-04

Mezuzah

In Israel you can find a Mezuzah in each room entrance.
Inside, you can find a parchment with the following prayer:

Sh'ma Yisrael Adonai Eloheinu Adonai Eḥad - Hear, O Israel: the Lord is our God, the Lord is One



This is a Jewish tradition that intends to direct one's heart towards the presence of the one God in each and every moment of our daily life.
An interesting concept, and an aesthetic one too, as there are many styles of Mezuzah.

2013-06-19

How to produce a Graphviz PDF with smaller margins?

Graphviz is a great tool to generate graph images from a textual description.

The following tip shows how you can generate a PDF file with smaller margins.
The source file contains:
digraph G {
    margin=0;
    "subject" -> "object" [label="predicate"];
}

Alternatively, the margin can also be set in the command line:
> dot -Tpdf -Gmargin=0 triple.gv > triple.pdf

2013-06-03

Programmable World

For the Programmable World to reach its full potential, we need to pass through three stages.

The first is simply the act of getting more devices onto the network—more sensors, more processors in everyday objects, more wireless hookups to extract data from the processors that already exist.

The second is to make those devices rely on one another, coordinating their actions to carry out simple tasks without any human intervention.

The third and final stage, once connected things become ubiquitous, is to understand them as a system to be programmed, a bona fide platform that can run software in much the same manner that a computer or smartphone can. Once we get there, that system will transform the world of everyday objects into a designable environment, a playground for coders and engineers.

It will change the whole way we think about the division between the virtual and
the physical.

Source: Wired

2013-05-23

Common MySQL / JDBC programming error that causes unexpected syntax errors

What is wrong with this code?

...
    String sql = "INSERT INTO PRODUCT (CODE, DESCRIPTION) VALUES(?,?)";
    PreparedStatement pstmt = connection.prepareStatement(sql);
        
    pstmt.setString(1, "A1");
    pstmt.setString(2, "Soccer ball");
        
    pstmt.executeUpdate(sql);
...

On execution, the execute method returns a com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException.

Why is that? The syntax looks OK...

It's tricky, but since the statement is prepared in advance, the method to call is pstmt.executeUpdate() without parameters.
If the SQL query is provided, the compiler accepts the code, but the '?' produce syntax errors.

PreparedStatement is preferred over Statement because it can give better performance and prevent many SQL Injection attacks.

The correct code is:

...
    String sql = "INSERT INTO PRODUCT (CODE, DESCRIPTION) VALUES(?,?)";
    PreparedStatement pstmt = connection.prepareStatement(sql);
        
    pstmt.setString(1, "A1");
    pstmt.setString(2, "Soccer ball");
        
    pstmt.executeUpdate();
...


Credits: Mark Matthews

2013-04-16

How to copy all files in classpath to a directory using Ant?

Try something like the following target:

...

    <target name=copy-deps">
        <copy todir="." flatten="true">
            <path refid="my-classpath"/>
        </copy>
    </target>

...

To execute (assuming that my-classpath is defined, of course):

ant copy-deps