Regular Expressions in Javascript cheat sheet

June 18, 2005
0 comments Web development

This is just so cool. It's a preview of VisiBone's printable cheat sheet of Javascript regular expressions. I really like the idea and will return here many times probably.

Just a thought though, on this page they have in their tagline "Are you still learning JavaScript from a book that's 95% English?". My answer to that: Yes. Using a cheat sheet is obviously a very efficient method but I [and probably most other people] are so stuck in thinking that educational information has to be transferred with lengthy human sentances. When I read computer books I often just read the headlines and look at the example code, but I would probably feel lost if the paragraphs of text wasn't there though.

So, is it time to change? Perhaps cutting out the friendly banter is a thing of the past. Who knows. We'll see.

UPDATE:

I ordered this now and received this in my order confirmation email:

" I can't describe what a thrill it is to get your business. My fondest wish is to make useful stuff -- and for actual people to actually use it. You're probably a complete stranger and somehow I've convinced you to give it a try. And you're actually paying me?! Almost too much to take, but I'll bear up. I'd love to know how it all turns out."

Scandinavian Airlines phone booking

June 16, 2005
16 comments Misc. links

The Scandinavian Airlines online booking really truely sucks. It's slow and confusing with all the little drop-down arrows that requires a P.H.D to understand. What's worse is that it doesn't play well with Firefox. So bad that people have written a greasemonkey script to try to do something about it. Unfortunately that script didn't work at all for me. Perhaps it's got something to do with that it says...:

"Booking System unavailable. Please try again later or contact SAS for assistance. We apologize for the inconvenience and hope to return to full service as soon as possible"

...for about a day. I tried yesterday afternoon and again this morning. How can the booking system be unavailable for at least one day (maybe more)?!

Truncated! Read the rest by clicking the link below.

\b in Python regular expressions

June 14, 2005
3 comments Python

Boy did that shut me up! The \b special character i python regular expressions is so useful. I've used it before but have forgotten about it. The following code:


def createStandaloneWordRegex(word):
   """ return a regular expression that can find 'peter'
   only if it's written alone (next to space, start of 
   string, end of string, comma, etc) but not if inside 
   another word like peterbe """
   return re.compile(r"""
     (
     ^ %s
     (?=\W | $)
     |
     (?<=\W)
     %s
     (?=\W | $)
     )
     """% (re.escape(word), re.escape(word)),
           re.I|re.L|re.M|re.X)

can with the \b gadget be simplified to this:


def createStandaloneWordRegex(word):
   """ return a regular expression that can find 'peter'
   only if it's written alone (next to space, start of 
   string, end of string, comma, etc) but not if inside 
   another word like peterbe """
   return re.compile(r'\b%s\b' % word, re.I)

Quite a lot simpler isn't it? The simplified passes all the few unit tests I had.

My trade salary has gone down, apparently

June 12, 2005
1 comment Work

Sorry about the cryptic title. My actual salary has not gone down but if you are to believe this chart the salary (in the US) for "Web programmer/developer (back end systems)" has gone down with 2.2% in the last five years but actually gone up by 8.2% in the last year.

What is quite interesting is that of "Content developer" which has seen a rise of 6.5% in the last five years. I guess that's the blogging. More and more people get employed now just to blog about a particular industry. This seems to be a modern trend that we'll see more and more of now that setting up a blog of your own is so much easier (I wrote mine from scratch :). I wonder where these "content developers" come from; their individual technical industries such as programming or design or if they come from literary background like book writing.

Anyway, looks like the general trend is that all salaries have gone up from 2004 to 2005.

chmod files differently to directories

June 10, 2005
10 comments Linux

Jan gave me the following piece of advice that I feel I have to write about to help me understand it. What I wanted to do was to set all file to 644 which basically means that the owner can write to it unlike any other losers and it can't be executed. The problem with doing a recursive chmod like this on all files is that you don't want to remove the executability of directories otherwise you won't be able to do useful stuff like ls inside the directory. The trick is to use the +X option. This is what I did:


$ sudo chmod -R 644 IssueTrackerProduct
$ sudo chmod -R +X IssueTrackerProduct

Truncated! Read the rest by clicking the link below.

Good design examples for a non-blog

June 9, 2005
1 comment IssueTrackerProduct

I'm on the lookout for a redesign of the IssueTrackerProduct. Not necessarily a complete redesign but its css and general looks need a serious upgrade. Sure it's built with web standards which means that all that is needed is to change some CSS, but in reality it's harder than that. I think I want to keep the general layout except that when you view a particular issue and I no longer want to center the issue and the followups and I want to have the options such as Subscription and Tell-a-friend in a right-hand menu. Prototype of issue view

The problem is that of inspiration. All good design I see on Zen Garden is for content that is very different from the issuetracker. For example, the issuetrackerproduct design must bare to do both the issueview and the List Issues which requires the whole screen. It just seems that all good design is made for web blogs which is very far from the issuetracker. I want to see design that is using up 100% of the screensize yet manages to not make the textwidth unreadably wide. Some of these narrow designs can be very nice looking but that's not what I'm after now.

Truncated! Read the rest by clicking the link below.

window.onload from before

June 7, 2005
10 comments Web development

In an DHTML solution I've been working on I need to tap into window.onload and append my own function in there. The code looked something like this:


<script>
function foo() { alert("foo"); }
window.onload = function() { foo(); }
</script>
... more HTML junk ...
<script>
function bar() { alert("bar"); }
window.onload = function() { bar(); }
</script>

If you run this it will only run the bar() function because it was defined last. Ideally one would want to write something like this in the second chunk of javascript:


<script>
function bar() { alert("bar"); }
window.onload = function() { foo(); bar(); }
</script>

which when you run it does both alerts but it's unfortunate that the second piece of javascript needs to know about parenting code.

Truncated! Read the rest by clicking the link below.

I'm back! Peterbe.com has been renewed

June 5, 2005
1 comment This site

Finally I got my domain name back. What happened was that it expired without me being notified. The reason I wasn't notified was that the email address that Network Solutions use is ancient and I don't check it anymore. What I had to do was to send a signed fax with a photocopy of me driving license to Network Solutions in the states to tell them to change my email address. Once I've changed my email address I was able to log in and renew the service for three years.

What confused the whole thing was that apparently I thought I could transfer the domain name over to mydomain.com who I use to administer the domain name. The reason it didn't work was that the domain could not be transfered when it was pending deletion.

Long story short: I'm back. To all those of you who have emailed me on mail @peterbe.com you and have got a delivery-error-message, do you want to resend that important piece of email now?

Sound of different languages

May 30, 2005
1 comment Misc. links

Ever wondered what Brazillian Portugese or Indonesian or Swedish sound like? Look no further. This German site has lots and lots of small soundclips where people around the world read a small paragraph from Le Petit Prince.

The site seems to be only in German but you get by relatively well without knowing German. I can imagine that this site will grow with time so soon they'll map a lot more of the interesting languages in Africa. So far, they've collected some 100 languages on this site. Well done!

Kittenwar a clever way of voting

May 29, 2005
5 comments Misc. links

Kittenwar.com, clever voting system At Kittenwar.com they show you two pictures of kittens with a big clear "vs." between the two pictures. You vote for wich one you think is the cutest. The "battles" are randomly selected and sometimes you have to say that an not-so-cute kitten is the winner even though you'd rather just pass that battle.

This idea is really clever because with the random element it does a "randomly permutative" comparison between as many pictures as possible. This is much better than sites Hot or not where you select on a Lickert scale how much you like each picture.

But for this to work, it must be dead clear what the criteria is that you're comparing with. If the criteria on kittenwar.com was "finest fur" the results would be very different.

Truncated! Read the rest by clicking the link below.