Saturday, December 18, 2010

Finally what I Desire

I've been wanting to get an android phone ever since I gave up on WebOS ever reaching our shores. And especially since working in a big locked down corp I really need a way to escape into the virtual world and hence I've wanted the Nexus One, then the Desire then the Desire HD for a long, long time..

I've signed up for the Digi 2 years contract (heh.. I've been a happy user of Digi for more than 3 years already, so I don't reckon I've got anything to lose) at the Digital Lifestyle Expo at KLCC.


Desire hd box

And so after a week of using it here's what I think of it.
I LOOOOOOOOVE IT!!!! :D

Okay.. now that is out of the way, let's be a little bit more objective here. First, what do I like about the phone.

I like the big screen. It's huge and makes reading the internet and stuff a real pleasure. But of course there's a price to pay. I also like the 8MP camera. It takes nice pictures and I think extremely nice videos. I like that it can do 3G (yes.. been using the Palm Centro for quite a while makes me a little behind on this aspect :P) and uploading those pics and vids doesn't take very long (actually, there's no waiting for it since it's multitasking and you can just let it continue in the background). I like that it can be turned into an instant wifi hotspot. And I especially love that it is easy to tether even on Linux (it's just an 'ifconfig up' and dhcpclient away on a Ubuntu server without needing any gui at all). I like how it integrates facebook and twitter and yes, I'm now on plurk too. So viewing new status and replying to them is even easier now. I like the built in GPS and since I like Google Maps before on my Palm Centro, I love it more now on my Desire HD. But I have done much travelling yet since I've got it so have not yet tested out in real life situation. I like the android market and the large range of software available to download.

And now for the not so nice part. One is the huge screen. Yes, it's lovely to look at, but the price is that it drains the battery like there's no tomorrow. I basically have to charge it every morning and afternoon. Of course it might be because I'm so new to it and I can't help but touch it all the time :P. I'm using it more like a little laptop rather than just a phone for calls and sms. So getting 4-5 hours of pretty heavy use is I think quite reasonable. And I'm not too far from a usb port most of the time anyhow. Another thing which I don't really like is... there's no physical keyboard. Being a long time Centro user, this is going to take a lot of getting used to. On the Centro, I was able to set shortcut on every single letter on the keyboard. So to bring up Butler to set my alarm, just press b for a long time. Want to call my wife, press w for a long time. But on the Desire HD, there's no such buttons. And you have only 7 home screen to set up shortcuts and widgets on. Another thing about the large display is that it makes the phone quite big. You can basically forget about using it on a single hand. Even to bring it up the display, you have to press on the tiny power button at the top of device, which means I usually hold it in my right hand and press the button with the index finger on my left hand. The fingers on my right hand isn't long enough to go around the device to reach it. Being big also makes it rather heavy. After hours and hours of use, you do feel a little cramped (okay, I don't use any other phones for hours and hours but I think anything smaller would have less effect physically). And typing means using a virtual keyboard on the screen. It is much easier than I thought but it's still not as easy as using the physical keyboard on the Centro. And though I like the large choice of selection in the app market, but being a noob makes it quite difficult for me to find what might be good and what is not.

But overall I love this phone and hopefully will be able to use it happily for the next 2 years at least.

*updated: only after reading kaeru's comment did I realize my palm was a centro, not a WebOS Pre. Changed the relevant parts.

Thursday, July 22, 2010

Grailsify legacy ms sql database

I had a problem. I'm developing using grails but my constraint is that I have to use a legacy ms sql database that was created by importing data from excel to access to ms sql. Thus the tables do not have any id field or primary key. And not only that, once I've done my work on my pc, and I do a full dump onto the server using MS own "SQL Server Import and Export Wizard 2008" it does not retain the identity property of the id field (that's auto-increment for all you lucky mysqlers). So when grails try to create a new record it fails. So so sad. But after a few days of depressive wanderings I decided to be a man and solve this. So here's the script in full, of how you would automatically create an id if the table does not have it yet, and if already has, will do the whole recreate process to make the id an identity again. Hope it would benefit someone.

declare @tablename varchar(1000),@importnew nvarchar(1000),@addconstraint nvarchar(1000),@dropold nvarchar(1000),@dorename nvarchar(1000),@dname nvarchar(1000),@dquery nvarchar(1000)
declare tables cursor for select TABLE_NAME from INFORMATION_SCHEMA.TABLES
open tables
fetch next from tables into @tablename
while @@FETCH_STATUS = 0
begin
print 'processing ' + @tablename
if exists(select column_name from INFORMATION_SCHEMA.columns where table_name = @tablename and column_name = 'idold')
begin
set @dropold = 'alter table '+ @tablename +' drop column idold'
exec sp_executesql @dropold
end
if not exists(select column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME = @tablename)
begin
if exists(select column_name from INFORMATION_SCHEMA.columns where table_name = @tablename and column_name = 'id')
begin
set @dorename = 'exec sp_rename "' + @tablename + '.id", "idold", "column"'
exec sp_executesql @dorename
set @importnew = 'select identity(numeric(19,0)) as id,* into ' + @tablename +'_tmp from ' + @tablename + ' where 1=0'
exec sp_executesql @importnew
set @dname = null
select @dname = coalesce(@dname+',','') + column_name from information_schema.columns where table_name=@tablename
print @dname
set @dquery = 'set identity_insert '+ @tablename + '_tmp on;insert into ' + @tablename + '_tmp (id, '+ @dname +' ) select idold,* from ' + @tablename + ';set identity_insert '+ @tablename + '_tmp off'
exec sp_executesql @dquery
end
else
begin
set @importnew = 'select identity(numeric(19,0)) as id,* into ' + @tablename +'_tmp from ' + @tablename
exec sp_executesql @importnew
end
set @addconstraint = 'alter table ' + @tablename + '_tmp add constraint ' + @tablename + '_pk primary key (id)'
exec sp_executesql @addconstraint
set @dropold = 'drop table ' + @tablename
exec sp_executesql @dropold
set @dorename = 'exec sp_rename ' + @tablename + '_tmp, ' + @tablename
exec sp_executesql @dorename
if exists(select column_name from INFORMATION_SCHEMA.columns where table_name = @tablename and column_name = 'idold')
begin
set @dropold = 'alter table '+ @tablename +' drop column idold'
exec sp_executesql @dropold
end
end
fetch next from tables into @tablename
end

It took a lot of googling to get that much. In that tiny piece of accumulated wisdom is how you would create a cursor so that you can loop over the items, how you would check whether a field exist or not in a particular table, does the table already have a primary key, how to rename column, how to insert value into an identity field by setting identity_insert to on, how to get a list of table fields and turn it into a comma separated string so that you can put that into another query. Phew.. But most importantly it allows me to import and export my ms sql 2008 database and know that this time the id field would still be intact and functioning (after running the script of course).

/me misses mysql, postgres and zodb... :(

Friday, June 18, 2010

New job, new things to learn.. gotta get in line..

It's been 3 weeks since I've started my new job at a big corporation. Transition into this new job was not easy and even now there is still a lot of pain of adapting. The biggest source of the pain? WINDOWS!!! T.T

Being a big corp, it's almost a requirement that your reliance on all things microsoft has to be solid and deep rooted. Of course we have open source equivalent for most of the stuff but the pressure is on for me to perform and to present some tangible results as soon as possible thus I barely had time to put some basic best practices in place. But finally after 2 days of googling and tweaking, I've got a small pc running ubuntu server serving trac for ticketing and serving out our main mercurial repo. We don't even have the basic infra yet and still management says "these are things are nice to have, but you need to deliver those reports soon. Our deadline was last month".

Then when starting to do development, I start to see how deep the rabbit hole goes. Never mind about the ton of spaghetti code we have to tangle with, database management (this is just our internal development database mind you) consist of importing excel file into access and using odbc to push those tables to ms sql server. Ha. Seamless I tell you.. >.<

So of course there is nothing in the open source world that can match that kind of right click send seamlessness. So for now I concede I have to use windows. At least until most of our database stuff is fully in the ms sql server and I can connect to that directly. But the pain of working in windows.. oh my.. Even looking for text in all the source code is not as easy as 'grep -ir something'. I think I miss grep the most. But of course I miss all the rest of our little treasure trove of command line tools to make dev so much easier. How I wish I had a 'tail -f' in one window of terminator while I restart the server and redo the query in another.

But I'm already here now and I should square my shoulders and get in line.

Some interesting thing I've learned already is how to set the default gateway for windows for example. You just do a:

route change 0.0.0.0 mask 0.0.0.0

That is to change the default gateway if it already exists. Want to know whether it already exists? Print it out:

route print


And also for setting up tomcat6 cgi, edit the conf/web.xml file in the tomcat root directory. Inside there you would see already commented out parts for cgi config. Just remove tags from 2 parts:

<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>


*note - you should add the passShellEnvironment part to allow the cgi to use perl and stuff.
And from:

<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping&gt


And then you have to change the conf/context.xml file to enabled privileged like this:

<Context privileged="true">


Once that is done you've got it made baby.. you can now download strawberry perl and awstats and have awstats even for a tomcat6 server. Follow the instructions here for more details: http://www.wrenbeck.com/flowbuilder/$$download.xsp/blog/3eab0461f928f/awstats_tomcat.html

Just one more note on changes to tomcat to enable awstats. You need to enable the combined log for it to work. For that edit the file conf/server.xml and at the end of the file you might find something like this:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="combined" resolveHosts="false"/>


Release it from it's remarked prison and change the pattern from "common" to "combined".

Learned quite a lot these past few weeks so I guess that's very good. Still have to use windows so that's pretty bad. But plus minus it all, it's still pretty good.

Sunday, June 6, 2010

Unforgettable holiday

Just came back from having a holiday with the family at Lumut. It was quite an ad-hoc decision to follow my parents to Lumut on the family day of their respective companies. So they have already left for Lumut since last friday evening, we didn't even start to get ready till saturday morning. By around 11 am we were already on our way. Looking it up on google maps, estimated time of 3 hours 23 minutes means we should arrive there just about a little bit late for lunch. That was our initial hopes.

Once we were on the road, we didn't exactly know which way to go. And even though I've looked it up more the less on google maps before, I didn't bother much about it because I thought my brother knew the way. Well, we were supposed to get off the highway at Bidor. We didn't realize that till we called our father a little after we just passed the Tapah exit. So we had little choice but to exit at Gopeng. And we got lost more within the maze of village roads and mark less landscape. Finally we arrived at Lumut around 5 pm. That's a good 6 hours, twice the estimated time for us to arrive.

We reached Lumut, exhausted and hungry. We ate a road side stall and they charged us quite outrageously I think. Finally we went to Teluk Batik, and we were even more disappointed by the humongous crowd there. I guess it is the weekend crowd, compounded with the school holiday crowd, compounded with even there was going to be a karaoke contest later that night crowd which we heard of at the stall we ate before. Even to get into the washroom was a long queue of at least 20-30 people OUTSIDE of the washroom building, never mind about the people still doing the 'washing'. But at least my kids got a nice ride at the battery cars & bike. RM 2 per ride. Seeing their happy faces after such a long day was such a great relief.

That night went to eat dinner, I don't even remember the name of the restaurant now. The food wasn't all that great. It tasted ok, but nothing to write home about. And the lights... Oh the lights.. Just while we were eating the whole restaurant (we'll, actually it was just a bigger road side stall) just went out. The whole place turned completely dark. Not once, not twice, but three times... By the third time we were done eating and decided not to spend any more time there.

Then the next day (today), I started to have a very sore throat. Actually it was already quite sore on saturday morning and I feel I was going to be unwell. And I guess compounded with all the stress of travel and all, by this morning it hurts for me to even swallow my own saliva. The pain almost makes me squirm. Eating breakfast was not a very pleasant experience. It was the usual nasi lemak buffet and the rendang ayam was quite nice, but the pain of swallowing stopped me from even thinking about taking seconds.

Then we went to the beach. Finally there wasn't too much people there. There was still a lot, but not as if you were in a mall on sale. And I finally had my first experience riding the banana boat. That's basically a long float where around 7-8 of us sit on and pulled by a speed boat. The speed boat would make a quick turn in the deeper waters which would make us all tumble over into the water. It was quite exciting. But then faced the unsurmountable problem of getting back on the float with a body as heavy as mine. Trying hard to pull myself on it, I nearly gave up. Good thing my brothers were able to pull me up. By the time we got back on, I just wanted to go back already. Was so exhausted. After a bit more playing in the water and the sands, we went back, cleaned up, checked out. Went to Lumut to have lunch and again I think the price was pretty outrageous.

Then we started to head back. Again, I didn't really know the way. And forgetting that I didn't know the way, we stayed back to buy some stuff at the Lumut Bazaar and didn't follow my father back. And so out of my ignorance, rather than heading to Teluk Intan where we would finally go back on the highway at Bidor, I went towards Klang. Oh my God. What a trip that was. I realized we probably made a mistake an hour or so later when there was still no sign of highway at all. And we ended up going through Sabak Bernam. And B44, Jalan Sungai Panjang, was one heck of a unmaintained road. It was like riding a speed boat on land. I had to drive slowly so as not to be thrown right off the road. It was painfully long and tedious to get through. By the end of it my nerves was really frizzled out already. Finally we went out onto the highway again somewhere at Behrang if I'm not mistaken. Felt so good to finally be on a road that you're sure off. Now finally the vacation is over and tomorrow is another day of work. I think I'm more tired now than before. This is certainly a vacation I won't soon forget.

Saturday, May 8, 2010

Ubuntu Lucid Lynx 10.04

Finally decided to install the latest version of Ubuntu on my laptop. I tried the upgrade through Update Manager path. Left it to run and by the time I came back from work, I booted to blank screens. The Grub works but that's basically it. So I booted into Windows, downloaded the CD iso and burnt it and did a completely fresh install. This went much more smoother. Everything worked out of the box for my Acer 4810TG Timeline. Wireless, sound, everything that I usually use (Haven't even tried out the webcam since I've never used it).

But then yesterday something strange happen. There was no more volume and chat applet on the panel. So had to search for how I would reset it to the default and found it here. Basically the steps involve:
1) gconftool --recursive-unset /apps/panel
2) rm -rf ~/.gconf/apps/panel
3) pkill gnome-panel

That's it and it all came back to normal default. Nice.

One thing I've got to mention is about the placement of the windows controller. At first I balked at the fact that it was on the left side of the windows rather than the right side like usual. And at work I actually switched it to be on the right side like normal using the following command:

gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close

But after a while I realized that I don't like it being normal again much. I got kinda used to it being on the left and wouldn't actually mind it, maybe even like it because it does create a sort of a unique experience, could be called a sort of an ubuntuish experience.. :P But anyhow, I didn't bother to learn how to reset it back on the left side at work. But now having formatted my home laptop, I've decided to keep it on the left. Feels more original.. :)

Tuesday, March 16, 2010

Dive into Java

Recently a friend of mine asked me to help him develop a small web application to be run on a tomcat server. So that would mean I have to develop the application using Java, which I have not used ever since my student days. But because the requirements were pretty small, I took up the challenge just for the opportunity to learn something new.

The system was meant to capture the answers of a questionnaire and calculate the score they got. Then display back the past scores. It's pretty small involving just CRUD and a small amount of business logic to calculate the scores. Could probably be done in a bit over an hour if using tools I'm already familiar with like CakePHP or Django. But with Java, it was a completely different story.

My experience with CakePHP when developing MyMeeting made me quite reluctant to ever not use a framework ever again. Unless it's just a small trial program to understand a new language, it's better to use a framework. In the framework usually there is already quite a lot of thought put into how things should be organised and what's the best way to achieve our goals. So you get the benefit of quite a lot of wisdom without having to go through acquiring it. So that was the first thing I did. I googled for a 'java framework' and BOOM. Despair. There was tons of them. So many I had no idea what to choose. So I started to search for reviews and comparisons. You basically can't read about Java framework without struts being mentioned. Tapestry was pretty popular too. But they all seemed to have quite a high learning curve and you read a lot about the DREAD of configuring xml files and all. Finally I tumbled on wicket. Reading reviews and presentations about it got me pretty excited. And when I started developing I realised this framework is just for the UI. It made it pretty easy to do quite ajaxy stuff, but there's nothing about database connection and stuff. And there was no tutorial on how to get CRUD even. So after more googling I finally found Databinder. It is basically using Wicket as UI framework and either Hibernate, ActiveObjects or Cayenne for the database abstraction and interaction. Alhamdullillah. With plenty of examples to copy and paste from (hey, I didn't have a lot of time okeh.. :P) , I was finally able to get simple CRUD working.

Of course by then I met with a lot of the things which made programming in Java a pain. The dependencies, all the declaration, putting in setters and getters for almost every variable. UGH!!!! But in the examples they showed how to set up your project to easily work in Eclipse. And I followed it. And now I understand why Java developers swear by their Eclipse IDE. It's way freaking cool. I mean want to put in all the setters and getters for every variable even though you've got around 50 of them? Forget about typing it, how about just right clicking on the file and choose 'source->generate getters and setters' and it will all be done for you. How cool is that? What's it? You just copied from one file to another a bunch of lines which declared types you've got to import? No problem. Eclipse will automatically copy the imports too if it's already resolved. It's way seriously cool. If only it had vim keybinding.. :P

Anyhow. That took most of my weekends recently but it was very well worth it. I'm not 100% comfortable with it yet, but at least now I can do dev in Java. And if someone was to read my resume and ask me do I know Java I won't have to answer 'Well.. I did a few assignments with it when I was a student'... :P So now the only languages I'd really really like to have a serious go at it is ruby (probably with Rails) and Lisp. Maybe the opportunity would present itself in the future. In the mean time, I still got to polish my Java-fu.

Wednesday, February 24, 2010

Ubuntu ROCKS!!!

ROCK!! Ubuntu really rocks!!

I've spent quite sometime even getting the wifi of this acer timeline 4810tg to work in archlinux, but in ubuntu 9.10, even the live CD was able to detect and use it. But that's not the best part. The best part is that I've finally got my Samsung SCX-4300 to work in Linux.. Wooohooo!!!

Followed the steps shown here. Installed the samsungmfp stuff from repo and walah.. scanner up and running. Oh.. and don't worry about the printer. It was detected and able to be used almost without any effort.

Sweet.. :) now I guess I'll need to buy a new toner for it, it'll be under heavy use from now on.. :D

Friday, January 29, 2010

Random musings..

It seems I haven't written anything for quite a long time. In regards to tech, there wasn't much to write home about lately. I've tried out a bit of android programming (ok, actually only got to the point of running the SDK examples on the emulator.. :P), I've dabbled a bit more with django and learned how to create form generated from the models, and of course learned a ton of things about plone. Currently my focus is more on attempting to port PloneMeeting over to be used on Plone 3. Still learning a lot more about this. I'm very excited about Plone 4. It's fast and it runs on Python 2.6. And that's basically it for tech more the less.

Apart form that, the current state of the country is pretty messed up if you ask me. I can't talk about it without feeling depressed. So I'm not going write anything about it here. It'll make me even more depressed.

On a happier note, my new house is almost ready to move in. Just have to unpack and organize all the stuff which we just brought back from Sepang Putra last week. There was quite a lot of things not to like about the house at first, but after a new coat of paint, some fans, a new sink and some pipeworks, it's turning to be pretty sweet. I'm hoping to finally be able to sleep at my own house by next week.

I really should try to write more often. My ideas are just not flowing anymore now.

Oh and one more thing. If you are in an organization which needs an easy to use intranet where members can share information, upload files, mark events easily, do contact us (ie Inigo Consulting). Manage & share your organizational knowledge. For more information go to http://www.inigo-tech.com. And once I can get PloneMeeting to work, you can even manage your meetings in your intranet too. Contact us now.. :D

Haiya ala Solah