Sam Levy's blog

Fixing switch - what I want out of switch statements

There are changes to switch statements that would make my life much easier. They are perhaps best explained by just showing you how I want them to work.

switch ($somevar as $s) { 
    case 0: 
        if (do_something()) {
            $s = 1;
            continue;
        }
        break; 
    case 1: 
        $var = "Something"; 
        continue; 
    case 2: 
        $var = "Some "; 
    case 3: 
        $var .= "Things"; 
        continue; 
    case $s > 4: 
        $var = "Too Much!"; 
    case $s > 0: 
        echo $var; 
        break; 
    default: 

Moving blogs

"The time has come," the blogger said, "To talk of other things. Of PHP and JavaScript, and safe MySQL strings."

Which is a complicated way of saying that the posts on this site will, from now on, tend to be about actual code, and my posts which are more off-topic will move to their new home on blog.samuellevy.com. I've migrated old blogs (and comments) over to there already. I'm leaving here everything that involves actual code, seeing as it still gets a fair bit of traffic, and I have code highlighting in drupal.

The future of programming

I've been thinking about the role that programming has in the world today, and the role it will have in the future. As a disclaimer, I'll mention that anything I write in this post is purely speculative, and not based at all on any form of research. This is just what I feel in my gut. As such, I'll try to keep it short, without ranting like Gene Ray.

It's time for us to re-think interfaces

There is a problem with user interfaces. It's a user experience (UX) problem that has been largely ignored for a long, long time. The problem is that we, as software developers, designers, and general techs don't understand how to be users. It's crazy, I know. In almost every bug, issue, and time tracker that I've ever seen, the user is asked to fill in information in a way which doesn't natively make any sense to them. This is because the information we want has no actual meaning to them.

The noble art of Venn

It's not news to anyone that Google has gotten into the "Social Networking" game. Google + isn't even their first attempt to break into this obviously lucrative market. At first I wasn't sure why I would bother with G+. Then I saw what it could be and wondered why everyone wasn't more excited about it.

Google introduced the social networking world to circles. The interface is sleek; the concept so obvious that I don't know why no-one ever did it before; the implementation failing almost completely to live up to what it seemed to promise.

Simple Photo Management and Galleries

I recently got my first decent digital camera. The first one that had changeable lenses, a manual zoom, and full control over all the settings you could want. It takes some great photos, and to ensure that there are great photos, I take a lot of them. Quality through quantity.

Sencha/ExtJS Combo box gotchas - and how to fix them

I've been working on a new project using ExtJs (now called Sencha), and have been spending some time on getting the combo boxes to work just right. The nature of the application that I've been working on (which will show up in my portfolio in due course), means that efficiency of data input is the most important feature.

The simple twitter guide

Twitter is a service for sending short messages. Why is it then that the help guides are so long? In this post, I will attempt to explain each main feature in 140 characters (or less). This guide explains:

  • 'At' messages (@messages)
  • Hash tags (#tags)
  • Re-tweeting (RT) and
  • Direct messages (DM)
  • Common Trends

The tutorial aims to explain these things in simple terms, and not focus on any particular client. In fact, twitter clients will usually give you buttons to do most of these things, but they can be confusing when you first start.

Securing your software: Password security

Password security is always a hot topic of conversation. Passwords are often your first line of defense against intruders, attackers, and all sorts of nasties. What is involved in ensuring password security, though? With something so essential, so vital, why don't we have standards about the correct length, strength, and storage to ensure that passwords are kept secure?

SQL Delete statement using Joins

A co-worker asked me a question about finding and deleting records in a link table which referenced records in either table which no longer existed.

My quick response was to provide him with a simple exclusion query:

SELECT  * 
FROM `Brand_Contacts` 
LEFT JOIN `Brands` ON `Brands`.`id` =  `Brand_Contacts`.`brand_id` 
LEFT JOIN `Contacts` ON `Contacts`.`id` =  `Brand_Contacts`.`contact_id` 
WHERE `Brands`.`id` IS  NULL 
OR `Contacts`.`id` IS  NULL

Syndicate content