It’s not my birthday, it’s a NEW YEAR, dumbass.

happy-birthday-and-happy-new-yearOn the January 1st this year I got one very odd email from online store I purchased something from couple of years ago (BTW, it was the worst online shopping experience ever: it worked like a soviet hospital, not an internet shop).

Anyway, it was a ‘Happy Birthday‘ email, and no, my birthday is not the January, 1st.

It’s very unlikely that I entered 01/01 as my DOB: I try not to tell it to online stores when the field is not required; even when it is I prefer to enter 02/29 to minimize the number of such automated HB congratulations.

So it got me thinking: why on earth would their database contain 01/01 as my DOB?

My best guess is that they are storing date of birth as a unix timestamp. And at some point the value I provided (NULL) got converted to 0 (zero).

And zero seconds since the Epoch means 01/01/1970: so, their software decided I just turned 45 and sent me a happy birthday email (I didn’t think it was possible, but my opinion about that particular store got worse).

What lessons should developers learn from this story?

  1. Never use TIMESTAMP when you can use DATE data type. They are different, and date of birth is definitely a DATE.
  2. Do not confuse NULL and zero (or empty string). NULL is a special value, meaning ‘NOTHING’. There are cases, when it’s the same as zero (e.g.: number of items purchased), but generally it’s not the same (as in my example with non-entered DOB).
  3. Use DEFAULT values properly. 0 and NULL are not necessary the same.
  4. Treat data carefully during upgrades/conversions. I’m not sure if the DOB field was there when I was registering at the website, but it could be introduced in the database later – and all old records may have got their values for DOB field set to 0 instead of NULL.

In my last guess is true, I’m not the only one who got that stupid ‘Happy Birthday’ notification when we should have received ‘Happy New Year’ notification instead.

Happy New Year to all (if any) readers of this blog!

Posted in Uncategorized | Tagged , , , | Leave a comment

Excessive resource usage

Just got an email from one of servers warning me about excessive resource usage:

Time:         Wed Sep 24 05:21:12 2014 -0500
Account:      val
Resource:     Process Time
Exceeded:     1844 > 1800 (seconds)
Executable:   /bin/bash
Command Line: -bash
PID:          21234 (Parent PID:21233)
Killed:       No

I was confused, because everything I was doing there ran smoothly and quickly – no scripts hanging or something like that.

Then I realized I could run `top` to see whether the process (I had its PID) is still there.

It was. It was my bash session. Server was notifying me that my terminal session was using resources excessively – by simply staying connected to the server.

Okay.

Posted in Uncategorized | Tagged , , | Leave a comment

Missing drive in Defragmenter

Everybody knows how to launch Disk Defragmenter in Windows 7: right click on the drive in Windows Explores, select ‘Tools’ tab and press ‘Defragment now’ button. You’ll see a list of drives available for defragmentation:

defragmenter

However, you may want to defragment removable drive, and sometimes it’s missing in this list. Yes — the drive is plugged-in, you can browse/modify files on that drive, yet you can not start defragmentation — because it’s simply not in the list Defragmenter shows you!

Well, it’s confusing — and it should be. First idea that comes to mind — you can not defragment removable drives. Google it: yes, you can. So, something is wrong with the drive? In my case it was some kind of error which I used to ignore (because I had no problems with the drive rather than closing this annoying dialog every time I plugged the drive in):

Do-you-want-to-scan-and-fix-removable-disk

So — you should ‘scan and fix’ your drive before it appears in Defragmenter’s list.

If your drive doesn’t require ‘scanning and fixing’ and still doesn’t appear as available for defragmentation — please keep googling. You are welcome to share you story in the comments.

P.S. I respect beliefs of other people — please do not start holy wars on ‘why would you want to defrag external disk?’

Thank you.

Posted in Uncategorized | Tagged , , , | Leave a comment

Why is it so hard to learn programming?

I wrote this essay for one of Coursera courses I took recently and decided that I’d share it with a world.

Steve Jobs on learning to program

The first language I wrote the program in was Basic. The most challenging step for me was to understand assignment statement which looked like this: x=x+1. I consider myself a mathematician who switched to programming, so for me understanding that statement was a real breakthrough: after I realized that 1) left ‘x’ and right ‘x’ are really different x’s and 2) this is not an equation but a command — after that everything was quite easy.

Learning second language (Pascal) was also pretty straight-forward: learn how to specify your commands for Pascal compiler (instead of Basic Interpreter), master couple of new principles (pointers, records etc.) and you are a Pascal programmer (well, almost). After that I learned PHP, JavaScript, and a little Ruby; now I’m mastering Python: the more languages you know, the easier adding new programming language to your skill set is.

I think that learning programming for me was quite easy because I had strong mathematical background. I knew logics, I knew how to prove things, I knew basic Boolean algebra and worked with numeral systems other than decimal. So the only thing I needed to understand really was that x=x+1 assignment: it broke my mathematical way of thinking and turned me into a (novice) programmer.

I have little experience teaching other people (of different ages) programming and what I find the most problematic for a lot of students is that in order to learn programming they have to learn two things simultaneously: 1) first they have to learn how to compose an algorithm 2) after that they immediately have to transfer their algorithm to a programming language.

Learning algorithms is quite challenging itself; mastering your first programming language when you have no experience in algorithms makes it extremely difficult.

And I don’t mean complex algorithms like sorting, binary search or graph theory. Even composing first algorithms for a basic executor like robot (whose set of commands is really narrow and includes only three of them: STEP/ROTATE/WALL?) is complex for people who have never done anything like that before. They are confused because they have very little experience controlling some executor by writing prior set of instructions that has to be clear, finite, produce a result – and a correct one – and solve not only one problem but a class of similar problems. Most students have experience in computer games where they control executors – but they do it in a real-time, and that’s a different story.

So, people are already confused. You don’t want to confuse them even more by explaining syntax: telling them about indentation, semicolons, memory and such. But you have to in most courses: you have to teach them programming, not algorithms.

The main difficulty in teaching programming (and learning it!) comes from the fact that in most cases you are teaching two things at a time: how to solve a problem algorithmically and how to write that solution in a language which is brand new for the students.

This problem goes away when students have already learned any programming language in the past and want to master second (or even second+) language: you just have to learn new syntax, couple of new principles and several abstraction models which are specific to a new language.

Writing first ‘hello world’ program is intriguing and solves a lot of problems (both for teacher and for student) – running this program means software is installed, environment is configured, IDE is working etc. – but it can be also quite confusing for a student who has no experience in so called ‘informatics’ – i.e. art of composing an algorithm.

Posted in Uncategorized | Tagged , , | Leave a comment

Linkedin Groups

linkedin
Joined couple of Linkedin groups to see what’s going on and to pick up the vibe.

Feels like PHP Mailing List in 2002.

I mean dumb questions and really, really dumb answers to them.

Posted in Uncategorized | Tagged | Leave a comment

Freemake_do_not_remove_this_folder

freemake_do_not_remove_this_folder

OK, I won’t, but only if you would.

P.S. I understand that this bug has probably been fixed (haven’t updated this software for a while), but still a nice bug.

Posted in Uncategorized | Tagged | Leave a comment

British PHP

British PHP
Posted in Uncategorized | Tagged , , | Leave a comment

Dropbox Support

My personal record: Dropbox responded to my email after 1 (ONE) month of silence.

I’m surprised.

Posted in Uncategorized | Tagged , | Leave a comment

Google Chrome: Use Space Bar to Confirm Form Resubmission

Confirm Form Resubmission

Ok, I can live with the fact that Google Chrome shows this “Confirm Form Resubmission” on certain pages where I typed URL manually (which means they were received via GET method, not POST).

But, Google, please, let me use Space Bar to click “Continue” button! I don’t want to switch to my mouse, navigate to that button and click it. I want to quickly hit space bar and continue web-development.

I’m seeing this window hundreds of time each day because I’m a web-developer. I don’t usually use my mouse when I’m testing forms. Tab key, Enter key are perfect for form navigation/submission, and Space Bar was perfect for resubmission confirmation.

Yes, it was working before. First, when Chrome was made public, it was not working. Then somebody fixed it and it was working just fine for years. And when I updated my Chrome earlier this week, it stopped working again.

Actually it looks like just a matter of setting focus to modal window since ‘Continue’ button looks like default window button.

Could you do that for me? Please?

Update from 2013-07-14: Google fixed this bug. Thank you, Google!

Posted in Uncategorized | Tagged , , | 2 Comments

Call from Gmail

Recently Gmail started recognizing phone numbers in email contents and converting them into clickable links. Once clicked, it shows ‘phone’ similar how it shows gtalk chat sessions:

Call from Gmail

I haven’t tried the calling feature itself yet, but I think that regular expressions should not pick up IP addresses and convert them to phone numbers. I’m not sure if it’s solvable programmatically, but who writes their phone number as 4 groups of digits separated by points anyways?

Posted in Uncategorized | Leave a comment