/** All developers are polyglots, but we are not gods */
That’s when cheat sheets come in handy {
My Portuguese friend João posted this very handy link on his blog, and I thought it worthy of sharing
}
Posted by Stefan Camilleri on {2008.July.30}
/** All developers are polyglots, but we are not gods */
That’s when cheat sheets come in handy {
My Portuguese friend João posted this very handy link on his blog, and I thought it worthy of sharing
}
Posted in dev, shortcuts | Tagged: dev, shortcuts | 2 Comments »
Posted by Stefan Camilleri on {2008.July.30}
/** Here is some handy regex to validate a date using british locale (dd/mm/yy or dd/mm/yyyy) */
Note, this allows / \ . or – as delimiters {
^(?:(?:0?[1-9])|(?:[1-2]\d)|(?:3[0-1]))[-.\\/](?:(?:0?[1-9])|(?:1[0-2]))[-.\\/](?:(?:\d{3}[1-9])|(?:\d{2}[1-9]\d)|(?:\d[1-9]\d{2})|(?:[1-9]\d{3})|(?:\d{2}))$
}
p.s. this regex has now been superseded with an improved version here
Posted in dev, regex | Tagged: regex | 2 Comments »
Posted by Stefan Camilleri on {2008.July.30}
/** A common problem which I have come across multiple times in the past is that of forcing a browser (any browser) to download a file rather than try to open it. */
There’s a myriad of solutions out there on the web discussing this very issue, and I never gave much thought to it until yesterday. {
I came across an excrept of code at my client which was trying to send a csv file to the client (i.e. the client pc), yet the browser (all flavours) insisted on trying to render it, rather than download it.
The solution turned out to be particularly simple; something we all learnt how to do very well when we wanted some sweets as kids… i.e. LIE (to the browser this time)
All you have to do is set the content type to application/binary and the browser will simply not bother trying to do anything with it.
Here’s the magic expression in Java, yet of course this also applies to any other lingo (and if you have a problem, ask me, tell me your language, and if I can, I’ll show you how).
response.setContentType("application/binary");NOTE: IE works slightly different from other browsers (what's new?), in that if you cancel the download, it will close the socket throwing an exception on the server. You of course will need to cater for this.
}
Posted in dev, java | Tagged: java | 1 Comment »
Posted by Stefan Camilleri on {2008.July.16}
/** When I just realise that no matter what, I can never cease to be amazed */
I’m working on some code right now, fixing up some system changes, and I have come across lots of crap, but this one tops it all IMHO {
400 lines of undocumented code in one method!
Go figure… and here I was thinking I was a crappy programmer when I was 20 since I used to commonly put around 50 to a 100 lines of code in my methods.
}
Oh well… just one of those nuisances you know.
Posted in aesthetics, architecture, dev | Leave a Comment »
Posted by Stefan Camilleri on {2008.July.13}
/** Cruising the sea of blogs by the coding monkeys here on WordPress, I cannot fail to realise that there is a good bunch of people out there who have not yet discovered how to use the wordpress way of pasting code into their blogs */
So, in the hope that some will actually read this and take advantage of it, here goes {
Well, it is no rocket science really. All you need to do is to enclose your code in a set of
put your code here
where ‘lingo’ can be any one of {
- cpp
- csharp
- css
- delphi
- html
- java
- jscript
- php
- python
- ruby
- sql
- vb
- xml
}
}
Hope that helps
<h2>Happy blogging</h2>
Posted in aesthetics, blog | 2 Comments »
Posted by Stefan Camilleri on {2008.July.12}
/** So, the never-ending debate as to which is the best typeface to use for programming has also started brewing in my brain. */
I found tons of posts on-line debating what was the best font, and for one, I always felt that Microsoft’s Consolas was by far the best programming font around (and technically it is almost, but not quite, entirely like the best coding font around).
To summarize what sparks the requirement of such a font, it basically boils down to {
}
So, to cut it short, here are the contestants {
}
And that is it really. I have concluded that for now, after testing all these fonts, Consolas remains the one of choice for me. ProFont was terribly inviting, yet the boldness of the font is just way too heavy in comparison to the normal formatting.
Now I’m just hoping to find a font which looks as good as Consolas does in 8pt, but at 7pt, since 8 is just a bit too big for my likes.
Posted in aesthetics | Tagged: dev | 12 Comments »
Posted by Stefan Camilleri on {2008.July.12}
/** This is the re-birth of my blog. Supposedly this would be the fifth or sixth time that I am creating a blog, so I am just curious as to how long this one will last! */
Reasons I’ve had a blog in the past are as follows {
}
…and well that is it!
Posted in ramblings | Tagged: nonDev | Leave a Comment »