Categories
Programming

Rooting the HTC Sensation XE

I found loads of guides online with even more text. The problem with these guides is that they explain which button to push but not what it does.

I am fairly tech-savvy which means I try to figure out what is going on and these guides fail to explain that.

So here goes, the TL;DR version to root your HTC Sensation XE and replace the bootloader to make backups or replace the OS.

We start by replacing the bootloader so we can install custom things, including the root access.

  • Step 1: Unlock your phone; this is called switching S-ON to S-OFF. I speculate this allows write access to parts of the phone. Follow the HTC instructions here: developer.htc.com
  • Step 2: Use ‘juopunutbear’ to unlock and replace the stock bootloader with a version that can be replaced. Yes, the ‘trick’ with the wire is required: it probably triggers a reset of one of the security mechanisms to cheat your way into the bootloader.
  • Step 3: At this point the bootloader can be replaced. Write your preferred bootloader image from your computer to your phone in the ‘fastboot’ mode using fastboot flash recovery myrecovery.img; see http://forum.xda-developers.com/showthread.php?t=1864053 and search for the ‘Flash the Recovery’ section which has a link to an image and the exact command for it.

Your HTC Sensation XE now can install custom firmware including the root access. How this can be done is future work.

Categories
Programming

Tethering on Google Android without root access

So you want to tether your brand spanking new Android phone (Google G1 or HTC Hero or alike) but you don’t want to bother with rooting your phone. Bad news: you can’t (wireless), sort of – read on.

Well technically you can but it requires a USB cable connection to make the phone act like a modem device which Windows (or Linux) can then use to ‘dial’ to the world wide web. The HTC Hero comes with this functionality built in (it just requires some HTC drivers which even works on Windows 7, albeit with separate installation of the drivers as the setup fails), for the G1 and others you can install PdaNet on your Android phone to do the same.

So in fact you can tether your 3G connection to your computer using an Android phone, but you can’t do it wireless. Bluetooth is incomplete and as such wont give you a DUN device so no dice there. And for the wifi tethering tool, you really really need root access. Why? Because it switches your WiFi card in your phone from normal to router mode. This allows other devices to connect to it and use the 3G device as a gateway.

So why shouldn’t you root your phone (besides risking to brick your phone)? You can’t buy paid applications from the Android Market anymore. For some no reason to hack their phone, I prefer to have the option to keep using paid applications. Perhaps in the future I’ll try to root my HTC Hero and I will post my findings.

Update: I rooted my phone after owning it for a year or so and I was able to by and install paid applications just fine. I forgot where I read this tidbit of information but it seems to be rubbish – rooting does not prevent you from buying apps.

Categories
Programming

Adding Gravatar to Joomla!

After stumbling upon Gravatar, a site serving your avatar globally, I looked for an easy way to add this functionality to Joomla!. After ditching Gravatar/Avatar for needing some other plugin to work in the first place, I installed gAvatar.

This plugin worked without dependencies and gAvatar is dead simple to set up. Just enable the plugin, change the rendering mode and you are done.

The only thing that can go wrong (and did for me) was the fact that you can choose for a floating avatar (which ended up floating in the text), a table avatar (using the default Joomla header style – which this site doesn’t use) or advanced templating.

That last option seemed like a good solution except that nowhere was described what it did or how it worked. A quick dive in the source showed me everything I needed to know: gAvatar adds a ‘avatar’ parameter to the article object. To use it, find the classes generating the article layouts and modify those.

To find those class files, I used the following in the template folder:

fgrep "article->text" * -R

And add the following (for example) to insert the avatar:

<?php if (isset($this->article->avatar)) : ?>     <div style="float: right"><?php echo $this->article->avatar; ?></div> <?php endif; ?>
Categories
Programming

Release of new utility: Bacula Reports 0.9

I write a lot of code, most of it unsuitable for release to the public but this little gem is worth a public release.

After using Bacula to backup all my servers (both Windows and Linux) for some time, the large number of mailings you get when using it on a small server park drove me insane. Even when using filters to sort out new mail, it is hard to see if everything is going as it should be.

Enter Bacula Reports: a mail aggregator for Bacula 2.x and 3.x.

Bacula Reports consists of a faux mail command (which does not send out reports by mail but rather analyses and stores them) and a report generator which aggregates all the stored reports into one mailing with an overview and some HTML styling to make it more readable (if you don’t want HTML, modify the template to generate plain text).

By integrating the scripts into the Bacula configuration at 2 points (a mail command used for sending out reports and a job to send out the combined report), the storm of daily mails changes into one neat report at the end of the backup cycle.

Normal error messages and operator messages are unaffected and will be delivered as they used to be, only the backup reports per job are redirected to Bacula Reports.

Requirements:

  • A linux server (32 or 64 bit, tested on CentOS 5.2 and Gentoo 2008)
  • A working Bacula 2.x or 3.x installation
  • PHP as a command line interpreter (run ‘php –v’ to see if you have it)
  • 10 minutes of your time to set everything up

The cool thing of the scripts is that they require only 2 small changes in the director configuration to reroute the status mailings and if you don’t like it or run into trouble, reverting is normally a matter of simply commenting out the modified lines and restoring the old ones.

One drawback for some people: it requires PHP on the command line (as stated before). The reason for this is very simple: I want to use the same code in the future for a web GUI and my unix-scripting skills are virtually non-existing compared to PHP or Java.

Even though its PHP, the scripts have a small footprint and run very fast – they should be easy to add to any existing Bacula environment.

{jd_file file==5} {jd_file file==6}

Categories
Programming

Amarok2 TrackInfo object in QtScript

I just started playing with QtScript in Amarok 2.0.1.1 and so far the documentation has been a big let down. A lot of things are documented for C++ but the conversion into JavaScript is a lot trickier then it looked.

This is ofcourse because the whole QtScript engine is all new and this will become better over time. In this posting I will show what the TrackInfo object holds, which is returned by Amarok.Engine.currentTrack();

 destroyed(QObject*): function () { [native] } destroyed(): function () { [native] } deleteLater(): function () { [native] } objectName:  title: Hotaka (radio edit) sampleRate: 44100 bitrate: 192 score: 49.5 rating: 0 inCollection: true type: mp3 length: 215 fileSize: 5195160 trackNumber: 1 discNumber: 0 playCount: 1 playable: true album: Hotaka artist: Juno Reactor composer:  genre: Electronic year: 2002 comment: DHA's Music Archive path: /mnt/music/Mp3/Albums2/Juno Reactor/Juno Reactor - Hotaka/01 Hotaka (radio edit).mp3 isValid: true isEditable: true lyrics: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">  <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />      <title>Juno Reactor Hotaka (radio edit) lyrics</title>  </head>  <body><h3><a href='http://lyricwiki.org/Juno_Reactor:Hotaka_%28radio_edit%29'>Hotaka (radio edit)</a> by <a href='http://lyricwiki.org/Juno_Reactor'>Juno Reactor</a></h3> <pre> Not found</pre><hr/>Additional Info: <ul> <li><strong>url: </strong><a href='http://lyricwiki.org/index.php?title=Juno_Reactor:Hotaka&amp;action=edit' title='url'>http://lyricwiki.org/index.php?title=Juno_Reactor:Hotaka&amp;action=edit</a> </li> </ul> </body> </html> 

So the next time you need some information about the currently playing track you know exactly which fields are available.

On a side note: the isValid boolean tells you if the track info you are parsing is in fact a running track. If Amarok is not playing all fields will be empty or zero. Check isValid before you start processing an empty data object…

Categories
Programming

Matlab and C++

Wouldn’t it be cool to use native code in Matlab? You can ^-^.

I started out by writing a small hello world program to test C++ but every time I ran it against GCC I got funky errors. After a while I found out why: g++ is the C++ compiler, GCC only does old-skool C. D0h!

This is the crap you would see:

# gcc test.cpp
/tmp/ccrnZKfr.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccrnZKfr.o: In function `__tcf_0':
test.cpp:(.text+0x66): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccrnZKfr.o: In function `main': test.cpp:(.text+0x76):
undefined reference to `std::cout' test.cpp:(.text+0x7b):
undefined reference to `std::basic_ostream<char, char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrnZKfr.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

 

The guide I found even explains how to make a small Makefile to speed up the process of compiling (and testing). The (short) guide is here.

Right now I’m waiting for Matlab to finish installing and then I’ll try to test my Hello World from within Matlab. More info how that works can be found here.

Technorati:

Categories
Programming

Matlab grammar

I described in a previous post how I was trying to parse Matlab code. I’ve given up on this endeavour because it is way too much work (we designated a Matlab compiler as a last resort to get everything stand-alone, we will require Matlab in our project to speed up development).

I will however provide my incomplete and broken grammar, as promised. I hope somebody can use this later on as we have dropped the compiler approach completely.

On a side note, we figured out why nobody has a complete grammar for Matlab: its too darn difficult – if you manage to somehow describe the syntax, implementing it (type checking and internal Matlab functions for example) will be a heck of a lot of work. But it can be done, that much is obvious by now.

matlab.g

// Simple grammar for interpreting Matlab files for the MDDP project.
// Written by Berend Dekens
//
// Note: this part of the project is abandoned and will not be completed. The grammar is mostly working in Antlr except
// for some dodgy errors. If you find this usefull and/or manage to fix the parser errors, please let me know so I can
// fix the problems.
//
// Known limitations:
// - No function calls without parenthesis
// Matlab allows function calls in the form of 'function_name arguments'. This is annoying and thus not allowed.
// - No functions calls (period)
// Currently we do not allow function calls at all. Implementing this means supporting a large portion of basic
// Matlab functions and support for declaring new functions across files. This is beyond the scope of this project.
// - No characters or strings in variables
// Our application is matrices and vectors (integers). Boolean logic is included for the sake of logic blocks and loops.
//
grammar simplematlab;
options {
output=AST;
backtrack=true;
}

// Grammar rules below, start the grammar with a list of statements
statementList
: statement (lineSep+ statementList? )?
;

lineSep
: ';' | '\n' | ','
;

statement
: 'if' parExpression statementList ( lineSep 'elseif' parExpression statementList)* ('else' statementList)? lineSep 'end'
| 'for' Identifier '=' (Identifier | integerLiteral) ':' (Identifier | integerLiteral) (':' (Identifier | integerLiteral))? statementList 'end'
| parExpression
;

// Expressions
parExpression
: '(' expression ')'
| expression
;

expression
: conditionalOrExpression (assignmentOperator expression)?
| '(' conditionalOrExpression (assignmentOperator expression)? ')'
;

assignmentOperator
: '='
| '+='
| '-='
| '*='
| '/='
;

conditionalOrExpression
: conditionalAndExpression ( '||' conditionalAndExpression )*
;

conditionalAndExpression
: equalityExpression ( '&&' equalityExpression )*
;

equalityExpression
: relationalExpression ( ('==' | '!=') relationalExpression )*
;

relationalExpression
: additiveExpression ( relationalOp additiveExpression )*
;

relationalOp
: '<='
| '>='
| '<'
| '>'
;

additiveExpression
: multiplicativeExpression ( ('+' | '-') multiplicativeExpression )*
;

multiplicativeExpression
: unaryExpressionNotPlusMinus ( ( '*' | '/' ) unaryExpressionNotPlusMinus )*
;

unaryExpressionNotPlusMinus
: '~' unaryExpressionNotPlusMinus
| '!' unaryExpressionNotPlusMinus
| primary ('++'|'--')?
;

primary
: parExpression
| literal
| Identifier (identifierSuffix)?
;

literal
: integerLiteral
| booleanLiteral
| 'null'
;

integerLiteral
: Digit+
;

booleanLiteral
: 'true'
| 'false'
;

identifierSuffix
: ('[' ']')+ '.' 'class'
| ('[' expression ']')+ // can also be matched by selector, but do here
| arguments
;

expressionList
: expression (',' expression)*
;

arguments
: '(' expressionList? ')'
;

Identifier
: Letter (Letter | Digit)*
;

Letter : 'a'..'z' | 'A'..'Z';
Digit : '0'..'9';

 

Categories
Programming

I Hate Grammar

I hate grammar. I learned the English language when I was 9 years old (as it is not my native language) while trying to read the manual of QuickBasic under DOS. By the time we actually got English lessons in school I was years ahead of most people in my class and even up to the end of high school I never had to read the books we used in school. Instead I read a lot of English books which provided enough sence for the language to stay clear of any official grammar.

But I am drifting here. The problem in computer land is that we use grammar. Every programming language uses a grammar to allow a human to tell the computer what it should do.

Right now I am working on a project where we want to compile Matlab code into C or C++, feed it to GCC and finally upload it into a Virtex IV FPGA. The FPGA has a Sparc V8 compatible CPU (the Leon 2 to be exact) and has a number of auxiliary processorswhich are dedicated for mathematical calculations. For those who care: we are using Montium cores for the calculations.

Even though we pretty much have solved how to drive the whole thing in theory (not in real life as we are just starting), putting it all together is a bit harder.

It starts with the Matlab interpreter and the grammar needed for the interpreter. I’ve been working with ANTLR in the past to generate a compiler for my own toy language. It supported pretty much everything the old QuickBasic language did except the syntax was much more like Java.

I installed ANTLRWorks to use the shiny new GUI to speed up stuff and immediately ran into a wall: Matlab uses a syntax which sometimes end a statement with a semi-colon (‘;’) and sometimes not, depending if the programmer wants to see intermediate results. I am trying to base my grammar on Java here as it is nice and strict – but stuff like this is rapidly making the adaption a pain in the …

Another hair puller is the syntax of the ‘if’ statement: no block structure… Another one lacking the block structure is the function definition. As we are targeting mathematical speedup here and our Virtex board has no display, I will probably sacrifice some stuff to simplify the compiler.

Right now I’m keeping integers and booleans, logic structures like ‘if’-‘else’ and ‘for’ loops. Floating points, bit operators, function definitions and calls – all have to go. Perhaps I will re-add them later on when needed but right now I don’t see any reason to keep them around.

As soon as I got my sub-set grammar complete I will put it up on my site as nobody on the internet seems to have done this before (I found posts from 1992 with no solutions…).

Categories
Programming

Java on PalmOS sucks

Yes, you read it coming from me – the idiot who practically worshipped Java because of its easy structures and I used to be convinced that its almost up for every task… “ALMOST”….

I found a tool called PalmOrb which allows me to use my PDA – Palm Tungsten T3 – as a matrix display for my computer while its in the cradle. Useless but cool – non?
Anyway, the guy maintining this piece of brilliance is dropping the project because he has so many real lcd’s hooked up he no longer needs to (ab)use a pda for the task.
Ofcourse this code is written in C and I have more experience with Java at this point. So I decided to try to do this in Java.

Categories
Programming

Alpha ready for book library

So far I got an alpha version of the book search working. Instead of writing my own version of the library thats already available I decided to start out with a popup window which is run by my (external) parsing system.