Posts

Showing posts from 2010

Locating Logs in CakePHP

This should be easy but "Beginning CakePHP" didn't include an index reference for application logs. But the online manual did (w00t!). (  CakePHP Manual Log Reference  ) For my future reference log location: webroot /app/tmp/logs Log File names: error.log debug.log

Evil Net::SMTP Hack with SMTP Authentication

For some reason my hosting provider doesn't like Perl's Net::SMTP SMTP authentication of PLAIN. Everytime, it gives an error. Unfortunately, there is not way to tell Net::SMTP::auth method to only use a predefined mechanism from Authen::SASL. It will tries the first one every time.... This happens to be the ever failing PLAIN not the working LOGIN flavor. I tried to pass in a Authen::SASL to the auth method but it will just be smart and override the mechanism list :( Well, here is my evil to turn the mechanism method into a read only method, put in the top of my script: package Authen::SASL; no warnings 'redefine'; # suppress sub refine warning sub mechanism { return 'LOGIN'; } package main; Awful hack but right now I can't find a better way around this problem without completely overriding the the auth method, which seems much worse. now to figure out how to open a good bug for Net::SMTP.

MySQL - alter column

I needed to convert a column from varchar(25) to varchar(64). Found this somewhere on the page:  MySQL 5.1 Docs ALTER table table_name MODIFY somecolumn varchar(64) NOT NULL The NOT NULL part needs to match what the column definition is today or else it will default back to NULL .

JavaScript form submission gotcha

The other day I fighting with some bad form data and I wanted to have it checked before the form was submitted (plus on the server side). The form is submitted using JavaScript (or javascript :), using: document.myForm.submit() . I would normally add a handler for this using prototype or YUI events but this is some pretty old (old old) code. So I thought I would use some of that sweet  onsubmit handler magic. Inline of course. Something like: <form action="/someaction" type="POST" name="myForm" onsubmit="return validate_form();"> ... Well to my frustrated amazement, the onsubmit handler didn't work. I thought maybe there was some strange caveat that prevent inline event handlers from working with javascript submitted forms. I changed it to using the function pointer definition: document.myForm.onsubmit = validate_form; Well that didn't work either, after some digging (and cursing), I came across a couple of references th

mysql - adding one year quickly

I don't want to forget how to add one year (or any interval) so I'm making a note. DATE_ADD functions in MySQL always seem to get me since Sybase seems so different (but probably isn't that much). Plus, I was being very smart and keep trying to put a + instead of a , . Silly Rabbit! Here it is: SELECT DATE_ADD(NOW(),INTERVAL 1 YEAR) An update to set expiration date 1 year into the future: UPDATE mytable SET exp_timestamp = DATE_ADD(NOW(), INTERVAL 1 YEAR)

Quick way to disable table header in JTable

Last week was Java week. It involved quickly adding a new tab to an existing Java applet application. The layout has a nice larger table header section and allows for the table itself to have a sub-header. That is pretty slick. Until you don't need a sub-header :). After a bit of searching I found a pretty Perl-ish way to disable table headers in Java's JTable. myTable.setTableHeader(null); I kept looking for a disableTableHeader method. This week its off to Excel, Web Posts and VBA again... yikes.

vim tip - equalprg to your favorite tidy-er

I've often wanted to reformat only a section of code or html in vim . Thanks to a pointer by another site (which I can't find at this time). I ran across the equalprg . Most of the time this will reformat a selected block in the current cindent level. This probably will work ok for html except if you want it to make sure all the tags are closed. But since this can be set to anything, you can change it over to use a tidy program (like perltidy or tidy). For Perl add: set equalprg=perltidy\ -nola For html tidy, you need to tell tidy to use XML only: set equalprg=tidy\ -i\ -xml