Undefined Favorites

by Mark Bowytz in Error'd on 2014-10-24

"It's great I can ship my favorites to Europe, I just wish I knew what they were," writes Nick.

44 Comments - Last Comment @ 14:40

The Beginning of the Zend

by Remy Porter in CodeSOD on 2014-10-23

Karol found a program that needs to look at a timestamp, and determine if that timestamp is before or after an expiration date. The code that was handling this looked like this:

public function _isSmsCodeExpired($id)
    {

        $genDateStr = $this->db()->query('SELECT date FROM table')->fetchColumn();

        if (empty($genDateStr))
        {
            return true;
        }
        
        $expireDateArr = array();
        $intervalSec = 120;

        $genDataTmp = explode(' ', $genDateStr);
        $genDataArr = explode('-', $genDataTmp[0]);

        $expireDateArr['year'] = $genDataArr[0];
        $expireDateArr['month'] = $genDataArr[1];
        $expireDateArr['day'] = $genDataArr[2];

        $genDataArr = explode(':', $genDataTmp[1]);

        $expireDateArr['hour'] = $genDataArr[0];
        $expireDateArr['minute'] = $genDataArr[1];
        $expireDateArr['second'] = substr($genDataArr[2], 0, 2);

        $intervalMin = (int) $intervalSec / 60;
        $intervalSec = (int) $intervalSec - ( $intervalMin * 60 );

        $expireDateArr['second'] += $intervalSec;
        $expireDateArr['minute'] += $intervalMin;

        $expireDateArr['second'] += $intervalSec;
        if ($expireDateArr['second'] > 60)
        {
            $expireDateArr['minute'] += 1;
            $expireDateArr['second'] = $expireDateArr['second'] - 60;
        }

        if ($expireDateArr['minute'] > 60)
        {
            $expireDateArr['hour'] += 1;
            $expireDateArr['minute'] = $expireDateArr['minute'] - 60;
        }

        if ($expireDateArr['hour'] > 24)
        {
            $expireDateArr['day'] += 1;
            $expireDateArr['hour'] = $expireDateArr['hour'] - 24;
        }

        $daysInMonth = date("t", strtotime($expireDateArr['year'] . "-" . $expireDateArr['month'] . "-01"));

        if ($expireDateArr['day'] > $daysInMonth)
        {
            $expireDateArr['month'] += 1;
            $expireDateArr['day'] = $expireDateArr['day'] - $daysInMonth;
        }

        if ($expireDateArr['month'] > 12)
        {
            $expireDateArr['year'] += 1;
        }


        $expireDate = new Zend_Date($expireDateArr);
        $now = new Zend_Date();

        if ($now->isEarlier($expireDate))
            return false;
        else
            return true;
    }

59 Comments - Last Comment @ 14:19

Tokyo Meet-up & Site Fixes

by Alex Papadimoulis in Announcements on 2014-10-21

Tokyo readers -- I am once again visiting your fine city this week, and thought it'd be fun to try for another Tokyo/TDWTF meetup. Earlier this year, we got together at an izakaya for nomihoudai:

13 Comments - Last Comment @ 2014-10-22

Is It Safer to Use Numbers?

by Mark Bowytz in CodeSOD on 2014-10-21

Mac didn't know anything about how the JavaScript on the search page worked, and he wasn't that great at CSS styling, but that didn't matter. He had his orders. As part of the latest round of enhancements, the front-end developer had added another search parameter which would be passed via the regular search URL, and the back end needed to be adjusted to accomodate. (You know... instead of 'http://initrode.com/search?a=xxx&b=yyy' it now was 'http://initrode.com/search?a=xxx&b=yyy&c=zzz'.)

No problem. Mac made his tweak in the code and ran a quick test...which failed instantly in a spectacular way. "WTF? It's a parameter. Must be already used..." he thought, but nope.

17 Comments - Last Comment @ 2014-10-23

Parallel SQL Queries

by snoofle in CodeSOD on 2014-10-20

Daniele worked at a pharmaceutical firm that had an old web application that allowed commercial customers to look up information. Since the data was quite complicated, there were numerous fields that needed to be queried in order to populate the form.

Unfortunately, as the amount of data in the system grew, the time to load the form grew as well. And grew. And grew.

75 Comments - Last Comment @ 11:29

The New Look is Here

by Alex Papadimoulis in Announcements on 2014-10-17

As you may have noticed, the site looks quite a bit different! As I mentioned back in March, it's been almost seven years since the look and feel of The Daily WTF has been updated, and I was getting pretty tired of the "2003ish" vibe the site had.

You guys gave some fantastic feedback to help guide the new design, and in July I shared a preview look. After some more feedback - both on the GitHub issue tracker and the forums - we put on the finishing touches and launched the site this evening.

174 Comments - Last Comment @ 06:59

Sorry, but You Can't Do the Math

by Mark Bowytz in Error'd on 2014-10-17

"I guess that Intuit might have reasons for not allowing me to say Math was my least favorite subject in school," writes Alan R.

58 Comments - Last Comment @ 2014-10-21
View Article Archives »