programmingTag Archive -

Things that are annoying me at the moment

Here’s a quick list of a few programming-related things that are irritating me at the current time:

  • Inconsistent, illogical, or just plain poor indentation of code.
  • A previous developers apparent thought process concerning the lack of a need to pass function arguments when everything you need can just be pulled in from Global scope.
  • “If” statements with no braces, mixed in with “If” statements with braces, and other strange inconsistencies.

But it’s okay everyone! I am patient, and loving, and will help this little code-base learn to use it’s gifts and talents for good.

Side Effects

Being a programmer sometimes has interesting side-effects on every-day situations.

Today, for instance, I was doing a lot of automation related programming, and some basic shell scripting. Only the shell scripting was really out of the ordinary. I arrived home after work, and found a nice frozen treat to hold me over until the movies tonite. It’s instructions called for defrosting before cooking. My first instinct was to somehow script the microwave to defrost for a time, then immediately begin cooking.

It was almost reactionary to the thought of having to come back to the kitchen to interact with the microwave a second time.

Perhaps I’ve been working too hard?

Great Django Debugging Tips from Simon Willison

http://simonwillison.net/2008/May/22/debugging/

Includes:

  • Making the most of the error page
  • Logging to the development server console
  • Using the debugger (pdb)
  • Handling errors in production

PHP/MySQL Conundrum: Inserting Large Data with PHP Memory Limits

I recently inherited a PHP application that stores uploaded PDF and JPG files in a MySQL database. Unfortunately, it is way beyond scope (and original architecture) to change this fact. Given that, there are some memory limit problems when the initial file is quite large as it’s contents are read to a variable which is evetually placed into the MySQL INSERT query.

Is there a method of updating/inserting to a MySQL field with binary/data directly from disk, or of somehow not reading in the file contents through PHP?

Also, my first thought was to buffer the file in with PHP and use CONCAT, where PHP only has a portion of the data at any given time – but that would require many DB queries (one for each buffered portion of the file), not to mention the very idea just sounds wrong.

Am I thinking about this the wrong way?

UPDATE:

There is a way, and it’s documented in the MySQL Manual, tho’ it took me a bit of searching to find it. The problem, in my case, is that it comes with this caveat:

To use this function, the file must be located on the server host, you must specify the full pathname to the file, and you must have the FILE privilege.

Which makes sense, but will probably prevent me from being able to use this method.