- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Everybody knows the source of good code snippet is on codeproject. It's the ultimate repository of high quality code that promotes code reuse.
Captch: awesomeness, indeed!
Admin
Admin
Sorry for the VB6 snippet; I'm a bit bored and I felt like killing 5 minutes. This is a slightly more efficient way of reading a file line by line.
Captcha: creative :-)
Admin
Not a WTF to me. Yeah, deleting first line in the loop is slow, but if the loop crashes (or is made to stop) on a specific (input) line, the program will resume processing starting exactly from that (input) line again on next startup, which might be an important requirement of the program.
Now try to think of how you would have done it otherwise? Counters? Databases?... Each has its own problems, at least the solution adopted by the code snippet is simple and works.
Admin
Internet Troll:
Trolls can be found under network bridges, and actually post factual information, and are kind and considerate to other posters on Internet forums. They try very hard to give people a good experience.
Dear sergiogiogio,
WTF IS WRONG WITH YOU
DaBookshah
Admin
If were swapping file opening tips here is a perl one
Both do the same thing. The difference comes when you point foreach at a your server logs and it runs out of memory! Foreach reads every line in the file into an array then steps through it, while reads it one line at a time.
Admin
You rip out the first page and read it. Then you but the book on a wooden table and photograph each page with a digital camera. Then print them out and rebind them. Then burn the original book. Rinse, repeat.
captcha = hacker (me != hacker)
Admin
Admin
The version of Hungarian that sucks is the VB version.
For some reason, the VB team didn't "get" the real reason to use Hungarian, which is not to tell everyone what datatype a variable is - it's to inform people about the USE of that datatype. This, even at a time when the damn IDE was quite capable of telling you what datatype a given variable was.
http://www.joelonsoftware.com/articles/Wrong.html
So it's more about saying to the coder things like "this variable contains nasty unsafe user input", or "this variable is being used to carry coordinate data" or "this is the length of a byte buffer". Preventing you from doing things like assigning the buffer length to a variable containing an X-coord. Which is perfectly legal if they are both the same datatype.
intWindowTopLeftX = intLength
xWindowLeft = cbLength
VB style hungarian at the top looks far more plausible as good code than the latter line which is proper "Simyonian" hungarian in its original sense.
Of course, these days, you'd be less inclined to use it because OO means that the context that most simple datatypes appear in is structs and objects, and well designed systems abstract things away to the point where if you try and assign a buffer length to a Point, the compiler will squeal.
Admin
A more sensible option would be to prompt the person for their PIN again. If the owner has walked off after kicking a small dog in disgust, no harm no foul. If the owner is still there, they can retrieve their card.
And don't tell me that this suggestion is insecure. It can only be insecure if the entire banking system relies on a 4 digit security code that... oh, wait a sec. Yep, retarded.
Admin
Admin
Yuck, I hate that: hardcoded filenames.
Just write
#! /usr/bin/perl
while (<>) {
/* do stuff */
}
and supply the filename(s), if any, on the command line.
Admin
You should not rely on Split like that in a production process.
The first time you get a truncated file watch what happens...
Reading the file a line at a time and processing that line is often a better approach, allowing the program to evaluate each line as it exists, and fail gracefully on a malformed line if it is found.
Admin
[quote user="Zlodo"][quote user="Tim Gallagher"]...Somewhat related to the subject, I had the displeasure of having an ATM crash on me yesterday. With my credit card inside...[/quote] We're getting off topic, but I wanted you to know, Zlodo, that this doesn't just happen in Norway. In 1991, I was in Montreal, Canada, on a business trip and dead tired from too many long days. I put my bank card into an ATM to get some cash. It politely told me that it was not on Interac (which is the principal inter-bank ATM system in Canada) and then impolitely kept my card. So there I was, 700 km from home, with no cash, no bank card, and several days of work to do yet. And of course it was a Sunday, so the bank was closed.
I drew a cash advance on my company credit card to get by. My company was not pleased, of course. On Monday, I went to the bank and was told that they could not return the card to me. The card would be mailed to my home bank "for security reasons."
When I got home several days later, my bank told me that they would watch for my card and notify me when they received it. When it arrived, naturally, they destroyed it and didn't tell me anything. Eventually, I had to get a new card issued.
Admin
Biometria sprzedam dom