One Liners
Posted by mkhairul - August 20, 2007 at 01:08:29 am - No CommentsCategories: blog
After all this time
I thought I must simplify things. Break things line by line, make it readable for the novice. Avoiding 1-liners altogether. But now, I see that its crucial. Makes sense though. Oh well, you heard the man, bring on the 1-liners!
Some Examples
Some exercises for FizzBuzz.
for x in range(1, 101): print [[[str(x), 'Buzz'][x % 5 == 0], ‘Fizz’][x % 3 == 0], ‘FizzBuzz’][x % 5 == 0 and x % 3 == 0]
for x in range(1, 101): print (x % 3 == 0 and x % 5 == 0) and 'FizzBuzz' or ((x % 3 == 0) and 'Fizz' or ((x % 5 == 0) and 'Buzz' or str(x)))
You can even download youtube videos with a Perl 1-liner. (Apart from installing all the modules).
In the end..
be careful with one liners. Comments are crucial. More than once I looked back at my code and wondering what the hell I’m writing. Should have spent more time writing the comment that made sense in a quick glance.
Now I must get back to work.
Notepad++ 4.2.2, and Javascript Pitalls
Posted by mkhairul - August 16, 2007 at 12:08:43 pm - No CommentsCategories: Tips, blog
New version of Notepad++ (4.2.2) have been released! My favourite text-editor.
A couple of posts (related to javascript) surfaced lately, either through Dzone or Reddit.
Pitfalls
From The 7 Deadly Sins of Javascript
- Validating user input
- Popping faux windows
- You cannot bookmark, print, minimize, maximize, or organize them, but they sure do look real.
- Striping tables like a Zebra
- Floating or flying widgets
- Dragging and dropping
- Retrieving the date and time
- Ignoring the rogue error
- Comma Caused Coruption
- The adulterous "this" can change what it refers to.
- Identity Theft
- String replace only replaces the first occurrence
- MouseOut sometimes means MouseIn
- ParseInt scoffs at your base ten numbering system
- for loops over everything including the kitchen sink
- Event Handler Pitfalls
- Focus Pocus
I’ve been the victim of identity theft for several occasions (3rd javascript gotcha). Heh.
I’d better equip myself with some small note-taking equipment, because when I’m waiting for the bus to arrive, ideas comes raining down on me and just like it came, it vanished upon arrival at the office.
Streamyx O’ Pain
Posted by mkhairul - August 14, 2007 at 01:08:02 am - 4 CommentsCategories: blog
It has been a couple of days now, my ping reply from google is around 777ms and above. My torrent download is 1-10KB/s. Not too bad, eh? I’ve been through worse, with ping reply reaching to 3000ms, unthinkable. Called up the customer support, as usual step by step scripted walkthrough which is amazingly frustating. I felt like talking into /dev/null or to a MySQL Blackhole Table. I’ll spare the details, just ask around some friends who is a bit tech-savvy and watch them spill it out. Burn baby, burn.
I browsed and did a little searching here and there.
Antara sebab TMNET dan ISP2 lain restrict bandwith usage untuk P2P,selain dari alasan yang ianya pengunaan bandwith yang sia2,ialah kerana tekanan dari pihak seperti RIAA/MPA diseluruh dunia. RIAA/MPA melobi senate US untuk meluluskan undang2 untuk menyaman ISP yang membenarkan P2P. Jadi TMNET,selaku sebuah global player mengambil inisiatif. RIAA/MPA is a very powerfull lobby on Capitol Hill and US Senate policies is streched even to foriegn nations.
The first line, waste usage of bandwidth. That is utter crap. I get my monthly bill.. like 4GB usage per month. For a 1MB user to fully utilise its connection, that user must download at least 270GB (something around that). 4GB is nowhere near 5% of 270GB. And some other users utilise it more than I do. I get crappy 10KB/s bt speed.
The evidence is clear, TMnet is using some kind of packet shaping thing to throttle down P2P traffic. More and more people are trying to bypass it.
Committed to bringing you the best, Awwww. Very touching, right here.. right at the heart. Might cause a heart attack one of these days screaming at the customer support and out of frustration of not being able to do anything other than seeing packets drop like flies. There’s not much that we can do about it, not much competitor around. One of these days, we might just have to run through World Health Organisation’s Mental Health Checklist (see The Corporation: Pathological Pursuit of Profit and Power). If we’re unlucky, the resulting diagnosis will be a Psychopath.
For more empirical evidence of crappiness. Major Internet Service Providers Using Traffic Shaping, and TM net is also listed as a BAD ISP. Some people told me that the words that comes out of the mouth of the current Minister of Science, Technology and Innovation is pure fictional and and out of utter ignorance. Not just any people, people that have sat on the same level with him. This gives a bad rep to the person who appointed him.
There’s also some view involving CALPERS, economic domino effects, our country begging for FDI and the government being pressured by the RIAA/MPAA, which sounded rational and credible or radical and at the same time logical, due to the user’s outstanding political knowledge in prior posts.
Is it me or is it just when I’m using BT that my connection becomes excruciatingly slow?
No match for me
Posted by mkhairul - August 8, 2007 at 02:08:54 am - No CommentsCategories: Troubleshoot, blog
Few hours ago, I tried to use MySQL’s Fulltext search. I opened up phpmyadmin, went to the database, clicked on the table, and clicked on the FULLTEXT icon. OK, now the fulltext index is created.
Then I tried using SELECT * FROM details WHERE MATCH(location) AGAINST(’view’);,
No results. I searched through forums, I re-read the documentation, I opened up a mysql in a nutshell book, but still no clue what is happening(where did the results go?). Did I miss something? I got it working in a previous project at work by joining an InnoDB table with a MyISAM table, works smoothly.
Argh. I even went through mysqlperformanceblog.com, searching for some hint (preferably answers) to my salvation. None, zip. I was tempted to try sphinx and xapian, but before I open up those can of "solutions", I might be better off sleeping and dream for revelation (fills up my energy bar too) and give it another try tomorrow.
Alt-Tab Thing..
Posted by mkhairul - August 1, 2007 at 09:08:06 am - 1 CommentCategories: Tips, blog
I got a new book, Windows Developer Power Tools. Thankfully I didn’t bought it, I was itching to buy it when I found out about colibri through it. It’s full with .Net development in it (surprise, surprise) which will be useless to me.
So anyway, found a simple thing which helps a lot (for me at least). TaskSwitchXP.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.
