Friday, May 08, 2009

Better looking tabs in jQuery UI 'cupertino' theme

Cupertino is, arguably, the best theme in the jQuery UI theme set. But it has a fatal flaw. The tabs have an ugly blue background to them which IMHO looks ugly.

So here's the fix.

Basically we are trying to convert this -
into this -
To accomplish this add the following CSS to your web pages -

#tabs, #tabs .ui-tabs-nav {
border: none;
background: none;
}
#tabs .ui-widget-content {
border: 1px solid #DDDDDD;
background: #F9F9F9 url(images/ui-bg_highlight-hard_100_f9f9f9_1x100.png) repeat-x scroll 50% top;
}

Now isn't that much nicer. More Mac-ish but still nicer :)

PS: No this cannot be done using Theme Roller (unless you want to break other ui widgets), but you are welcome to try!

MySQL Workbench Lua scripting is awesome!

So I needed to change the MYSQL engine for all tables to MyISAM. No problems! -

foreach_table(sc, function (ts) ts.tableEngine = 'MyISAM'; end);

And I needed to reset autoincrement values in all tables. No problems again!

foreach_table(sc, function (ts) ts.nextAutoInc = ''; end);


Of course you would need to include the lua utility library script I mentioned in my previous post.


Ruby on Rails helper scripts for MySQL workbench!

I've been using DB Designer 4 for quite a while now and while it produced very pretty ER diagrams, it was a bit limited in functionality.

In particular it did not behave well with Rails style databases because of the following -
  1. Table names are plural
  2. Foreign keys are singular! E.g. a foreign key to table "Products" will be called "product_id"!
  3. Primary keys are always "id", regardless of the table name.
These pecularities with the Rails db schemas made it impossible for DBDesigner to infer table relationships, and I simply made peace with that fact and used DBDesigner anyways (the lure of the pretty ER diagrams was too much!)

Well I recently discovered the "successor" to DBDesigner called MySQL Workbench. And amongst all the cool things it brings, the most important is its support for LUA scripting! Surely that can do some nifty things like add support for rails schemas! Alas a quick search on the net revealed no prior scripts I could use.

Now I'm knew zero percent Lua before today but a few minutes with the Lua cheat sheet got me up to speed! It is kind of like a mix between Python and C. I also found some handy prebuilt functions for Lua scripting here which really helped me understand the MySQL Workbench API (which is sadly enough mostly undocumented).

A few hours of hacking later I had the solution ready in the form of a script! Here are the steps to import a rails schema with all the relationships -

  1. Download the script here.
  2. Then run it by pressing Ctrl+Shift+R and selecting wb_library.lua from the location where you saved it.
  3. Make sure there are no errors in the output window.
  4. Reverse engineer your DB schema to get all the tables into an ER diagram. None of the tables will be related to each other die to the problems mentioned above. We'll fix that in a minute!
  5. Select "view > advanced > GRT shell" to open the shell which will allow you to invoke functions from the script.
  6. Now the semi-hard part. You need to get an object of your schema so that you can pass it to the script. Type the following in the shell - print(get_schema(1).name);. If this matches your database name then great! otherwise try print(get_schema(2).name); then print(get_schema(3).name); and so on till you find the index of your schema. (Remember that Lua is NOT zero indexed like usual programming languages. This means that there is no index 0). I'll assume that the correct index is 2.
  7. Type the following in the shell - sc = get_schema(2). Where 2 is the number you got in the previous step. Now the variable sc points to the correct schema.
  8. Now the final magic step! Type connect_all_rails_fk_relationships (sc); in the shell! Watch the magic happen!
It really does work! Maybe someday I will convert this to a plugin with a user friendly GUI!

PS: The script also includes a Lua port of the RoR inflectors (pluralise and singularise). Maybe those are useful independent of MySQL workbench. Check them out.

Wednesday, May 06, 2009

My current non-work-related interests

A brief list off the top of my head -
  1. FOSS document sharing and publishing. Especially an alternative to PDF.
  2. Any web dev topics PHP/RoR/Python, AJAX, anything.
  3. FOSS platforms suitable for embedded systems. OpenMoko, Android, Embedded Forth/Erlang/Scheme/Python.
  4. FOSS Functional programming. Haskell, Erlang, Scheme.
  5. Foss alternatives for shared Calendars, shared code development, shared todo lists, milestone and task management.
  6. What's up in Ubuntu/Debian. Ubuntu 9.04.
  7. Gnome roadmap. Gnome translations into local languages. Getting a better user experience in Gnome (install Thunar, AWN, and global menu bar!)
  8. What's up with Firefox? What's up with Chrome? What's up with Epiphany and Dillo?
  9. New advances in Javascript engines. V8. Tracemonkey.
  10. FOSS based massive information management. Search engines.

Set Thunar as the default file manager in Gnome

Here's a simple trick for a leaner Gnome desktop -

Install Thunar as the default file manager on Gnome!
  1. Install thunar - sudo apt-get install thunar
  2. Change the following Exec lines -
  3. in /usr/share/applications/nautilus.desktop to Exec=thunar %U
  4. in /usr/share/applications/nautilus-folder-handler.desktop to Exec=thunar %U
  5. in /usr/share/applications/nautilus-home.desktop to Exec=thunar
That's it! Thunar will open automatically instead of Nautilus in most places. Some locations like Computer and Network are "pseudo" locations which can only be opened by Nautilus.

India needs a pirate party!


From Wikipedia - The Pirate Party -

The Pirate Party (Swedish: Piratpartiet) is a political party in Sweden as well as the fourth largest party counted in registered members[1] in Sweden which has given rise to parties with the same name and similar goals in Europe and worldwide. The Party strives to reform laws regarding copyright and patents. The agenda also includes support for a strengthening of the right to privacy, both on the Internet and in everyday life, and the transparency of state administration. The Party has intentionally chosen to be bloc independent on the traditional left-right scale[2] to pursue their political agenda with all mainstream parties.

India needs one!

Getting Real Synopsis - Very very rough cut

I made notes as I stormed my way through the Getting Real book freely available online -


1. Fix time and budget. Cut back on the scope if needed. Cutting back on the scope has the added bonus of keeping you focussed on the most important bits of your application.
2. Pick a worthy adversary and then undercut them. Do not fight on their "home turf". Change the rules of the game. Force them to fight you on your own terms. Having an existing competitors makes your promoters understand the market and the business model more easily. BUT do not overanalyse the competition! Don't follow, lead.
3. Be passionate. It shouldn't be a chore. The app should excite you! Be your best salesman!
4. Be thrifty. Be lean. Embrace agility, change, and openness. The heavier you are the harder it is to adapt when a paradigm shift comes along.
5. Look for creative emergent solutions. Keep it simple. Let it happen.
6. For version 1.0 three's company. A developer, designer and sweeper (someone who can roam both worlds). That's the developer staff. One more guy for logistics. Basss.
7. Stay close to your customers. Be truthful. Be yourself. i.e. don't be evil.
8. One point app. What's the big deal? The cutting insight, the vision? If you need more than a sentence, it's not as great as you think it is.

Examples -

Campfire - group chat over IM sucks.
Basecamp - Project management is communication.
FedEx - Being on time is worth money.

PS: A good side mantra for a future app - Err in favour of the users. Users get the benefit of the doubt.

9. Ignore details for version 1.0
10. Wing it. Ignore problems. Spend more time on short term problems than long term problems.
11. Focus on a small core market segment. Know your customers. Don't try to please everyone. Core group will spread word around faster as well.
12. Don't scale while you still don't need to.
13. Be opiniated. Write software KNOWING what's best for your customers. Have a vision.
14. Half not half assed. Build little but well.
15. Focus on the nuclear plant, not the color of the bike shed.
16. Just say no to feature creep. Listen but don't act until it realy keeps on coming back and then you really need to. Tough Love.
17. Every time you say yes to a feature, you are adopting a child. Be prepared to take good care of it and expend time, money and energy in doing so. Understand the true costs of every new feature.
18. Replace feature requests with conventions. Users will really not mind that much.
19. Ask people what they DON'T want instead of what they want. People really want everything that they don't have.
20. Get something running as soon as possible and get feedback. Real things get real reactions.
21. Work in iterations. Be prepared to throw previous work away. Mockups -> HTML -> Version 1.0. Rinse repeat.
22. Avoid user preferences screens. Make the call on behalf of your users.
23. Decisions are temporary. Don't be afraid to take a call FAST. This isn't brain surgery. Lives aren't at stake. Be prepared to revise your opinion later in face of more clarity. Be prepared to throw previous work away. Execute, build momentum and move on.
24. Ideas a worthless. Execution is gold.

Awful idea = -1
Weak idea = 1
So-so idea = 5
Good idea = 10
Great idea = 15
Brilliant idea = 20

No execution = $1
Weak execution = $1000
So-so execution = $10,000
Good execution = $100,000
Great execution = $1,000,000
Brilliant execution = $10,000,000

To make a business, you need to multiply the two.

25. Test in the wild.
26. Smaller tasks. Smaller timelines.
27. Solve the one problem staring you in the face. Take on a big problem one thing at a time.
28. Hire all rounders, not specialists. Keep them communicating. Outsource to specialists.
29. Keep work timing flexible but get UNINTERRUPTED stretches whenever you get them. Allocate time for fun, don't think about work when having fun. Don't kill yourself.
30. Meetings are toxic. Don't have them. 30 mins max. Lesser people the better. Have a clear singular agenda.
31. Celebrate small victories.
32. Hire temps before permanents. Kick the tires before hiring anyone.
33. Go for open source enthusiasts.
34. Go for quick learners.
35. Go for happy over frustrated. Enthusiastic question askers over silent & stoic.
36. Go for good writers and clear thinkers.
37. Interface before code.
38. Design the "blank" state before the "real" state of the app.
39. Don't ignore the "error" state.
40. Context over consistency.
41. Think about your interface messages. Make them user friendly.
42. Keep admin and regular interfaces combined.
43. Keep code simple.
44. Use tools that keep programmers happy. RoR and Ruby.
45. Choose the easy way instead of the right way. If a feature works slightly differently than what you expected, no problems.
46. Set aside time and money for code mainentance.
47. Keep data flowing. Mashups, RSS feeds, widgets. Let users run wild.
48. Eliminate unnecessary formal documents.
49. Write stories not detail. Strategy not tactics.
50. Use real text instead of Lorem Ipsum.
51. Give your product a personality. Polite? Stern? Forgiving? Strict? Funny? Deadpan? Serious? Loose? Do you want to come off as paranoid or trust-
ing? As a know-it-all? Or modest and likable?
52. Give away freebies. Give away your hit single.
53. Signup and cancellation should be painless. No lock in.
54. fEarn customers money. Don't employ "tricks" like signup fees/long term contracts
55. Give plenty of advance notice for bad news.
56. Hollywood Launch. Teaser -> Preview -> Launch. Reward early adopters.
57. Build an ace community based promotional site. Overview, tour, videos/screenshots, manifesto, case studies, buzz, forum, blog, faq, pricing, signup.
58. Share information / experiences with the community. Good Karma. Pay it forward. Create evangelists.
59. Be an early adopter of "cool" features / technologies. Take advantage of your agility. Generate the buzz. Ride the hype wave. Target the special interest groups.
60. Track your buzz. Pay attention to feedback.
61. Upsell within the app.
62. Pick an easy memorable name. Don't sweat it if you don't get the exact domain name. e.g. backpackit.com or campfirenow.com
63. Development team === Support team. Break down the barriers. Feel the pain. Cut out the middle man.
64. The product should require ZERO training.
65. Quick responses to support questions.
66. Use forums to let users help each other.
67. Be open. Deliver all news, god or bad. Publicise your screwups.
68. Issue a major upgrade 30 days after launch.
69. Keep the heartbeat going. Blog. Newsletters. Buzz. Treat your customer like a friend.
70. No betas. Straight to version 1.0. Betas mean nothing thanks to Google.
71. Prioritise your bugs. Ignore the small ones.
72. Don't panic after a bad decision. It's probably not as bad as you think. Ride out the storm.
73. Keep in touch with your competition.
74. No bloat. No kitchen sink. Mature doesn't mean complicated.
75. Be a surfer. Watch the ocean. Keep looking out for that new big wave on the horizon. Be the first to ride it.
76. Finally. Execution and People! Two things that can make or break. Rest is all gravy.

Tuesday, May 05, 2009

Check your computer configuration in Linux (Ubuntu)

Quoting verbatim from this post -

CPU Specification

taufanlubis@zyrex:~$ cat /proc/cpuinfo

processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) 4 CPU 2.40GHz
stepping : 1
cpu MHz : 2400.238
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc up pni monitor ds_cpl cid xtpr
bogomips : 4804.04
clflush size : 64


Memory Usage

taufanlubis@zyrex:~$ cat /proc/meminfo

MemTotal: 481420 kB
MemFree: 5640 kB
Buffers: 72200 kB
Cached: 259676 kB
SwapCached: 7980 kB
Active: 228516 kB
Inactive: 216040 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 481420 kB
LowFree: 5640 kB
SwapTotal: 979956 kB
SwapFree: 971976 kB
Dirty: 8 kB
Writeback: 0 kB
AnonPages: 104716 kB
Mapped: 94236 kB
Slab: 20624 kB
SReclaimable: 9300 kB
SUnreclaim: 11324 kB
PageTables: 2056 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 1220664 kB
Committed_AS: 512424 kB
VmallocTotal: 540664 kB
VmallocUsed: 7500 kB
VmallocChunk: 532700 kB


Harddisk Partition


taufanlubis@zyrex:/proc$ cat partitions

major minor #blocks name
8 0 39121488 sda
8 1 10241406 sda1
8 2 1 sda2
8 3 979965 sda3
8 4 12538732 sda4
8 5 15358108 sda5


Ubuntu Version

taufanlubis@zyrex:~$ cat /proc/version

Linux version 2.6.20-16-generic (root@terranova) (gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)) #2 SMP Sun Sep 23 19:50:39 UTC 2007

taufanlubis@zyrex:~$ cat /proc/version_signature

Ubuntu 2.6.20-16.32-generic

More Mac goodness for Ubuntu - Setup global menu bar on Ubuntu Hardy (8.04)

Global Menu Bar just a swell idea and It's quite a surprise that the idea hasn't caught up yet with the Gnome developers. Macs have had it forever and it should really be the default behaviour for Gnome, given its obsession with clean user interfaces.

So if you are lucky enough to be running Ubuntu 8.10 (Intrepid) or later, you are in luck. Simply follow the installation steps listed on the installation page and you will be set to go.

For Hardy, there is just one more step that is not very well documented in the installation page. You will need to add the following bit of code in your ~/.gnomerc file - export GTK_MODULES=globalmenu-gnome

For me the .gnomerc file did not exist so I simply created an empty one. Note that adding that line to your ~/.bashrc file or ~/.profile file will NOT work (as opposed to what the installation guide says)! So create a .gnomerc file if needed.

Log out and then log in, and pat yourself on the back, you just made your user interface a little bit better!

Grim Fandango reference in The Curse of Monkey Island



In The curse of Monkey Island (MI 3) - the "quite patron" in the chicken shop is (a rather poorly drawn) Manny Calavera! Examine his badge and it says "Ask me about Grim Fandango"!

Nice surprise for a Grim Fandango fan!

Linux advice - Use Epiphany instead of Firefox


I'm running Ubuntu Hardy (8.04) LTS on my not-yet-so-old HP laptop (1.8 GHz Intel Core 2 Duo, 512 MB Ram), and running netbeans+firefox+komodo totally saps out the system! (Don't even ask why I need both Netbeans and Komodo at the same time.) So I did what I should have done a long time back and switched Firefox for Epiphany. It's based on the same Gecko rendering engine which powers Firefox but performs better, doesn't leak as much memory (Firefox easily climbed to over 200 MB of memory usage in a few hours where as Epiphany mostly stays consistantly under 80 MB), and integrates MUCH better into the Gnome desktop (as it uses Gtk instead of XUL stuff). Epiphany needs to be the default Gnome browser.

Added plus which is really a corollory of my last point about Epiphany being based on Gtk - Epiphany behaves well with Gnome Global Menu Bar! Yea! But more about Global Menu Bar in another post.

Sunday, May 03, 2009

Open Office won't eat meat, shave, drink or print on Tuesdays!


https://bugs.launchpad.net/ubuntu/+source/file/+bug/248619
https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/255161

Apparently having a "Tue" at the fourth byte in the postscript files causes them to be incorrectly identified as "Erlang JAM" files! This in turn causes them to not be printed.