For the past couple of years, there have been no links to this site. After all, it’s really just notes to myself. But there have been tons of visitors! I have no idea how the robots find these things, but they did. And I had left the settings so that visitors could create accounts in order to post comments.
If you have ever tried to use PHP to process CSV files that contain non-ASCII characters, you know there is a problem out there with lots of solutions that may or may not work. Mostly the latter from what I can tell. Herewith some comments from a PHP command line program that I use to populate a PostgreSQL table with data derived from a spreadsheet.
This is all command-line stuff under OS X.
The IEEE-754 analyzer project fails when using the Opera web browser. I have reported the problem to Opera (Bug DSK-303966), but there is no way to track it, and it has not been fixed as of version 10.60. The problem shows up when I check for decimal recurrences. I keep an array of remainders (numeric strings) in an array, and compare each to remainder (also a numeric string) to all the elements in the array. If
remainders contains the string '1' and the remainder is also the string '1', Opera evaluates
(remainders === remainder) as
I see from my previous post on this project that I've been working on it for over three months now. I had no idea it would take so long. (That can be properly translated into, “I had no idea how ignorant I am!”)
A major source of complication has been my decision to let people enter values in “natural” ways. That, to me, means that the code should be able to handle real, rational, mixed, binary, and hexadecimal representations of values, have the code figure out which is which, and to generate equivalent decimal, binary, and IEEE-754 representations of whatever value the user enters. Regular expressions make the task of recognizing the input format pretty straight forward. (There are radio button to force a particular interpretation in cases where the same input string is ambiguous.) The problems so far have come from the need to translate between decimal and binary values while maintaining precision that exceeds that of the floating-point standard so that final results, after rounding, are accurate.
Herewith, some lessons learned so far and some notes to myself.
If you want to center a table horizontally, you need to apply a CSS rule that specifies margin:auto;. But for that to work, you need to give the table a width, which is a problem because the browser is going to set that based on the contents. Percents, ems, and pixels all have disadvantages in this situation.
But you can specify a width of zero, and all browsers tested (current versions of IE, Chrome, Safari, Firefox, and Opera) will render the table in its natural proportions.
The main point of this blog is to record the stuff I need to remember. Like, what to do when Apple does a security update and breaks my web server. Which happened again today. I've learned when there is an update to wait a day until info about it actually shows up on the Apple updates page. There is always a link to the info in the update dialog box, but they push the update before updating the info about the update.
Just use the built-in do shell sript command:
The docs make a big deal about the code being run by sh rather than by your login shell,
but a she-bang at the beginning takes care of that:
This will set up a tunnel between the local machine and a computer named example.com where I have already added the public key for my local machine to the .ssh/authorized_keys file.
Then you could do, for example:
psql -h localhost -p 2110 dbname
Add -f to make the ssh command run in the background.
The -N option says just to set up the tunnel without running any commands on the remote host.
I’d like to be able to have visitors fill in a form that includes their email address, send a message to that address, and have a program process the email. Standard user verification stuff. On Solaris or Linux, I know how to do it: use procmail to recognize the messages to be handled, and pipe the message to a processing script. The only thing is, I want to do this on my OS X server, and as usual, I want to keep the Apple software (for email in this case) intact. So I need to learn the “Apple Way” of doing things. As of this writing, I still don’t have it working, but here is what I have learned about using Sieve to filter my email.