nuSOAP problem – Method not allowed
Posted by mkhairul - February 3, 2010 at 10:02:39 am - No CommentsCategories: Tips, Troubleshoot
I got a call from a friend working at the previous company that I worked for. I did the integration between their flagship application with a 3rd party payment gateway involving SOAP.
As usual, people call me expecting me to troubleshoot problem on the phone. At first I was a little bit confused as to what the problem is, but then I remembered that I had already solved it and went through my notes.
The web service client is calling the web service on SSL, it requires the use of cURL. Enable php_curl extension and everything should work fine.
Listing non alphabet records – MySQL
Posted by mkhairul - January 7, 2010 at 12:01:18 pm - No CommentsCategories: Tips
I know this is rather simple, but I thought I’d just put it here because I haven’t been posting quite as often as I would like.
There’s this application, where it needs to list companies by alphabets. Click on ‘A’ it displays all companies that starts with ‘A’ or ‘a’.
So there’s this ‘Others’. Companies that starts their name with other symbols.
A simple regex will do the job.
SELECT * FROM table WHERE column NOT REGEXP '^[a-zA-Z]'
The application does not work
Posted by mkhairul - December 17, 2009 at 04:12:48 pm - No CommentsCategories: rants
There’s a project I’m involved in where the staff says to their boss that the software that we provide does not work. Since I have dealt with quite a handful of people in the past, I knew this was not the case.
The software that we use is Moodle (we dont actually sell Moodle, just the services like customization, training, setup and configuration). It seems simple enough to use but if you involve some complex process to it (like managing classes etc), it would be overwhelming to use hence the claim that was supposed to be “I don’t know how to use it” to “It does not work”.
I am slightly annoyed at this claim, since we’re dealing with a bunch of IT people (and working collaboratively trying to make this project a success) the phrase should be more precise on the things that “does not work”. For example, “I don’t know the step to do so and so”, “We can’t log into the application”, “We can’t batch upload the student csv files”, etc.
Oh, did I mentioned that the client is up far north, so collaborative work through the internet might be somewhat hard and awkward for them.
I’m going up there on new year’s eve to show them that the damn thing works and refute all the nonsensical claim that was made.
Pondering while reading
Posted by mkhairul - December 16, 2009 at 11:12:41 pm - No CommentsCategories: blog
One of the few stuffs that I do while reading a book is to ponder at a sentence that makes a really good quote. Since I’m driving around now (less public transport), my speed to finish a book almost halted but I still bring a book everywhere I went to because you never know there’s bound to be late appointments, clients, waiting for something, etc.
Pondering is what I do when I read before going to sleep, sometimes the pondering puts me to sleep, other times it gives me the urge to write something in my notebook or do some google search and more reading on the subject matter.
Anyway, its nice to ponder.
Secret Sauce for Software Development
Posted by mkhairul - December 9, 2009 at 04:12:54 pm - No CommentsCategories: blog
From kirk’s post, The Secret Sauce. Words of wisdom from Ralph Johnson..
The state of the practice in software development is pretty dismal. Some groups do a great job, but most do not. As I tell the students in my software engineering course, if you manage requirements, make sure the developers talk to each other, release working code regularly, have some sort of a systematic testing process, use build and version control tools, and periodically stop and see how you are doing and how you can improve, you will be better than 90% of the groups out there. Of course, I could be exaggerating. Maybe it is only better than 75%.
Sounds simple enough. The human factor makes it difficult.
Defaced
Posted by mkhairul - December 8, 2009 at 06:12:42 pm - No CommentsCategories: rants
Recently my blog have been defaced twice, I have a couple of ideas what it is (but have not tested it yet). Hopefully I have time to look into it and fix it up.
Using Guard Clause
Posted by mkhairul - November 25, 2009 at 12:11:05 am - 2 CommentsCategories: blog
Guard Clause, explained in Refactoring: Improving the Design of Existing Code (Chapter 9: Simplifying Conditional, Replace Nested Conditional with Guard Clauses), focuses on the key principle of refactoring: clarity.
A colleague of mine requested a function to validate the time format (10:00, etc). I quickly posted something on pastebin which looked like this.
sub valid_time{
my ($time) = @_;
# format kena betul. 10:00 ataupun 23:00
if(!($time =~ m/([0-9]{2})\:([0-9]{2})/))
{
return 0;
}
my ($hour, $min) = split(/\:/, $time);
if ($hour eq "" or $min eq "")
{
return 0;
}
if($hour > 23 or $hour < 0)
{
return 0;
}
if($min > 59 or $min < 0)
{
return 0;
}
return 1;
}
It was not as good as I expected. So I changed it a bit.
sub valid_time{
my ($time) = @_;
# format kena betul. 10:00 ataupun 23:00
if(($time =~ m/([0-9]{2})\:([0-9]{2})/))
{
my ($hour, $min) = split(/\:/, $time);
if (($hour eq "" or $min eq "")
or ($hour > 24 or $hour < 0)
or $min > 60 or $min < 0)
{
return 0;
}
}
else
{
return 0;
}
return 1;
}
By using the Guard Clause, hopefully it is more readable.
sub valid_time{
my ($time) = @_;
# format kena betul. 10:00 ataupun 23:00
if(!($time =~ m/([0-9]{2})\:([0-9]{2})/)){ return 0; }
my ($hour, $min) = split(/\:/, $time);
if($hour eq "" or $min eq ""){ return 0; }
if($hour > 23 or $hour < 0){ return 0; }
if($min > 59 or $min < 0){ return 0; }
return 1;
}
I remembered that I read somewhere sometime ago, there should be only one exit point in a function, at first I thought it was a rule or something, apparently it is not.
One entry point is enforced by modern languages, and one exit point is really not a useful rule. Clarity is the key principle: if the method is clearer with one exit point, use one exit point; otherwise don't.
MySQL: Comparing float / double
Posted by mkhairul - October 30, 2009 at 02:10:56 am - No CommentsCategories: Development, Tips
I have not done a lot of raw SQL for quite a while. In my current job, I need to do it. Since we’re using MySQL 4, my options were quite limited as I have to be wary about any features to a specific version (especially > 5).
So I was trying to find how to exclude the amount 0.00 from the result. The obvious one would be
foo.value > 0.00
But the comparison is not precise (I googled a bunch of links, but now they’re gone, you can try to google “mysql float comparison”), I would leave the detailed explanation for you to find out.
The way that I found that fullfills the result that I need is,
ROUND(foo.value, 2) > ROUND(0, 2)
Web Services (SOAP) limits
Posted by mkhairul - October 27, 2009 at 12:10:07 am - No CommentsCategories: Tips, Troubleshoot
I’m getting swamped by the task of making an application work with a vendor’s web services. Back in Al-Madinah International University, I did some web service stuffs but that was not an issue as it only sends small amount of data for each transaction.
But now there’s a need to send a lot of data (as much as possible) in one transaction. A single record is at least 500 bytes of data (with all the XML markups), I tried to test by sending an incremental amount of data (starting with 50 records) and worked my way up there, trying to get its limit.
The data is sent back and forth using ajax, when I get a 500 error, I knew it was caused by the amount of data that have to be put in a SOAP envelope.
With 1GB of RAM, I couldn’t even reach 100 records. I tore apart an unused PC in the office and got it up to 2GB and managed to reach 140 records (actually it is 150-160 but, I chose the average limit). Went off to the local pc hardware store and bought a 2GB ram stick. With a total of 3.24GB RAM, I tried it..
I tried sending 200 in one fell swoop and it works. Hopefully tomorrow I can test it more and see how it goes. In the quest to know more about Web Services, here’s some links that I have read.
- High Performance Web Services: Tackling Scalability & Speed
- Large Data Strategies
- Web Services Performance Consideration – Best Practices
- Discover SOAP encoding’s impact on Web service performance
- Improving Web Services Performance (patterns & practices)
- Checklist: Web Services Performance
- Best Practices for Web Service: Part 7, web services infrastructure
Reflections on changing jobs
Posted by mkhairul - October 16, 2009 at 03:10:10 am - No CommentsCategories: blog
Here I am, thinking, reflecting on the past while waiting for my download to finish. Some stupid stuffs that I did a few months back.
Changing jobs. Never ever, change a job in 24 hours. Especially for an unknown company whose office you have never seen. You could think that they’re being lenient and all for meeting at a restaurant for a chat (which actually is an interview), but there’s always “udang disebalik mee”.
Think for a while (in my case I didn’t), if you had an office that you’re proud of, why the hell wouldn’t you invite a potential employee to come over for an interview? This should raise a flag (+5 suspicion).
One of my other mistake is asking a developer who is a good friend of the technical manager for an opinion on the working environment. Obviously it will be biased. Should have waited for a whole month before jumping the ship to investigate further.
There’s also other bunch of mistakes that I made:
- I did not ask about the environment in detail
- I did not ask about developer level documentation
- I did not ask about version control in detail (they used it, but there’s no comments in the commits, you’d have to diff the file to see what have been done)
- I did not ask if there’s any code review being done
- I agreed on the odd working hours (there’s no amount of money that could substitute for this, ok maybe RM10,000. You’d miss a lot in socializing with friends, cats and other stuffs). Burning out by spending too much time on work is certainly not worth it
- I got sucked into a promise of a ‘family environment’ when in reality every company is govern by a market norm (no exceptions, unless you’re one of the founders of the company, then yes it is like a family)
- I was promised that the transition will be fully paid by the company from the old one when in reality their policy only allows them to pay half.
Well that certainly was depressing to think about. Always take your time to dig deeper for more understanding on the environment and work being done at the company that you’re going to.
GimpStyle Theme design by Horacio Bella.
