This week I’ve been rather busy working on a number of projects – mostly in languages that I don’t typically use (notably Javascript). As such, I found myself digging around for information more than is typical, and came across some gems that helped me out when I was at a standstill.
In the most recent instance, I had need of a negative assertion in a regular expression. I came across this page that pointed me in the right direction. Specifically: x(?!y).
This matches x only if it’s not followed by y. While this can easily be done with [^y], it becomes more challenging when you have an entire phrase (or even multiple letters). So this was perfect for my needs. This ought to work in regular expressions for other languages too – I just needed it for Javascript.
Then this page reminded me of the need for the g flag on regular expressions to match all occurences within a string. Again, something I should have known, but I was apparently in a rush.
I was having trouble retrieving numeric values from cookies until I came across this article. It doesn’t specifically mention the issue, but it does include the eval necessary around the retrieved cookie that will turn it into a numeric value if needed.
Then I ran into a requirement for a unique date value, and I didn’t want to use a lengthy date. I liked the idea of just a single number. So I found this piece on the Chronological Julian Date and the Chronological Modified Julian Date. Perfect and easy to calculate.
A huge debt of thanks goes to this ancient tip on creating cookie “arrays” in Javascript. A co-appreciation award goes to PHP itself for automatically handling arrays in cookies. These two tips made my job much easier.
I also could not have accomplished my tasks without using techniques presented here (specifically the action method of the form) for sending forms to different places when different paths are taken within the code.
My last issue with Javascript was that I needed to join the elements of an array together and I just wanted to do it with join. Unfortunately, join in Javscript doesn’t work like join in Perl. So I had to find yet another page, which pointed me to the join method on the string itself. Sweet.
Finally I needed some help with PHP, and specifically accessing databases quickly and simply. No problem, ezSQL to the rescue. Thank to Brad for the pointer.