lion

A tumble-style blog that has bringing you nonsense since 2006
Jan 24
15 days ago.

Fixing keyboard volume on iPhone 3Gs

So, I got my iPhone 3Gs about six months ago, upgraded from my original iPhone. It’s amazing what a little bit more RAM and processor speed can do for you.

iPhone 3Gs

(William Hook)

Anyway, so, one of the things I noticed was that when I upgraded my phones (I use the other one for a iFitness and Notes while at the gym, shopping, or something similar) that the keyboard clicks on the keyboard of my 3Gs got very quite while the clicks the keyboard of my original iPhone were just as loud as previously.

Some research later, I found out that Apple lowered the clicking noise of the keyboard on the 3.1.2 update. Bummer. So, my savage search for a fix began.

After scoping the Apple discussion board for a fix, I found out that there is a little trick to get the volume audible again, and even a way to adjust it the way you like. Make sure your phone isn’t on silent and follow the directions

  1. Open the iPod application
  2. Play a song for a few seconds and pause it
  3. Go home, turn up the volume as high as you’d like
  4. Open Settings, go to Sound, and then manually use the slider to turn down the ringer volume
  5. Go back home and you’ll find that your ringer volume was changed, but the volume of the clicks remains at the level it should have been

Not sure how long this fix will last, but it works fine two days later!



Chatter

Dec 19
1 month, 21 days ago.

Detecting timezone with javascript and PHP.

While working on Boxed Thoughts last night, I came across a problem. The auto-detection I had previously written for finding a timezone had broke. After a bit of pondering I decided to scrap the entire thing and redo it from scratch. Easy? Not really.

On BT, every date is printed through a function that formats, times, and adds appropriate data to the date.

    echo display_date(time(), $format, ...);

There is just one vital problem with finding a timezone server-side: you can’t.

Javascript was my alternative. So, after attempting to create/finding buggy scripts that would do the deed in javascript, I stubbled upon Jeff Bezos’s blog post.

After a bit of reading, learning, and eventually falling in love, I packaged his idea up in a simple function:

function determineTimezone() { 

    var rightNow = new Date();
    var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
    var temp = jan1.toGMTString();
    var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
    var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);

    var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
    temp = june1.toGMTString();
    var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
    var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
    var dst;
    if (std_time_offset == daylight_time_offset) {
        dst = "0"; // daylight savings time is NOT observed
    } else {
        dst = "1"; // daylight savings time is observed
    }

}

Now that we have the actual javascript done, how do we translate this information to the server for PHP to work with?
I had two methods. The first was to use an AJAX request to send that data to the server for it to store in the user session. I disliked this, though, because it required additional calls to the server, and at BT, we’re all about not wasting and reserving resources.
The second method I chose was to create two cookies, one containing the offset information and the other containing the daylight savings information.

function determineTimezone() { 

    var rightNow = new Date();
    var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
    var temp = jan1.toGMTString();
    var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
    var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);

    var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
    temp = june1.toGMTString();
    var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
    var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);
    var dst;
    if (std_time_offset == daylight_time_offset) {
        dst = "0"; // daylight savings time is NOT observed
    } else {
        dst = "1"; // daylight savings time is observed
    }

    //We use jquery's cookie plugin.
    $.cookie('timezone_offset', daylight_time_offset);
    $.cookie('timezone_daylightsavings', dst);
    return null;
}

Now we go to the server end:

class common {
...
public static function fetchTimezone() { 

	$offset = $_COOKIE['timezone_offset']; //
        $time_zone_dst = $_COOKIE['timezone_daylightsavings'];

        $offset *= 3600;
        $zone = timezone_name_from_abbr('', $offset, $time_zone_dst);

        return $zone;

    }
...
}

PHP can happily read the data placed by javascript now. So we push the contents of the cookies into timezone_name_from_abbr(); and get a nice little location. For example, in my case you get “america/chicago”.
Just as a note, I suggest you save your cookies in the user session, just as a time saver.

Last but not least, we actually need to display the date:

function display_date($date, $format, ...) {
...
        $time_zone_name = common::fetchTimezone();

        $datetime = new DateTime($date);
        $datetime->setTimezone(new DateTimeZone($time_zone_name));      

        return $datetime->format($format);
}

First we get the result of common::fetchTimezone(); that we created above. Then we can use PHP’s nifty DateTime and DateTimeZone classes to do the hard work for us. and last, you return the format, exactly the same as you would with date();

The only drawback to this method is that on the first page load, PHP will not have a cookie to get the timezone:

Server side executed [reads nonexistent cookie]
| |
v v
HTML/Javascript rendered [sets the cookie]

Therefore it will default to your server’s original timezone on the first load. Other than that, there shouldn’t be any problems. Of course, you’ll need to splice some of the above into your own code, but it should be similar.



Chatter

Nov 26
2 months, 14 days ago.

Debugging IE7 is a pain

I hate Internet Explorer with an ever burning passion. It’s not the fact that it pretty much rejects every kind of javascript I compose, or the fact that it renders CSS without any kind of pattern or sequence. No, that’s not it at all. I just hate the fact that there is absolutely no native way to debug your content to get it to work.

internet_explorer

Now, while IE7 was a vast improvement over IE6 (I don’t even bother messing with those users, sorry guys, you’re pretty much hopeless, even Google ditched you), it still sucks horribly. For developers, it is not very friendly. IE8, on the other hand, was god sent. However, IE8 has a good rendering engine, leaving IE7’s behind. Also, based on statistics, IE7 still holds just as much traffic as IE8 (even being a year after launch) and less than half of the traffic of both IE6 and IE7 combined (w3). Now, one can honestly say that Microsoft sucks at pushing out updates to their users but that is ridiculous – even Opera can do it without much effort.

Anyway, I’m looking for some tips to debug in IE7 (other than Visual Studio). I have tried both companion.js and debug-bar so I’m going out on a limb here.



Chatter

Nov 22
2 months, 18 days ago.

It’s been awhile

So I thought I would share this:

A lot of people seem to have forgotten, or never noticed, that Lady Gaga wrote songs for a lot of people (Britney Spears, PCD, Fergie, +) before she was finally scout out.



Chatter

Sep 29
4 months, 12 days ago.

Boxed Thoughts: Coming soon

v3.notemine.com

Check that link for a preview of Boxed Thoughts. After a (long) time of work, it looks like it’s starting to surface. Now just to move those Propel components I forgot to take out…



Chatter

Aug 29
5 months, 13 days ago.

Wow.

My Macbook still sounds like a plane, and I launched a small online portfolio because I need work.

Go see



Chatter

Aug 10
6 months, 2 days ago.

Planes

20174021_7d60747603
[Source]

This is kind of like what my MacBook sounds like. I think I should take it in soon.



Chatter

Aug 8
6 months, 4 days ago.

Objective-C and the iPhone

Objective-C

The other day I was wondering (almost completely out of the blue) how to write an iPhone application. After a bit of exploration and refresh on basic C, I learned the objective-C language. After that, I had to apply it to Apple’s methods for creating iPhone apps. It took about two and a half days and had it’s ups and downs. If you’re not used to C or MVC structure, it will be hard as shit. I’m still new to it, but so for I’ve written an app that has a home screen and a options that menu folds down over the current view.
I’ll be diving into it a little deeper after I release the v3 of Notemine. But for those who are aspiring to create one with little to no language, it’s easy and there is a lot of online documentation out there to get you started.



Chatter

Jul 11
7 months, 2 days ago.

iPod Cords

I update my iPod about once every week. It’s an old school iPod Photo from back in the day, before technology could fit into your skinny jeans.

Anyway, my usual cord went MIA. Then I went and got another one. When I opened the drawer full of my miscellaneous and unused cables, I found out that I have like six of those things. Of all of the things I lose (I can honestly set something down and two minutes later forget where I put it) I have never had trouble finding an iPod cord. Possibly because I have so many of them. Then again, who doesn’t have a couple of them laying around their house. Weird, isn’t it?

connecter


Chatter

Jul 10
7 months, 3 days ago.

Hell yea.
[source]



Chatter

Dan is

& this is his thumblish-blog.
I want to know more!

btw, you can contact me at:
dan[at]contagious.nu

Elsewhere