A solution to the MagSafe auto-adaptor problem

November 26th, 2009

Apple came up with this great MagSafe idea, which they of course patented. The problem is, they won’t give a license to anyone else to make adaptors, and they don’t themselves make DC auto-adaptors. This makes it basically impossible to run your MacBook [Pro] in your car, or any other 12 volt DC system (without an inverter, which is inefficient and annoying).

I found that you could get DC adaptors from mikegyver.com, but what they do is they just modify Apple’s adaptors so you can switch the MagSafe end between a DC adaptor or the supplied AC adaptor. This works, but it’s either slightly expensive ($60 US) and inconvenient, if you send in your own AC adaptor to be modified, and you go with the generic DC adaptor option, or very expensive (up to $220 US) if you get them to supply the MagSafe part, and choose the higher quality Kensington or iGo DC adaptor. Or a whole bunch of options in between. I had almost resigned myself to buying one of these from them, but then I looked on eBay…

Turns out you can get a new Kensington 120w adaptor (MacBook Pros only need 85w) on eBay, shipped to Canada, for about $38 Canadian (retail they’re something like $100-$150). Kensington is one of the “top brands” making laptop adaptors, and these adaptors are AC and DC, and have tips for pretty much every brand of laptop… Except, of course, the MagSafe.

$38 is a really good price for the Kensington adaptor, but how does this help if it doesn’t have a MagSafe end? Well apparently you can get anything from Hong Kong (and for really cheap too!). I don’t know how they get away with it, but there’s a Hong Kong company that makes MagSafe ends for the Kensington adaptor. I ordered one, for about $21 total – and they sent two! The wire plugs into the N3 tip on the Kensington adaptor. They sent 2 of these wires (one long, one short), and an N3 tip (which I now have 2 of, since the adaptor itself came with a full set).

I’m quite happy with it all; it’s all quite clearly new, and it works perfectly. And for under $50 Canadian total, it’s a bargain, especially since it’s pretty much the best you can get, and I didn’t have to send anything away or put any of it together myself. Plus, I get a backup MagSafe plug, and a backup for my AC adaptor (since the Kensington does AC and DC)!

A skirmish with IE6 won

October 31st, 2009

I was recently making the navigation for a site, and I discovered yet another problem with IE6. I had a simple <ul> full of <li>s with links (<a>s) in them, which so far works fine in IE6. But when I set the <a>s to display: block; (to make the clickable area the full width of the <li>), IE6 makes a blank line below the <a>s. As it turns out, the problem is simply that in IE6, the default width of the <a>s becomes 100%. You may think “well don’t blocks normally default to 100%?” – well, close, but not exactly it seems. They default to auto as far as I can tell, and the difference is that 100% is literally 100% of the parent’s width. You’d think that would be fine, but you must remember that in the CSS 2 box model (which IE6 does use if you put it in “Standards Mode” with a Strict doctype), the padding, border, and margin all add to the final amount of space an element takes up – the width attribute is only the width of the content. When you set width to auto, it first calculates everything other than width, and then makes width take up the remaining space (or if the element is floated or absolutely positioned, the width of the content it contains). Luckily, just setting the width of the <a>s to auto fixes it.

Fun with DBD::mysql on Snow Leopard

September 27th, 2009

I upgraded my MacBook Pro to Mac OS X 10.6 Snow Leopard a few days ago. Everything seemed great until I tried to go to my new wobsite on my local server, and got an Internal Server Error (which is what you get when you use CGI and anything goes wrong). I checked my error log (/var/log/apache2/error_log), and found that DBD::mysql wasn’t installed anymore. The following is the long and spectacularly boring (but possibly informative) adventures of getting it to work again. Spoiler: I won!

First I tried reinstalling DBD::mysql via cpan, which ended with a “Symbol not found: _mysql_init“. So I thought maybe I’d reinstall MySQL with fink and see if that helped. Turns out I had to reinstall fink first. In the end it didn’t help, but I noticed that fink also had a package called dbd-mysql-pm588, so I installed that… which didn’t help either. Apparently Snow Leopard upgraded perl to 5.8.9/5.10, so even though the package installed fine, it was for 5.8.8 and wasn’t used by the new versions (I’m not really sure how there can be 2 versions in the first place, but I’m sure it wouldn’t work for either of them).

My next idea was to reinstall MySQL with a package from mysql.com. I tried the “Mac OS X 10.5 (x86)”, figuring 32-bit would be more likely to work (there was no package for 10.6). It installed no problem, and appeared to work – but no change on the cpan DBD::mysql front. I noticed however, that cpan was still using the MySQL libraries in /sw (the fink ones). So I uninstalled (“disabled”) everything MySQL-related in fink. That did make it use the libraries I installed from the official site, but still no dice.

Finally, I tried installing “Mac OS X 10.5 (x86_64)” – success! DBD::mysql installed perfectly with cpan… Only thing: all my databases (and users) were gone. Not as huge a deal for me as most people probably, but still not great. I figured my databases probably weren’t actually gone though, and I was right. I found them in /usr/local/mysql-5.0.51b-osx10.5-x86_64/data/ (which of course was the location of the old version I had installed).

Copying all my databases* (to /usr/local/mysql-5.1.39-osx10.5-x86_64/data/)with the server not running worked, and then copying the “mysql” database made the users work again too. There are probably subtleties I’m missing with this method, but this isn’t a production server, this is just for me to develop on – so what matters is just that it works.

And that, is the story of how I bested the mighty DBD::mysql daemon**, and claimed my glorious reward: everything working as it used to.


* These data directories are owned by root, meaning you have to use sudo (or otherwise act as root) to do anything with them. I went about this the dangerous, but convenient way: sudo bash (which starts a new shell as root).
** Technically it’s just a perl module, but that just doesn’t sound quite the same. mysqld is a deamon though, so there was a deamon involved.

I’m the perfect target?

September 6th, 2009

So I was listening to the radio a couple few months ago, and there was a woman talking about how a whole bunch of people were killed somewhere (I forget where). Which is horrible of course, but this isn’t about that (if it were, I’d probably put more effort into finding out where it was), this is about how she said it. She said something along the lines of “10,000 people were killed, including women, children, and the elderly”… which really only excludes one group: male ~18-60 year olds (depending your definition of child and elder). So apparently, as far as killing people goes, I’d be a relatively OK target!

I guess what she really meant was “including people who probably couldn’t fight back very well” (which some might argue wouldn’t include women, but it might actually be somewhat true in the country it happened in). But I still think it’s somewhat amusing that, in an effort to make it sound like a worse tragedy, she essentially picked out one demographic as more OK to kill. Is it really more OK to kill someone who could potentially fight back, anyway?

Also, not that I have anything against them, but by definition “the elderly” have already lived most of their lives, and are therefore closer to dying of natural causes anyway. So, by killing them, you’re destroying less potential life… And yes, I just brought math into it; I should probably stop now.

Oh really?

February 2nd, 2009

“Oh really?” is approximately what I thought when I saw the following:

Statistics of a Compact Flash card in questionable health:
Conflicting size information

Apparently some frogs can hover, in certain situations:
Frogatto hovering

The question is, should I be amused by Facebook’s incompetence, ignore, or ignore? …Or accept Ben Fish?
Facebook requests

If you thought command-line interfaces were cryptic before, try this!
Broken Terminal

It wasn’t exactly the information I was looking for… But the presentation was more interesting than expected:
Disk Utility window

A completely transparent border… I really wonder how something like this can happen by mistake:
Finder window with transparent outline

Sticking the post in the ground would’ve been boring:
Upside Down 911 sign

My Pocketses: An Inventory

January 8th, 2009

In a half-hearted effort to not have two posts in the same category (yet), I’ve resorted to inventorying my pockets.

So, what’s in my pocketses? I like to be prepared for anything. In leu of a sonic ratchet or something, I keep the following in my pockets at (almost) all times:

The wrong pocket:

  • Lighter
    I don’t smoke anything, but why should I let that limit my convenient access to fire?
  • Swiss army knife
    Swiss army knives have all sorts of useful functions; knife, cork screw, can opener, etc. This one in particular though, has something that other (less broken) knives lack: a rotatable plastic cover. In the event that there’s really nothing better to do, this cover can be rotated out of place, and then back again… this could be done for hours.
  • Keychain LED light
    A recent addition to my arsenal, which I got it for free with an order of 2 Pherox bulbs. It’s not really a great flashlight, since the button has to be held down for it to stay on, but it’s very handy as a temporary light – to find the light switch, for instance.

The right pocket:

  • Hackysack
    If you don’t know where your towel is, you should at least know where your hackysack is. Playing hackysack is the perfect thing to do in a lot of situations. For instance, if you’re waiting in a lineup, and you don’t like the person standing in front of you – with a hackysack, kicking them can be made to look like an accident. This one was bought on the site of the original Woodstock Festival.
  • Wallet
    My wallet contains no ID, or means of getting money. Instead it contains:

    • Cash.
    • A guitar pick.
    • Fake fake ID (it has real information on it).
    • 7.3 business cards (some of them with random information on the back).
    • A small piece of paper which on one side reads “GOOD ONLY FOR DATE AND SHOW INDICATED ON REVERSE.”, and is blank on the other side.
    • 3 fortune cookie fortunes.
    • Receipts for the following: “SHIMA BAR TAPE CORK”, Wall-E movie ticket, the wallet itself.
    • 5 pieces of paper with addresses and phone numbers of people and places in Montreal, Toronto, and Ottawa. The oldest of which dates back 6 years, and appears to have been through the laundry.
  • Most of the time there’s a bit of lint in my packets as well. You never know when that might come in handy.

Learning AS3

December 15th, 2008

This post is about my mission to learn ActionScript 3 (Flash’s scripting language). I decided to learn it when a friend asked me if I could make a Flash gallery for her new website. It would’ve been much faster to just make it in AS1, which I already knew pretty well, but it seemed like the perfect project to learn AS3 with. I was already curious about AS3, because it’s much more strict and object-oriented, which I generally consider to be a good thing.

My first impression was that the documentation was quite good, but I quickly came upon some fatal problems with the basic setup of the scripting. It was a relatively small project that could easily be done without making my own classes, but big enough that using classes was really the right way to do it – and besides that, part of the point of learning AS3 was to learn about its class system. So I tried making a simple class, in the “actions” of a frame, and got errors – even copying unedited from the documentation. I tried a bunch other other things, including trying to enclose it in a “package” (like a namespace in C++). None of it worked, until I tried following one of the most basic tutorials in the docs. That worked, but I still couldn’t figure out why it was working, when what I made didn’t.

After some trial and error and asking around on the net, I found out a few key points:

  1. Class definitions must be in separate files.
  2. You can only have 1 class definition per file, because,
  3. Files with class definitions must be named exactly the same as the name of the class they define.

These rules must be followed, because you never tell Flash where the class is defined. Instead, when you try to use a class, it automatically looks for the file called ClassName.as (and it’s case sensitive, even if your filesystem isn’t), in a list of places, including the folder the .fla file is in. If you use packages, you have to make a folder named after the package, with all of its classes inside it. And their contents have to be encapsulated in package package_name { ... }.

Once I figured that out, the rest was well covered in the docs. I don’t really like those rules, but they’re not too bad. Far worse is the fact that I couldn’t find any documentation that stated them. Anyway, I finished the project in about 4 days, and now I know a bunch of AS3! I also made another similar gallery based on the first one, for another friend, which originally was for a DVD, but now she wants it for her website as well (with a bunch more features).

For the record, I don’t really like Flash, but I think it has its uses, and AS3 is a pretty good language in my opinion.

And now I’m being pestered about writing this instead of working on changing the other gallery for web use…

Conviction

November 13th, 2008

I think it’s in our nature to want to be sure about things. One example of this is music; in most music, the singer is completely sure of what he or she is singing, and usually the more conviction they sing with, the more enjoyable the song is – even if you completely disagree with the lyrics. Probably for most of the time we’ve been evolving, knowing more was generally a good thing – even though what you knew wasn’t necessarily true, it was true enough on average that it was a net benefit. Unless you had reason to distrust them, a fellow human who was very sure about something was a good source of information. I don’t think that’s true anymore.

In this day and age, the people who are the most sure of themselves are often the worst sources for information, because usually the reason they’re so sure about something is that they refuse to consider any counter-arguments (conspiracy theorists and preachers, for instance). There’s so much information available now, that it’s easy for someone to convince themselves of almost anything by simply looking at all the evidence that supports it, and none of the evidence that doesn’t.

Of course, logically, this doesn’t make sense, since there could be (and probably is) just as much evidence to the contrary. But because we have this need to be sure about things, it’s easy to fall for it anyway. The scientific approach is the opposite: look for evidence that something isn’t true, and the more you can’t find, the more likely it is that it’s true. But this only works for falsifiable claims, and it doesn’t hold much weight if there simply isn’t much evidence either way.

It is my opinion however, that the scientific approach is (in general) the best way to figure things out. And that far from being its downfall, the fact that it can never prove something 100% is what makes it so good. While very often it is most useful to act as if we know something, based on previous experience making it seem very likely to be true (the sun will rise tomorrow morning, for instance), I think it’s important to remember that we don’t really know anything.

In conclusion: take everything with a grain of salt. Especially this blag post, as I didn’t do any research for it (other than 20 years of observations).

Nikon/Pentax lens experiment

October 29th, 2008

A couple days ago, I came across a post on the Pentax SLR forum on dpreview, saying old Nikon lenses actually sort of fit onto Pentax SLRs. This was particularly interesting to me because I have a Pentax K20D, and my brother has an old Nikon film SLR with a bunch of lenses. Apparently, even though the Nikon F mount turns the opposite way (counter-clockwise) as the Pentax K mount (clockwise), the F mount fits inside the K mount, and will turn about a 16th of a rotation clockwise – enough to be firmly in place, not enough to not worry about it spontaneously falling off. To fit, the lens’ dot needs to be at about 2 o’clock on the camera, rather than lined up with the camera’s dot.

So of course, I had to try this myself. We first tried my brother’s Sigma 28mm f2.8, which fit fairly well. Next was the 55mm f1.2, which unfortunately didn’t really fit, due to being “AI”. Next was a reversing ring, which fit after my brother took out one of the screws (they’re there to prevent turning too far counter-clockwise; unnecessary for turning clockwise). Once that fit, we screwed the 28mm into it (backwards of course). That yielded macro magnification not only better than my Vivitar 100mm f2.8 1:1 macro, but even slightly better than the same with +5 diopter (which I used for my snow flake pictures). Though not quite enough better to counteract the convenience factor (with the Nikon lens, I’d have to do manual stop-down metering, and aperture wouldn’t be recorded in the EXIF info).

Finally, here’s some sample pictures. Note that none of them are actually very good quality, they’re mainly to compare macro magnification.

 

 

28mm, f2.8, 1/60s

28mm, f2.8, 1/60s

3.5mm headphone jack. 28mm reversed, f2.8, 1/80s.

3.5mm headphone jack. 28mm reversed, f2.8, 1/80s.

 

Ruler showing ~1.1cm. 28mm reversed, f2.8, 1/40s.

Ruler showing ~1.1cm. 28mm reversed, f2.8, 1/40s.

 

Ruler showing ~1.4cm. 100mm (with +5 diopter), f3.2, 1/200s.

Ruler showing ~1.4cm. 100mm (with +5 diopter), f3.2, 1/200s.

 

Castle picture on a tin. 28mm reversed, f2.8, 1/25s.

Castle picture on a tin. 28mm reversed, f2.8, 1/25s.

Castle picture on a tin. 100mm (at 1:1, no diopter), f2.8, 1/60s.

Castle picture on a tin. 100mm (at 1:1, no diopter), f2.8, 1/60s.

My first blag post

October 29th, 2008

I decided to make a blag, because while I still have an inexplicable vendetta against them (it all started many years ago, when someone on Neopets asked me what the tag for a blog was), without one I just end up babbling on about things to random people. And not necessarily the people who are actually interested. I also thought I should just try it out.

As with most (reasonable) first blog posts, I make no promises about content or update frequency. But I’ll probably talk about a lot of different things.

Why the default theme? Because I don’t care enough to change it, and because content matters more anyway. If one day I actually care, and have good enough content to deserve it, I’ll change the theme (or make one).