Home

xRIM: The Virtuous Cycle

Posted on January 10, 2012 at 01:56 AM

Categories: tech, theories, mobile, business, barcamp, startupcamp, jobs

Blackberry_parachute

What would happen if a handful of ex-RIM employees started up new companies? Food for thought. Thousands have been laid off, we could get dozens of new startups. The groups would be experienced, knowledgeable, compatible, the ideal for a founding team. They would be connected to former colleagues wealthy from stocks from RIM's early days, making it easy to raise seed capital.

On the other hand, the RIM "diaspora" could drift away, getting jobs in the US, seattle, silicon valley… pulling valuable human connections, knowledge, and experience out of the local loop.

It's not hard to see that the first scenario is better for the region. The existing cluster grew because individuals, once they get a taste of the industry, cycle through many companies. In fact, this region has been an entrepreneurial centre since the industrial age. Electrohome for example, a major electronics company in the mid-20th century, was founded in Kitchener. While Toronto has more tech and sheer scale, KW has a greater concentration, and it's concentrated groups of entrepreneurs that create the upwards spiral.

I can't go without mentioning silicon valley, because I spent a significant part of my formative career time there. Around the time of Electrohome, there started a lovely chain of diasporas and virtuous cycles in the bay area. Shockley left Bell Labs to start his new company. The "Traitorous Eight" left Shockley to form National Semi. More left to start Intel and AMD. At SRI, Engelbart's employees skipped out to join PARC. PARC people left in many directions–including the Mac division at Apple, as well as Adobe and 3Com. Ex-3Com people are all over the place. More recently, there's the Xoogler effect, leading even to specialized ex-google-only VCs.

My point is this: if we can keep the xRIM in the area, then cool tech will be created, the cluster will expand, and new startups will grow. That's a good thing. So, let's see if we can see the silver lining in the cloud and open up some doors.

Oh yeah, and come out to StartupCampWaterloo12.

How to interview well at Google

Posted on August 29, 2011 at 10:11 PM

Categories: tech, code, infographics, jobs

Interview_flow_chart

Some friends of mine have been interviewing at Google and I've been helping them prepare. After some practice interviews, I drew up this flowchart for them to take with them (mentally) to the interviews.

Google uses "oral exam" type interviews:

For another strategy, pull out your copy of CLR(S) (you do have a copy, right?) and re-learn everything. It's all fair game in a google interview.

After you start reviewing, you must do practice interviews. Invite a friend over to ask you questions. Here is what they have to do:

  1. Pick a challenging question and read it to you.
  2. Not give you any help at all.
  3. Ask for a solution in pseudo-code. When you provide it, ask for the order of magnitude runtime analysis.
  4. If you make a mistake, after a while, they should say "are you sure that's correct?"
  5. If you don't give the optimal solution, they should let you develop it, and when you're done, say "do you think there's a better way to do it?"

Believe it or not, interviewing someone isn't a fun as you think, so provide them with beer and/or pizza. Meanwhile you must do your work on a whiteboard. If you don't have one, use a flip-chart or as a last resort paper.

Trust me, answering questions in real time on a white board isn't like doing them in your head. You must practice this or you're going to mess up the interview. Practice with a friend!

Finally, use the interview flowchart to answer the questions:

  • The first, simplest solution just has to work. Don't worry about runtime at this point.
  • Start with pseudocode. Only real code if they ask for it.
  • Do a bunch of examples. Make up some sample data and run through it by hand. This will help you understand the problem better, even if you think you already do.
  • Once you complete a simple (slow) solution, prove it works and then move on to making it faster.

If you do well, the interviewer will tell you you're done before you run out of time. Good luck!

Scientific American infographics or chartjunk?

Posted on July 29, 2011 at 08:35 PM

Categories: infographics, science

0711graphsci

This data graphic isn't just crazy, it's misleading.

Enhanced information graphics are part Scientific American magazine's refresh effort. They probably feel the pressure from Seed magazine's great imagery. Right now they're they're just flailing around and showing how to do it wrong.

When I first looked "Baby's Life, Mother's Schooling" I thought it was a periodic table of the elements with psychedelic colours. My first intuition was the blue arrows would show the increase in child survival in each country as mother's education grew. But the colour gradients and line thickness changes confused me.

So I read the accompanying text. It purports to explain:

"Mortality drops in proportion to the years of schooling that women attain … as seen above in each rising line."

(this is wrong).

The legend clarifies what the colour gradients mean. It seems that the thickness and colour of each line shows the rate of infant mortality. The rising arrow, on the other hand, shows how much, between 1970 and 2009, education levels have gotten better for women. That's not what was advertised.

I thought I was looking at improvements in child health, not improvements in parental schooling. Where's the real data? Try to read the thickness of each line from left to right. It's not easy to quantify the thickness change by eye, and yet this is the key chart data.

Examples:

  • Things seem to be going well in Guyana. But in fact, the change in infant survival has been minimal. Line thickness stays the same.
  • Yemen appears to be doing poorly, but in fact, infant survival got better, even as women's education stagnated, contradicting the central theme. Line thickness decreases, even though the angle is flat.

(See the full chart.)

The irrelevant time data obscures the relevant correlation data. On the basis of this evidence, I claim that the chart is not only ugly but actually misleading.

In addition to these massive flaws there are also some only major flaws such as:

  • The table of elements style obscures the geographic layout.
  • The grid layout distorts actual continent shapes beyond identification.
  • The colours surrounding each continent are unnecessary non-data ink and clash with the data colours.
  • The extra world map in the legend adds to the confusion about geography.
  • Since the arrows point up, the title should say that "child survival rates go up" rather than mortality going down.

That's a load of complaining, and it would be inappropriate if I didn't end by showing how to fix it. So. If I had been involved in the editorial design, I would have suggested that the artist replace the grid with a real world map, which can easily contain the data elements in free-form layout on top of the relevant country. Next, I would have made each arrow a mini-graph keyed to education in the X dimension and survival in the Y dimension. I would have calmed or eliminated the colouring, since it adds no information.

Multivariate charts are tough to implement, all infographic designers are aware of that. However, that's no excuse. Scientific American should be a beacon of good data graphics, not a disseminator of chartjunk. They need to get their game in shape before they consider themselves serious purveyors of data visualizations.

Amazing comment spam

Posted on July 24, 2011 at 06:24 PM

Categories: meta, internet

I got some really awesome comment spam recently. Here's an example, from my post on Nerdcore music (I deleted the comment because it contained a spam link):

LOL. I think you may have missed your calling. What you need to do now is get some oversized pants and some dark shades. Add a little bling, and they go on tour. You'll pull geeks out of the woodwork. Heck, I bet you could fill a decent sized coffee shop. On second thought, maybe you should stick to your day job.

If this was written by a human, they put some actual thought and energy into it. If it was written by a chatterbot, I'm seriously impressed. Either way, great work, whoever you are!

How to buy speakers

Posted on June 03, 2011 at 11:42 PM

Categories: music, audio

Altec_1202_01

A friend just asked me for some advise on buying speakers — should she get Bose or Paradigm? Well, I had a few words to about that, so here's my response:

Here's an answer that's probably much longer than you wanted but you've hit a personal obsession! Maybe I'll turn this into a blog post :-)

I'm going to throw you a curveball with a totally unorthodox opinion. Speakers are funny, there's no trade secrets or patents that big brands have to make better speakers. It's basically heavy metal and the more expensive the components the better the speaker. And the components are all commodity parts, so big companies have no real edge or benefit. Ads will tout the benefit of odd designs and so on but really what you want is a big, heavy box with good metal inside. MDF (yes, fibreboard) is a great material for the case because it doesn't vibrate.

But—if you get a good pair with a good system, you're going to hear the difference and you'll never go back!

I would stay away from the big brands, because you're paying for marketing, not parts. Bose spends a ton amount of money to convince people that their speakers are awesome, so when you buy the speaker, you're paying for all that marketing. They also use tricks like compression and bass boosting that psychologically make people think it "sounds better" or louder but break down the fidelity of the audio to the original recording. If you want to stick with a known name try B&W.

But you don't need or necessarily want to get a brand name. Instead go for some tiny company in some guy's shed. A friend of mine bought a pair of speakers made by a guy in a shed in Hamilton and they're awesome. My speakers are AudioEngine 5's and they're made by some tiny company in Mississippi and they're very very good. They put the system in my car to shame. Guys in sheds make great speakers because they buy the best parts and have no overhead and there's no magic—what you want is totally dedicated craftsmanship.

When you decide to invest in speakers the first thing to do is head to a proper audiophile level shop and listen to as many as you can. Check out for example Alternative Audio. Turn the system way up to find out what happens to the sound. There's big difference in how they sound just like different instrument makers (they are effectively instruments). For example here's a comparison of two brands on audioholics.

The audio forums are the best place to get unbiased opinions from people who really know what they're talking about. Most reviewers (like on gadget sites) will be judging based on features which don't matter. What you want to know is, do people who have good ears think they sound good. One fun forum for people who really know their hardware (like which crossover is best?) is diyaudio.

You can also trust true audiophile sites because those people are just obsessed. For example have a look at stereophile.com. They have just reviewed for example a pair of bookshelf speakers from a Canadian company called Totem Dreamcatcher. They loved them and they're about $600.

You should be able to get a really good set for under $1000. Don't go higher because you get into stupid money territory and the law of diminishing returns kicks in real fast. Also seriously consider buying used, because they don't degrade over time. No moving parts, and the good ones have good components. You can save a ton of money used. For example look on Audiogon.

If you want to read a really awesome and trippy description of one person's highly convincing theory, check out Mother of Tone ... it's worth checking out as a musician and makes a lot of sense. Start back at the beginning if you have time.

Regarding surround: first get a good stereo pair, and then add the other three, which don't matter nearly as much, simply to add the surround experience.

Finally, speakers are only a part of the chain. All audio hardware follows the general rules above: there's no special magic, don't believe what brands tell you, it's all about components, heavy metal is good, listen before you buy.

In summary there is no "best speaker manufacturer". Go to a high end shop, listen and find out what you like, and then buy used or online from a guy in a shed.

(Pictured is Altec Lancing Voice of the Theatre—a true classic)

How to embed a 480p YouTube video

Posted on April 19, 2011 at 10:17 PM

Categories: code, internet

Google doesn't provide any "official" way to embed a YouTube video in 480p. It always drops you down to 360p by default, and that just looks crap. You can embed in HD so why not 480p? No one knows. But don't despair, there is a way!

Here's some code for you:

<object width="853" height="505">
  <param value="http://www.youtube.com/v/MOVIE_ID&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;rel=0" name="movie">
  <param value="true" name="allowFullScreen">
  <param value="always" name="allowscriptaccess">
  <embed width="853" height="505" allowfullscreen="true"
    allowscriptaccess="always"
    type="application/x-shockwave-flash"
    src="http://www.youtube.com/v/MOVIE_ID&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;rel=0"&gt;
</object>

That will give you an "HD width" 480p video. Just change "MOVIE_ID" to the ID of your video (e.g. "J-lHxxToCfo") in both places. The width of the embed will be 853px, which is 16:9 for HD video.

What if your video is 4:3, i.e. 640x480? I can't find any clean way to embed at exactly that size, if you use the above code you'll get black bars on either side. However you can use a negative margin to get a box of the right shape. Just wrap your object like this:

<div style="width: 640px; overflow: hidden;">
  <div style="margin-left: -107px;">
    <object etc ... ></object>
  </div>
</div>

The controls will go off the screen but at least the user will still be able to click the centre of the video to start and stop it. Here's an example:

My column width is less than 640px but hopefully you get the idea.

CS Rap / Geeksta Rap / Nerdcore

Posted on February 13, 2011 at 10:50 PM

Categories: (none)

I'm not convinced by gamer nerdcore but good CS Geeksta Rap is cool. Finally some street beats that talk to me!

Monzy's Kill -9 (video) is pretty entertaining. Check out Dale Chase Coder Girl. "She's not another shallow copy I can sudo" heheh.

I found a few new lines in a dream recently. Don't know if they'll ever fit into a rap though.

Java or Scala it doesn't matter to me
If you want I'll even write your app in PHP

10 PRINT "HELLO"
20 GOTO ONE-OH

Your bytecode is subject to my interpretation

Use my RJ-45 I'll put a packet right into your ass

If you don't do what I want then I will fork your git
I'm fully dedicated but you just can't commit

Why condition your battery once when you can do it three times?

Posted on October 13, 2010 at 09:46 PM

Categories: mac

MacBook users have started to discover over the last few years that their batteries can take a total nosedive into uselessness in just a few months. The first battery on my 2008 MacBook Pro was dead by the end of 2009, flat dead, and out of warranty too. Damn. Cause of death? Lack of "battery conditioning" also known as "calibration".

If you want to know how to calibrate your battery, you can refer to this hard to find guide from Apple:

To calibrate the battery:

  1. Plug in the MagSafe power adapter and fully charge the MacBook or MacBook Pro battery until the light on the MagSafe connector changes to green and the Battery icon in the menu bar indicates that the battery is fully charged.
  2. Allow the battery to rest in the fully charged state for two hours or longer. You may use your computer during this time as long as the power adapter is plugged in.
  3. Disconnect the power adapter with the computer on and start using it with battery power. When the battery's charge gets low, you’ll see the low battery warning dialog on the screen.
  4. Continue to keep your computer turned on until it goes to sleep. Save your work and close all applications when the battery's charge gets low and before the computer goes to sleep.
  5. Turn off the computer or allow it to sleep for five hours or longer.
  6. Reconnect the power adapter and leave it connected until the battery is fully charged. You may use your computer during this time.

Pretty easy to understand, right? Yeah, the only problem is that even though you're supposed to this every month or two, there's no facility on the mac that actually, you know, prompts you to do it. Nothing, nada, zap diddly doo. You'd think that Apple with their vaunted usability standards would pop up a message at the right time saying "hey, now would be a good time to condition the old battery, here's how to do it".

Also, Apple's instructions are missing two other key pieces of information. The first is that you should immediately download a wonderful app called Coconut Battery. Go ahead, I'll wait. It will tell you how crap your battery is and you can save the data to get a history over time.

Second is that that condition is not something you can overdo. Don't just do it once. Do it twice, three times even. Keep doing it until you stop seeing  capacity gains in coconut battery. Most recently, my first condition went from 71% to 76%, and the second brought me up to 80%. I'm going to see how high I can get.

All in all this is a bit of a failure on Apple's part, and it makes you wonder if perhaps they are making a load of money from selling replacement batteries. It doesn't seem in character for the company. More likely, they just haven't put the time into designing a proper monitoring system that detects when you need to condition. Hopefully we'll get that soon.

Warning: May Cause Earthquakes

Posted on September 13, 2010 at 02:04 PM

Categories: theories, future, predictions, science

Ge_led1

It seems like things that cause earthquakes are the ultimate in evil or hyperbole. But now we've achieved that end: human technology can cause earthquakes. Hurray!

A recent Scientific American article discussed a new way to generate free power called enhanced geothermal. It works great, there's just one minor drawback, it causes constant earthquakes. The project in Oregon is far enough from settlements that it merely annoys the neighbours with the small rattles. But still. A technology that causes earthquakes? That's fantastic!

Here's another one: geologists are worried that Taipei 101 may have torqued the earth so much that it opened up a new fault. Cool! The residents of the building will be OK because it's highly earthquake resistant.

All new technology presents benefits and dangers. People say that the atomic bomb is purely a danger. But think about the upside. Major international conflicts have ceased because they're too dangerous. And if we ever find a giant asteroid coming our way, we're probably going to need nukes to blow it up, right?

So I think we can actually measure our progress by the sheer destructive power of our technologies. Now that we can cause earthquakes, can the colonization of other planets be far away?

How Apple could fix Mac OS X

Posted on May 26, 2010 at 12:01 AM

Categories: mac, predictions

Mac OS X 10.7—the OS that no one is talking about—should be the next major release of the venerable Mac OS X (since 1989!) So, what will it look like? Seems like nobody knows. All of the focus has been iPhone and iPad for so long that it seems like everyone has forgotten about the old desktop/laptop computers.

Frankly, although Mac OS X is easier to use than Windows or Linux, it's still not what I would call "easy to use". I see not only my parents but even programmers bumble around with trying the locate the right window, the invisible application with no windows open, and lots of UI fragmentation (for example, should you have a "start screen", or open a blank document, or open the last document, or what).

As far as things went in the past, Apple was stuck with that system. For example, if they had moved the menu bar from the top of the screen to the top of the window (like every other operating system ever) there would have been howls of protest from the Mac clan back when they introduced OS X. Believe it or not, OS X was actually a step backwards from OpenStep in many ways. Steve Jobs and the NextStep clan were forced to adopt many old Mac conventions even when they didn't work particularly well.

Remember that the Mac interface was designed for a strictly one-app-at-a time system. That's right, the first Macs did not have multi-tasking, not even fake "co-operative" multi-tasking. So the whole idea of having menu and windows separated wasn't so confusing at first. But then System 6 came along with the MultiFinder and things started to go a little wacky (and note, that was after Jobs left the company).

The iPhone was a blank slate, and so Jobs and the UX gurus at Apple could go back to square one and design an OS that was well and truly proper. Don't doubt that they spent many years on it prior to the public even hearing about the iPhone touch UI, probably since circa 2003, maybe sooner. There were always tablet dreams circulating in the company. I had conversations about it there in 2001.

The blank slate meant they could get rid of all the broken things in Mac OS X. And indeed in all window-based operating systems. Like, floating windows. The original "windows" designs at Xerox PARC didn't float, they were just arranged in a grid. Much simpler to understand. And that indeed is the paradigm used on the iPad, where they are called panels instead.

So... what comes next? I predict that the next step for Mac OS is going to be a major revamp of the UX for desktops and laptops to bring back the best ideas from the Touch UI. I would personally be glad to see the last of the Apple Menu, the File menu, all of the submenus. Most of the Finder I could scrap as well (keep the column view of course :-). No application should ever NOT have a window visible—that's just crazy. It would be nice if they could sort things out so that I don't have to care which applications are running vs. not running. Maybe they could even—somehow—eliminate floating windows. Maybe that's too much to ask.

Since they've been able to break with the past in the iPhone/iPad, I hope that they'll be able to find a way to bring the best parts of the new and integrate them with the old Mac OS X ... the user interface that hasn't changed in any major way in 20 years.

(PS: and I wouldn't count on it being called 10.7 either...)

Another job opening :-) iPhone developer — learn on the job

Posted on May 04, 2010 at 04:32 PM

Categories: code, business, iphone, jobs

My iPhone custom software development business is expanding yet again and we need more part-time programmers. The last round I hired two people, now we need more. Our recent apps include Unitron's uHear to test your hearing, OurKids, the Kik chat app, and others.

You must:

  • know C, C++, pointers, object and object-relational patterns already
  • be ready to learn the iPhone SDK fast (we'll help)

I've personally been programming on the Cocoa SDK since 1998 back when it was called OpenStep, so if you can pick things up, we can get you up to speed in a few weeks.

Demonstrate your qualifications by answering 2 out of these 3 tricky questions:

[Question 1] (C Pointers) Here is some slightly odd C code, but it will produce an (int) result, provided that you make some small changes in order to make it compile. What is the result going to be, and why?

int * a = 1990;
int result = &5[a];

[Question 2] (Database design) Create an entity-relationship diagram for a small subset of the Facebook database. In particular, include in your diagram:

  • User
  • Photo (including who is tagged in the photo)
  • Wall Post

Focus on the relationships/associations between these three objects, and only include one or two of the most important static fields (like a person's name). Make sure to indicate the cardinality of a relationship e.g. one-to-one/one-to-many/etc.

To get an idea of what I'm looking for see: http://en.wikipedia.org/wiki/Entity-relationship_model

Here's a tool you can use to draw it online: Gliffy. Then just send me a screenshot. Or feel free to use ASCII art or draw on a piece of paper and photograph/scan, as long as it's very clear.

[Question 3] (C++ Objects) The C++ program below has just 2 compile time errors, 1 runtime error, and there is 1 single line missing. Send us a fixed version that compiles and runs correctly. The errors will test your knowledge of object use and management in C++, and the missing line will test you on abstract/virtual inheritance.

SEND TO: simon@semacode.com. Include your answer(s) and some source code that you have written, whether it's open source, for assignments, for fun, or whatever.

REMUNERATION: Competitive.

MORE INFO: http://simonwoodside.com/pages/consulting

(PS Please keep the answers to yourself)

//// File: futurama.cpp ////
#include <iostream>

class Drinker {
public: Drinker(); void drink( int potency ); int _numberOfDrinksSoFar;
private: virtual int cantDrinkAnyMoreThan() = 0;
}; Drinker::Drinker() { _numberOfDrinksSoFar = 0; }
class Robot : public Drinker { int cantDrinkAnyMoreThan() { return INT_MAX; } };
class Human : public Drinker {
};
void Drinker::drink( int potency ) {
  _numberOfDrinksSoFar += potency;
  if( _numberOfDrinksSoFar > cantDrinkAnyMoreThan() ) { std::cout << "I'm all done." << endl; }
}

int main (int argc, char * const argv[]) {
  int beer = 5, coffee = 3;
  Human fry;
  Robot * bender;
  for( int i=0; i<6283; i++ ) { bender.drink(beer); }
  for( int i=0; i<100; i++ ) { fry.drink(coffee); }
  std::cout << "Bender: " << bender->_numberOfDrinksSoFar << "  Fry: " << fry._numberOfDrinksSoFar << std::endl;
  fry.drink(1);
  return 0;
}

Maybe Nokia just can't make good software?

Posted on April 28, 2010 at 04:20 PM

Categories: tech, theories, symbian, mobile, predictions, nokia

Nokia looks to be in serious trouble. They've delayed Symbian^3, which was supposed to be the sort or basic catch-up version of their main smartphone OS. Symbian^4 is supposed to be the move ahead again version and who knows when they'll release it. Meanwhile, Maemo or whatever they're calling it these days is more like vaporware even though theoretically it's out on a couple of devices.

Hey, you know what? Maybe Nokia just can't write good software.

Think about it ... when was the last great release of software from Nokia. The first version of Symbian S60. Which, if you remember your history, was actually written by PSION. Symbian has not improved in any major way since then. The first Symbian smart phones were epic—the Nokia 7650 was way ahead of its time in 2002 and make Nokia the smartphone kings. But after that they didn't seem to be able to put out a really substantial upgrade.

Big companies have a long history of not being able to complete operating system upgrades. Back in the late 80s early 90s Apple managed to fail to create a new OS not once but twice—Pink and Copland—were both epic failures of massive proportion. Making software is hard.

The question is, can Nokia learn how to do it. One option - which I have advocated in the past - is to simply ditch Symbian and get on to the Maemo train full stop. But it's not clear if Nokia has the guts to do something so drastic.

Well, they'd better grow some, because they haven't put out a competitive smartphone since the N95 three years ago. Their current offerings are jokes. Android, Blackberry and iPhone are way ahead of them. And, the investors are starting to figure it out. Hopefully Nokia's shareholders will beat them up until they take the drastic measure before it's too late.

Review of Resonance by Daniel Stepp (mac os x/windows)

Posted on April 25, 2010 at 09:51 PM

Categories: music, tech

Resonance-icon

Once upon a time while tripping across the 'net I stumbled upon a piece of software called Resonance. The web site is cryptic:

resonance includes a mathematically-precise binaural tone generator, capable of producing fifteen hundred unique binaural frequencies.

What is a binaural tone? Why would I want to listen to one? I downloaded it to find out.

The interface is equally mysterious, but fortunately it has some presets which immerse you into audio soundscape that defies clear description. Those binaural tones were pulsating, interacting stereo waves that gave me a tingly feeling, the kind of feeling that you get when you're learning something profound. Maybe some people would call it a spiritual feeling.

If you look up binaural tones, the great wiki has some descriptions of odd and perhaps unbelievable effects they can have on your body and brain. I don't know if I believe a word of it. But I do believe there is something odd happening when I listed to Resonance.

The author does because he created the program to help him concentrate:

I personally use it when I am programming or writing, basically whenever I need a lot of concentration. Others use it for relaxation, sleep aid, meditation, yoga, background noise...etc. [via email]

He also pointed out that for best effect you should use headphones with no other sound or music playing. Even though, Resonance does include a variety of natural sounds effects from the Earth Recordings library—which accounts for the large size.

This is definitely an odd program, but I have a feeling that it would be a great candidate for conversion to the iPhone, where I think it could gain a cult following.

Bottom line: if you're interested in audio phenomena or unusual interface design, check it out. Resonance.

Bug Points

Posted on March 27, 2010 at 03:34 AM

Categories: code

An incomplete list.

Per:

  • line of code: 1 point
  • line of generated code: 5 points
  • repeated line of code: 50 points
  • repeated comment: 10 points
  • TODO note: -10 points
  • comment explaining hack: -10 points
  • hack: 50 points
  • clever hack: -50 points
  • memory leak: 10 points
  • ignored warning: 100-1000 points
  • public but should be private: 100 points
  • unreadable line of code: 50 points
  • whitespace at the end of a line of code: 15 points
  • a tab: 25 points
  • incorrect indentation: 5 points

Compare: technical debt.

Job Opening: iPhone part-time / contract coder wanted -- we'll teach you

Posted on February 11, 2010 at 03:07 AM

Categories: code, business, iphone, jobs

My iPhone custom software development business is expanding and we need more part-time programmers. Our recent apps include Unitron's uHear to test your hearing, OurKids, an upcoming app for Kik, and others.

You must:

  • know C, C++, pointers, object and object-relational patterns already
  • be ready to learn the iPhone SDK fast (we'll help)

I've personally been programming on the Cocoa SDK since 1998 back when it was called OpenStep, so if you can pick things up, we can get you up to speed in a few weeks.

Demonstrate your qualifications by answering 2 out of these 3 tricky questions:

[Question 1] (C Pointers) Here is some slightly odd C code, but it will produce an (int) result, provided that you make some small changes in order to make it compile. What is the result going to be, and why?

int * a = 1990;
int result = &5[a];

[Question 2] (ORM) Draw an relational/DB model that would work for the Twitter database or the Facebook database. You don't have to cover all of the features, just the basics. You can use ascii art if you like.

[Question 3] (C++ Objects) The C++ program below has just 2 compile time errors, 1 runtime error, and there is 1 single line missing. Send us a fixed version that compiles and runs correctly. The errors will test your knowledge of object use and management in C++, and the missing line will test you on abstract/virtual inheritance.

SEND TO: simon@semacode.com. Include your answer(s) and some source code that you have written, whether it's open source, for assignments, for fun, or whatever.

REMUNERATION: Competitive.

MORE INFO: http://simonwoodside.com/pages/consulting

(PS Please keep the answers to yourself)

//// File: futurama.cpp ////
#include <iostream>

class Drinker {
public: Drinker(); void drink( int potency ); int _numberOfDrinksSoFar;
private: virtual int cantDrinkAnyMoreThan() = 0;
}; Drinker::Drinker() { _numberOfDrinksSoFar = 0; }
class Robot : public Drinker { int cantDrinkAnyMoreThan() { return INT_MAX; } };
class Human : public Drinker {
};
void Drinker::drink( int potency ) {
  _numberOfDrinksSoFar += potency;
  if( _numberOfDrinksSoFar > cantDrinkAnyMoreThan() ) { std::cout << "I'm all done." << endl; }
}

int main (int argc, char * const argv[]) {
  int beer = 5, coffee = 3;
  Human fry;
  Robot * bender;
  for( int i=0; i<6283; i++ ) { bender.drink(beer); }
  for( int i=0; i<100; i++ ) { fry.drink(coffee); }
  std::cout << "Bender: " << bender->_numberOfDrinksSoFar << "  Fry: " << fry._numberOfDrinksSoFar << std::endl;
  fry.drink(1);
  return 0;
}

(Update Feb 14: updated code to make my intentions clearer)

Real or Fake?

Posted on February 05, 2010 at 01:37 AM

Categories: graphics, tech

It's getting harder to tell. Be sure to watch it in fullscreen:

The Third & The Seventh from Alex Roman on Vimeo.

Not only that but Alex Roman did a fantastic job on this. The Third & the Seventh homepage. Thanks to Tinselman.

Previous related entry: Fake or Real?

14 Errors in anti-Light Rail thinking

Posted on February 01, 2010 at 09:46 PM

Categories: (none)

6434f4874065a75ed03672e49872

I'm part of a group called Hamilton Light Rail which has been pushing for the development of a european-style light rail (aka Tram) in Hamilton. Recently the Hamilton newspaper The Spectator published an anti-LRT rant by a businessman who owns, among other things, a car wash. His opinion piece is so full of factual errors that I couldn't resist making a list. I actually found 14 factual errors (that is errors that require no argument, simply a correction of information from easy to access sources). So, without further adieu (sic) here it is:

  1. Chicago does not have a light rail. (It does have a heavy / commuter rail system. There was an LRT proposal in Chicago which was cancelled at an early stage.)
  2. Detroit does not have a light rail. (There is discussion underway to develop one.) (It does have a medium/heavy rail rapid transit line which loops overhead, running the same system as Scarborough RT.)
  3. Hamilton employment in 2008 was 362,000. I don't know how much of that is downtown.
  4. The LRT project in Hamilton began moving in 2007, whereas issues related to the Pan Am games did not arise until 2009. Metrolinx plans, and LRT in Hamilton in particular, were already firmly developed, including routes and support statements from different government levels, before the Pan Am games began to influence planning.
  5. The 2007 Pan Am Games in Rio attracted in the range of a billion viewers, so it's difficult to assert that people haven't watched it.
  6. When you drive to downtown and park you face the same issues of finding a parking location as you do if you drive to an LRT terminal.
  7. The US Department of Energy projects that gasoline prices could double in the next decade (AEO2009).
  8. Downtown will not be closed off. One recent proposal suggests a pedestrian zone for one block (TODO I can't find the source) of King Street.
  9. Downtown parking garages will still be accessible by cars either from the reduced lanes, or in the case of a pedestrian zone, from the opposite street. For example, Denningers (outdoor) parking lot is accessible from both King and Main.
  10. Statements regarding access to business assume that shoppers drive to a parking lot in front of their target business, make a purchase, get in their car and drive to the next business. In fact today even with our current car centric model that is not the case in downtown Hamilton. Many shoppers drive to the vicinity of the business, park, and then visit multiple stops on foot.
  11. LRT plans do not include removing sidewalks. Pedestrian areas would increase.
  12. Parking provisions should naturally be different in areas with different densities of population and business, including differences between the mountain and downtown.
  13. An overhead railway proposal for Hamilton in the early 80s was roundly and appropriately dismissed due to the effect it would have on the street environment. The few overhead railways that have been built worldwide do not share the success of on-street LRT. Manhattan recently converted its defunct Elevated railway platforms into garden parks.
  14. LRT does not require 20 metres width. Each direction requires the width of one standard lane of traffic, which is 11-12 feet wide (3.5 metres).

Reise Zum Mars film

Posted on January 30, 2010 at 07:53 PM

Categories: links, film

Screen_shot_2010-01-30_at_7

Mucho thanks to The Cartoonist for discovering this lovely Steampunk film "Reise Zum Mars" (journey to mars, in german). Made by german film student Sebastian Binder, along with Fabien Grodde and Alexander Schumann, it's a short film based on a draft screenplay by Walter Dexel, an early 20th Century Constructivist. But don't worry, it's just music and action, so there's no need to know any german to watch it. And what's more, the lyrics to the song are in english anyway.

And you can watch it at their cool web site, which also has some interesting making-of videos.

Unfortunately they only show the video at the original size. So, if you want to watch it full screen, here is a direct download link that I hacked out of their SWF file: Reise Zum Mars direct FLV download (106MB).

Overall I have only two criticisms: one, that it needs an increase in brightness, it's quite difficult to make out what's happening. This is a simple post-production blunder. Second, the music is a little heavy. On the other hand, the silent-movie farce kind of atmosphere/acting works well.

I love steampunk, and I love this film.

Full lyrics to Yazoo (Yaz) song "I Before E Except After C"

Posted on January 13, 2010 at 06:14 PM

Categories: music

The full lyrics for this great Yazoo song are not to be found on the entire internet. I did some fun audio processing to extract all the different voices... some of the words are a bit tricky.

There would, stop because
there will always be, because
there will always be, for two
there will always

inside, you can feel the
outside, you can see the difference
inside, stop, inside, difference
outside, out stop, inside, you can feel the difference
feel the
you can difference, difference, difference
you can see the, feel the difference
you can stop, stop, and see the, you can stop, you can see the difference

Dragons, the policeman knew,
were supposed to breathe, to breath fire, fire, to breathe fire
and occasionally get themselves, get themselves
slaughtered, slaughtered, slaughtered
he decided.

That would definitely not he decided
stop, stop
definitely not
stop, stop
not
definitely
That would that would that would
stop
definitely decided
decided decided decided
not not
stop
he decided

(repeat)

[old woman 1]
the basis of the all important process
involved in the mixing, and regeneration, of a person's voice
incapable of any distinction, between frequency response
is such that the entire output, is revealed in the voice
is the actual voice itself, and the voice being used
is the voice being used, is the voice being used
used voice being used
being used voice
being voice

(repeat)


[young woman, with laughter]
this type of formation can only be explained
when two or more separate units are linked together
thus forming a string only detectable
through specially designed equipment
or at least that's what I thought
stop.

is that enough?

(repeat)


[old woman 2]

despite the pure outlook
which have been forced upon me
stop stop upon me
force the tools available
I decided to use the tools available
mainly because the function of the stop the stop
available being used
demanded an experience which I did not fully understand

(repeat)

Yes, I'm all right [laughter]

The only word I'm not 100% sure about is "pure" for old woman 2. Aside from that it's solid.

Is the man Vince Clarke? Is the young laughing woman Alison Moyet?

What I want to know is, where did they get the text these people are reading? Did they make it up? None of it seems to search in google.

Mobile phones access agricultural market price information in developing nations

Posted on January 09, 2010 at 09:46 PM

Categories: tech, mobile, future

Esoko

The most critical piece of information for any farmer is what to grow. What grains are going for good prices at the market. What is overproduced and what is underproduced. What is in demand. Farmers must know this information in order to make a living, hopefully a profit.

Let's say you're a farmer in rural part of western Africa. You have very little in the way of communications—the roads are poor, telephone lines are poor or non-existent, internet access is not there. In fact, your village may only contain a few people with literacy to even use the internet. Aside from travelling for hours or days the only way to access market information could be through a shared mobile phone.

Then you need a trust-worthy source of information on the other end. Preferably one that can communicate via SMS text messaging, because it's much cheaper than making a voice call. I've been collecting some information about these kinds of services in Africa and intending to write up what I found for quite a while, so here it is, a summary of the agricultural market information providers operating in Africa that I am aware of.

Esoko

Esoko is the easiest to find on the internet. It was founded by Mark Davies, a serial entrepreneur who started up a number of successful internet companies including CitySearch in the UK before transplanting to Ghana where he founded BusyInternet, an internet café, ICT centre, and business incubator in Accra. In 2005 he started TradeNet which is now renamed to Esoko.

I've played around a bit with Esoko and it looks like the real deal. I viewed prices for a variety of produce for a wide variety of markets in Ghana, for example. The data seemed to be fairly up to date. I was able to set up an alert for myself on prices for certain commodities in certain markets, so the system would SMS the prices to me on certain days of the week. You can also 2-way SMS into the system with different code and they will send you back the info you are looking for by return text message.

I couldn't actually test the SMS because I don't have an African cell phone # but assuming that works (and I'm sure it does) this looks like a great system with tons of accessible and useful information. They currently have at least some data for Afghanistan, Burkina Faso, Côte d'Ivoire, Cameroon, Mali, Mozambique, Ghana, South Africa, and Sudan so if you're operating in any of those countries, check it out.

They also seem to be looking to expand their platform as a service into other parts of the world, see: esokonetworks.

Others

Another service is Trade at Hand, which operates in Senegal, Mali and Burkina Faso. I haven't been able to try this service, but their representative Raphaël Dard tells me via email that they are oriented towards international exporters in those countries, and provide prices in the major agricultural market in Rungis, France. They distribute information via SMS to farmers who sign up at federated agencies within the country.

Hans Hesse tells me on his blog that Zambian National Farmers Union runs a service for that country at http://www.farmprices.co.zm/, unfortunately the site is down as I write. There is some information on the ZNFU site, which appears to be right up to date, and have an SMS interface with short-code 4455 (from inside Zambia). Good stuff.

Last but not least, Engineers Without Borders's Megan Putnam shared with me a report from an EWB volunteer who examined a project called ECAMIC which facilitated the use of Esoko. One issue they noted was charging the phones in the many locations where no grid power is available. Another is dealing with the metrics for quantity and quality of each commoditiy, which may not be easy to transmit over SMS (some might be weighed, others rated by size and quality).

To summarize. It's important to be skeptical of any technologically driven development initiative. That said, I'm quite keen on this one because it is based on mobile phones, which are a huge and expanding business concern in Africa, a huge force for development, and probably the continent's biggest success story right now. They are also durable, cheap, and run on very little power. The information systems I've mentioned here are early days, but they seem to work and provide value to their users. I won't link to testimonials and success stories because I'm too skeptical about them as marketing for development agencies. But reading between the lines there are enough different people trying this out and getting positive results that I would encourage everyone involved to stick with it and keep pushing the boundaries.

Light + Music

Posted on December 21, 2009 at 04:12 AM

Categories: graphics, music, tech, theories, film, future

I'm proposing a talk for TEDx Waterloo. The subject is Light + Music, an overview of visual music, the past and future, of this wonderful field where two of your senses get together and jam and have a good time.

The theme of TEDxWaterloo this year is Tomorrow Started Yesterday, which is pretty appropriate for this subject. The visualization of music certainly started with dance, which was probably one of the most ancient of human arts, although we cannot say for certain when it started. Music certainly existed over 50,000 years ago. On the other side, the future of music is certainly digital, and the digital signal lends itself to being interpreted in multiple ways—witness mp3 visualizers and VJs.

But I want to start with what is sound. In 1904 Heinrich Rubens created a tube to see the sound as light—literally—glowing from the flames of his curious contraption:

Sound is a wave through the air, and like all waves you can reduce it to a sum of waves at different frequencies. I won't get into sine waves and circles and cycles and oscillators because I don't have the time. But take waves of different speeds, some large and slow, others small and fast—just like in water—and add them up, you get sound. The rube's tube simply shows the amplitude and pitch of the wave as it creates a standing wave inside the tube.

An oscilloscope does the same thing!

Guess what, your iTunes visualizer does the same thing too. It just jazzes up that information into prettier pictures. The basic ones show an oscilloscope like the ruben's tube, or a "spectrogram" which provides much more information—it actually breaks down the signal into the component sine waves, and shows the strength of each. Usually frequency is vertical, time is horizontal, and the intensity of colour is the intensity of sound at that pitch. Here's a spectrogram of a violin:

spectrogram of a violin

And here's a video of a whiz-bang mp3 visualizer. It may look crazy but it's just oscilloscope + spectrograph driving it:

.

Maybe you can look at the spectrogram and tell a flute from an electric guitar, but most people can't. That's why Anita Lillie made a program that tries to show the timbre of different instruments in colour against the notes of the scale. This is where the future of direct visualization is going:

Visualizing Music by Anita Lillie from S Woodside on Vimeo.

.

All of that said… there is more to visual music than can be imagined by computers. Artists will surely have a word to say. And we can go back to the early days of film to find inspiration from Len Lye, famous for his abstract film, A Colour Box (1935):

And you might have already seen this one. Fantasia: Toccata and Fugue in D-Minor, by Oskar Fischinger in 1940!

There is much more, such as the Star Gate sequence in Kubrick's 2001, Lapis by James Whitney, The Bead Game by Ishu Patel, Synchromy No. 4: Escape by Mary Ellen Bute in 1938. Bret Battey's Luna Series #3: Sinus Aestum is more recent—2009. After three quarters of a century, the art is being revived.

.

Tomorrow though, it will be the other way around. Instead of looking at sound, you can go the other way, you make light and get sound.

The most significant entry in this green field is surely TENORI-ON, a completely new form of digital instrument created by Toshio Iwai and Yu Nishibori for Yamaha in Japan. It's being used in concert by artists such as Little Boots. I would like to leave you with these two examples, which might blow your mind.

Little Boots .. watch her set it up :-) :

Jim O'Rourke ... a little deeper, but stick with it and your mind will expand. Steve Reich needed 18 musicians! :

.

I've skipped over a lot of really cool stuff, so if you want to see more in a fast, wide-ranging and crazy presentation, head over to TEDx Waterloo and nominate me for the show :-) I might even do some live demos :-)

A little ToneMatrix Music

Posted on December 05, 2009 at 10:45 PM

Categories: graphics, tech, links, art, infographics, film, iphone

André Michelle, inspired by the TENORI-ON, created a grid-sequencer called ToneMatrix. It's an interactive experience written in Flash 10 that merges graphics, visualization, interactivity, and music. There are also iPhone knock-offs such as the free TonePad. As for ToneMatrix, click here to check it out and create your own tunes. Here's one of mine.

Eine Kleine ToneMatrixMusik from S Woodside on Vimeo.

You can also right-click on the ToneMatrix flash app and copy/paste numerical sequences to load and save your music. The sequence for the above is:

98386,1024,4096,1024,67474,96,65540,32768,65618,1024,64,0,65618,4,65600,0

Share and enjoy.

How to prepare a build for distribution in the App Store using the Program Portal, XCode, and iTunes Connect

Posted on September 28, 2009 at 04:59 PM

Categories: code, iphone

Apple does a pretty good job of explaining how to prepare the meta-data for an app submission in iTunes Connect, but it's not completely obvious how to prepare your actual build in XCode.

Assuming that you've already got Ad Hoc distribution working, it's not too hard. I was looking for advice and didn't find it, but I did find a question on StackOverflow that people had actually downrated and not really answered. So I figured out how to do it and added a proper answer. So without further adieu, rate me up on StackOverflow to give me wonderful wonderful karma, and view,

How to prepare a build for distribution in the App Store using the Program Portal, XCode, and iTunes Connect on StackOverflow

something I found written on a piece of paper

Posted on September 19, 2009 at 01:22 AM

Categories: (none)

Picture_1

I don't know what it means.

What happens when you don't understand open source licenses?

Posted on September 17, 2009 at 12:20 AM

Categories: tech, code, opensource

I was just checking out a TextMate-like editor for Windows called E Text Editor. It looks pretty good, but I was a bit surprised when I read about his "Open Company License".

To be clear, this is something he came up with himself, and it's not a bad idea. To be double clear, it's NOT open source. And he says that up front. He added "just one" clause to the standard BSD license:

Any redistribution, in whole or in part, must retain full licensing functionality, without any attempt to change, obscure or in other ways circumvent its intent.

Not bad. Users gain because they can modify the software and use the modified version all they want for in house purposes, and they don't have to share those changes with anyone. But they still have to pay him, and that's why it's not open source.

Unfortunately for him, he made a little mistake, because the clause only stipulates on redistribution.

So if you want E Text Editor for free, just download the source, modify it to remove the licensing code, build and use it. As long as you use it only yourself, you're perfectly legit and don't have to pay.

In addition, he left open a rather major hole. Anyone can now make a completely separate small program which downloads the source code, automatically applies a patch which removes the licensing code, builds it and installs on the local computer. This is the way in which many applications include GPL software into non-free, just in reverse. To be clear, my hypothetical program does this:

  1. You download my program, FreeE and run it on your computer.
  2. FreeE goes online and grabs the source code for E Text Editor.
  3. FreeE applies a patch to remove the code that makes you pay.
  4. FreeE builds—on your local machine—a new copy of E Text Editor without the pay code.
  5. FreeE quits and you delete it.

As long as you never distribute your copy of E Text Editor that you get this way, you're totally clear and legally able to use it without paying.

Alexander Stigsen, the author of E, might want to consider changing his license. But even if he does so, the versions he released under the current license will always have this hole. So go ahead, get some free as-in-beer software :-)

My university can't draw.

Posted on September 14, 2009 at 12:57 AM

Categories: art, predictions

Logo2

This is their idea of a good new logo.

After the previous new logo got crapped on because it totally sucked.

The new new one? Looks like a beer glass being poured out.

While that may be appropriate reflection of the student body, it's not my idea of a good image for the school. Please UW, fire your graphic designers and hire new ones who can draw. Maybe go to Toronto to find some good ones? Or New York?

Prediction: this is going to go on for a long time...

Maemo is coming

Posted on August 26, 2009 at 01:54 PM

Categories: tech, symbian, mobile, nokia

So according to what everybody is saying, Nokia is going to start using the Maemo operating system + SDK in their high-end smartphones. This is good news. Symbian is basically a smoking pile of junk. It's too old, and too crap, to be fixed. Toss it out the window and good riddance.

I realize this won't happen overnight, but the sooner we can get a more modern, well-documented, programmer-usable SDK available for Nokia phones the better. Maemo looks good at first blush. You develop on Linux instead of horrible, horrible windows, which is good and means that a proper SDK for Mac is probably possible. You use Qt which is apparently pretty good. So, good news all around.

Nokia needs to fix a lot of other things to keep their game going in the smartphone market. They need to stop messing around with resistive touch screens for one thing. But without a great OS they can't make anything else happen. So, I hope that they follow this up with more symbian abandonment and more alternative awesomeness.

UPDATE: And here it is (video of N900).

Google: what is zero?

Posted on August 20, 2009 at 09:05 PM

Categories: tech, internet

Picture_1

Apparently it's 1.15463195 * 10^-14.

Who Will Get What? -- a US healthcare infographic

Posted on August 20, 2009 at 08:42 PM

Categories: infographics

Who-will-get-what

Who Will Get What? This is an information graphic based on Health Insurance Reform in Three Steps by

Saying goodbye to Guido Sohne

Posted on August 14, 2009 at 12:05 AM

Categories: tech

51026129_5ea64f54ca

Some people's deaths hit me harder than others. When Douglas Adams died in 2001 I was devastated. I also took it pretty bad when Guido Sohne died last year. I'm glad that he's now been rewarded with a post-humous award—in his name—and triggered a belated reaction to the original news.

Guido Sohne was an African software developer and open-source proponent who grew up in Ghana, went to Princeton, and then—amazingly—returned to his native land. Why did he do it? It's awfully tempting to stay where wages are high, where computer products are easy to get, peers are easy to meet ... he would have had no problem there. But instead he chose to return to Accra, and later Nairobi (Kenya).

I met Guido on a mailing list called PubSoft, focused on global issues around open source software. I've been an open-source nut for a long time. I've also been interested in international development and especially Africa since I lived for 6 months in a rural development project in Lesotho at an early age.

Guido and I struck up a cyber-relationship—we never met in person and only talked a few times on the phone. I was really interested in his views on the development of internet and computer technology in Africa. I can go and read what people are saying, but Guido was "one of us"—a CS grad from a big school—and a really nice guy and had a lot of credibility. I learned a lot from him about the realities. And, also, lets face it he was ahead of me in terms of exploring the boundaries of web technology—introduced me to Ruby on Rails for example.

Somehow or other I wound up hiring him to do some work for my company Semacode—I needed software written, didn't have many connections at that time, and he was looking for work. He did some himself and also managed another African native who he managed very effectively. We had a great business relationship which is especially important since he's on the other side of the world, and trust in business is so critical. He was totally reliable.

The source code by the way is still in the Semacode barcode decoding source base and is good code—has been built on over the years (since 2004 or 2005??).

And I know that Semacode was a great opportunity for him too as it has great web presence and is (still) really cool up-and-coming technology.

He had some business ideas that we discussed, we exchanged I don't know how many emails, and finally he got a job at Microsoft. Crazy, I know, because he was a Linux fan and always used a Mac. But I know other people who are otherwise good people who wind up at Microsoft and anyway: (a) MS is much less evil now and (b) this is Africa we're talking about ... how many major software companies have significant operations there?

(As an aside, did you know that there is only one major software company with HQ outside the USA?)

And then... I got an email that he died. At 34. In his sleep. There was no warning that I knew of. He always looked and sounded healthy. Maybe he had a heart condition or something. I don't know.

I often wonder if the reason he went back to Africa was because he had been diagnosed with some kind of "eventually-will-kill-you" illness and had a sort of revelation, to do something more meaningful than the traditional CS job. Well, that's looking for a reason for someone to be so extraordinary. I know good programmers and he was well up there. But he also had a vision, great people skills, drive, energy, communication and a good heart. So. I still can't believe he's gone.

Where have all the great actresses gone?

Posted on August 12, 2009 at 08:00 PM

Categories: theories, film

Sarahconner

Movies are great for many reasons, but having a superstar actor/actress can make even a half-ass movie bearable or even good. There's lots of great actors who can pull it off these days. To give a few random examples. Benicio Del Toro. Bruce Willis. Brad Pitt. Clooney. Clint Eastwood, after all these years. ... much as I hate to admit it, Leonardo DiCaprio.

We used to have them. Just looking at the 80s & 90s: Sigourney Weaver pulled off many hits, including Alien, Terminator, ... Renée Zelwegger was awesome headlining in Bridget Jones, Nurse Betty... Jodie Foster carried Silence of the Lambs & Contact. Meryl Streep, Katharine Hepburn, Kim Basinger.

Where are they now? They seem to have faded away. Julia Roberts seems to be gone. Zelwegger is doing voiceovers. Foster hasn't been seen lately. Hepburn is out of town, and Basinger seems to be mainly in movies I haven't heard of.

Does Kate Winslet count? Uma Thurman? My theory is that there's still great actresses out there, but they're not getting good parts.

Regarding growing up your acts_as_taggable and lack of primary_key

Posted on August 12, 2009 at 07:53 PM

Categories: code, rails

This is a comment on "growing up your acts_as_taggable" post on Evan Weaver's blog snax.... because comments there are closed.

If you are upgrading from an older acts_as_taggable installation and moving to has_many_polymorphs, as I did, your old table will have create_table :id => false. That will be unhappy. You should add this to your migration:

add_column :taggings, :id, :primary_key

And that's all.

Fictional magazine covers from Blade Runner

Posted on July 29, 2009 at 06:31 PM

Categories: film, future

Blade Runner is one of my all-time favorite films. I got my hands on the extended features and one popped up that I thought I'd share with you—some fictional magazine covers from a fictional news stand on a fictional street in a fictional universe. I believe that the news stand is seen—briefly in passing—during the chase through the streets. Here are all six grabbed from the feature, designed by production illustrator Tom Southwell.

Praise for uHear

Posted on July 22, 2009 at 05:37 PM

Categories: iphone

Picture_1

I still think that the uHear application I made for Unitron is pretty cool. So do some other people.

Can't believe it's free *****

by DancingRomantic - Version 1.0 - Jul 22, 2009

It's apps like this that make the iphone the most powerful of all smartphones. Great work!

It's amazing how much app crap there is out there.

Closures with return values in Java

Posted on July 07, 2009 at 12:29 AM

Categories: code, java

Here's how to get everything you need from closures today in Java, without waiting for the big foreheads to argue over how to make it nice and perfect.

You've almost certainly used something sort of closure-like when you've used the Runnable interface. You can for example create an anonymous subclass of Runnable and .run() it:

  Runnable closure = new Runnable() {
 void run() { System.out.println("Hello"); }};
closure.run(); // prints Hello

In particular in Java Thread class implements Runnable. You can do more interesting things, for example:

  StringBuffer _myString = new StringBuffer("Hello");
// Java will only close around final variables because it's dumb
final StringBuffer foo = _myString;
Runnable closure = new Runnable() {
public void run() { System.out.println(foo); }
};
closure.run(); // prints Hello

This is why it's called a closure—the anonymous subclass Closes Around the variables in the scope in which it's defined. So, it has access here to myString. If you change _myString in the original context the closure will use the new value.

You can pass closures around, for example pass it to another method in another class, and it will still remain closed around the Original context. Like this:

  public void anotherContext( Runnable closure ) {
StringBuffer foo = new StringBuffer("Goodbye");
closure.run(); // still prints Hello from its own context
}

This is all available out of the box in Java, a little boring. It would be interesting if the closure could work on variables BOTH from its original context and that you pass into it at the same time. This can be done, but Runnable doesn't allow it, so we'll make our own Runnable:

// A general-purpose closure class that can receive and
// return values when you call it.
// This is an abstract class... override these functions for
// whatever kind of closure you need.
// If you call a non-overriden function, it will throw you.
public class SemaRunnable {
public void run() { throw new RuntimeException("Must override SemaRunnable.run()"); }
public Object run( Object param ) { throw new RuntimeException("Must override SemaRunnable.run()"); }
}

Now I can do a simple example (from the Wikipedia article):

SemaRunnable bestSellingBooks = new SemaRunnable() {
public Object run( Object thresholdObject ) {
int threshold = ((Integer)thresholdObject).intvalue();
// assume bookList is in the local context:
myBookList = bookList.booksWithSalesGreaterThan(threshold);
return myBookList;
}
};
// call books = bestSellingBooks.run( Integer(5000) );

Here's a more complete example. In some code I'm working on, I need to pass an image—not just an image, but also the ability to get just a subImage of that image. I don't want them to have to know how to do image manipulation. Here is how I do it using closures:

    SemaRunnable getSubImage = new SemaRunnable() {
      public Object run( Object param ) {
        int x = Array.getInt(param,0); // these four variables
 int y = Array.getInt(param,1); // are coming in
        int width = Array.getInt(param,2); // from the
 int height = Array.getInt(param,3); // caller
// Now I will close on a method in my local context:
        short[] subImg = dataForSubImage( x, y, width, height );
return subImg;
      }
    };
someObject.setClosureToBe(getSubImage);

...

// This method is being closed upon in the local context:
public short[] dataForSubImage( int x, int y, int width, int height ) {
...

someObject in some completely different part of my code, gets the closure and calls it like this:

  // completely different class, which received closure object
int [] subImageData = (int[])closure.run( new int [] {new_x, new_y, new_w, new_h} );

You don't have to call it closure. And you can pass as many params either way as you like, storing them in arrays, since array is an Object in java.

But... but... but..., people will say, why not create a class which does this, and import the class, and construct the class, and make calls on the class, it would do the same thing. They just answered their own question: it requires lots of LOCs.

And there's other good reasons. For example, let's say you have two versions of your function for different situations, you can simply swap them out of they are closures. The beauty of it is, the java compiler doesn't know or care what's happening, because everything is just SemaRunnable and Object. So it's not going to complain that a function or class name has changed. That means metaprogramming goodness. Sweet.

So, practical closures in Java. It may look a little unfamiliar at first, but once you know how to do it it's easy and can be really useful.

EXTRA SPECIAL BONUS: An implementation of the full monty, closure that takes a closure, makes a new closure from it, and returns that. I promised myself I'd go to bed early, but instead I stayed up and wrote you this code which is guaranteed to actually work, because I tried it. Try running it.


// By: Simon Woodside sbwoodside (a)(t) gmail (d)o(t) com
// See: http://simonwoodside.com/weblog/2009/7/7/a_little_bit_more_serious/

// To try this out:
// % javac Test.java && java Test

// Demonstration of how to do closures in Java
// In this case, |derivative| is a closure which approximates derivatives, and
// |sineDerivativeApproximator| approximates the derivative of ... you guessed it ... sine.

// It's hard to believe, given how much code there is, but in javascript this would be:
// function derivative(f, dx) {
// return function(x) {
// return (f(x + dx) - f(x)) / dx;
// };
// }
// (See http://en.wikipedia.org/wiki/Closure_(computer_science) )

import java.util.*;
import java.lang.reflect.*;
import java.lang.*;

public class Test {
public static void main (String args[]) {
System.out.println("Closures coming up!");
Test test = new Test();
test.go();
}

// SemaRunnable is a general-purpose closure class that can receive and
// return values when you call it.
// This is an abstract class... override these functions for
// whatever kind of closure you need.
// If you call a non-overriden function, it will throw you.
public class SemaRunnable {
public void run() { throw new RuntimeException("Must override SemaRunnable.run()"); }
public Object run( Object param ) { throw new RuntimeException("Must override SemaRunnable.run()"); }
}

void go() {
// Let's start with a really simple example.
// See my blog post for more details:
StringBuffer _myString = new StringBuffer("Hello");
final StringBuffer foo = _myString;
Runnable closure = new Runnable() {
public void run() { System.out.println(foo); }
};
closure.run(); // prints Hello

// Now let's do something more fun.
// A closure that receives a closure and returns a new closure.
// This is going to be wordy because Java Arrays and Number objects are TERRIBLE

// Return a function that approximates the derivative of f
// using an interval of dx, which should be appropriately small.
SemaRunnable derivative = new SemaRunnable() {
public Object run( Object params ) {
// params must be { SemaRunnable f, Float dx }
final SemaRunnable f = (SemaRunnable)Array.get(params,0); // get f
final float dx = ((Float)((Object[])params)[1]).floatValue(); // get dx
SemaRunnable approximator = new SemaRunnable() {
public Object run( Object xFloat ) {
float x = ((Float)xFloat).floatValue();
float fOfXPlusDx = ((Float)f.run( new Float(x + dx) )).floatValue();
float fOfX = ((Float)f.run( new Float(x) )).floatValue();
float answer = (fOfXPlusDx - fOfX) / dx;
return new Float(answer);
}
};
return approximator;
}
};
// Now create a closure that will simply return the sine(x):
SemaRunnable sineClosure = new SemaRunnable() {
public Object run( Object xFloat ) {
double sine = Math.sin( ((Float)xFloat).floatValue() );
return new Float(sine);
}
};
// And finally put it all together:
SemaRunnable sineDerivativeApproximator =
(SemaRunnable)derivative.run( new Object [] { sineClosure, new Float(0.001) } );
for( double x = 0.0; x<3.1416; x+=0.1 ) {
Float result = (Float)sineDerivativeApproximator.run(new Float(x));
System.out.println( "Sine(" + x + ") = " + result );
}
}
}

I ran out of time to demonstrate this, but you can also modify variables in the context from inside the closure, even though they are final, by creating a final array containing the variable, and then modifying the object contained in the array. It's not pretty but it works.

Something I found written on a piece of paper

Posted on July 04, 2009 at 05:55 PM

Categories: art

I'm not sure if it means anything:

Existential crisis was
written on the egg.
I cry sis. Sis is tense. She has
no shawl. Where is my shawl?
she cries. Perhaps her shawl is
partial by now, the cat
unwound it an hour ago. The cat
in the hat? The very same, and
a top hat it is. I am no
magician, just a logician, I
cannot unravel this riddle cries she.
A crisis
I say, if the cat is in the hat,
a magician's hat will it
reveal when the hat I
repeal? Simple,
says she, by Occam's razor we
may cut a hole in the
hat and oculate inside. But
we have but Occam's hatchet
I say, and a blunt tool it is,
more liable to crush it. Let us
wait and see, cries sis
sensing an existential crisis.
This interminable solution has left
me with no determinable
resolution.

Singin' in the Rain's crazy dream ballet sequence

Posted on July 02, 2009 at 12:49 AM

Categories: art, bittorrent, film

Singin-in-the-rain-ballet-sequence

I just watched the movie Singin' in the Rain... and by far the best part was this sequence where Gene Kelly dances a ballet with Cyd Charisse. Wow!

The set is a surreal, Dali-esque painting, which uses forced perspective to appear to vanish into infinity. It features stairs that look like stripes on the ground, strange shadows... but the most surreal is Charisse's 50-foot long white silk veil, which wafts up into the sky like it's floating on air. There must have been some incredible fans, and the choreography of the air current with the ballet is incredible.

I don't know how Gene Kelly thought it up, and how he managed to get it made and into the movie. It has almost nothing to do with the plot. It's totally unexpected, but mind blowing. I've never seen anything like it.

Here it is, but really, you should rent it or download it in high quality...

An awesome little flash game

Posted on June 30, 2009 at 01:40 AM

Categories: links, art, games

Little-wheel

You've got to try this.

It's like a tiny little myst adventure in beautiful steam-punk 2D flash game.

Play Little Wheel a tasty little morsel by One Click Dog.

via Das Cartoonist.

Tinselman should like this.

The Entire Cast of Futurama -- someone should make a poster

Posted on June 21, 2009 at 02:28 AM

Categories: tv, film, future

Futurama_cast

Here is as close as we've ever got to a poster of the entire cast of Futurama... from their most recent direct-to-DVD movie Into the Wild Green Yonder. It's notable for two things in my mind: first, it doesn't include most of the principles (they would be easy to add) and second, wow, Futurama just doesn't have as many characters as Simpsons. Simpsons has a LOT of characters. What do they say, 50 active on-going basis? That's a lot.

And now my fellow Earthicans ... More Futurama is Coming ...

Comedy Central was happy with the specials and with the 72 produced episodes of "Futurama" it acquired from 20th Century Fox TV in 2006. "Yet there is nothing like new, self-contained episodes week to week," said David Bernath, Comedy Central's senior vp programming. "This is all about reinvigorating the franchise, giving it a new burst of energy."

In other words, futurama pays.

OK, this is stupid but I came up with this joke for Zap Brannigan.

SCENE: ZAP BRANNIGAN IS YET AGAIN TAKING CHARGE OF A
TOP-PRIORITY MILITARY MISSION BY DRAFTING SOMEONE. LET'S SAY
LEELA. IT COULD BE ANYONE, THOUGH.

ZAP: Ahh, do you remember me? I'm Zap Brannigan.
Captain Zap Brannigan. I put myself in your charge.

SOMEONE: How generous of you.

ZAP: By which I mean I put myself in Charge. Of You.

Lame joke? Maybe. But I don't see YOU making up jokes and blogging them for everyone to see.

How many programming languages do you know?

Posted on June 16, 2009 at 10:31 PM

Categories: tech, meta, code

List of programming languages that I know* that appear on the Official Wikipedia List of Programming Languages**.

  • * Or once knew... but I could pick it up again, I swear. It's like riding a bicycle. I don't include languages that I tried to learn but failed... like Scheme and Prolog.
  • ** Commonly recognized as the standard in Lists of Things. Let it be known that I only include those languages that are turing complete, so CSS and HTML don't count.

Begin listing:

  1. AppleScript
  2. BASIC (Apple ][+)
  3. Bourne Shell
  4. C
  5. C++
  6. DLX Assembler (not listed, but it's a language...)
  7. HyperTalk (my first, favourite language!)
  8. Java
  9. JavaScript
  10. Lingo
  11. MATLAB
  12. Modula-3 (and don't I wish I didn't?)
  13. Objective-C
  14. Pascal
  15. Perl (and don't I wish I didn't?)
  16. PHP
  17. Python (and don't I wish I didn't? :-)
  18. Ruby (my third, favourite language!)
  19. μC++ (is it really a separate language? Well, it requires a separate compiler...)
  20. Visual Basic (sufficiently different from basic BASIC)
  21. XSLT (yes it's turing complete) (my second, favourite language)

So. Thoughts. FIrst, I can say that I know more than 20 languages. Second, my # of languages isn't going up as slowly these days, but the depth is. Third, my big hole is functional languages. Only XSLT is really functional-ish (people get mad when I say that).

I'd like to learn oCaml.

All of this work courtesy of procrastion and needing to quote a number of languages on my updated Custom Software Development page.

Rails "core team" fucks up big time

Posted on June 07, 2009 at 11:03 PM

Categories: tech, code, rails

Hey, if you have a rails app that uses the recently introduced authenticate_or_request_with_http_digest Rails 2.3 / http_authentication.rb, you've got a big fucking security hole. Anyone can log in if they provide a wrong username and no password, or a nil username & password.

Kind of terrible, right?

So Nate posts it on his blog after a week of trying to get the attention of the Rails security people, and they blame him in their security alert:

Due to communication difficulties and a mis-understanding between the reporter and the security team. This vulnerability has been publicly disclosed on several websites, users are advised to update their applications immediately. Steps are being taken to ensure that the security email is more reliable in the future. We regret the nature of this disclosure and will endeavor to ensure it doesn’t happen again in the future.

And they give him no credit. Most of the RCT idiosyncracies I can write off but don't fuck with security.

uHear -- test your hearing with an iPhone

Posted on June 04, 2009 at 11:39 PM

Categories: code, mobile, iphone

Here's a little movie I made of an iPhone app called uHear I developed for Unitron. This is also a bit of an experiment because I've uploaded the movie to Amazon S3 and you're watching it from AWS.

Anyway, the video is short, and shows you four parts of the app:

  1. The standard hearing sensitivity test, which finds out how quiet you can hear at various pitches in each ear,
  2. the speech & noise test, which tests if you might have trouble hearing over noise like in a restaurant,
  3. lots of hearing-related info, and finally,
  4. a live audiologist lookup based on your current location, powered by google maps API.

You'll want to turn your speakers up or the first bit might seem a bit pointless.

Making this app was pretty cool, my client was excellent, I worked closely with their audiologist in charge of this project and really pushed the boundaries of playing back audio on the iPhone in a very precise way. We also implemented some really cool UE/graphics designed by Tom Auger of Zeitguys in Toronto.

Incidentally, I'm available to do more iPhone consulting on a part-time basis :-) Bring in Simon & Woodside when you need crack software development (but not software development for crack).

Nokia blows it on the N97

Posted on June 04, 2009 at 03:17 PM

Categories: tech, symbian, mobile, nokia

Nokia's new N97, I was hoping it would be the next great phone. But looking at a review in AAS, it looks like they totally blew it on the keyboard. There are only three rows of keys, which means that the space bar is in completely the wrong place. Gak!

ZDNet UK notes that the touchscreen is resistive instead of capacitative and apparently this results in a substantially less appealing touch compared to the iPhone. Yet another strike against.

Finally, I note that the camera is still the 5MP unit in the N95. I have that camera. It's good, but it's not great.

Despite the fact that the new home screen looks really cool (and much better than iPhone) and that it actually has keys, this means that we're not looking at the next great Nokia device that I was expecting. My search for a great device that combines a huge touchscreen and a decent keyboard/keypad apparently will have to continue.

StartupCamp Waterloo Numero Six

Posted on June 03, 2009 at 11:29 PM

Categories: business, barcamp, startupcamp

Startupcamplogo

StartupCampWaterloo6 will be... is ... was. Yesterday in fact.

In presentation order:

  1. Ultrasaur RM kicked things off with a great 30-second pitch "Your sysadmin is hacking your server. How do you stop them?" ... they tried last time and were denied, so the moral is, try, try again. They were first pick this time.
  2. Thinkpanda with coolest logo and a demo you can't get into right now... an interesting tool for social bookmarking (my words, not theirs) which reminded me a bit of delicious and looked like it would be great as a part of groupware like Base Camp.
  3. Neverboard Studios... these guys had a pretty cool looking iPhone game and were like, how the hell do we get attention for this thing? They want to charge $$ for it but are worried that they'll never break through the attention barrier. We bounced that one around the room for a while... hopefully had some useful advice... Afterwards at the bar I suggested that they lace the sound effects of their game with profanity in the hopes that Apple will ban it, and ride on the publicity from that. And if they do let it through, people will want it— for the same reason.
  4. Kaimera Media with a concept for a theme park ride video capture system—like the thing that captures a photo of you on the roller coaster, but video. kiosk that burns a DVD for you on the spot. Definite win for simplest, best developed business plan of the evening.
  5. Primal Fusion, definitely known around the Waterloo startup community for being pretty well funded and definitely brainy. Demo, which I've tried the private beta on their first product, and while it's interesting, I think there's a lot of what they've done that's not exposed in this version that needs to be in the next before it's clear what they are achieving. By the way, I cheated on including Primal Fusion in the sequence because Mark missed the 30 second pitches. I've been power corrupted. But I suffered accordingly, as my discussion topic was pushed off the end of the agenda. I won't give up though... I'll have another one next time.
  6. Pager Duty was I think my favorite of the evening, although obviously they didn't do so well on the 30 second elevator pitch or they would have been farther up the presentation order. Very simple, to the point—if you need to have people on call, they will make sure that people are effectively notified with a simple service-style web system.
  7. Giftah has what looks to me like a solid plan, allowing you to buy/sell excess gift cards and they take on the guarantees. Interesting discussion, including acknowledgement that they do have larger, better funded competitors in the USA like Plastic Jungle ... how to get traffic, etc.

I suspect you'll be seeing some of these companies around in the future doing cool stuff.

Oh yeah—and if you were there remember to take advantage of the Communitech Entrepreneur in Residence (EIR) program definitely—just call them. Say I sent you :-)

Also, we REALLY need a single unified calendar of events and it looks like watcamp.com might provide.

Possible idea for next time: handing out red cards to anyone who says "Facebook". Also, giving a prize for provoking the best discussion.

Thanks to the Accelerator Centre for providing space, and Tech Capital, Sun Microsystems, and Communitech for food & drinks. This is a totally non-profit venture and all labour is volunteer :-) My posse is Jesse and Mic.

The old server was always crap, but...

Posted on June 01, 2009 at 12:59 AM

Categories: tech, unix

% uptime
 00:59:46 up 607 days, 14:13,  2 users,  load average: 0.06, 0.17, 0.36

no wonder I found a lot of wacky old processes running on there...

How to make samba on ubuntu use your unix passwords

Posted on May 31, 2009 at 01:47 AM

Categories: unix

You need something called "password sync" ... obvious right?

This will help:

Unix and Samba password sync on Debian Etch

...only took me an hour to figure out how to get logging working and decode the obscure error messages....

This is probably what you want to do if you get this:

Authentication for user FAILED with error NT_STATUS_WRONG_PASSWORD

Incredible Hulk easter egg: Nick Fury letter

Posted on May 30, 2009 at 05:59 PM

Categories: film

Nick_fury

So there I was, watching the Incredible Hulk titles again in slow-motion, because I'm always curious as to what the special effects people write into the various fake news stories and computer graphics. Sometimes it's funny. And I came across this little easter egg which seems to have been missed by fans on the net.

Nick Fury and S.H.I.E.L.D. Command are never mentioned in the film. He's part of the comic team Fantastic Four I think (I never really read a lot of comics as a kid, sorry...) which I guess will be having a film some day. Anyway, here's what it says:


Nick Fury
Shield Command
Code RED
New York, NY 060584

Details: Classified. Subject is THREAT LEVEL RED, surveillance only.
The Bruce Banner manhunt is still not over. This shadowy figure re-
nowned as a doctor and professor at the Culver University Science De-
partment has once again slipped through the authorites hands and is
still on the run.

That's verbatim by the way. Apparently the letter was never on screen long enough (just a few frames) to warrant a thorough spell check.

How come Marvel puts their logo on their movies, but DC Comics doesn't?

Why do people on eHarmony close with "I am pursuing another relationship"?

Posted on May 27, 2009 at 01:14 AM

Categories: theories, eharmony

I have a theory about this one. Because they can easily go to Matching and turn it off temporarily. But I think that some people leave it on, because they want the ego boost, even though they're going to shut down the match anyway.

How to do rails tests when running with restful_authentication

Posted on May 26, 2009 at 01:18 AM

Categories: code, rails, ruby

The Restful Authentication plugin seems to be the standard right now, although I'm staring to wish I'd tried something else, maybe AuthLogic... because restful_authentication is kind of poorly documented. One serious error of ommission is how the hell do you update your tests so that you can run them on controllers that require a logged in user? Well, I have had the pain, and so you can have the quick answer, here it is.

Assuming you are using ActionController::TestCase ... first edit test_helper.rb:

  # Add this helper function to test_helper.rb
# It will allow you to run any block under the aegis of
# a controller of your choosing. This is not something
# that is possibly by default
def run_with_controller( controller_class )
old_controller = @controller
@controller = controller_class.new
yield
@controller = old_controller
end

Now you can use that helper method in your test cases, in the setup function do this:

  def setup
run_with_controller(SessionsController) do
post :create, { :login => "george", :password => "monkey" }
end
end

What you're doing here is simply making a POST to the Restful Authentication SessionsController to "create" a new session, pass in a login/password that exists in your fixtures. And that's it.

By the way, if you chose to install with RSpec because of the dire warnings that old fashioned tests will be out of date, but aren't currently using RSpec for you other tests, you should copy the rspec fixture data into test/ so that you get the right password hashes. Tricky...

Don't use porn in your slides at a tech conference

Posted on May 15, 2009 at 09:47 PM

Categories: tech, rails, theories, ruby

So Merb developer Matt Aimonetti made a presentation at GoGaRoCu heavily laden with soft-core pornography and some people got upset. In particular, a woman got upset—Sarah Allen. It didn't help that she was one of only six women at a 200 person conference. Holy shit!

Don't put sexual images of women in your slides. If you must do it, then put just as many sexual images of men in your slides. Be fair. Unless of course you're presenting to a club that only allows male members. Which in a way is what pisses off the women who are reacting to this incident—because it implies that Ruby/Rails/whatever is a men-wanted-only club.

If I had been there, I suspect I would have walked out. I've walked out of presentations, movies, plays, etc. for less. I have low patience no pride.

Why the lucky stiff posted a summary of women rubyist's reactions, and there's discussion aplenty there and elsewhere on the net. Hopefully the positive outcome will be a community that is more aware of issues that differ between men and women, and therefore has more women in the future.

sudo apachectl stop && sudo apt-get remove apache2 && sudo apt-get install nginx

Posted on April 30, 2009 at 12:56 AM

Categories: tech, code, rails, internet

Nginx-logo

I binned apache finally on semacode.com. It was easy. A little bit of "this is really the last straw" frustration with mod_rewrite and I ditched it.

I've been threatening to leave you, apache, for years. Ever since I first cursed your horrid rewriterules, I knew that it would never be the same between us. You were good, once. You weren't just "a patchy" web server, but a scrappy one... once. But 2.0 you just didn't live up. You didn't fix your big warts. You got flabby. Even the decision by your developer team to finally remove the default MIME type didn't redeem you in my eyes.

No, it was just one poke in my eye too many, when you insisted on unencoding my percent encoded URLs before passing them to the rails/mongrel proxy, and there was just no way to make you stop doing it, no matter how many googles I searched. And so I said: enough is enough. Everyone on Rails uses nginx now, and I will too. I'm tired of learning how to sacrifice chickens to the apache configuration gods. Bring me something new, clean, shiny, fast, and easy to configure!

Learning how to configure nginx took an hour on the outside—it's very easy and keeps all the good parts of apache's syntax and throws away the complete crap. It even allows me to compress stupid blocks into one-liners! :

  if (-f $document_root/system/maintenance.html) { rewrite  ^(.*)$  /system/maintenance.html last; break; }

Isn't that gorgeous! I agree. And so the "engine x" russians get my love now. It's all over. Sayanora. End communication.

Intelligent humour

Posted on April 26, 2009 at 09:27 PM

Categories: links, art, internet

Intelligent online cartoons:

There's plenty of crap out there. Can you add any other good ones?

How to really URL encode an NSString in Objective-C, iPhone, etc.

Posted on April 22, 2009 at 02:52 AM

Categories: code, mac, iphone, objectivec

Trying to encode URL parameters on Mac or iPhone? Frustrated because NSString stringByAddingPercentEscapesUsingEncoding encodes non-URL characters but leaves the reserved characters (like slash / and ampersand &) alone? "Apparently" this is a "bug" apple is aware of, but they haven't done anything about it yet, and so, here is a solution that actually works.

Try this:

  NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
 NULL,
 (CFStringRef)unencodedString,
 NULL,
 (CFStringRef)@"!*'();:@&=+$,/?%#[]",
 kCFStringEncodingUTF8 );

As an example, @"'Decoded data!'/foo.bar:baz" will become "%27Decoded%20data%21%27%2Ffoo.bar%3Abaz".

Obviously you would use this, not on the full URL, but just on the parameters.

"trusted user" status on Daily Kos

Posted on April 21, 2009 at 12:04 AM

Categories: meta, theories

Well, apparently I've achieved the vaunted and much-desired "trusted user" status on DKos. That means I can rate people down, as opposed to just up. I'm probably not going to do it much, just like I rarely troll rated people when I had privs on SlashDot (back when /. was interesting...)

Daily Kos probably gets as much traffic as /. did back in the heyday, but their rating system is much different. Ratings are simply thumbs up as far as normal users are concerned, so the higher the number, the more recommended that comment is. Whereas in /., every comment was rated from 0-5. /. allowed you to quickly filter to view only comments above a specific level, which filtered out a lot of gunk but also meant that most people were actually reading less. This I think probably led to a situation where important and interesting comments were not seen by many people, and it was almost a competition for cleverness, etc. Whereas the system on DKos leads to much more of an actual dialogue.

Anyway, what lead to this was my analysis on the subject of the 46-page 2005 "torture" memo by White House "attorney" Steven Bradbury, which you can read here, if you have the stomach for it. (it's really nasty stuff, to be honest, and I felt ill after reading it and writing about it).

Update: trusted user status is gone! Thank god, the stress was getting to me.

The better way to code error-handling routines

Posted on April 17, 2009 at 12:50 PM

Categories: code, rails, ruby

There's an excellent guide to Rails 2 that I'm reading through right now, but I don't like this bit:

    if @comment.save
redirect_to post_comment_url(@post, @comment)
else
render :action => "new"
end

It's much better like this:

    render :action => "new" and return unless @comment.save
redirect_to post_comment_url(@post, @comment)

They do exactly the same thing, but mine is 2 lines instead of 5, and mine clearly eliminates the exceptional/error case first, and then leaves you to see the normal case. In fact, I virtually always code this way when I can, deal with the error cases first, and return, and then the rest of the function is an un-nested normal case handler.

Simplelog-X... is coming...

Posted on April 11, 2009 at 02:50 AM

Categories: meta, rails, ruby, simplelogx

So I just made some major updates to the software running this site, which for now I'm calling "Simplelog-X". And the source code for simplelog-x is now on github.

This will probably interest people who are running the original SimpleLog by Garrett Murray which he no longer supports (and incidentally it doesn't run on Rails 2.x). Simplelog-X also has quite a few other changes aside from working on (presently) Rails 2.2.2, all of the details are in the README.

I'm not going to annouce this loudly just yet because I still have a whole ton of my own site files in the public directory, and I need to move them to public/system I guess and get them out of the repo but still capistrano-friendly.

I was just making a lot of changes and it struck me how much more I know about Rails now than when I started this journey...

Dubai, I'm shocked!

Posted on April 08, 2009 at 05:02 PM

Categories: theories, predictions

Dubai-785156

So Dubai isn't a wonderland and actually is a vast petrol- and credit-funded nightmare that is on a knife's edge of sinking into the sands, forever gone? I'm shocked! Who could have thought it.

If a recession turns into depression, Dr Raouf believes Dubai could run out of water. "At the moment, we have financial reserves that cover bringing so much water to the middle of the desert. But if we had lower revenues – if, say, the world shifts to a source of energy other than oil..." he shakes his head. "We will have a very big problem. Water is the main source of life. It would be a catastrophe. Dubai only has enough water to last us a week. There's almost no storage. We don't know what will happen if our supplies falter. It would be hard to survive."

The dark side of Dubai (in The Independent) via The Cartoonist (see also Laid-Off Foreigners Flee as Dubai Spirals Down)

Here's a thought. Don't build a big city in the middle of a desert. And here's a prediction: Dubai will be gone in 50 years.

Zuckerberg melts down, facebook redesign sucks, worse than 80s Steve Jobs

Posted on April 03, 2009 at 06:09 PM

Categories: theories, internet, predictions

I absolutely hate the latest Facebook redesign. And, for the record, I loved the last one, so I'm not some kind of knee-jerk negativist. The new facebook removes the single most important feature, the live news feed. Facebook's major contribution to the online world was the live news feed. Everything—updates, pictures, interests, links, notes, etc. etc. etc. all in one time-sorted feed. It was brilliant, and obviously I think so since I make some kind of minimal replication of it on my own front page.

And now they have removed it. The new... thing ... whatever it is .. that I get is more like twitter. I don't need another twitter. I already have twitter. What I want is my live facebook feed. Now, if I want to see what photos people have been tagged in, what apps they have been using, etc., I don't know what to do. The right hand side seems to have some stuff there ... but I can't filter it.

Now what kind of idiot would destroy their company's chief asset in an eyeblink? When you've got something that good, you don't change it, you nurture it. Look at google's home page. They are so careful in making changes. They do statistical A/B tests on every single change they ever make, and only keep the ones that make people's results better. When they make a change that sucks, it's also minor and gets rolled back quickly. So my point is this: for FB to ruin their own user experience is really out of the ordinary and insane.

Who would do such a thing? Only a tyrant who's lost touch. Which means Mark Zuckerberg has become a tyrant and lost touch. For evidence that he's become a tyrant, we can look at the following evidence:

Gawker: A tipster tells us that Zuckerberg sent an email to Facebook staff reacting to criticism of the changes: "He said something like 'the most disruptive companies don't listen to their customers.'" Another tipster who has seen the email says Zuckerberg implied that companies were "stupid" for "listening to their customers."

TechCrunch: Facebook says this is about getting a CFO with public company experience ("We have retained Spencer Stuart to lead our search for a new CFO and will be looking for someone with public company experience."). Which is complete nonsense (and poorly thought out nonsense at that), because [Gideon] Yu, after a short stint at YouTube and an even shorter stint at Sequoia Capital, was the treasurer and SVP Finance at Yahoo. Which is very much a public company.

For evidence that he's lost touch, well, there's plenty. As of now over 1 million users have gone to the trouble to install an app specifically to complain about the new layout. I know that facebook has ~ 175 million users, but that's still a HUGE user backlash.

Now apparently they are going to roll back some of the changes... we'll see how that goes. Presumably at a company of that size the investors are going to force Zuckerberg to back down. See this Joy of Tech comic for an idea. But people are also going to compare Zuckerberg to Steve Jobs of the 80s, when he was forced out of Apple for being an asshole.

Let's be completely clear on this. Steve Jobs WAS an asshole in the eighties! My impression is that the film Pirates of Silicon Valley is quite accurate. And from working at Apple during Steve's second coming, I can say that he still could be a real asshole, the kind that gets things done and doesn't have patience for idiots. The difference is, that Jobs never did anything really stupid to his user base.

So, what's going to happen now? I suspect that Z won't back down very easily, and that we're going to see more conflict, clashes and problems in the future. It's unfortunate, and I hope that wiser heads prevail and FB recovers the truly awesome user experience that it used to have.

Update: Gawker thinks Zuckerberg should go. Strong stuff.

And Business Insider: Mark Zuckerberg has begun "believing his own hype," a source says. He believes he is the genius the magazine covers say he is. Mark has always been an executive who made life difficult for those he disagreed with. "Mark is a very demanding person to work for, if you screw up, one day you are in, the next day out, persona non grata," says one former employee. Now that he thinks he's Steve Jobs, he's unbearable.

New server for simonwoodside.com

Posted on April 03, 2009 at 05:19 PM

Categories: tech, meta, rails

R300

Yup.

Got a new server.

The old box, was a Penguin Computing rack-mount purchased in 1999 or 2000. It had a PIII and was totally maxed out RAM-wise—at 512 MB. Anyone who's tried to run rails on a box with that much ram might understand why I had occasional downtime. mongrel would just give up sometimes. Trying to install new gems was fun as well. Still, the old box had a good run.

The new box is a Dell R300... Core 2 Duo... RAM is at 4GB right now, max 24. And we've gone with RAID-1 since we don't really need the space but like the redundancy.

Also, we switched from debian to ubuntu. Ubuntu is a bit less secure but a hell of a lot easier to deal with in terms of package management and installation.

Welcome to the World of Tomorrow!

Posted on March 29, 2009 at 01:18 AM

Categories: tech, art, future

Worldoftomorrow

When I was just a young tyke, getting beat up by my peers every day, I retreated to the little school library to immerse myself in visions of the future. Little did I know that some day the mythical year "2001" would come and pass in a blaze of ... nothing spectacular. Well anyway, I think it's fun to look back at those visions of the future and look in awe at the coolness of how we should now be living.

My absolute favorite of all time series was called "World of Tommorow" by Neil Ardley, who also collaborated on the famous "How Things Work" with another of my favorites, David Macaulay (see him talk at TED!).

I love how Ardley saw us with huge gigantic wall-sized computers completely taking over our houses:

Or maybe you'd prefer to see what the tank of the future will look like (n.b., it's robotic!)

Playing holographic games could also be fun...

And there's more—two whole books are online: World of Tomorrow - Health and Medicine, and World of Tomorrow - School, Work and Play. I want my wall-screen TV.

Under the lid of a power line conditioner, the APC H15

Posted on March 25, 2009 at 06:24 PM

Categories: tech, photos

I just acquired an "APC AV H15 Home Theater 1500VA Power Filter and Power Conditioner", which is usually just called the APC H15. It's a pretty popular device basically to smooth out the AC power for home theatre type systems, and also protect your equipment from any kind of bad power juju. Some people buy these kinds of things to make their speakers sound better, but my system probably isn't good enough to notice at this point. My concern was that my apartment has bad power, and I've been having random computer shutdowns, blown lightbulbs, and even weird lines in my new LCD TV. Fortunately I got this silver H15 less than half price because they're moving from silver case to black case.

To me the most impressive thing about this kit is that it's HEAVY. 25 pounds as a matter of fact. So naturally I wanted to crack it open to see what the hell was inside.

Here's the front and back. Click on any of these pictures and on flickr click "All Sizes" to see 5 megapixel full resolution versions (ID parts to your heart's delight).

APC H15 frontAPC H15 back

Three easy screws gets the top off. NB If you've been using it there might be "hot" components inside (electrically speaking) even if it's unplugged. This one was fresh out of the box. Don't touch anything unless you know what you're doing.

APC H15 open - top

So, not just an empty case then. What the hell is that huge thing in the middle?

APC H15 inside #13

Looks like a massive toroidal core transformer operating as a constant-voltage transformer if you ask me. Provides voltage regulation and surge protection at the same time.

APC H15 inside #27

Some ceramic capacitors. Don't know what they do, beyond storing power.

APC H15 inside #17

The yellow/green toroidal things are Common Mode Chokes and reduce line noise. The red box is a surge cube relay (surge protection) and the blue boxes are Interference Suppression Film Capacitors for EM noise. I googled it.

And finally, here's the back panel.

APC H15 back panel

If you must have more, you can visit my flickr photoset with 37 detailed images...

The Shape of Things That Hum

Posted on March 20, 2009 at 08:36 PM

Categories: music, bittorrent, film

The Shape of Things That Hum is a series of 11-minute short documentaries about different electronic instruments. It goes through a bunch of classics, most I recognize the sound easily but never knew the name or the story. Here's the proper order:

  1. Minimoog, the grand-daddy analog synth of them all
  2. Vocoder, making a voice sound like a synth
  3. Roland DX-7, the first proper digital synth
  4. Roland TR-808, early drum machine
  5. Roland 303, a sort of bass synthesizer
  6. Various subjects
  7. Akai Sampler

The whole thing was first broadcast in 2001, in Britain, maybe Channel 4? I'm not sure. In any case it seems to have been more or less ignored, and it's definitely a sort of niche appeal subject. At the moment it seems like youtube/google video is the only source, but let's hope that someone out there will make a torrent with proper quality at some point.

Here's a link to all of the episodes, the best quality I could find. Click on "More from this user" to see them all. Or just google for the title if you can't find it there.

Urban camouflage / hiding in plain sight

Posted on March 13, 2009 at 04:38 PM

Categories: art

7_lappen02

Check out this artist hiding out in an Ikea store using a unique urban camouflage. Watch as he disappears in plain sight!

This Japanese clothing designer has another safety-minded approach: a vending-machine dress.

And finally, something I really wish I could buy. A sure-fire way to hide on the street when life just becomes too much:

It comes complete with vents so you can look out and watch the world go by while you hide and wait for your therapist.

I just wonder how you get into it without being noticed...

How To Save the World Without Destroying It (Too Big to Fail. It's True.)

Posted on March 10, 2009 at 11:25 PM

Categories: theories, finance

Cross-posted in my Daily Kos diary, where it will be almost certainly ignored (because kossacks mainly care about breaking news).

A Metaphor

Suppose I had a car company, Woodside Cars, Inc., and we discovered an amazing new way to power cars using a miraculous substance called unobtanium. We'd roll out a line of new cars, and everyone would buy them, because they never have to be filled up. People would buy shares in the company too. The cars are great, they're well made, they save money, and have a high resale value. But then, after 3 years, suddenly the cars start to fail. It's mysterious. Some of the unobtanium is corrupted. It's unpredictable. Some of the cars just stop, others keep going. Overall there's a 50% failure rate but no way to predict which ones will die and which will keep on going. Suddenly the resale market vanishes, no one wants the cars, and the stock price collapses overnight.

Why did the stop price drop so precipitously? The problem with unobtainium existed all along. But no one knew about it. One morning everything was fine, Woodside Cars was worth $50 billion, the next morning, it was worth $25. The details aren't important, the important thing is: the world collectively decided that the company wasn't worth as much as they thought. The wisdom of the market took care of the rest.

Now we might pity poor Grandma Joe who had her life savings tied up in Woodside stock. But only stupid people invest their net worth in the shares of a single company, right? Not so fast. Many people had their money in Woodside. Woodside has been making cars for 70 years and has always been stable before. Even charities, and small companies, have their money in Woodside shares. In fact, millions of people had their money in Woodside. Fortunately, they still have half their money left.

And then the lawsuits start. People are mad that their cars are broke. They start a class action suit. And it looks like that suit could drag down Woodside's remaining business in regular cars, even though those regular cars run on gasoline and electricity. This is bad news for Woodside shareholders. They run the risk of Woodside's "toxic business" dragging down its regular business and making their shares worth a big fat zero.

So the government steps in. "Woodside is too big to fail" say prominent business leaders and politicians. "Just think of the economic damage that it could do." First they loan Woodside money to buy back the bad cars, and then the split Woodside into two companies – one to carry on with the good business, and the other one to deal with the broken cars and the lawsuits.

Of course, in reality very few people would put all of their money in a company like Woodside. Woodside was free to develop and trade in new kinds of cars, based on any kind of fuel they like. Banks, on the other hand, have restrictions. They are regulated and insured and subject to constant scrutiny. Banks aren't companies... they're banks.

They used to be.

Now they are companies.

In fact there's even a phrase for it: the "shadow banking system". It sounds scary, and it should because it's regular companies, with all of their exposure and foibles, pretending to be banks. These so-called "financial services companies" are just as innovative and subject to unexpected losses as any high-tech, manufacturing, or services company, just as they wormed their way into the heart of the world's monetary system.

Too big to fail? Yes, Dorothy, they are too big to fail. Like Woodside, if they fail, suddenly a lot of individuals and businesses – perfect good citizens who truly believed that they were investing their money wisely – are going to be broke. And through no fault of their own. The effects will spread. People who never touched a Woodside car will suffer.

Yes, the executives should be axed. Yes, the regulations should be changed. But the company is really a bank, whether it's Woodside Cars, or AIG, and needs to be treated as such. If it's allowed to fail, then the economic costs will be massive. Certainly the company made mistakes, and there's good reason to punish it for that. But. They didn't break the law. Unobtainium was legal when it was introduced. Maybe it shouldn't have been, but it was.

Of course the real situation is much worse. It's like unobtainium has been added to the fuel of every car that anyone makes or drives, except that no-one knows which cars are good and which cars are bad. Unobtainium has become so essential that there's no way to quickly remove it from the transportation system – it will take years. Car companies are struggling to figure out which of their suppliers have tainted parts. Even the government can't figure out which parts are good and which are bad.

That's more like the actual banking crises. Unobtainium is bad debt. Oh, there's a million ways to name it – CDOs, MBSs, CDSs, etc., etc., but it's all fundamentally bad debt. These shadow banks, running amok, have infected the entire system. When no one knows which accounts are good and which are bad, they won't borrow and they won't lend.

The knee-jerk reaction is to save the system by destroying it. Let them fail. That is short sighted. All of our so-called money is inside these companies. If they fall, we fall. Yes, we must fix the system, punish anyone who broke the law, and  change the rules so this won't happen again. But that's a very big job and won't happen overnight. In the meantime, unobtainium has infected the system so badly that it needs heroic measures to stave off total collapse.

Next time I'll talk about why the fundamental rules of executive compensation created this problem, and how I think they must be changed to make sure this "never happens again".

iPhone programming: how to switch to a landscape view at the moment of your choosing

Posted on February 27, 2009 at 05:12 PM

Categories: code, mobile, iphone

Maybe someday, Apple will make it easy to rotate manually into a landscape view. But right now it's been causing me enormous headache with hideous frames issues. Running an app in landscape the whole time is easy, but doing just some views in landscape is insane, especially if you're trying to switch while in the middle of a navigation controller.

However I've found an easy solution which is to use a new window. Just reset the whole view problem. You can then fake out the navigation bar using the method of your preference. Here's the bare bones. For me, I'm going from a tableView, click on an item and get a "results view".

// In ResultsListController, a UITableView delegate:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  ResultsViewController * resultsViewController = [[[ResultsViewController alloc] initWithNibName:@"ResultsViewController" bundle:nil] autorelease];
  resultsViewController._recordIndex = indexPath.row;
  UIWindow * window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // this is a leak!
  window.backgroundColor = [UIColor redColor]; // just for debugging
  [window addSubview:resultsViewController.view];
  [window makeKeyAndVisible];
}

Now ResultsViewController has its own NIB, and the view is set to be sideways in IB.

// In ResultsViewController
- (void)viewWillAppear:(BOOL)animated; {
// First rotate the screen:
  [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
// Then rotate the view and re-align it:
  CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation( degreesToRadian(90) );
  landscapeTransform = CGAffineTransformTranslate( landscapeTransform, +90.0, +90.0 );
  [self.view setTransform:landscapeTransform];
}

// Connect your "back" button in the results view to this:
- (IBAction)back:sender; {
// return screen rotation to normal:
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
// Get rid of the window, and the "normal" window will re-appear from underneath
self.view.window.hidden = YES;
[self.view.window resignKeyWindow];
}

Easy as cake!

UPDATE: There's follow-up Q&A on the iphonedevSDK forums.

The StartupCamp Report - StartupCampWaterloo5

Posted on February 26, 2009 at 06:34 PM

Categories: tech, links, business, barcamp, startupcamp

So last night was StartupCampWaterloo5—the Original Startup Camp with the Best Format(tm). We had on the order of 60-80 people in attendance. We didn't do formal count of startups this time, but there were 12 proposed demos on the whiteboard, and I know of at least 3 other groups that were represented. As usual we had a keynote speaker: Mark Evans, who among other things runs the mesh conference in Toronto. He usually talks about social media, but he focused for us on communication, highlighting good and poor first impressions and public communications strategies of various websites.

Twelve people/groups put themselves up for doing a session, and gave 30 second pitches about what they wanted to discuss on the theme of starting up. We did our approval voting, ate food (thanks sponsors!) and had time for the top 4:

  • Kareem Shehata showed us his new Aeryon Labs Unmanned Aerial Vehicle—sadly he did not yet have government clearance to fly it, but it's a serious piece of kit and he had some kick ass videos. It's controlled via a Google Maps style interface. We talked about business models. http://www.aeryon.com/

  • I led a discussion on the subject of where to get Free Money from the government. Suggestions included SR&ED, NSERC USRA, Various OCE programs, Youth Employment Strategy, Ontario Interactive Digital Media Tax Credit, MS BizSpark, Youth.gc.ca - $15K for employee < 30, OMDC, Ontario Interactive Tax Credit, Services Canada (summer jobs)... and to look at the recent techcapital blog post.

  • Avery Pennarun "eql=data" a project he's working on to make MS Access databases web accessible. Business model was a bit of a question mark but interesting technology and Avery gives good talks. http://eqldata.com/

  • Grigory Kruglov—a UBC student current on co-op at RIM - talked about his business venture Outwick.com. It's aimed at collecting information about events like concerts, cultural events, public parties etc. and making it easy for people to find events at the time & place of their choosing using data mining, tagging etc. Very interesting, and we had a cool talk about viability, how to commercialize, etc.  http://outwick.com/

We also ran a live twitter stream on the main display using #watcmp. Afterwards many of us adjourned to Molly Blooms to imbibe the beverages of our choice.

Thanks to my co-instigators Jesse Rodgers and Mic Berman, and to our sponsors: Accelerator Centre, WatStart, Sun Microsystems, and Tech Capital Partners who provided space, support, and food!

PS And I almost forgot—Graham Hardie shot video and promises to put it online!

A "short" list of financial market crimes

Posted on February 11, 2009 at 06:02 PM

Categories: theories, finance

3093937818_2e7f1fa285

It seems like the truth is slowly emerging about all of the horrific things that went on during the boom times and are now emerging from the muck as the swamp is drained. Someone like Bernie Madoff can always cover his debts while the market is rising, but suddenly his ponzi scheme fails when it crashes. It seems that there is now a laundry list of semi-legal crap that is similarly being outed.

A lot of these terms might sound like stupid jargon but they are actually useful jargon, because they are the name for a specific thing, and that thing is fucking up your bank account and making you lose your job.

You should probably already know a few terms of useful "jargon". To start off with, "debt" is not just what you have on your house, it's something you can buy and sell. The value of the debt is based on someone (a ratings agency, a market)'s assessment of how likely to be fully paid over time, and how much the interest is. So the "best" debt (most expensive) would be say a government bond at 10%. Options (e.g. call and put), and Short Selling (which is much like a "put option"), these are both kinds of Derivatives. Briefly, options and short selling allow you to make a stock market trade where you benefit if the stock goes DOWN. Think about how evil that is for a moment, will you? Normally you only buy shares if you think they're going to go up. Derivatives is a broad category, including options, which allow you to trade things on the stock market which aren't actually company's shares. So, you can trade options, or you can trade debt, or the price of oil in 10 years, or whatever. "Downside risk" is the bad stuff that happens if the market does poorly, people default on loans, or whatever.

Secrecy

Underlying all of the below is that no-one knows what the fuck is going on. Most of these tricks don't require reporting to anyone, any market operator or regulator. You can mess with the stock market in so many ways without telling anyone. Maybe the insiders at the other big financial companies on Wall Street will figure it out or hear rumours. But the general public, and even CEOs of normal companies, rich people, readers of Wall Street Journal, normal people, poor people—know nothing until years later.

Naked Short Selling

You can short sell stock you don't own? Are you kidding me? Have a look at The Story of Deep Capture. Basically, I own a big financial company, say a hedge fund, and I want to kill your company. So I short your company and naked short sell it, which adds massive number of shares to the pool, driving down the prices of the existing shares. Then I transact my real shorts or put and make a killing while your stock suffers big time.

Credit Default Swap

OK, this one is a kind of insurance. I loan money to someone but I'm not sure if they'll pay me back. They might go bankrupt and default. So, I get "debt insurance" (like a CDS) and if the default happens, you the insurer pays me instead. Except that CDS isn't exactly like insurance, because (a) I don't actually have to be the lender and (b) you don't have to actually be a regulated insurer. In addition, there is no central place where CDSs are tracked, and you can resell them on and on, making it VERY confusing to know what they're really worth. Which is one of the reasons why banks won't borrow or lend right now, because they have no idea what their CDSs are worth. And of course, they are priced based on "normal" default rates, which go out the window when there's a crash. Why is that a big deal? Because EVERYONE has their money in them ... CDSs were recently valued at $55 TRILLION. Needless to say, Bear Stearns, Lehman and AIG were huge into credit default swaps.

Collateralized Debt Obligation

Wonderful stuff. Long ago, in a galaxy far away, the bank that loaned you money was personally responsible if you defaulted. But no longer. Now that bank can package up your loan and many others into a "CDO" and sell it to other people. Theoretically they will tell you which CDOs are good debt and which aren't so good. But, to be honest, they don't care. They sell someone else the debt, and then it's not their problem anymore if the borrower defaults. So, people get sloppy. And then, the various companies that are supposed to asses the risk in a CDO did/do a very bad job of modelling the downside risk. So when for example the housing market drops by 20% suddenly the CDOs are completely underwater and no one knows any more what they're worth. Maybe they're worth nothing. Who knows? And it doesn't help that some CDOs are actually made up of ... you guessed it ... other CDOs.

Synthetic CDO

Hey, let's kick it up a notch. The above are so boring. They're not, you know, complicated enough. So the financial geeks decided to make CDOs which contained, not actually debt, but Credit Default Swaps! Get it? Hilarious eh? Why would anyone want to do this, I don't know.

The Annual Bonus

I think this one is ultimately responsible for all the others. Financial company performance by the executives is measured on a YEARLY basis. That means, if you are CEO or whatever and you are making a decision, you think only at most ONE YEAR OUT in terms of what it will do for your company. You never think beyond a year, because you are getting paid in at most one year for your decisions, never beyond that. As long as you get your bonus before the shit hits the fan, you're laughing. I think that if these financial firms re-arrange their compensation system so that decisions have to bear fruit for a longer term—maybe 7 years—a lot of the shenanigans would never have happened. You could do that, for example, using employee stock options, locked-in shares, and I'm sure that the wizards can figure out other ways as well.

Well there you have it, my shit list for the financial market circa 200X. And if you want to read so much that your head will explode, try The Economists's Jan 22 Special Report on the Future of Finance. It's 25 pages (in the magazine) and the index is on the right side of your screen. See especially When markets turn. And don't be scared to learn a little more financial jargon. It might save us all next time.

Update 1: And let me add just one more thing. The banks don't know what their own assets are worth. In case you didn't get that above, a lot of banks own a lot of CDOs, CDSs, etc., etc. They don't know what they're worth. That's why there's a "credit crisis" ... they don't trust each other, because they don't even trust their OWN balance sheet. No one will borrow or lend. And that's just how bad it is.

Update 2: You might find useful this video on CDOs and this one on CDSs from Marketplace.

Image from worthbak.

Wondeful joy! Mix Ruby and Objective-C with MacRuby

Posted on February 10, 2009 at 02:51 AM

Categories: code, mac, ruby

Macruby

How great is this. You can use any language you want in your MacRuby projects. Want to add in some code you already wrote in Objective-C++? No problemo!

Check out the cool screenshot below which shows everything in action! (You might have to click on the full post view to get the picture).

Also, you might be wondering how to get full bi-directional bridge going on between Ruby and Objective-C/Cocoa. In otherwords, how do you call/access/include/import/require your own Objective-C classes from Ruby and your Ruby objects from Objective-C? It's actually done sort of automagically. If you have a Ruby class Foo and a ObjC class Bar...

(You seem to have to use NSClassFromString(@"FooController") to avoid getting a linker error. Apparently the bridge is not yet running at compile/link time. Also, you (seem to) have to type your bridged objects to id in ObjC, although maybe there's a way around both those limitations that I don't know about yet.)

# Foo.rb
class Foo
def foo
puts 'FOO'
bar = Bar.new
puts bar.bar
end
def baz
return "BAZ"
end
end

// Bar.h
#import <Cocoa/Cocoa.h>
@interface Bar : NSObject {
}
- (NSString*)bar;
@end

// Bar.m
#import "Bar.h"
@implementation Bar
- (NSString*)bar; {
id foo = [[NSClassFromString(@"FooController") alloc] init];
NSLog(@"%@", [foo baz]);
return @"BAR";
}
@end

And you will get this output when you call Foo.foo:

FOO
2009-02-10 02:46:28.017 Untitled[37257:10b] BAZ
BAR

Boing boing boing! Enjoy!!!!

How to make WYM Editor support embed objects (such as flash videos, youtube, etc.)

Posted on February 08, 2009 at 02:27 AM

Categories: code, internet

Hello! I've got a big update for this post, so skip to the end for the goodness!

I use WYM Editor for editing my posts, it's awesome, there's only just one small thing that I don't like about it, which is out of the box it doesn't allow you to copy/paste embed tags like you would use to embed a flash video, youtube video, etc. into your posts. It actually strips out embed tags if you try to put them in.

Why they would not support this, is out of my mind, I can't understand it. There doesn't seem to be any sense in it. Oh well, I know javascript and XML so I can fix it right? Sure, why not.

So, here is a patch that enables basic support. You can switch to "HTML mode" (i.e., the mode where you can see the sourc code, 2nd button from right in the standard view) and paste in some embed code, the stuff you get from YouTube that looks like this:

<object width="480" height="295">
<param name="movie" value="http://www.youtube.com/v/jzHBszZn6uo&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/jzHBszZn6uo&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed>
</object>

The embedded item might or might not actually appear in the preview mode at that point. Don't worry about it. Save it, view the final result, it should be there.

It would be nice if the developers would take this and build it in so that you can actually copy/paste them in the "normal" way.

Here is the patch, apply it by hand, or copy/paste it into a patch file and apply using the patch command.

Index: wymeditor/jquery.wymeditor.mozilla.js
===================================================================
—- wymeditor/jquery.wymeditor.mozilla.js	(revision 119)
+++ wymeditor/jquery.wymeditor.mozilla.js	(working copy)
@@ -80,10 +80,11 @@
     
     //replace em by i and strong by bold
     //(designMode issue)
-    html = html.replace(/<em([^>]*)>/gi, "<i$1>")
-      .replace(/<\/em>/gi, "</i>")
-      .replace(/<strong([^>]*)>/gi, "<b$1>")
-      .replace(/<\/strong>/gi, "</b>");
+    // this messes up embed tags—changes them to ibed
+    //html = html.replace(/<em([^>]*)>/gi, "<i$1>")
+    //  .replace(/<\/em>/gi, "</i>")
+    //  .replace(/<strong([^>]*)>/gi, "<b$1>")
+    //  .replace(/<\/strong>/gi, "</b>");
     
     //update the html body
     jQuery(this._doc.body).html(html);
Index: wymeditor/jquery.wymeditor.js
===================================================================
—- wymeditor/jquery.wymeditor.js	(revision 119)
+++ wymeditor/jquery.wymeditor.js	(working copy)
@@ -2068,6 +2068,17 @@
     "13":"dl",
     "14":"dt",
     "15":"em",
+    "embed":
+    {
+      "attributes":[
+      "allowscriptaccess",
+      "allowfullscreen",
+      "height",
+      "src",
+      "type",
+      "width"
+      ]
+    },
     "fieldset":
     {
       "inside":"form"
@@ -2243,10 +2254,11 @@
     {
       "attributes":
       {
-        "0":"type",
+        "0":"name",
+        "1":"type",
         "valuetype":/^(data|ref|object)$/,
-        "1":"valuetype",
-        "2":"value"
+        "2":"valuetype",
+        "3":"value"
       },
       "required":[
       "name"
@@ -3449,7 +3461,7 @@
     this.block_tags = ["a", "abbr", "acronym", "address", "area", "b",
     "base", "bdo", "big", "blockquote", "body", "button",
     "caption", "cite", "code", "col", "colgroup", "dd", "del", "div",
-    "dfn", "dl", "dt", "em", "fieldset", "form", "head", "h1", "h2",
+    "dfn", "dl", "dt", "em", "embed", "fieldset", "form", "head", "h1", "h2",
     "h3", "h4", "h5", "h6", "html", "i", "ins",
     "kbd", "label", "legend", "li", "map", "noscript",
     "object", "ol", "optgroup", "option", "p", "param", "pre", "q",

The Big Update

Thanks to Maxwell Scott-Slade for commenting and pointing to his even more improved version on his blog. I've taken his & my work, added the ability to support flashvars attribute (required for flickr embeds among others) and forked the wymeditor svn repository into GitHub. Get WYMEditor that supports flash on GitHub.

If you want to use it, just:

% git clone git://github.com/sbwoodside/wymeditor.git
% cd wymeditor/trunk
% make

The result will be in build/build/wymeditor.tar.gz.

How to make an iPhone button highlight (hold state)

Posted on February 05, 2009 at 07:26 PM

Categories: code, iphone

Here's how to use iPhone SDK to make a button hold it's on/highlighted state when you click on it:

- (IBAction)badButton:sender; {
  badButton.highlighted = YES;
  if( _hasChosen == NO ) {
    _hasChosen = YES;
    [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(badButton:) userInfo:nil repeats:NO];
  }
}

On simulator it looks perfect, but on device there's a brief moment when it goes white before it goes blue/highlighted again.

What is the Hitch Hiker's Guide to the Galaxy really about?

Posted on February 02, 2009 at 12:32 AM

Categories: theories, film

Hhgttg

The Hitch Hiker's Guide to the Galaxy is about life, the universe, and everything, ... and the fact that it makes no sense. Life makes no sense. Nothing that happens makes any sense. There is no purpose, to meaning, no answer, just an endless series of coincidences, catastrophes, and occasionally good times which we just have to put up with until we die. This is the thesis of HHGTTG, and also a good bit of Douglas's other work.

The story is told through the Book, or rather, the Guide. The Guide is the voice of the narrator, who spends most of his time talking about the book, that most famous of all books to come out of the great publishing houses of Ursa Minor Beta, and which the narrator notes, is the subject of the whole story in the first place. Arthur is just a new reader of the book, Ford an old writer for the book, and the other characters embody it's general philosophy: that the universe is fucked up (Marvin), and you might as well just try to have fun (Zaphod).

All of them have essentially zero control over their own lives, even when they think they do. Trillian and Ford seem to have wilfully chosen to just hang on for the ride, and Zaphod seems to be doing the bidding of unknown voices in his brain. Even the hyper-intelligent trans-dimensional aliens can't figure out what to make the answer to the Ultimate Question, or prevent a bunch of bungling bureaucrats from messing up their shot at obtaining the Question. I'm not trying to belabour the plot here, just point out that it makes sense only if you realize that Douglas is trying to tell you that it doesn't make any sense at all. The Big It. Everything. Nothing Makes Sense.

It's like that moment in the Simpson's when the lawyer invokes the Chewbacca Defence. It doesn't make sense. That what the Hitch Hiker's Guide is all about.

So you can't shoehorn that into a movie about romance and character development and happy endings. All of the best material, what Douglas created, is the ultimate joke of the pointless randomness of life. And that's not only what Douglas' story is about, but what the book inside the story is about. That's why the backbone of any good retelling of the story must make the book itself the central fixture and the backbone of the narrative. Keep as much of Douglas's precisely crafted dialogue in place as possible, and don't worry too much about plot or character development. Make sure that when the audience finds out that the answer, after all that time, searching, questing, is 42, that they laugh in the knowledge that it doesn't make any sense, and it doesn't have to, and you'll feel better if you don't worry about it and just go along for the ride.

And maybe, after the pointless early demise of the author himself, in a fashion so fitting that it ought to have been written by him, we'll eventually get an ultimate movie version that does justice and helps us all feel a bit better about losing him before he could write so many more great works.

I just realized that "Bachelor's Degree" is sexist

Posted on January 16, 2009 at 02:13 AM

Categories: theories

Crazy eh?

Bachelor

The PC Police missed that one.

What happened to Sphera Software?

Posted on January 12, 2009 at 01:46 AM

Categories: mac

It was a mac shareware company that made some great games: Scramble in particular, was a lot like the current Word Challenge game on Facebook, and then there was Spin Crisis, and a CHM reader called Chimp... and now they are gone without a trace. Their old domain takes you to some band.

All I know that isn't available on google is that when I emailed them, the response was from Shawn Henry. Shawn, if you're out there—what happened?

Update: Here's Sphera Software's home page on the Wayback Machine. It identifies the following people as having been part of Sphera: Shawn Henry (head programmer, student in Ottawa), Neale McDavitt (graphic designer, Montreal), Michael Keogh (musician, Ottawa), Anca Szilagyi (wordsmith, Brooklyn). It looks like several of them were students, and maybe the company broke up when they graduated.

Unfortunately they didn't leave forwarding addresses. But I'm sure you can find some of them if you google.

iphone objective-c pain ... give me ruby, bastards!

Posted on January 11, 2009 at 02:37 AM

Categories: code, mobile, ruby

I'm writing an iPhone app in Cocoa Objective-C and really wishing that I could be writing it in Ruby instead (cocoa-ruby on iphone anyone?).

Take this one line:

    if( ! [foo isEqualToString:bar] ) {

Oh yeah, I can really tell what that does by glancing at it... not! But here's the equivalent ruby:

    unless foo == bar

Shorter, more obvious, easier to write, easier to read and maintain. Why does Cocoa need to be so wordy? Even [foo equals:bar] would be better. But no, that would be too ... ambiguous. I don't know. isEqual: is defined in NSObject but who knows what highly dangerous or unexpected result it would have between two strings. Maybe it would only be true if they were the same pointers, or copy: results. No one in ObjC land seems to be thinking about making syntax easier for the programmers, do they? And why don't we have overloading???

For example, if we had method overloading, you could easily have different versions of equals: (or isEqual: if you must) that handle NSString*, NSWhatever*... of course this would require the compiler to be smarter, and the runtime to be smarter, and who uses Objective-C other than Apple ... no one, that's who. Hey, here's an idea—why not ditch ObjC wholesale for Ruby? It's not like Ruby is going to be, you know, slower. Well, of course it will be slower in the C sections.

At least now with "Fast Enumeration" in Objective-C 2.0 we can do something like this:

    for( NSString * bird in [NSArray arrayWithObjects:@"owl", @"parrot", @"partridge", @"pigeon"] ) {

Although again, it's really annoying that there's no convenience syntax for creating an array. How hard would it be? Not very hard, that's how hard. In Ruby it would be simply:

    for bird in ["owl", "parrot", "partridge", "pigeon"]

At least we have convenience syntax for NSString * animal = @"Bandicoot" right? I suppose we should pray at the altar for that one and hope they never take it away...

Finally, I have to kiss good-bye to any kind of interesting use of first-order functions and closures. Technically Objective-C CAN actually do dynamic function calls at least, but it's so bloody wordy that I rarely use it unless forced to. I can't use the lovely map function in Objective-C which adds considerably to my line count.

But wait, Apple is adding closures?  ... why don't they spend the effort on making Ruby Cocoa better instead? Or maybe give me garbage collection on the bloody iPhone.

Lego + Eddie Izzard = Death Star Canteen

Posted on January 11, 2009 at 02:21 AM

Categories: links, film

Hilarious video, great animation, Lego + Eddie Izzard in the Death Star Canteen

Eddie Izzard — why not better known on this side of the pond. He's hilarious. Maybe american's don't like straight cross-dressers. Dunno. Great comedic timing.

I'm still working on embedding video in WYMEditor. Why are they so stupid?

Great percussionist video: Evelyn Glennie

Posted on December 24, 2008 at 01:42 AM

Categories: music

Evelyn Glennie is a deaf percussionist. I guess that this is possible because percussion creates vibrations that you can feel with your feet, your hands, your fingertips, maybe even your whole body. She is now one of the few or only professional solo percussionists in the world. Anyway, the TED conference gave her a 30 minute session which is reproduced here in high definition (definitely consider plugging into decent speakers or headphones). Evelyn Glennie on "How to Listen". Click on the High Definition link under the video to get the real video.

My home theatre: Audioengine 5, Airport Express, Sharp Aquos 32D64U, and a Mac Mini

Posted on December 23, 2008 at 01:17 AM

Categories: music, mac, bittorrent, film, photos

Someone asked me recently to describe my home theatre. I've put quite a lot of thought & work into it. But not a lot of money. My goal from the start was to achieve the maximum return with the minimum of complexity.

The Home Theatre PC

So, right from the start I knew that it was going to be as much digital as possible. I don't care about live TV and I'm a bittorrent expert so I knew I wouldn't have to mess around with cable connections. But more to the point, being digital means you don't have to worry about analog components or duplication. For example, you can concentrate on having just a single Digital/Analog Converter (DAC)... a key component in your audio set-up.

The first thing I bought was the DAC & speakers. I had a new apartment and I wanted to be able to listen to music there. In particular, I wanted to be able to do two things: listen to music coming off my Nokia N95, which functions like an iPod, and listen to music coming off my laptop, a MacBook Pro. I did a lot of research online to figure out how I could get the best sound with a budget of $400. And I wound up finding a REALLY nice pair of speakers.

I actually restricted my search strictly to powered speakers, or, as they are commonly called, "ipod speakers"... and most of them are fairly crap. Even the ones from Apple didn't really score that well when I listened to them. I'm a musician on the side and I know what good sounds like. None of the ones I could find in stores reproduced sound the way I wanted—clean, like the original, faithful. They were bass heavy and muddy. But online I read a review of AudioEngine 5, a pair of "ipod speakers" that got fabulous reviews—from audiophiles.

You probably know that audiophiles are nutcases, but there is something to be said for their discrimination and knowledge of the art. If an audiophile says something is good, then it probably rocks if you're a normal person, even a musician like me. So, I found a deal and bought the A5s for $350. And I picked up an Apple Airport Express at the same time.

Audioengine 5 bookshelf speakers

Both purchases turned out better the more I learned. The A5s have built-in amplifiers, which means that I don't need to (a) buy an amp (which I planned) or (b) match the amp to the speakers. That's a relief because sound matching amp/speakers would be a LOT of work. With the Airport Express, I started to notice something odd. When I plugged my MBP directly into the speakers, it sounded OK. But when I played through the Express, it sounded GREAT. Turns out the Express has a quite good DAC inside. Sweet! The improvement is highly audible.

OK, a little digression here about speakers. Most products, you get what you pay for. Not with speakers. Speakers are in fact somehow immune to the whole mass production economics. Most audiophiles seem to agree that most, or perhaps all, consumer grade speakers are absolute shit. To get good speakers you either spend absolutely boatloads of money, buy second-hand, or ... you can buy from very small companies, even individual crafters. Audioengine falls into the last category. Even though their website may look slick, this is a small enthusiast company that just wants to make great speakers.

What's up with that? I don't know. I think partly it's the analog ecosystem. For good analog components you just cannot avoid spending a lot of money on expensive electronics to put inside. You can't skimp or replace things with digital. You have to have huge capacitors, big transistors, lots of coiled wire, heavy metal. Good speakers are HEAVY. They are made not from plastic or even titanium but MDF—that's plywood in normal english. You can't fake this stuff, you have to have it, but it's not rocket science, just good workmanship. So, buying from a small company like Audioengine is not silly, it's a great choice. End of digression.

So... now I had a REALLY good sound system and spent countless hours discovering all kinds of wonderful things about my music collection. It really makes a difference. In fact, I admit that I've poisoned my ears on lesser systems... I just need to hear the higher quality. The music is just ... better. There's more in it, detail wise, spatially, musically, tonally. Get a good pair of speakers & DAC, and you too can discover the magic.

Next up: TV. Starting out, I thought I wanted the biggest plasma I could buy. I read all of the reviews, the dark room tests, HD movies, the works. Plasma is the best, blah blah blah. Went to a big store and suddenly I realized different. Two things for me. One: I'm only about 8 feet from my screen and I don't want to be dwarfed. So, I can knock down the screen size dramatically, in fact, I went down to 32 inches. Crazy eh? Second: I have a sunny upper-floor viewing room with a window directly opposite the display, and I intend to watch during the day. That means matte screen which means LCD. Benefits are that I save money due to the small size, don't have to worry about burn in or wasting power, and I know what LCDs are like from long experience. So I wound up with the Sharp AQUOS 32D64U. This model has 1080p, which was essential for me. I have to be future proof. It's going to be a long time before there's a higher resolution than that for films.

The ultimate HTPC: a mac mini

Finally, I need something to tie it all together, and here my Mac bias definitely played a role. Mac Mini of course. Of course it helps that they are silent, small, and look very good indeed. No ugly boxes for me. I run VLC and mplayer, but mainly Plex, and awesome port of XBMC. Video goes through a DVI to HDMI converter into the TV, and sound goes analog into the speakers (A5's have two inputs). My only complaint is again, the Mini's analog audio output is not as good as the Airport Express. Eventually I will have to buy a dedicated DAC.

This setup does everything I need, and it's got a good future. If and when I want to move up to new components, all of these pieces will make excellent secondary system components for a second room. They all go together really well, look good, and look and sound great. All told the whole system was about $2K which is a reasonable price considering that I'm basically completely satisfied at this point in time.

For the future? I might—might—try out surround sound at some point. I'm not crazy about—pointless for music, but for the movies—maybe. I definitely don't need a bigger screen. A proper external DAC, driven by USB port, is probably the next item to get, and then I would begin the search for a new amp/speaker combo. Realistically though I can't upgrade my speakers (or add a sub-woofer) until I move into a house. My apartment does not have thick walls and with the A5 bookshelf-sized speakers I can crank it up any time without waking people up.

So, there you have it... complete system, as digital as it can get, and in the $2K range. I'm happy.

The Home Theatre PC - back

Spotlight does Math (but not conversions)

Posted on December 21, 2008 at 09:56 PM

Categories: mac

Mac OS X has Spotlight (Cmd-Space) which rocks for not just finding files but launching applications (just start typing the name). I just discovered it also does math, just like google. For example, try typing in 5*9+pow(sqrt(10),3) . Nifty.

Alas it doesn't do currency conversion or unit conversions. Maybe in 10.6...?

Ruby on Rails Feed/RSS Aggregator (35 lines)

Posted on December 07, 2008 at 03:17 AM

Categories: code, rails, ruby

I wrote myself a feed aggregator for my front page. And... voila! I'm finally satisfied with it to post it.

Update: I've now published this as a complete standalone rails app on github/sbwoodside/portal. The important bits are app/controllers/portal_controller.rb and config/config.yml.

For me I run this as a standalone rails app, separately from my weblog. You could do that (and redirect requests to / or /index.html with Apache or nginx/etc. Or you could integrate it into your own app. Up to you.

Features:

  • Will aggregate ANY feed, no matter how badly mangled by the creators, using FeedTools (I also tried feed_normalizer and simple rss but they're not as good)
  • Deals with slowness of downloading feeds, RSS, etc., and REXML by caching
  • Deals with need to recache using elegant http/cron periodic system
  • Display the feeds in a facebook-like news feed format, sorted by dated.
  • You can easily re-label the feeds, add and renew feeds (in the code)
  • Only 35 lines of controller code!

The heart of it is the controller, obviously. The best thing? It's only one page of code! Ruby rocks!

require 'feed_tools'

class PortalController < ApplicationController
layout 'site'
# Instructions: 1. Change @@secret. 2. Add a cron job to regularly call /?recache=yes&secret=XXXXXXX
# This is a feed aggregator that uses FeedTools because it handles practically any feed.
# But FeedTools is super slow in every way so this aggregator stops using it as soon as possible.
# TODO add XML feed output

@@secret = "change_this" # change this to protect your site from DoS attack
# The array of feeds you want to aggregate. If you change this then manually delete the whole cache.
@@uris = ['http://simonwoodside.com:8080/posts/rss', 'http://simonwoodside.com/comments/rss',
'http://semacode.com/posts/rss',
'http://api.flickr.com/services/feeds/photos_public.gne?id=20938094@N00&amp;lang=en-us&amp;format=rss_200',
'http://api.flickr.com/services/feeds/activity.gne?user_id=20938094@N00']
# A map between the "official" feed titles in the XML, and the titles you want to show when rendered.
@@title_map = { "Simon Says" => "Simon Says:", "Simon Says: Comments" => "Simon Says comment:",
"Uploads from sbwoodside" => "Flickr picture:", "Semacode" => "Semacode blog post:",
'Comments on your photostream and/or sets' => 'Flickr comment:' }

def index
if params[:recache] and @@secret == params[:secret]
cache_feeds
expire_fragment(:controller => 'portal', :action => 'index') # next load of index will re-fragment cache
render :text => "Done recaching feeds"
else
@aggregate = read_cache unless read_fragment({})
end
end

private
# This will replace cached feeds in the DB that have the same URI. Be careful not to tie up the DB connection.
def cache_feeds
puts "Caching feeds... (can be slow)"
feeds = @@uris.map do |uri|
feed = FeedTools::Feed.open( uri )
{ :uri => uri, :title => feed.title,
:items => feed.items.map { |item| {:title => item.title, :published => item.published, :link => item.link} } }
end
feeds.each { |feed|
new = CachedFeed.find_or_initialize_by_uri( feed[:uri] )
new.parsed_feed = feed
new.save!
}
end
# Make an array of hashes, each hash is { :title, :feed_item }
def read_cache
@@uris.map { |uri|
feed = CachedFeed.find_by_uri( uri ).parsed_feed
feed[:items].map { |item| {:feed_title => @@title_map[feed[:title]] || feed[:title], :feed_item => item} }
} .flatten .sort_by { |item| item[:feed_item][:published] } .reverse
end
end

It's actually pretty simple but it took me a while to get the balance just right. What you need to do is set up a cron job or other repetitive task that does an HTTP load on http://mywebsite.com/?recache=yes&amp;secret=XXXXXXXX ... every once in a while. You can use wget or curl, or whatever. You might want to recache every minute, five minutes, hour, whatever. Since it's done as a part of the controller there's no nonsense about running backgroundRB, RubyCron and all the other nonsense at HowToRunBackgroundJobsInRails. Yay!

Here's the view:


<div id="feed-stream">
<% cache do %>
<%
lastday = -1
@aggregate.each do |item| %>
<div class="item">
<%
mydate = item[:feed_item][:published].getlocal
if mydate.yday != lastday
%><div class="item_details"><p style="text-align:right"><%= mydate.strftime('%A, %B %e') %></p></div><%
lastday = mydate.yday
end
%>
<div class="item_content">
<%= item[:feed_title] %>
<a href="<%= item[:feed_item][:link] %>"><%= item[:feed_item][:title] %></a>
</div>
</div>
<% end %>
<% end %>
</div>

My cache is all Hashes. I don't cache the FeedTools object because I discovered that even after FeedTools has parsed your feed, accessing the supposedly "final" data is incredibly slow (like maybe 10x or 100x slower than a hash).

Here's the model:


require 'feed_tools'
class CachedFeed < ActiveRecord::Base
validates_presence_of :uri, :parsed_feed
validates_uniqueness_of :uri
serialize :parsed_feed, Hash # note that if this exceeds a certain KB size, it will likely fail (thinking it's a String)
end

And the migration:


class CreateCachedFeeds < ActiveRecord::Migration
def self.up
create_table :cached_feeds do |t|
t.column :uri, :string, :limit => 2048
t.column :parsed_feed, :text, :limit => 128.kilobytes # use for serialized object
t.timestamps
end
end

def self.down
drop_table :cached_feeds
end
end

Well, that's all you need. When I started out to make this I thought I'd find a simple example out there but there wasn't anything. It turns out that there's a number of interesting challenges — picking a parser to deal with difficult feeds, XML, and malformatted XML... to deal with caching ... to deal with background processing. Took me a while to get it all just right.

It powers my own front page ... consider to be under standard ruby open source license. As the vending machine says: Share And Enjoy!

What Nokia needs to succeed

Posted on December 05, 2008 at 02:15 AM

Categories: theories, mobile

Making predictions is fun. I made some predictions a long time ago about the iPhone and it's fun to go back and see which ones came true. #1 was "Apple will design the plans, and they'll twist the arms of the carriers to make them simple to understand and attractive to Apple's users" — that seems to be accurate.

Now that Nokia has demonstrated that they can deliver a device to compete with the iPhone, the question is, can they deliver the rest of the solution to match? Not an easy thing to say. You need a lot more than good hardware to make the kind of great customer experience that Apple shines at.

So here's 9 things that Nokia needs to do to retain and win back their smartphone dominance.

1. Forget the carriers. Nokia has a great brand (outside the USA) in part because many of the carriers they deal with have virtually no control. They need to make the same deal everywhere, including the huge US market. When you get a nokia, it has to be a totally nokia experience. Just like iPhone.

2. In line with that, every unit sold must run the same firmware. Right now there are a zillion firmware versions for the N95 alone. This is insane and frustrating for users and developers. Everyone should be running the same version, just like iPhone.

3. Simplify product line. Again. Like Apple. Nokia has about fifty billion products on the market, all with insane numbers instead of names, and so none of them get any buzz. Names are good, small numbers of models are good. How about 3? Even 10 models would be a dramatic improvement, and probably enough to cover the gamut from $10 developing market to whatever is the highest in the range.

4. App store. Duh. BUT — this requires absolute cross-carrier uniformity and a way to ensure that every subscriber has a data plan...

5. Getting away from copying Apple here. How about they shape up their open source story? What they've started with is a good start, but it needs to be better. Developing for Symbian is just about the worst thing in the world. Apple's SDK is better but you still have to use Objective C. How about Nokia lets us code in a nice modern language like Ruby? They could really leverage open source excitement if they made that a possibility.

They can really jump the queue on Apple with this one, because OSS just goes against the grain at Apple. It's not that they don't like open source, but it doesn't work with the secrecy and the total control thing. But Nokia could leverage open source efforts to really turn their platform into something to care about as a programmer. Android is starting from scratch, but Nokia has a developer community already in place, loads of users, and all of those people would jump at the opportunity to make and use cool apps.

6. Open up the platform. If nokia is seriously about open sourcing Symbian, then they should let people go so far as to actually installing their own versions of Symbian OS on their phones. That would just rock, and the user mojo would be amazing. Of course the carriers will hate it, which is why 1. above is 1. And they'll probably have to keep key sections of the OS (radio functions probably) under control.

7. Continue the content creation story, and back it up with better web integration. Keep pushing the megapixels and the video capture, etc. But, I should also be able to, with no setup, upload my high resolution movies I make with my Nokia directly to a Nokia-branded website (or flickr, if I so choose). Not using some stupid PC tools, but directly, over my WiFi network. There's no reason Nokia can't do this, and they've already made a good start with the kick-ass Sports Tracker app/web site combo.

7. Keep converging. Turn by turn GPS navigation is good, I can throw out my garmin. Keep going! They'll naturally stay ahead of Apple because they are inherently conservative on features, not wanting to add too many, each one has to be perfect and the market mature enough. Nokia can stay ahead here. I only want two electronic devices — my phone and my PC. And hey, if I can get rid of my PC that's great (integrated projector??). Unlikely, maybe. But Nokia should aggressively continue to add core features.

8. Keep innovating form factors. Another nokia advantage to stay with. Although I admit this conflicts with simplifying the product line. Wild and wacky form factors ARE cool...

9. Keep drinking whatever they are drinking. Somehow Nokia is the most Apple-like company that isn't Apple, even though they are a massive decentralized conglomerate with no dictatorial genius at the helm. Whatever they feed their people, keep doing it.

Nokia N97 - the form factor that RIM should have used in Storm, and Apple never will use in iPhone

Posted on December 04, 2008 at 04:57 PM

Categories: tech, symbian, mobile

So Nokia has announced the N97 touch screen device with real keyboard—the form factor that RIM should have used for the Storm, and the Steve Jobs will never allow at Apple.

Link to video.

As you can see the screen slides away from the keyboard. This is really the ideal form factor and the one that I've had in mind ever since I saw the iPhone and wondered what RIM and Nokia should do about it. As I've said before, I'm not a fan of touch screen. However, there are quite a few use cases where they are massively better for UE than a directional pad. For example, a web browser.

So the obvious solution is to provide the best of both worlds. I'm pretty surprised that RIM didn't take this approach with the Storm. Their customer's #1 favourite feature after all is the keyboard. Did they think that they had to copy the iPhone too closely? Or maybe they couldn't get the mechanical design to work. Well, this N97 renews my faith that Nokia can still design a great device.

As for the iPhone, I don't think Steve will ever allow this style for the iPhone, as he's too much of a design purist and he obviously hates buttons. The iPhone is a gorgeous lump of solid "metal" & "glass" (how it appear anyway) that expresses a purity of design and function that other companies will struggle to ever match (and probably never succeed). Adding moving parts to that would ruin the experience.

Now if only Nokia would simplify their line-up and naming system. Why not give this phone a NAME? huh? Apple has made their product line simple — even obvious — to understand by providing clearly named products and doing basically what car makers do: upgrading them once a year. Nokia needs to do the same and step away from the numerical and mostly meaningless current system.

And one last thing. They still need to fix the development process for Symbian. It sucks, and it's even more blatently bad now that Apple is making it so ridiculously easy to learn how & develop & market products for the iPhone.

PS One more thing, the last one I promise — Nokia also needs to, starting with this new phone, have a SINGLE firmware version that runs on ALL of the devices worldwide, with a simple update system, so that all users are running exactly the same software. Their current system is so insane I'm not even going to explain how bad it is.

New version of FractalTrees X (FTX) 2 beta 1

Posted on December 03, 2008 at 02:28 AM

Categories: code, mac

So after something on the order of 4 years I've finally upgraded my FTX program that draws fractal trees in 2 dimensions. I'll update the program's home page later, but in the mean time, here's the download link, with source code included.

Fractal Trees X 2 beta 1 (FTX2b1)

This has the advantage over the "alpha" in that it actually works the way it's supposed to.

Why am I returning to this after so long? Well, suddenly coding for Macs is cool again, and also I was going to try out MacRuby. So... first get it working in ObjC again I guess, and then we'll see — maybe I'll port it to iPhone and sell it for $0.99 a pop :-) :-)

(NB This version probably only works on Intel / 10.5.)

Yummy FTP for Mac OS X: still good, still ignored

Posted on December 01, 2008 at 03:18 PM

Categories: mac

Atheists most discriminated against group in the USA

Posted on December 01, 2008 at 02:56 AM

Categories: other

Hard to believe... But so says wikipedia. I wonder why this doesn't come up more often. Would being "outed" as an atheist be as bad as being "outed" as gay or muslim or . . . whatever?

Facebook are idiots

Posted on November 29, 2008 at 08:55 PM

Categories: internet

In my email:

From: root+f90z4fj9@facebookmail.com

Unfortunately, the settings that control which email notifications get sent to you were lost. We're sorry for the inconvenience.

To reset your email notification settings, go to:

http://www.facebook.com/editaccount.php?notifications

Thanks,
The Facebook Team

So this is spam right? Blatant phishing? But wait, the URL is real, not fake. I still don't believe it, so I go to Google. Apparently this is real.

OK, so the good news is that FB sent the message as plain text, but since most email programs auto convert to links, that's not helping. Every FB user in the world is now being desensitized to phishing.

They should have said "log into facebook, and go to this or that tab to fix"

Of course, why did they lose everyone's settings in the first place.

Mesh networking 5 years later

Posted on November 28, 2008 at 12:50 AM

Categories: theories, wifi, internet

The last time I blogged about mesh networks was 5 years ago (almost exactly!). I was pretty pumped about the possibilities in those days — like the idea of creating a 2nd internet using mesh protocols, routing from house to house using WiFi, circumventing ISPs.... hey, it's still a cool idea, and maybe even possible still, especially with the excess capacity that we have with e.g. 802.11n. Latency would probably be pretty high..

Anyway, back then mesh was a DREAM but now it's a REALITY. The OLPC "XO" laptop for developing nations uses it! The perfect use case actually. And we have 802.11s, etc., etc... cool.

In the long run I expect that "self-forming" (if not exactly "mesh") networks over wireless will be a VERY important part of the internet and future networks, if not the most important way that data gets moved around in local and regional areas.

Getting a "Secure Rip" (a perfect/high-quality mp3 rip of a CD) on a Mac

Posted on November 25, 2008 at 12:29 AM

Categories: music, tech, mac, bittorrent

I've been trying to figure out how to get a perfect CD rip on my mac. The problem in a nutshell is that ripping CDs is "unreliable", in other words, it is impossible to be sure when you rip a CD that you have the correct digital data. How good a copy you get depends on your drive and the software you use.

Why care? In the most extreme cases you can literally get blips and pops in your MP3 file. This might occur even with a totally unscratched disc. But more likely you will get a subtle degradation of quality which will be noticeable if you have a good sound system, and that sucks. So.

The gold standard in secure ripping is Exact Audio Copy, a Windows-only program and likely to stay that way forever. Why? Because you can run it in boot camp or Parallels or whatever. If you want to use EAC definitely follow a how-to guide such as Exact Audio Copy Guide. EAC does not come preconfigured properly.

If you must use a Mac-native program, check out Max, and have look online in how to set it up for maximum secure mode, because it doesn't come in that mode by default. Max was originally written more as a transcoding program (converting between formats) but now supports a linux-originating cd ripper called cdparanoia. Audiophiles still prefer EAC to cdparanoia, and I'm not going to tell them they're wrong, even though they are occasionally insane and overly conservative, so I would say stick with EAC.

Oh yeah, and I would also say, rip into FLAC format. Then, use something like Max to convert from FLAC to MP3 320 Kbps (using LAME "insane" mode) for import into iTunes, use on your ipod/phone/mp3 player, etc. In practise it's unlikely you will be able to hear the difference between a lossless format and a 320 mp3. If you REALLY need to you can use Apple Lossless until Apple supports FLAC, but I like FLAC better as it's the open standard and everyone uses it. Archive the FLAC files for the future. You get to keep a perfect copy but not waste GBs of space on your mobile device.

And by the way, if you download music from BitTorrent, you might as well get FLACs, and they are almost always ripped with EAC.

UPDATE: Actually X Lossless Decoder looks like a good replacement for Max. It has the added ability to split a single huge FLAC/CUE combination into multiple MP3s (or any other format) automatically. Just drag the .cue file onto XLD and you're away.

BarCampWaterloo (November 2008 Edition) roundup

Posted on November 25, 2008 at 12:18 AM

Categories: tech

Yet another BarCamp in Waterloo came and went. Phun. Saturday we talked about Windows 7, what's the best platform for mobile development, and a wide ranging debate on programming languages. Learned more about Haskell. A little bit. Was possibly only person to have heard of Scala or Groovy. Wild. Also there were other discussions too, including a nice chat I had with Ali A. (missed a presentation for that one).

Myself and Jesse Rodgers run BarCampWaterloo totally on a voluntary basis, we don't get any money, and the sponsors pay directly for whatever they are buying for us. In this case, Gary Will's WatStart bought lunch (pizza—good quality too). Waterloo Accelerator Centre donated the space! And, Tech Capital VC bought us snacks and drinks (non-alcoholic) in a wide variety of persuasions.

What I love about BarCamp is that it's totally in the hands of the people that show up. Jesse & I and the sponsors merely provide a forum and a teensy tiny bit of structure, everything else is in the hands of the participants. You arrive, if you feel like talking about something, showing something, or just raising a discussion topic (e.g. programming languages) you just write it on the whiteboard at any time. It's so freeing and wonderful.

As for who was there, we went around the room and I didn't have paper to take notes with. There was the usual ~ 30 people, including a few peeps from AideRSS (current darling of waterloo tech startups :-), other startups such as FossFactory (cool idea, and we talked about how they will make the business model work a bit), Well.ca, CastRoller, and a couple others I missed.

In addition one of the students from VeloCity, UW's experiment in high-tech oriented student residence (or else, a new metropolis for bicycle fanatics). A smart and lucky fellow. And other students, professionals at larger firms, and other authentic techies. And we had in the audience both an eeePC and the latest macbook pro, made from a single solid block of diamond.

And if all of that sounds like fun, make sure to join our BarCampWaterloo FB group to find out about the next one (or if you hate Facebook, look at the wiki page).

BlackBerry storm clicks, I like it.

Posted on November 21, 2008 at 05:03 PM

Categories: tech

One of my biggest dislikes with touch-screen devices is the total lack of tactile feedback. There are other things I don't like about them, but that's a biggy. So when I played around with the BB Storm's clickable screen. I liked it. I only played with the browser, which was competent, actually quite good, and very close to as good as the iPhone. So I can't provide an overall review of the Storm. But the clicking, that's good.

Thank god

Posted on November 05, 2008 at 12:19 AM

Categories: (none)

That's all I have to say.

Vuze (Azureus) search template for The Pirate Bay (TPB)

Posted on October 31, 2008 at 05:55 PM

Categories: code, bittorrent

Vuze provides a built-in search function to make it easier to find bittorrent files that you want to download. And, it's extensible, so you can add new search "templates" for torrent sites beyond the ones that they support by default.

There's a Pirate Bay template floating around but it doesn't work any more, so I made up my own. And here it is:

Download The Pirate Bay (TPB) search template for Vuze.

To install this sucker, you can just double click the file. If that doesn't work, try this:

  1. Download it (duh)
  2. Do a search in Vuze
  3. On the right, it says "Show results from..." "All" and then some options, and then "Add/Edit". Click Add/Edit.
  4. Below the list, click "Import a new template"
  5. Browse to tpb.vuze and open it.

UPDATE: some people are having trouble. Please post your Vuze version # and operating system if it works, or doesn't.. maybe there's a pattern.

UPDATE #2: It seems that if you are running in a language other than English, this might not work. If you can confirm that I would appreciate it. Thanks.

UPDATE #3 2009-12-10: The Pirate Bay changed their format a bit, so I updated the template. Click the download link to get the new one.

Good advice from Futurama

Posted on October 30, 2008 at 12:47 AM

Categories: tv

Futurama, possibly one of the best TV shows ever made, say some people. And full of good advice for every day situations too.

  • You were doing well until everyone died
  • Don't do anything that affects anything. Unless it turns out that you were supposed to do it; in which case, for the love of God, don't not do it!
  • Bodies are for hookers and fat people.
  • The Dave Matthews Band doesn't rock.
  • If you want a box hurled into the sun, you've got to do it yourself.

I was going to make up a sort of "All I need to know I learned in Kindergarten" kind of poster, but I need more quotes so I'll just have to re-watch more Futurama. So much good TV & Movies to watch, so little time...

A bit of torrent #6: Three Businessmen

Posted on October 23, 2008 at 11:53 PM

Categories: bittorrent, film

This week on A bit of torrent ...

Three Businessmen (1998)

...a surreal film called Three Businessmen. You may not know that you're going to like this movie. You may not thank me for making you watch this movie. But ultimately, your mind will be expanded and you will have a bit, just a bit, more sympathy for the common business-person.

Basically, you've got two businessmen, pictured, thrown together in a sort of haphazard fashion, and they go trekking across the universe (sort of) in search of a bite to eat. On the way, they have many adventures, bond, and talk a lot of silly business speak. Etc.

(Eventually there is in fact a third.)

OK, there's no plot, virtually, and no action, no violence, no sex, no nudity, no guns, no special effects, hardly any budget. But on the other hand. It's by Alan Cox, who you just might remember from Repo Man (he's also the actor on the right). And it rewards multiple viewings. And it's a bit trippy. I liked it. Will you?

Download Three Businessmen (1998) torrent from The Pirate Bay now.

Till next time: bye bye.

Apple are idiots

Posted on October 17, 2008 at 07:22 PM

Categories: code

I just tried to open my old XCode project for FractalTrees X in XCode. No dice—XCode doesn't even recognize the "pbproj" extension any more, and that's only from 2002... Then I try to open my NIB at least? And it's totally toast. Nothing. Won't open. Won't upgrade in ibtool. Nothing.

How to program a computer, for children ... II

Posted on October 16, 2008 at 02:28 AM

Categories: links

A while ago I wrote "How to program a computer, for children". I was actually inspired by Ming's efforts along the same lines. I just read it and decided to take a slightly different tack, doing it all with math (since programming is all math anyway).

Incidentally... why has a rather bizarre system called Shoes which is apparently supposed to teach children to program but I suspect might frighten them instead. For adults, you have surely read his guide to ruby ... right?!?!?!

And here we go.

Programming a computer is a lot like writing instructions for someone really, really stupid. Imagine a person who knows nothing. They don't know how to walk, talk, read, or write. In fact, the only thing that they know to do at all is simple arithmetic. They can add, subtract, multiply, and divide any number at all. But that's all. They can't do anything else without being told how to do it in the form of math.

So, to get a computer to do something, you must turn it into math. Let's say you want to get a computer to go around the room. First you have to explain what "go" means in terms of math. Then what "around" means... in terms of math. And what is "a room" ... that's not math yet, so computers don't know what it is.

Well, let's start with "go". Let's give it a try:

How to "go":
1. increase the total number of footsteps that you have ever taken in your life, by 1.

See how I turned that into math? That's how computers think. Unfortunately, computers don't know what feet are either. But that's OK. For now, we'll assume that someone else has already built a foot for our computer, and when we tell it to increase by 1, it will know what to do. In computer language, this would be:

totalNumberOfSteps += 1

Now it's not completely true that computers can only do math. They can also repeat the same thing over and over again, like a mindless machine. It's called a "loop". If we just take one step, that's not really "going" very far. Instead let's have the computer "go" further.

How to "go":
1. totalNumberOfSteps += 1
2. do that over and over again

Since the computer is mindless, it will do this forever, so we can rewrite this into computer language like this:

1. totalNumberOfSteps += 1
2. repeat forever

OK, so now the computer goes. But will it ever stop? I don't know... if it has an atomic power plant, it might be millions of years before it stops. And in that time, it will grind its way through even the thickest of reinforced concrete walls. And it will never go "around" the room because it can only go forward.

So maybe we ought to give the computer a way to measure how far it's moved. Let's say it's got a little measuring wheel that touches the floor. Whenever it takes a step, the wheel clicks around a little more. In fact, it's just like an odometer on a car, that tells you how far the car has ever gone.

That's all fine, but how can the computer know if it moved? Remember it can only do math and repeat things. Well, the guy who made the odometer gives us two number:

odometerReadingBeforeTheStep
odometerReadingAfterTheStep

Clearly, if the "After" number is more than the "before" number, then we moved forward without hitting a wall. If not, we're stuck. We can use some fancy math to write this down:

odometerReadingAfterTheStep > odometerReadingBeforeTheStep

That just means that the number of the left is bigger (>) than the number of the right.

OK... so does that help us? How do we fit that into steps 1 and 2? Another little trick that computers can pull is to check some math before they take a step. So they can (a) do math (b) repeat things (c) check math.

It works like this:

if 1 == 1 then oneIsEqualToOne += 1

That's a pretty stupid example, but you know, 1 is "equal to" (==) 1, in math, that's true. So, oneIsEqualToOne will be put up by one number.

We can use that for our robot to. Can you see how yet?

1. totalNumberOfSteps += 1
2. repeat if ...

If what? Remember the odometer?

1. totalNumberOfSteps += 1
2. repeat if odometerReadingAfterTheStep > odometerReadingBeforeTheStep


Pretty simple. Add a step, and then do it again if the odometer shows you moved forward. If it doesn't, the computer just stops, because it has no more instructions. That's called "halting". When the program halts, you check it's progress. In this case, it will have walked into a wall. And then stopped. Always. That may not sound like much, but we're halfway to getting around the room.

My Sharp Aquos TV runs linux

Posted on October 15, 2008 at 11:51 PM

Categories: links, unix

I was reading the manual for my HDTV (I know, who the hell does that?) when I noticed a GPL license notice and acknowledgment for among other things, "linux kernel". Wild.

Here's a link to the mandatory software download page.

Did some fixing of the site, and got some comments!

Posted on October 14, 2008 at 01:49 AM

Categories: meta

Well I just cleaned up some bugs in the site, mainly in the static content area (so stuff in the Software and Content sections works now!!!)

Also I got some comments. For some reason I was scared of having comments on the site back in the day, but now... whatever. So I have some comments about good old FractalTreesX here and here.

Now I just need to restore all my old tags... and fix the previous/next navigation system so it's more prominent... and see if my google rank recovers...

Useful software: PDFCrack, Map.Hamilton iMapper, and Skim for PDF annotation

Posted on September 27, 2008 at 10:31 PM

Categories: links

Some miscellaneous useful software.

"Forget" your PDF password: use open-source PDFCrack. Installs easily on Mac command line (use gmake).

Looking for high-quality maps and "satellite" imagery of Hamilton? Try Map.Hamilton's iMapper. The interface takes a few minutes of experimentation to figure out, and then it's cool. Make sure you switch to Aerial Viewer (latest year) to get their ground imagery, which I think is actually generated by airplanes. It's quite a bit higher resolution than Google Earth has.

Want to annotate your PDF files? Try Skim. Seems potentially easier than using OmniGraffle... (and cheaper...)

Cool URIs should never change ... & site updates

Posted on September 15, 2008 at 01:36 AM

Categories: meta

I'm a terrible person. When I upgraded to Rails I totally broke a zillion URIs on this site, in particular most of the weblog links. I also probably lost a lot of google juice in the process. Well, now I have restored all of the weblog archive links in accordance with Cool URIs don't change (and I should practice what I preach...)

Incidentally I also made a number of other long-waiting fixes to the site, like installing the correct google analytics, fixing the top navigation links, adding a sidebar on the front page, speeding up the front page (somewhat.. still wrestling with that one). I still need to fix the tag browser so that it's as good as it used to be. And some day maybe I'll convert all of my old content over to some new CMS (well, I probably will never do that actually...)

"It should be required reading" is for idiots

Posted on September 14, 2008 at 11:16 PM

Categories: (none)

Number of books that "should be required reading": 855,000.*

I hate it when people say that something should be required reading. Do you think that your pet crap is something that everyone cares about? I don't give a shit about your agenda.

Here's my list of what should be required reading:

  • Parts, at least, of the Bible, so that you can see how odd and contradictory it is. The gospels are good though
  • A bit of Shakespeare
  • Well, that's about it. So long suckers.

* according to Google

Best movie links (...the answer is Citizen Kane)

Posted on September 13, 2008 at 06:53 PM

Categories: tv

I just went for a walk in the rain. It was nice and mellow. Nothing with me, no keys, no wallet, and best of all, no cellphone.

Anyway, here's some nice links to lists of all time greatest movies.

The mother of all lists of course is the IMDB Top 250. IMDB has been around forever! ...it's been on the web since 1993 which is like before the web even existed. Basically any movie on this list is worth watching. And it's the popular choices, as opposed to the critics, so they aren't just chosen for originality or historical significance (like some of the below) but rather because they're good to watch.

For the "critics choices" you can use the Best of Rotten Tomatoes. Rotten Tomatoes has to be one of the worst named websites of all time. But no matter. The problem with the all time list is that it includes movies that are loved by critics but aren't necessarily very watchable. However, they have a useful feature which is to see the top movies by year. For example here is the top 10 for 1969 (I've seen 5 of the 10 so far...). It's a cool way to explore cinematic history.

For more critic's lists, try the British Film Institute top 45 list. And here's more detail on their top 10. And then there's the American Film Institute top 100 (linking to wikipedia because the AFI site requires a stupid login).

And finally here are a few more from random publications:

Well, that's enough of that. It's interesting to see the differences in the list. Is the best movie of all time The Godfather? Casablanca? Citizen Kane? Or as IMDB users would have it, Shawshank? (I don't think so...). Forget about the latest releases. Watch the classics.

My eHarmony Procedure

Posted on September 01, 2008 at 01:26 AM

Categories: theories, eharmony

Yes, I use eHarmony. I have my match distance set to something like 200km so I get about 5-8 matches a day. I try to sift through them pretty quickly to separate the wheat from the chaff. Here's my current procedure:

  1. First pass is to eliminate people who are definitely not an option. Starting with the most recent match, I command-click (middle click) to open in a new window and then I look at the small photo:
    1. If they closed me, I close them, don't bother looking at photo or description.
    2. If there's no small photo, I close. It's not worth the hassle to request photos. A picture is worth 1000 words.
    3. If it looks like I wouldn't like them, I close without reading anything.
    4. If they look potentially interesting, I don't do anything (so they stay in the queue).
  2. If I closed in the above action, I switch back to the original tab, because eHarmony is too slow in closing, and also it doesn't return you to the right place in your list if you go back. Once I'm done going through everyone, I close all the tabs, reload the main page, and get ready for the 2nd pass.
  3. Now I'm on the second pass. All of the women left have passed the first sight test. Now I look at the photo details. I find it's very important for me that there's both a closeup face shot and a shot from father back so you can see what they look at. I include these in my profile. Without both, I close. If I don't like what I see (and this can be facial expressions, the context, as well as more normal attractiveness levels) I close without reading anything.
  4. OK, finally, after doing the above step for everyone, the people who are left are worth reading about. In fact, at this point I only really feel the need to skim what they wrote because as I said, your character is written all over your face and the context of the photos. So I usually contact anyone who's made it this far.

So there you are. I do this in phases, because it's annoying to be really interested in someone, and then the next 5 people are horrible. So, I save myself the pain by going in passes and only increasing how much I care after I've eliminated the uninteresting people already. After all I need to manage my own sense of involvement or I'll just get tired of it.

I actually at one point wrote a pretty nifty greasemonkey script for firefox to add various close buttons at the top of the page to make it easier to close people. But it made me nervous. A couple of times I clicked the close button when I meant to click something else. Also, I just don't like Firefox—prefer Camino. So, no more of that.

unflac.sh - Convert FLAC files into 320 kbps MP3 files

Posted on August 17, 2008 at 01:19 AM

Categories: (none)

Convert FLAC files into 320 kbps MP3 files. Someone might find this useful. I call it unflac.sh. It will take every .flac file in the current directory and convert it to MP3 using lame's "insane" preset (which shows what the lame people think about mp3...)


#!/bin/tcsh

# Deal with FLAC, CUE file to convert to high-quality MP3 with LAME

# Split a foo.cue / foo.flac combo (e.g. from EAC) into separate flac files
####cuebreakpoints *.cue | shnsplit -o flac *.flac

# convert flac to MP3
foreach f (*.flac)
flac -c -d "$f" | lame —preset insane - "${f}.mp3"
end

# Re-add the tags to the separate files
cuetag.sh *.cue *.mp3

You'll need to have flac and lame installed. It also tries to restore tags using cue but that doesn't seem to work. So sorry.

Why would I do this? Basically, because:

  • my MP3 player (N95) doesn't support FLAC
  • and doesn't have the room for it anyway
  • and iTunes doesn't support FLAC either (stupid apple...)

Some day when I have a player that does, I'll probably switch to all FLAC, or apple lossless or whatever, but in the meantime 320 MP3s from lame are pretty good. I won't say I can't hear the difference because I haven't tried REALLY HARD, but for the listening I'm doing I can't hear the difference...

the ultimate cut out book

Posted on August 11, 2008 at 01:02 AM

Categories: (none)

You have probably seen the book with a space cut out to hide a knife, a gun, another book... but what about a house?

(actually, hiding a book inside a book... that's a cool idea...)

Anyway, that's Olafur Eliasson has done. He cut a house into a book. There's no text. Just the house. And it's in negative space. Here's what it looks like:

Your House

Wild. I found this in grafik magazine. No website, but a real paper work of art.

Eliasson is just too cool. Have a look at what he does with white lego bricks... and just generally feast your eyes on his works.

Jesse Rodgers's blog

Posted on August 06, 2008 at 01:09 AM

Categories: links

Who You Calling A Jesse?

He is apparently

Trying to sort the brilliant ideas from the lesser ones.

Unfortunately, he is not very successful. But he is trying.

He also uses SimpleLog, the best Ruby on Rails blog out there that doesn't work under Rails 2.0, has been abandoned by its author, but still works great for me.

Because I can

Posted on August 06, 2008 at 01:06 AM

Categories: (none)

Open Source Software for Mac. Lots of Good Stuff. Very nice.

The Loudness War

Posted on August 02, 2008 at 10:41 PM

Categories: music, tech

What the hell is the Loudness War? It's music business, baby. Put it this way. Everything is getting LOUDER.

IF YOU'RE LOUD YOU GET NOTICED PEOPLE READ YOU FIRST BUT EVERYTHING STARTS TO SOUND THE SAME.

That's just a simple "visualization" of what the loudness war is doing to music (recorded music anyway).

You could perhaps lay the blame on 5-CD changers. If you had one back in the 90s, you probably noticed that whenever it switches discs, you had to adjust the volume. And then MP3 players didn't help, although now the software will automatically adjust the loudness of tracks to match each other. And car CD players, where everything has to be loud to even hear it. But really, it's the fault of computers, and in particular a device called a digital compressor.

Basically here's the problem in a nutshell. Music has variations in volume, between the quiet parts and the loud parts. If you're in a movie theatre, concert hall, or at home with a good stereo, this is exciting, it's dynamics. The music can start out quiet, and then build up and then reach out and grab you by the throat in the exciting bits. This is GOOD.

But psychological studies have shown that people subconsciously think that louder is better, and the problem comes in when you are moving from one song to another. If you go from a loud song to one that starts out really quiet, your subconscious brain is going to tell you that the quality of music just went down, and you're going to hit the skip button or change radio stations.

So the producers use the compressor to "compress" (yeah, that's why it's called a compressor...) the dynamic range so that the difference between the quiet parts and the loud parts is minute. Basically, they make everything LOUD.

A few years ago Rolling Stone had an article called The Death of High Fidelity, it's about the Loudness War, and you can see a sort-of good video about it on YouTube

There also a a great article from IEEE Spectrum magazine: Tearing Down the Wall of Noise. Good reading.

All in all these stories demonstrate without a grain of doubt that (a) the Loudness War is real and (b) it's causing damage to the music. Constantly loud music makes you tired and ultimately isn't satisfying or good. The subconscious thing is temporary, but the damage to the music is permanent.

What can you do about it? Buy music that isn't compressed, for starters. Some artists are fighting back, like Norah Jones with Not Too Late and Dylan's Modern Times. Or, just buy OLD albums, like CDs from the 80s, the time before compressors existed. Or buy vinyl, which for physical reasons doesn't really allow compression, but to me, having to go back to old tech like that is just silly. The music industry needs to fix this on the new technology. Even if they can crank up the volume, they shouldn't turn it into pure noise.

PS: Seems that you can use "Average RMS Power" to get a rough idea of the dynamic range of a tune. And you can measure that using various tools, e.g. Amadeus Pro (Analyze > Waveform Statistics). Here are some values from my library:

  • Norah Jones, Feels Like Home, Sunrise: -13.5 dB .... that's not great but it's not as bad as it could be ... I don't really listen to this much any more though, and I think it's partly because it's tiring to listen to.
  • Decca Georg Solti Nibelung, Walkure Act I: -25 dB... I have no trouble with ear fatigue listenging to this one.
  • Beatles, Revolver, Taxman (no idea what edition): -16 dB ... I find it a bit loud, but I guess partly that's intentional?
  • Cowboy Junkies, Trinity Sessions, Blue Moon: -21 dB .... what can I say? niiiiice.

OK, so I guess pretty much everything in my collection is OK at least. Probably because I delete anything that has crap dynamics. For comparison here's some stuff I wouldn't listen to.

  • Coldplay, Viva la Vida:-12.3 dB ... well, it could be worse.... a bit... this would be a lot better with better dynamics.
  • Rihanna, Disturbia: -11 dB ... just looking at the waveform for this makes my ears hurt in advance.

Yeah, those are fairly hard to listen to.

Someone ought to make an average RMS database.

Azureus's stunning visualizations (Vuze)

Posted on July 18, 2008 at 07:51 PM

Categories: graphics, tech

In order to get around Bell Sympatico's bittorrent throttling I recently switched to Azureus (aka Vuze). If you switch to the "classic" UI mode, it has some stunning visualizations of what's happening with your torrents.

The main screen contains a bit more information than you might need, but if you play with the columns that are visible (right click on the headers) you can get something like this:

Azureus main screen

What you've got there is downloading torrents at the top and finished ones at the bottom. Green happy faces are currently in progress. Gray ones are queued. In the bottom right corner you can see that my total download speed is 311 kilobytes per second, and total upload is 50kB/s (I'm on ADSL).

Azureus peers

Suppose I want to zoom in on one particular torrent — double click on it. This shows each of the peers I'm connected to. What pieces of the file do they have? How far complete are they in total? Bittorrent downloads files in chunks and it does the chunks randomly, not from start to end, so this information can be interesting.

Azureus Pieces

The above shows me EVEN MORE details if I really want it (OK, some of this stuff is really excessive). It shows which of the pieces I've got (blue) and which ones are downloading (in red). Just in case you wanted to know...

Azureus swarm

Swarm (above) is an actual animation of the pieces of the file as each of your peers around the edges send the bits to you in the middle. And it also shows the reverse as well. And the pie charts show how much of the torrent each peer has. Wild stuff.

So, that's if you want to know what's happening with one particular torrent. But what if you want to know about your overall connection with all the different peers and torrents? Well, Azureus gives loads of graphs and charts for that as well.

This one is your overall bandwidth monitor:

Azureus activity

Nice. I love staring at this one. It's a really good example about how to cleanly show multiple related variables in a time-based chart (aka histogram). For the top one, the blue filled area is your download speed. Really interesting is the gray line, which is the average download speed of the SWARM. In other words, what is your average peer getting? If you're below this line, then you're getting screwed — or there's something wrong with your configuration. If you're above it, you're doing well. It's a good way to get a quick fix on the health of your downloads as compared to other users. It also makes it really easy to see if you're being rate-limited by your ISP.

On the bottom half, you can see that I've enabled Auto-Speed and it's automatically cranking the max upload speed up and down based on measuring my bandwidth and other factors that I'm not too clear on.

There's other visualizations but those are my favourites. Some of them aren't really documented and I don't really understand exactly what they mean (transfers and vivaldi for example). Still, obviously one of the azureus open source developers is a data viz keener and s/he's done some fine work.

Hacking the java compiler: using anonymous subclasses as closures

Posted on July 10, 2008 at 11:17 PM

Categories: tech, code, java

UPDATE: new more comprehensive post on this subject: Closures with return values in Java.

In Java, closures/first-order functions are not a language feature. However, as everyone knows, you can effectively get a first-order function by using an anonymous subclass instead. Something like this:


class MyClosure {
void run() {} // override this
}
void doSomethingClosureLike() {
MyClosure closure = new MyClosure() { void run() { System.out.println("We're inside a closure!"); }};
runTheClosure(closure);
}
void runTheClosure(MyClosure closure) {
closure.run();
}
// will print We're inside a closure!

Anyway, it's simple enough, you pass the class instead of the function and there's a little extra verbage but it works!

Also you get closure-like functionality, because inside run() you can access variables from outwhere where you created it. E.g.:


void doSomethingCooler() {
final String myString = "Foo!";
MyClosure closure = new MyClosure() { void run() { System.out.println("The string is: " + myString); }};
runTheClosure(closure);
}
// will print The string is: Foo!

You can also access global variables that change over time, and the closure will use whatever is the current value WHEN THE CLOSURE RUNS.

There's just one small annoying thing, which is this particularly annoying compiler message:

local variable (WHATEVER) is accessed from within inner class; needs to be declared final

If you were do change myString to not be final, you'd get that error. Bummer. You could make myString a global variable and that would work, but that's stupid. There is a better way. Try this: UPDATE: This doesn't work, see new version at the bottom, thanks commenter the.d-stro.

void doSomethingCooler() {
String myString = "Foo!";
final String myStringFinal = myString;
myString.concat(" Bar!");
  MyClosure closure = new MyClosure() { void run() { System.out.println("The string is:" + myStringFinal); }};
 runTheClosure(closure);
}
// will print Foo! Bar!

Now you can even change myString after you assign myStringFinal, because Java, although they say it doesn't use pointers, really does use pointers. I.e. it passes by reference. So, myStringFinal is actually just a reference to myString, and keeps pointing to it even when you change the contents of myString.

You can CHANGE it (like using concat()) but you CAN'T reassign it. That will break the pointers. It makes sense if you think about it—myString will have a new memory address, and myStringFinal will still be pointing to the old memory address (and the old string value). So, this won't work:

myString = "won't work"; // breaks myStringFinal

You can use this technique with any object (but not primitives like int).

UPDATE

The last source block is wrong because java Strings are immutable. Here's an example that will work as advertised:


void doSomethingCoolest() {
StringBuffer myString = new StringBuffer("Foo!");
final StringBuffer myStringFinal = myString;
myString.append(" Bar!");
MyClosure closure = new MyClosure() { void run() { System.out.println("The string is: " + myStringFinal); }};
runTheClosure(closure);
}
// will print The string is: Foo! Bar!

ALL NEW "Simon Says" content RIGHT HERE

Posted on July 10, 2008 at 02:52 PM

Categories: tech, meta, links, art

Wow, WYM Editor is so cool that I can just like type in a new blog post whenever I want to. Wild!

So anyway, I've been saving up a whole load of links and stuff for months until I had this new site all sorted out. So here's something.

Hmm... where did my "stuff to blog about" folder go?

Oh, here's an awesome one. Nikkei Electronics Teardown Squad. These guys kick ass. Watch as they take apart a MacBook Air and declare "No Waste Outside, Nothing but Waste Inside".

About 30 screws were used to attach the keyboard alone. "The total number of screws in the MacBook Air was several times the number used in a PC we make," one of the engineers said.

Burn, baby, burn!

OK, here's another one from the files. Nathan Fawkes Art. He's part of a network of film animators and illustrators and concept artists who all have their stuff up on blogspot.

And I'd like to remind myself particularly about this post about science fiction.

Restoring the old posts

Posted on July 07, 2008 at 12:35 AM

Categories: tech, code

OK, here's a test of how WYMeditor works, because I'm going to try to copy/paste some code in here. I just had a little foray into my past with XSLT. I had 344 old blog posts (starting year 2000!) to convert from XML to SQL. Nothing better than XSL for the job! Here it is.

NB: I haven't restored images as of this writing.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes" encoding="ASCII"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ- </xsl:variable>
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz-_</xsl:variable>
<xsl:variable name="allowed_letters">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_ </xsl:variable>
<xsl:template match="/">
<xsl:text> USE `sw-blog-dev`;
</xsl:text>
<xsl:apply-templates select="weblog/entry"/>
</xsl:template>
<xsl:template match="entry">
<xsl:text>INSERT INTO `sw-blog-dev`.`posts` (`author_id`,`created_at`,`modified_at`,`permalink`,`title`,`synd_title`,`summary`,`body_raw`,`extended_raw`,`body`,`extended`,`is_active`,`custom_field_1`,`custom_field_2`,`custom_field_3`,`body_searchable`,`extended_searchable`,`text_filter`,`comment_status`) VALUES
</xsl:text>
<xsl:text> (2,</xsl:text> <!— author_id —>
<xsl:text>'</xsl:text><xsl:apply-templates select="date"/><xsl:text> 12:00:00',</xsl:text> <!— created_at —>
<xsl:text>'</xsl:text><xsl:apply-templates select="date"/><xsl:text> 12:00:00',</xsl:text> <!— modified_at —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="PERMALINK" select="title"/><xsl:text>',</xsl:text><!— permalink —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="XHTML" select="title/text()"/><xsl:text>',</xsl:text><!— title —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="SYND_TITLE" select="content"/><xsl:text>',</xsl:text><!— synd_title —>
<xsl:text>'',</xsl:text><!— summary —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="XHTML" select="content"/><xsl:text>',</xsl:text><!— body_raw —>
<xsl:text>'',</xsl:text><!— extended_raw —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="XHTML" select="content"/><xsl:text>',</xsl:text><!— body —>
<xsl:text>'',</xsl:text><!— extended —>
<xsl:text>1,</xsl:text><!— is_active —>
<xsl:text>'',</xsl:text> <!— custom_field_1 —>
<xsl:text>'',</xsl:text> <!— custom_field_2 —>
<xsl:text>'',</xsl:text> <!— custom_field_3 —>
<xsl:text>'</xsl:text><xsl:apply-templates mode="TEXT_ONLY" select="content"/><xsl:text>',</xsl:text><!— body_searchable —>
<xsl:text>'',</xsl:text><!— extended_searchable —>
<xsl:text>'markdown',</xsl:text><!— text_filter —>
<xsl:text>1);
</xsl:text><!— comment_status —>
</xsl:template>
<!— must remember to backslash all single quotes —>
<xsl:template match="date">
<xsl:value-of select="translate(.,'/','-')" />
</xsl:template>
<xsl:template mode="PERMALINK" match="title">
<xsl:value-of select="substring(
translate(
translate(., translate(., $allowed_letters, ''), ''),
$ucletters,
$lcletters
),
0,42)"/>
</xsl:template>
<xsl:template mode="SYND_TITLE" match="content">
<xsl:call-template name="escapesinglequotes">
<xsl:with-param name="arg1"><xsl:value-of select="normalize-space( substring(.,0,42) )"/></xsl:with-param>
</xsl:call-template>
<xsl:text>...</xsl:text>
</xsl:template>
<xsl:template mode="TEXT_ONLY" match="content">
<xsl:call-template name="escapesinglequotes">
<xsl:with-param name="arg1"><xsl:value-of select="normalize-space(.)"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template mode="XHTML" match="content">
<xsl:apply-templates mode="XHTML"/>
</xsl:template>
<xsl:template mode="XHTML" match="node()|@*">
<xsl:copy>
<xsl:apply-templates mode="XHTML" select="@*"/>
<xsl:apply-templates mode="XHTML"/>
</xsl:copy>
</xsl:template>
<xsl:template mode="XHTML" match="text()">
<xsl:call-template name="escapesinglequotes">
<xsl:with-param name="arg1"><xsl:value-of select="normalize-space(.)"/></xsl:with-param>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template mode="XHTML" match="@*">
<xsl:attribute name="{name()}">
<xsl:call-template name="escapesinglequotes">
<xsl:with-param name="arg1"><xsl:value-of select="normalize-space(.)"/></xsl:with-param>
</xsl:call-template>
</xsl:attribute>
</xsl:template>
<xsl:template name="escapesinglequotes">
<xsl:param name="arg1"/>
<xsl:variable name="apostrophe">'</xsl:variable>
<xsl:choose>
<!— this string has at least on single quote —>
<xsl:when test="contains($arg1, $apostrophe)">
<xsl:if test="string-length(normalize-space(substring-before($arg1, $apostrophe))) > 0"><xsl:value-of select="substring-before($arg1, $apostrophe)" disable-output-escaping="yes"/>\'</xsl:if>
<xsl:call-template name="escapesinglequotes">
<xsl:with-param name="arg1"><xsl:value-of select="substring-after($arg1, $apostrophe)" disable-output-escaping="yes"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<!— no quotes found in string, just print it —>
<xsl:when test="string-length(normalize-space($arg1)) > 0"><xsl:value-of select="normalize-space($arg1)"/></xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Niiiiiiice.

Blogging on Rails

Posted on July 07, 2008 at 12:00 AM

Categories: tech, meta, rails, ruby

Hi there.

Well, I'm back. I was running this site on really ancient technology — AxKit — so 2001. Now I'm running it on modern technology, i.e. Rails 2. And doesn't it rock. Now I have a cool GUI editor to type into, I have easy programming in ruby, and I have of course polished both my design and my CSS/XHTML skillz considerably in the mean time, hopefully making this all easier to look at and navigate.

So I'm running on SimpleLog here, but it's not "stock". Oh no. Stock SimpleLog right doesn't run on Rails 2, but this one does. Also, I made it even MORE simple than it used to be:

  • Support Rails 2.0 (no need to freeze an old rails)
  • no themes—annoying to use anyway, and no one was publishing themes either
  • replaced the editor/preview panel with WYM on Rails, which is by FAR the best WYSIWYG / GUI editor I've ever found, and the end of a long search for me

...and so on.

IPTables unix/linux firewall, simple commands

Posted on April 02, 2007 at 09:56 PM

Categories: unix

Since all the iptables documentation out there is super complicated, here's something really simple.

To see all of the ports that are open, run:


       sudo iptables —list
      

To add a new rule (to open a new port, e.g. 8080):


       sudo iptables -A tcp_in -p tcp -d my.hostname.com —destination-port 8080 -j allowed
      

That's assuming you have a chain called "tcp_in" of course...

And to delete a rule, run iptables —list, count the number of the rule (the index #) and then:


       sudo iptables -D tcp_in [index]
      

Simple enough....

The Quick and Easy Guide to moving your project from CVS to Subversion

Posted on March 05, 2007 at 12:00 PM

Categories: unix, code

So you want to use SVN? Fine, it's easy to move a project from one to the other.

Get cvs2svn

Go to a checked out copy of your cvs project and run cvs admin -kb filename on any binary files.

Commit to CVS.

Assuming that you've got a simple CVS project with no branches that you want to keep, do this:

./cvs2svn-1.5.1/cvs2svn —trunk-only -s project-name /path/to/cvsrepository/project-name mv project-name /path/to/svnrepository/ 

Tinselman

Posted on February 25, 2007 at 12:00 PM

Categories: links

Tinselman is the very amusing blog of the co-creator of Myst, Robyn Miller. It's a bit iffy on a daily basis ... and very eclectic. A bit like this blog, but better.

He's got this ongoing thread about the Republic of Tinselman, which appears to be something dating back to some attempt to create a fake republic on Wikipedia, or something, but whatever. It's just stuff.

He also seems to be a big fan of Walt Disney . To be particular, Walt Disney, and Disneyland. Not necessarily the Disney company or the movies per se. In fact, thinking about it, or maybe I read this somewhere. Anyway, that he wanted Myst to be a bit like Disneyland, which I think it is.

It's worth noting that Robyn Miller is the one who did the music for Myst and Riven, and he left after Riven. It's a bit obvious looking at any of the sequels after that the original spirit isn't there. With his brother Rand, he also did pre-Myst stuff like Cosmic Osmo, which was pretty cool and all done in the absolutely brilliant and amazing but now-forgotten HyperCard . In fact, did you know that the original Myst for Mac was written and deployed in Hypercard? Amazing but true.

Actually, that reminds me of a story, which is that back when Myst was first released I was working at this rather unusual place called the Southam InfoLab . Anyway, I was mainly a HyperCard hacker and pretty damned good at it if I may say so. And I managed to hack into Myst and actually look at the source code running it. HyperCard is an interpreted language, the language is called HyperTalk, and there was no compiler for it. So, they implemented this fiendishly complex system for preventing you from breaking into debug mode and viewing the code, but I managed to hack it. I don't remember doing much with it though, because the source code for Myst was way over my head at the time.

Anyway. Robyn is clearly a very interesting an unusual person. I think it would be very interesting to meet him and peer into his brain some day. Once you get past the "oh my god he's the guy who made Myst" thing then his blog seems to be quite interesting.

A bit of torrent #5: Police Squad!

Posted on December 03, 2006 at 12:00 PM

Categories: tv, bittorrent

police squad

My name is Lieutenant Frank Drebin, Police Squad, a division of the Police Department. I just got a call from headquarters. Someone killed off a cop series in the prime of its life, and we couldn't find the body. Fortunately some new evidence turned up, and it looked like we might have found the body and it's killer.

And so begins this week's episode of A Bit of Torrent , a weekly (almost) feature of Simon Says where we highlight the absolute latest in downloadable content. This week in the crosshairs: Police Squad!

If you've ever seen Leslie Nielsen or any of the Naked Gun movies, you know what to look for. You know what I mean. Exactly. It's basically six mini-Naked Gun movies in a row.

Download Police Squad (complete) on The Pirate Bay .

Sadly, the show was cancelled before its time. Cigarette? Yes. I know.

an unusual Mac OS X graphics bug

Posted on November 28, 2006 at 12:00 PM

Categories: graphics, mac

When I first saw this, I thought, hey cool! Then I took a screenshot and when it came through in the screenshot, that was even cooler. It's not often you get something like this. Memory corruption, maybe, not terminal, and not detected by the graphics software. My laptop gets hot sometimes, maybe the memory got corrupted that way? It happened on wake from sleep. Anyway, voila.

graphics bug

It sort of went away when it redrew areas of the screen but not completely, so I restarted.

New features on the blog: pagination, save to digg, del.icio.us

Posted on November 17, 2006 at 12:00 PM

Categories: meta

I just added two new features. First, now you can finally page through the posts 15 at a time (or whatever # it's set to show on the front page), using the "Previous Page" and "Next Page" links at the bottom. Second, you can save a specific post to Digg or delicious by just clicking on the appropriate little icon in the meta-data at the top of the post. As if anyone would want to do that. I don't, but I saw it on a bunch of other blogs so I thought I'd do it to.

I guess in theory you could use digg to discuss the post, if everyone used digg.

Some fun with Saxite, a logo, my first "font"

Posted on October 21, 2006 at 12:00 PM

Categories: meta, art

So Saxite is the new name for my siteware project. For those of you not paying attention, it's all written in XSLT and XML and it runs on AxKit.

I decided to make an icon so I came up with this icon, below.

Like it? I was inspired by a recent issue of Computer Arts Projects (one of the fantastic UK graphic design magazines that my local Indigo store carries) that was all about fonts, to do some of my own font work. So, I had a visual idea of what I wanted the logo to look like, with the X as a white space in the middle, and then I looked for a font on my system that was very blocky and thick and wound up with Arial Black. "ITE" on Arial Black are very generic, but I really didn't think that the S worked at all for me, and the A didn't fit, and the X I didn't like either (not wide enough).

saxite icon

So I started with the A. I actually did the A from scratch, not even bother to look at the Arial A. It's more like half of an A anyway. Next I got the X in the shape I wanted, and filled in the negative space on the right side with the I. Getting the hole in the A to look right was tricky, right now it's actually a white copy of the shape of the A!

Oh yeah, and check out the arrow in the A too :-) (it's pointing right). And check out the angle bracket on the right side of the X :-)

saxite icon

I spent by far the most time on the "S". I didn't like the original Arial S and wanted to replace it the most since it's by far the most identifiable letter of the ones I used. Also it didn't look blocky and aggressive enough in my opinion. There was quite a bit of variation in the width of stroke which I didn't like, so I drew my own "S" over top of it with a more even stroke (drawn with beziers). I also didn't like the flat ends so I switched over to ends on 45-degree angles. Getting it to balance was interesting ... the bottom end of the S actually extends out beyond the curve above it, while the top end is shorter than the curve below it. Weird.

I actually tried out another one which was even more streamlined, with the top and bottom strokes ending totally horizontally (like in the Star Wars logo) but that looked too, I don't know, sci-fi?

Finally I added the hole to the right of the X, before the I. And then I redrew the rest of the letters by hand so that they would all flow together. Now there's no Arial Black left at all.

Oh yeah, and post-processing in Photoshop to give it that 3d look.

The "quest for colour"

Posted on October 20, 2006 at 12:00 PM

Categories: art

Although I love graphic design, I've never been able to get the hang of colour. I usually work in black and white. My colour palettes usually suck. The colours on this site are nice but that's a very lengthy evolution and they could still be better.

Now if I ever need a colour palette I'll just go to this flickr set by lunaryuna called quest for colour . It's bloody brilliant.

Here's a random sample, just reload to see another 4, or click through for higher-rez versions...

4 random x user_set 47745789@N00 371908 m

A bit of torrent #4: The Fast Show

Posted on October 02, 2006 at 12:00 PM

Categories: tv, bittorrent

This week on "a bit of torrent" ...

fast show

Aren't british comedies brilliant? Bittorrent — isn't that brilliant? I mean, downloading TV over the internet — what will they think of next? It's fantastic. The Fast Show, isn't it great? It's a bunch of sketches but before they wear out, they start the next one. And all the sketches are brilliant. Well, not all of them, the one with the thief wasn't so good, but then they get him off the set and on to the next one. Brilliant!

Meanwhile.... nothing will ever touch the true genius of "A bit of Fry and Laurie" — seriously, don't even go there — but The Fast Show gets pretty close at times. It's called the fast show because (a revolution in comedy at the time) the sketches are short and sweet. No lengthy build-ups here. Good ones come back in the next episodes, and they have a series of really hilarious steadies like the "brilliant" guy, who thinks everything is great, even the Nazis; Ted and Ralph, who aren't really funny, and a soccer newscaster who always goes off on a tangent about "boys in the park, jumpers for goalposts, eh?"

fast show

Most of the best characters are played by Paul Whitehouse so it's weird that I've never heard of him before. He's a bit of a chameleon. He appears in two of the attached pictures but every time, it's a different voice, a completely different look, different body language. He hasn't been in a lot of movies but even so I'd not be sure that I'd spot him.

Anyway, definitely a top pick. Here are some links. There are 3 seasons. There's also some specials out there somewhere.

TorrentSpy :

UPDATE: ... but don't bother with season three. It's a dog.

tags tags tags

Posted on September 12, 2006 at 12:00 PM

Categories: meta

I just spent a whole bunch of time sorting my tags. Because I have the best tag browser ever and so I'm having some fun going through and tagging my content and making my tags better now. For example, I had no rhyme or reason for uppercase, some were mixed-case, some were uppercase, some were lowercase. I decided to make them all lowercase.

So, a bunch of tags were renamed which will break links but too bad, backwards-compatibility is for losers. Also, I don't think people have really linked to my tags yet. But they will....

Anyway, I also added some new tags and went back and tagged a bunch more old posts too. Have a look at original/prediction (my "original work" making predictions about the future). Or how about computer/wi-fi (lots of developing world stuff in there...). Or how about just meta (navel gazing fun). Yum.

dailykos uses my graphic as the "open thread" image

Posted on September 10, 2006 at 12:00 PM

Categories: meta, art

I came up with this image yesterday when I was thinking about Disney's role in the fantasyland movie that ABC just broadcast (Disney owns ABC and apparently backed the film).

Disney Politics Logo Hack - colour

To be honest, I just like the colours. I always thought this was a cool logo. But anyways, no more Mr. Nice Guy or whatever. I had a look at the font on their original logo and it looks to me like Rockwell Light so I had a go in PhotoShop and changed "Pictures" to "Politics". Now Disney can put this up on the front of all their political propaganda pieces.

It didn't make much of a splash when I posted it in my diary so I figured it wasn't that good, but I guess that there really isn't any proper correlation between Recommendations and actual merit on DKos—at least in the "long tail" of non-superstar diarists. I think that has something to do with their horrible, horrible tagging browser.

Even better tag browser!

Posted on September 06, 2006 at 12:00 PM

Categories: meta

Well now I've got an even better tag browser . In fact I think it's the coolest tag browser ever. It's better than the flickr tag browser and the technorati tag browser and amazingly, even then del.icio.us tag browser . And what is delicious for if not tag browsing. Well.

Anyway, I used a sort of crazy CSS-float-left thing to make the big and small boxes all go inline together. It would have made more sense to use inline-block but it's not supported in Mozilla yet (weird).

Also, you will note that this new browser really brings out the awesomeness of my two-level tagging scheme because now for the first time you can see how the levels work. And I'm discovering that maybe I have some duplication oops, and I'm also completely inconsistent in how I capitalize. Hmm. I might edit my tags (I suppose that's bad for google though, oh well).

Anyway, the big names in the filled-in boxes are the "categories" and the names in the small white boxes are the "tags"... some day I might allow to view just the tags but I'm not quite sure what that would mean.

Note to self: I should add some category browser on the left side there.

Linkdump: cousin Suzanne, "Me", Excel little graphs, The Grooming of the Woodside Man

Posted on August 28, 2006 at 12:00 PM

Categories: graphics, tv, links, unix, art

A bunch of links and things.

Ahree Lee created (or is creating?) an amazing short film. Starting in 2001 she started to take a picture of herself, every day, in the same pose. As of 2004, she created a short film called Me in which the images are flashed at you at the rate of about one week per second. If you want to download the film, you can use mplayer (like I did...) with something like this from your unix shell. (Note that the rtsp URL might change, you can get it from AtomFilms web page / View Source.) (Also note that I had to insert a backslash in front of the exclamation mark, probably inserted by atomfilms to foil script kiddies trying to use this method.) I think you could do some cool analysis of the images over time.

mplayer -dumpfile out.rm -dumpstream 'rtsp://shockreal.edgestreams.net/real.atomshockwave-secure_!/me_300.rm?auth=caEascHb6b7dRbpdudXcLbKdibBaHbDbbdP-be81D5-cOW-REAwJrGowGoHn3wlB&aifp=123&span=10800' 
suzanne thomas

My cousin Suzanne Thoma finally has a website. She still sings but mostly she's now a freelance graphic designer. My opinion: website needs some work. I'm not sure that my parents would be able to navigate it.

How to create little bar charts inside the cells of an Excel spreadsheet looks useful and pretty easy to do. Generally speaking Excel's graphing sucks, and it looks like the Excel 12 graphs aren't going to get any better. Apple's iWord graphs are somewhat better but not perfect and some important graph types are missing.

Finally, let's hear it for art: The Grooming of the Woodside Man V1 by Simon Donikian and The Grooming of the Woodside Man V4 .

Enough for now...

I can't get enough of ravenblack quizzes!

Posted on August 19, 2006 at 12:00 PM

Categories: meta, links

I just can't get enough of these ravenblack.net quizzes! They're so awesome! The author is a genius!

Wait, the author is also really weird and has a RavenBlog !

While I'm here and screwing around, here's a Googlewhack: aquaplane wimax

Also, I'm redoing some fundamental bits of the XSLT that runs my site, so things might be a bit haywire for a few days.

Some links between Republicans and Vets for Freedom

Posted on August 16, 2006 at 12:00 PM

Categories: infographics

I was just reading this article on The Vets for Freedom faux grassroots movement . If there's one think that I don't like, it's astroturfing. See why at wikipedia . Especially political astroturfing, the worst kind.

The web of connections in the article is pretty confusing so I came up with this information graphic to try to untangle it a bit.

Some links between Republicans and Swift Vets and Vets for Freedom

I have large versions in Some links between Republicans and Swift Vets and Vets for Freedom (PDF) suitable for printing at any size, and also bitmaps in PNG , and JPEG .

Keep an eye on this page and / or the blog generally, as I may update the infographic if more information becomes available.

It's licensed under creative commons CC-BY-SA , so if you want the original file (in OmniGraffle ) let me know.

I cross-posted this on sbwoodside's diary on DailyKos . If you want to comment, you can do so there (or just email me).

nifty animated information graphic

Posted on August 11, 2006 at 12:00 PM

Categories: links

Imagining the Tenth Dimension is a cool, flash-animated information graphic. Unlike a lot of flash graphics, this one really needs to be animated, the movement really adds to the explanation power of the graphic.

After watching it, you're supposed to understand why "String Theory" has ten dimensions and what they are. In theory, anyway.

Customizing CSS with the Sympa Mailing List manager .. and CFH 416

Posted on August 01, 2006 at 12:00 PM

Categories: meta

I recently decided to customize the CSS style sheets on my Sympa mailing list manager -based semacode.org forums . It wasn't quite as easy as I think it should have been. The "instructions" in the Sympa docs are not exactly friendly. However after puzzling through it myself I found that it wasn't too hard. Here are the notes I made in the process.

set css_path in robot.conf e.g. css_path /var/www/lists.semacode.org/css #filesystem path css_url http://lists.semacode.org/css/ #fully-qualified URL! then set chmod the css directory, chmod a+rw so that sympa can change it then on "skins admin" page do "install static css" (static = not generated on the fly by tt2, I think) it will install style.css and some other .css files in the css directory then set the css directory back to whatever permissions you want it to have then modify the "static" css files however you like 

...and there you have it. So far I haven't done much, just a little bit on the archives view . Ultimately I hope to steal all the good looks from projects like phpbb and others.

Also my next appearance on Call for Help should be in episode #416, whenever that airs.

Two-level tags

Posted on June 24, 2006 at 12:00 PM

Categories: meta

I've thought before about putting in a two-level tagging system on my blog. I guess that it comes from that I'm dissatisfied with "tags" per se. They're just not rich enough. With a simple tagging system, it's hard to organize your tags into groups, for example, which to me is a big problem.

I'm not the only one to do something about this: see also tag bundles on del.icio.us , and also "meta tags" (which are tags about tags I guess).

I think that the common "solution" is to give mix tags together, so if you're talking about developing software on OS X you'd tag with "development", "software" and "OS X". But that's an implicit, not an explicit relationship. Also, designing a tag browser that lets you see which articles are tagged with all three of those tags is a hassle. Finally, there's no sense of hierarchy.

On the other hand, going to hard in the other direction (totally formal hierarchies) is also not viable in my opinion because it's too much work. You can get stuck with a specific hierarchy that doesn't always work (like in a library catalogue), or you can get confused by deranged mazes of hierarchical relationships (like Wikipedia's categories ).

This is a problem in software development too. I remember when working at Apple. NextStep always had a single-level namespace, which meant that each and every library and application class had to have a unique name. This is a really big hassle and so people wound up prefixing their class names with two uppercase letters in order to prevent collisions. So NSThis and NSThat were the names for "NextStep" classes (provided by the system), and your own app would be MAThis and MAThat (for "My App" ...). Then of course what if two people choose the same prefix. Or what if the name of the app changes, and your prefix becomes historical and a little spurious. (Like in OS X, all of the system classes still start with NS...)

Apple introduced a two-level namespace at some point in 2001 I think, which made the problem go away (although the NS prefix remains). I think that two-level systems are good. People can remember two levels of hierarchy very easily, it's a sort of natural relationship (like having a filesystem with files and folders but no sub-folders ... wouldn't that be simple??).

So I decided to put into place a two-level tagging system here in my blog. The "top level" tag is the category and the "second level" tag is the tag . Top level categories include links , original , and a big one: dev (for software development). You can see all the categories by clicking "Browse all tags" at the top to take you to the categories and tags browser .

There's a couple more things I want to do. One is to integrate the rest of the site into the system, so that any of the pages on the site can be tagged and included in an overall tags-based browser for the site.

Also I need to improve the UE a bit ... one thing is to have the ability to see a list of each category and its sub-tags. Also, I need a page-overflow paging type system to deal with huge pages like the one for the "dev" tag.

Can you still hear?

Posted on June 20, 2006 at 12:00 PM

Categories: links

Here's a flash app that you can test your hearing , how high it goes at higher frequencies. Best to start at the top and then notice when you can start to hear something. For me, it's 18 000 Hz which is pretty good considering how bloody old I'm getting. How about you?

This all came from a shopkeeper in england who used high frequency sound to repel teens . Fascinating and clever idea.

Oh by the way, you need a decent set of speakers or headphones to do this, otherwise you can blame your crappy speakers :-)

Videos from JavaOne SF 2006

Posted on June 04, 2006 at 12:00 PM

Categories: (none)

/shared/saxinc/movie.xml href=/weblog/media/2006/20060518-paul-yerba.3gp

What have we here? You guessed, some cheesy grainy videos from San Francisco. Let's start with the big one. It's Paul. Yup. And he's not aware he's being filmed. Hmm. Then, he realizes he's being filmed, and so he insults me.

/shared/saxinc/movie.xml href=/weblog/media/2006/20060519-sea-lions2.3gp

Next I give you ... what was that?

/shared/saxinc/movie.xml href=/weblog/media/2006/20060519-sea-lions3.3gp

Oh, it was a sea lion. Yawn.

Please note: Many crappier videos were deleted in the making of this blog.

A bit of torrent #3: SNL best of Will Ferrell

Posted on May 22, 2006 at 12:00 PM

Categories: tv, bittorrent

will ferrell

I've been watching a lot of torrents lately and frankly, a lot of it has been crap. Like this "Around the world in 80 treasures" show where the host is just insufferable (deleted). Also I've been watching these SNL best of shows and they're pretty good. This one is the best so far.

Go and grab the torrent from The Pirate Bay or view the IMDB page . Until next week, enjoy your A bit of torrent !

Fake or real?

Posted on May 21, 2006 at 12:00 PM

Categories: graphics

Can you tell the difference any more?

man

Go to the source to find out.

I got 400 spam mails yesterday

Posted on May 20, 2006 at 12:00 PM

Categories: meta

Does that seem like a lot to you? It seems like a lot to me.

Possible circumvention method for Apple's new iTunes 6 Music Store DRM

Posted on May 19, 2006 at 12:00 PM

Categories: theories

jhymn icon

Apple uses a form of DRM with the iTunes Music Store . While I love iTMS, I can't stand the DRM. The files come down as .m4p files which are AAC with an Apple DRM system called Fairplay .

Now with iTunes prior to version 6.0 there was a great program called JHymn which would strip the DRM from all your iTMS song automagically. Cool! It was built on reverse-engineering work by DVD John and enhanced by other people. Unfortunately, Apple messed around with FairPlay in iTunes 6.0 and JHymn no longer decrypts it.

But wait—says I—I have an old Airport Express and it plays my encrypted music just fine! It was made a long time before iTunes 6.0 came out. Is it possible that the music is being transmitted over the WiFi connection unencrypted?

The AirPort Express contains a little computer that can translate mp3, AAC, and AIFF files into an analog output. I know that it only supports certain formats, because I have audio files in other formats that iTunes will play on my computer but not on my stereo. That means that the Express must contain hardware/software that understands AAC. But it would only understand the old Fairplay, not the new one.

That means that iTunes 6.0 is taking out the new DRM before it sends it over the air to the express. And that means it should be possible to write a program that finds that stream of unencryted data and read it back into an unencrypted AAC.

Useful resources for Ultimate (the disc sport...)

Posted on May 09, 2006 at 12:00 PM

Categories: (none)

Subscribe to:

Blogroll: