Skip to main content

Posts

Showing posts from 2012

The Coolest Shortest PHP Function I Will Ever Write

Having now released my own programming language, FELT , and learned a lot about this and that in the process I have of late, in the evenings, been struggling to reconcile my love of LISP and how simple FELT makes some PHP coding task leaner and meaner with the fact that I still have to use PHP for my day job. In my language, FELT , I have used the square brackets to define a "normal" array and curly braces to define a "key-value" array, mainly because this is identical to JSON format and anybody familiar with Javascript coding just won't have any issues getting to grips with that now will they! Let's take some simple examples of FELT code: (defvar simple-array [1 2 3 4]) (defvar simple-map {:name "Eric" :age 42 :occupation "Viking Hacker"}) When FELT has done its thing, we get the following PHP code, $simple_array = array(1, 2, 3, 4); $simple_map = array('name' => "Eric", 'age' => 42,

You are not here not reading this post...

Some days it's hard to really appreciate what a software developer is or does. And I have "been one" for over a quarter of a century and I still don't know what I do. I can translate management speak into meaningful English and then understand what "they need" as opposed to "what they think they need." I can translate "business requirements" into an internal mental model composed of data stores and processes and subsequently translate that model into "working code" in any language you care to mention to produce a "deliverable". But... I still don't truly understand what happened along the way. I think it is more to do with the underlying nature of the universe rather than the mechanical processes. Codds rules and normalisation for instance, one can learn, understand and apply these rules to great effect but what does "de-normalisation to 2NF" mean to a bunch of atoms and molecules which don't

Sherlock Holmes and the "Case of the Errant Erlang Macro"

The compiler dutifully informed me that: case error_logger:logfile({open, ?IMP_LOGFILE} ) of was giving out: /imp_scan.erl:137: syntax error before: '}' ...and boy did I end up scratching my head until finally, applying Rule #1 (you spelled it wrong) coupled with the Holmes conjecture I realised that (a) I was indeed wrong again and (b) the compiler was correct and here was the problem: -define(IMP_LOGFILE,"/tmp/impscan.log"}). Yes, having decided that the string was best made a constant I refactored the code and accidentally left the trailing closing brace in the macro, hence my confusion! The error message was referring to that brace but because the parameter was itself a tuple I had become confused. Just another day on the job. PS: As I like to call it, the "Holmes conjecture", How often have I said to you that when you have eliminated the impossible, whatever remains, however improbable, must be the truth? .

That's me in the corner, losing my religion...

Some days this job is so hard. No amount of soothing music, coffee, snacks, socks off etc. manages to bring your head back into that "special place", some call it the "zone". Today is one of those days. Perhaps it stems from the fact that I find myself having to work on something that is just looking pretty pointless right now. Not even the fact that it's Erlang seems to be lifting my spirits today, not even the fact that I don't have to touch PHP with a barge pole is even raising a smile. So what is the difference between a "good day" and a "bad day" as a developer? You'd think that after twenty-six years doing it I'd have some idea. I think it relates to a sense of purpose and corresponding sense of achievement. When you perceive that your efforts are actually not going to be in vain; when you perceive that you are being "useful", "effective" and ultimately that you as a person are being "valued"

Snow Leopard and crontab

It seems that somewhere along the line the ability to list and edit your user crontab went away, maybe they are wanting to migrate people across to "launchd" and "launchctl" as the preferred way of doing things. One of the things I still like about Apple is the fact that under the hood it's still  rock solid Unix, and that most of the time, if it works on Ubuntu it works on OS X too, sometimes it may look a little different but in the end you can still bask in some command line warmness to be able to achieve what you want. So, if the commands crontab -l and crontab -e appear not to work anymore, how do you get the same result? For the record, running uname -a on my iMac gives me: Darwin Macintosh.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 Your mileage may vary if its radically different than that... a long time back I wrote a PHP class wrapper around the cron system so that it would

PHP screwed me again...

Writing a WordPress plugin this time, as Fletcher might have said, "You wanna stay away from nonces Gobber, bad news they are." My code had created a meta-box to allow me to tick / untick a simple check-box against pages and posts so that I could restrict content to registered users. Every time I hit the "update" button I got the lovely little error box telling me there was a problem saving my post and to try again. Thanks WP, very helpful. Anyway, I tracked the problem to a piece of code that I had transcribed incorrectly from the WP codex page, don't ask me why I hadn't cut and pasted it directly from the page as I normally do, but here's what I had and what I should have had, first the bad code... wp_nonce_field(   plugin_basename(     __FILE__, ' tnjpay_restricted_nonce'   ), ); and the correct code is... wp_nonce_field(   plugin_basename(__FILE__),   'tnjpay_restricted_nonce' ); Simple, but in the cut-an
Happy 2012. I am moving my unread blog from one place to another as I want to re-use that server account for something useful, to me at least anyway. So, enjoy not reading this one either. :)