Adding graphics, comments to PDFs
I needed to fill out a PDF document today, date it, and sign it. It took me a good hour to accomplish the task as while the latest incarnation of Acrobat has custom stamp feature, annotated text doesn’t print by default (I also wanted to avoid having to print out the document only to scan it back in). In fact, I found no way to print text annotations. Whether “Documents and Stamps” was selected in the Print properties or not, the text annotations would remain missing from the printout. It should not be this difficult to add a text box to a PDF document and then flatten it to be part of the document, and not an annotation per se.
After some more Googling later I happened on this page that outlines a simple way to add “flatten” options to the Acrobat document menu. The associated script to be placed in “Program Files/Adobe/Acrobat 9.0/Acrobat/Javascripts/” folder (the script works with older Acrobat versions, too, as the mentioned instructions are for Acrobat 7.0) is just two lines long:
| | | copy code | | ? |
| 1 | |
| 2 | app.addMenuItem({ cName: "Flatten page", cParent: "Document", cExec: "flattenPages(this.pageNum)",cEnable: 1, nPos: 16}); |
| 3 | app.addMenuItem({ cName: "Flatten document", cParent: "Document", cExec: "flattenPages()",cEnable: 1, nPos: 17}); |
| 4 |
With the above script installed, the task was a snap: I added my signature from a transparent PNG as a custom stamp, added the text annotations, and then flattened the document. Done! Now the annotations print out as they should (whether or not “Documents and Stamps” is selected in the Print properties as now the annotations are part of the ‘base’ document). I can’t imagine why Adobe doesn’t include “flatten” as a default feature!
Ternary beauty
Posted by Ville Walveranta in Programming, Technical on 08 February 2010
I love the ternary operator. It can often simplify a much more complex conditional into few characters. In PHP (and other c-like languages) it’s possible to all sorts of things with the ternary. The following are examples from PHP.
If $b is true, print “true”, otherwise print “false”. Echo doesn’t work here.
| | | copy code | | ? |
| 1 | |
| 2 | $b ? print "true" : print "false"; |
| 3 |
Here’s something I learned today: it’s possible to assign a complex variable to an “internal” shorthand, and then in turn use the shorthand for the final assignment (based on the comparison). This way it’s not necessary to repeat the complex variable in the assignment section which makes the ternary much shorter and thus cleaner.
So instead of this:
| | | copy code | | ? |
| 1 | |
| 2 | $a = ($myObject->anotherObject->arr['somekey'] > 7 ? 7 : $myObject->anotherObject->arr['somekey']); |
| 3 |
You can do this:
| | | copy code | | ? |
| 1 | |
| 2 | $a = (($b = $myObject->arr['somekey']) > 7 ? 7 : $b); |
| 3 |
Awesome!!
How To Destroy Brand Confidence In One Hit
Posted by Ville Walveranta in Hardware, Technical on 20 January 2010
Couple of a weeks ago the power supply of one of our PCs failed. The system is about one and half years old, so fine – sometimes things break. I replaced the power supply and the system was back up and running. The failed OCZ power supply was under warranty, and so I sent it in for replacement. The usual way: I pay the shipping in, they pay the shipping back.
The replacement – a reconditioned unit – arrived yesterday. First thing I noticed that the “WARRANTY VOID IF BROKEN OR REMOVED” sticker was, well, broken. Hm. So today I went ahead and installed it back into the original system, taking out the temporary PSU. I really hate replacing power supplies when the case is even slightly congested and this one was pretty tough to get to. Finally, the replacement PSU was in place and I hit the power button. Nothing!
Few moments of testing later I had determined that the unit OCZ sent as a replacement was DOA. I had to rip it out and put the temp PSU back in. Note to self: from now on the PSU replacement protocol will include stand-alone testing the new unit before I touch the target system.
I very much doubt the unit broke in transit; I’m guessing they either didn’t test it after repairs were completed, or for some reason the unit was never serviced and so I got someone else’s failed PSU in exchange to PSU I sent in for warranty service. The only way OCZ can salvage the situation at this point and avoid getting on my bad list is if they offer to pay shipping both ways. It’s not that much money, but the time wasted on this far exceeded what the replacement is worth.
Many companies forget that the value of warranty they offer not only comes from what they can advertise but also from the PR – positive or negative – depending how they handle warranty.
UPDATE 21 January 2010: Five Star Damage Control
OCZ handled the situation about the only way they could’ve handled it to minimize the negative impression that had already been created: they offered a free upgrade to a new product, or a pre-paid shipping label to return the DOA unit to service/exchange (apparently in case I had to keep the same model, such as a component for a tightly specified system). I chose the upgrade. Let’s hope the new unit works!
UPDATE 22 January 2010: Not so fast, my friend
More to come. Dealing with OCZ tech support turned out to be less than what the first impression promised.
Disabling reCAPTCHA extra function buttons from tab index using jQuery
Posted by Ville Walveranta in Programming, Technical on 30 September 2009
Here’s an easy way to disable the “Get a new challenge”, “Audio Challenge”, and “Help” buttons from reCAPTCHA display block using jQuery.
Simply add the following to $(document).ready(function() { … } on the page you have reCAPTCHA on:
| | | copy code | | ? |
| 1 | |
| 2 | $(document).ready(function() { |
| 3 | $("#recaptcha_reload_btn, #recaptcha_switch_audio_btn, #recaptcha_whatsthis_btn").attr("tabindex", -1); |
| 4 | }); |
| 5 |
Now when you tab out of the word entry field, the extra function buttons are skipped. This is a usability issue because if the extra buttons are left active in tab index, user can easily accidentally reload the challenge image when she thinks she is moving to the next item on the form (which is often the “submit” button), and then quickly hits Enter.
Explorations in the World of Linux
Posted by Ville Walveranta in Technical, UNIX on 05 September 2009
I’ve been a FreeBSD admin for the past decade, and during this time have become quite familiar with the *BSD system. It has its quirks, but overall it’s very clean and easy to maintain.
From time to time – usually when I’ve been getting ready to upgrade to the next major revision of FreeBSD – I’ve taken some time to research what the current pros and cons are for FreeBSD vs. some Linux distro. Always, in the end, FreeBSD has won. However, a development project I’m starting to work on will utilize Zend Server, which is only supported on handful of common Linux distros and on Windows (which is, by default, not an option as I strongly maintain that Windows is not suitable as a web server platform). There is, of course, Linux compatibility layer in FreeBSD, but as Zend doesn’t currently support it as a platform for Zend Server, I wouldn’t feel comfortable using it in a production environment.
So even though I find FreeBSD superior to Linux in many ways, I’ve now spent some time getting acquainted with Linux. I first started with Red Hat, then moved to CentOS which is the Linux distribution I’m currently testing. Now it’s not bad, per se, but I frequently come back to the thought: “Why would someone, anyone prefer THIS over a BSD system?!” The package management with yum, rpm, and the GUI overlays is easy enough, but it’s chaotic! Having to enable and disable repos, set their priorities, etc. seems unnecessarily complicated. On the FreeBSD side there is the ports collection which provides most of the software that one can imagine ever needing. The odd few items that either aren’t available in ports, or whose configuration is somehow not complete enough through ports can be easily compiled from the source tarball. Everything’s quite easy to keep track of, and to duplicate if one’s building a new system.
I’m sure some of this feeling stems from the fact that I have been using a BSD system for so long, and from the fact that I probably don’t yet know Linux well enough (say, to build the system from a scratch..). But as far as I can tell, package management is done with yum and rpm (on CentOS, say), by adjusting repository priorities, and enabling/disabling repositories. That is messy!
Well, I now have a functional development server running Zend Server with Apache, Subversion, and MySQL, and as the vendor (Zend) dictates the rules, I must continue development on Linux. Perhaps in six months time I’ll have more favorable comments about it as compared to FreeBSD… but I sort of doubt it. My guess is I’ll just learn to live with it, every now and then wistfully glancing to the direction of the BSD server.