Saturday, April 30, 2011

Green Travel: Bring a Folding Bicycle on an Airplane

I was in Los Angeles last week to attend an event; a friend from high school had gotten married, and his wife was having a baby shower. Shortly after I received the invitation, the best deal I could find was 3 weeks away, and so I booked the first flight leaving Oakland on a Tuesday morning, and the last flight coming back to Oakland the following week on a Wednesday night. My sister, who lives in LA, being a mother of an almost 4-year-old girl, hadn't been getting much sleep, and she balked at picking me up when my plane arrived at Burbank airport at 7:15 am. I decided that, when I arrived at my destination airport, I was not going to jump into a rented car, but get on my bike and, depending on the grace and mercy of the public transit system, ride to where I needed to go. The last time I was in Los Angeles was 4 years ago, for my sister's own baby shower, and I had a rental car for a week; by the time I came back to the Bay Area, I had gained 10 pounds, due to increased caloric intake and lack of physical activity. This time I was going to save money and get some more exercise. Here's what I did to become a green traveler (or, a green traveller, as they say in the United Kingdom):

What you will need:
  • tape measure
  • folding bike
  • bicycle lock
  • clear plastic garbage bag
  • bungee cord, also known as a shock cord
  1. Confirm your airline's baggage policy. I was allowed to check-in two bags for free, in accordance with the Southwest Airlines checked bags policy:
    Weight and Size Allowance:
    Maximum weight is 50 pounds and maximum size is 62 inches (length + width + height) per checked piece of luggage. ...[O]verweight items from 51 to 100 pounds and oversized items in excess of 62 inches but not more than 80 inches (e.g.; surfboards, bicycles, vaulting poles) will be accepted for a charge of $75 per item.
    If you don't want to be forced to pay $75 at the ticket counter, use measuring tape and a scale to make sure your bicycle conforms to the size and weight limitations. Besides your folding bike, I recommend you bring a backpack as your other bag, because your folding bike's wheels are smaller than your standard bicycle, and you don't want to make your ride even more unstable by having a heavy bag slung around your neck, hanging off one side, making your bicycle ride unpleasant and unsafe.

    If your bicycle lock is a U-lock, it's likely the TSA agent may consider that it can be used as a weapon, so don't try to bring it onto the airplane cabin in your carry-on; rather, lock your U-lock to your bicycle during the check-in.

  2. Pack light. Erykah Badu, in her famous "Bag Lady", exhorts, "Bag Lady, you're going to miss your bus. You can't hurry up, cause you got too much stuff."

    Do not be the bag lady, who would surely hurt her back, dragging all her bags like that! Besides my folding bike, I had one backpack, into which I put my laptop computer, a change of underwear and an extra pair of shorts, an extra 16-inch inner-tube, and hard plastic steel-core tire levers, in case I got a flat tire. I got a lot of my tips for how to pack light from this article.

  3. I decided to enclose my bike in a plastic bag in an effort to conform to Southwest's Special Luggage Sports Equipment Policy:
    Bicycles (defined as nonmotorized and having a single seat), including Bike Friday and Co-Pilot, properly packed in a hard-sided bicycle box that fall within the dimensions and weight limits established for normal Checked Baggage, (i.e., 62 inches or less in overall dimensions and less than 50 pounds in weight). Pedals and handlebars must be removed and packaged in protective materials so as not to be damaged by or cause damage to other Baggage. Bicycles packaged in cardboard or soft-sided cases will be transported as conditionally accepted items.
    "Conditionally accepted" means Southwest assumes no liability for damage sustained during transport. I decided on a see-through transparent bag because I imagine the airport baggage handlers will be a bit more careful if they are able to see that it's a bicycle they are handling, than if the bicycle was in a canvas bag or hard-sided case. Once your bike is unfolded at your destination airport, you can easily store the plastic bag in your backpack.

  4. You will also want to bring a spare inner tube that is in your folding bike's tire size, and tire levers, in case you get a flat tire. Los Angeles has a lot of gas stations, bike shops, and people with bicycles and tire pumps in their garages, where you can use a pump if need be, but if you will not be in a densely populated area, you may also want to bring along a bike pump. By the way, for those of you concerned with how the change in air pressure during a flight may or may not affect the compressed air in your bicycle tires: before I began my voyage, I had my tires inflated beyond the recommended upper limit, and at both of my destination airports, when I received my bike, there was never any problem with my tires or inner tubes.



My 2005 Dahon Presto Lite. This model is no longer available for retail sale. I bought mine second-hand. It came without mud guards.


Folded size, with right pedal, is 30 x 20 x 17, for a total of 67 linear inches. On this model, the right pedal is easily removable. Folded size, without right pedal, is 30 x 20 x 11, for a total of 61 linear inches. Weight is about 18 pounds.


Folded bike with U-lock, locked to frame.


Folded bike with U-lock, locked to frame, covered by clear plastic garbage bag, and secured with bungee cord.

Did you ever have any problems, or unexpected events or hiccups, with checking-in your bike at the airport?
On my recent flight, during both check-ins, with my removable right pedal affixed, neither Southwest ticket counter agent made an issue of the extra few linear inches or, for that matter, ever took out a measuring tape. There was one incident where, during my first check-in, a Southwest ticket counter agent said she would have to charge me $50 to transport a bicycle. However, I pointed out that, on their website, the Southwest policy is that bikes under the size and weight limit count as checked-in baggage and are not subject to a fee. The agent looked up the policy, gave my folding bike a once-over, looked at the bike's weight, and said it was ok.

If you're looking to buy a folding bike, I recommend:

http://foldingcyclist.com/folding-bike-buyers-guide.html

though one drawback is the guide doesn't have folded-size dimensions. If you have the time to look for a second-hand, well-maintained bike for a good price, I recommend Craigslist, which is how I found mine.

Conceivably, you could also bring a folding bike with you on a boat cruise, or sight-seeing in an RV or tour bus. So now you have another option as a green tourist. Next time you travel, don't rent a car; bring a bicycle.

Friday, April 29, 2011

How to Pack Light, for Men and Women

In preparation for a recent trip to Los Angeles, I read up on some tips on how to travel smart and avoid baggage fees. Debra Saunders advises people to pack heavy, but this part of her column I definitely agree with:
European travel guru Rick Steves has recommended that, regardless of the length of a trip, that the savvy male tourist pack only three pairs of socks and underwear, a pair of shorts, two short-sleeved shirts, a long-sleeved shirt, a sweater, a windbreaker and one pair of shoes. On his Web site he tells vacationers they should fit everything they are taking into one "carry-on size bag."

A tip for couples traveling with a small child or children, from John Flinn:
"But you can't pack light if you're traveling with small children," protested several readers. Apparently no one told Andy Sedik of South San Francisco: "My wife and I just returned from a two-week trip to Eastern Europe with our 14-month-old daughter using only two carry-ons, an umbrella stroller and a diaper bag. Not only is it possible, it makes life on the road so much easier. Once you travel light, you never go back."

Tips for men from John Flinn (Note the sidebar, "The Art of Packing", which covers 'Packing for Cruises' and 'What Women Want'):
This is everything I pack for a typical three-week trip to Europe or South America, riding trains and buses and splitting my time between town and country. It all fits easily into a carry-on bag, with room left over for a bottle of Côtes du Rhône, a baguette and a few souvenirs.

Tips for women from Eliza Hussman:
I had carried around heavy suitcases for years, mostly because I always seemed to get a bad case of the "what ifs" while packing: "What if someone spills something on my dress and I need a backup?" or "What if it stops raining while I'm there and I need a swimsuit - or three?" or the dreaded "What if those sandals don't look as cute with that dress as I'd thought and my friend asks me if I brought a different pair?"

Tips for women from Christine Delsol
  • Two pairs of shoes is the maximum: Good walking shoes that will hold up for eight or 10 hours at a stretch, and a lighter pair -- comfortable sandals that can go with skirts for more formal outings in hot climates, or perhaps stylish flats in cooler weather.
  • A light, longish skirt is the best staple for hot climates. Unlike shorts, skirts can dress up or down, they are as welcome in restaurants and cathedrals as at the beach, they ward off sunburn and require little space. Take several.

Friday, March 25, 2011

How to use Perl, PHP, Python, R, and Ruby to find Euclidean distance between two points

According to Wikipedia:
In the Euclidean plane, if p = (p1, p2) and q = (q1, q2) then the distance is given by:

Assuming you are using the Cartesian coordinate system, your two coordinates must both be of length n, where n can be any non-zero positive integer. So if the two points in question, p and q, each had 3 values:

p = (p1, p2, p3), q = (q1, q2, q3)

Then n would equal 3, and the distance formula would be:



The hardest part for me, when putting this all together, was figuring out, for each scripting language, how to iterate over, i.e., step through, the respective elements of both coordinates, simultaneously:

Perl 5 (5.12.2):
use List::Util qw(sum);
use List::MoreUtils qw{ any pairwise };

sub get_distance_between
{
if (scalar(@_) != 2)
{
die "You must supply 2, and only 2, coordinates, no more, no less. Stopped";
}

my $a_ref = shift;
my $b_ref = shift;

if (@$a_ref != @$b_ref)
{
die "Coordinates do not have the same number of elements, stopped";
}
else
{
@x = pairwise { ($a - $b)**2 } @a, @b;
return sqrt(sum(@x));
}
}

# Usage:
@a = (1008, 2243, 976), @b = (1005, 2249, 974);
$ad = get_distance_between(\@a, \@b);
print "\$ad == $ad";

PHP 5.3.6:
function subtract_and_square($n, $m)
{
return(pow($n - $m, 2));
}

function find_distance_between($p, $q)
{
$numargs = func_num_args();
if ($numargs != 2)
{
die("You must supply 2, and only 2, coordinates, no more, no less.\n");
}
else if (sizeof($p) != sizeof($q))
{
die("Coordinates do not have the same number of elements.\n");
}
else
{
$c = array_map("subtract_and_square", $p, $q);
return pow(array_sum($c), .5);
}
}

Python 2 (2.5.4):
def get_distance_between(p, q):
if len(p) != len(q):
raise Exception
else:
sum = 0
for pval, qval in zip(p, q):
sum += (pval - qval)**2
return sum**(.5)

R (2.12.1):
get_distance_between = function(p, q)
{
if (length(p) != length(q))
{
stop("\nCoordinates do not have the same number of elements.")
}
else
{
element_products = mapply(function(a,b) (a - b)**2, p, q)
sqrt(sum(element_products))
}
}

Ruby 1.9.2:
require 'generator'

def get_distance_between(p, q)
if p.length != q.length
raise Exception
else
sum = 0
syen = SyncEnumerator.new(p, q)
for pval, qval in syen
sum += (pval - qval)**2
end
end
return Math.sqrt(sum)
end

In the Perl example, thanks to Miller Hall and Jon Bjornstad for their review and suggestions on how to improve my Perl code to make it more readable.
In the R example, thanks to Spencer Graves and Nicholas Lewin-Koh for pointing me to mapply and plyr (which I did not have time to research and use).

Update: On October 31, 2011, my friend Nikita Borisov, assistant professor in Computer Science, offered the following suggestion on facebook re the R and Python code:
This person clearly hasn't used these languages very much. In R, you can say sqrt(sum((p-q)**2)). Similarly, in Python you can write sqrt(sum([(x-y)**2 for (x,y) in zip(p,q)]))
Thanks, Nikita!

Monday, March 21, 2011

The 3 Most Important Things a Programmer Must Know

Write code, run code, fix code is essentially what a programmer does, said the speaker at an intriguing talk I recently attended, hosted by the Perl Mongers group. Zed Shaw is the author of Learning Python the Hard Way and in review, I have to agree with this user-generated comment:
Very knowledgeable not just with Python, but he has a deep understanding of programming. He inspired me to be a better thinker and programmer.
I was interested in this talk because Zed Shaw made a name for himself by coding the Mongrel web server, as well as Mongrel2, both of which were and are integral parts of Ruby on Rails. I looked forward to the rather unique confluence of a core Ruby on Rails programmer giving a talk about Python at a Perl meetup. I had a prior discussion with a female attendee at a Ruby on Rails Workshop for Women on why religious wars in technology were so prevalent; some people get worked-up over a particular choice of scripting language (Perl vs Python vs Ruby) or text editor, and soon flame wars ensue on the internet about which technology is best. Rodney King asked us after the Los Angeles riots, and Zed is living proof that we can all get along, at least when it comes to scripting languages.

Zed took a year off to learn jazz guitar. He realized, when learning music, you have the concept of a trainer, who tells you to play individual chords multiple times until you get better at it. Then the trainer tells you to play another chord, and then play a song in both chords, in a progression, until you have some experience under your belt. Whenever you want to learn something difficult, it's hard to explain the ideas unless you have some experience under your belt. Using this same principle, Zed decided to introduce the beginner to simple coding exercises, until you get better at writing computer programs, and then he slowly introduces the concepts to you.

The fact that Zed was able to use an analogy from music learning in explaining hard-to-grasp concepts in computer programming makes his experience valuable and his book a must-read for me. Zed strikes me as hard-working, dedicated to his craft, and he knows something about how to get beginner programmers engaged in a new, complex, but rewarding venture. One last thing he said that really hit home for me: Zed recommends learning parsing and lexing, the two most important things, other than algorithms, that a programmer must know. Right now, Zed is doing C and Lua, and he mentioned software called Corona that enables the Lua programmer to write iPhone games.

Monday, February 28, 2011

Reality Television's 'Cheaters' is Fake

I'm someone who has lived in Oakland for about 3.5 years now. I love what I do everyday. I like hanging out with my friends, and maybe having a few drinks on the weekend. That's it really. Well, I'll also admit to enjoying so-called "reality" television, which sometimes caters to the dark human desire to live out revenge fantasies. Most anyone who's been jilted, especially in love, has dreamed of getting even. It's why shows like Cheaters are so readily watched: you locate your significant other and have them followed by private investigators, who covertly record their rendezvous. Then you surround the target with a television crew of 15-20, along with a vocal leading man who takes charge for you and orchestrates the ambush of the person you feel has hurt you. You overcome the protestations of your target with a video recording of the infidelity, embarrass the heck out of that denying, unfaithful, lying liar, and, if the planets are aligned correctly, a shoving match or physical altercation may ensue. As I grew accustomed to watching the show, I realized the real payoff was the thrill of not knowing what would happen next, and I'll confess to craning my neck, out of morbid curiosity, to see if the confrontation would turn violent, much like you might expect fisticuffs or a brawl at a hockey game, crashes at a race-car event, or some other dramatic development of extreme behavior we humans can all process and talk about the next day.

The host of Cheaters who leads the charge to surprise your cheating lover, and plead your case, was once Tommy Habeeb (stage name Tommy Grand), but, since 2002, it's been Joey Greco (Clark Gable III took over starting in 2012). Joey was present during some episodes I still remember, such as the one where Steve French, caught, spooked, cornered and insulted, kicked in a car's passenger window, and then decked his accusatory girlfriend Rene Reardon in the face, or the episode where entrepreneur Aaron Rodriguez, in a relationship with a subordinate female employee, Emily Cruz, discovers he had kissed his girlfriend's mouth, just after she had performed a sex act on another male coworker, Jay Evans, right under Aaron's nose. Earlier, we saw that subordinate male employee urinate in the office coffee; we then see the man-being-cheated-on, Aaron, drink the very same coffee laced with urine:Let's not forget the explosive confrontation that interrupted Dalia Santiago's outdoor marriage ceremony, as it slowly dawns on the bride in her wedding dress that the man she was about to marry had been carrying on with Jamie Isaacs and had been recorded picking up a one-night stand at a saloon:
Good times, good times... Yet, come to find we the Cheaters audience may all have been cheated on, by Cheaters! According to the Houston Press:
Actors don't need to be tailed by Gomez for weeks on end. They don't present security risks, and they don't need counseling. They also tend to be younger and better looking than real cheaters, who often will not consent to allow the show to air their faces.

The bogus cheaters interviewed for this story say they've never heard of Goldstein and that Gomez stressed to them never to reveal to Grand or the camera crew that they were acting.

One of the actors, Michelle, met Gomez last fall. "What he told me was that some of the episodes are real, but...a lot of people didn't want to be on the show once they'd been busted, so they would do these ringer episodes to supplement the show," says Michelle, who asked not to be identified by her last name.
If the reports are true, it's all very troubling, for it means Bobby Goldstein was trying to hide information from his business partner, Tommy Habeeb. I think it's telling that when the Houston Press report first came out in 2002, alleging falsehood on the part of Cheaters, Tommy Habeeb and Bobby Goldstein parted ways shortly after because Tommy had "differences with the production company"; I can even imagine the confrontation that occurred between Habeeb and Goldstein, with Tommy demanding that Bobby be straight with him, then Tommy and Bobby have their falling out, and Tommy leaves the company. Two reports from Inside Edition in 2009 seem to indicate that the infamous program where Tommy's replacement Joey Greco got stabbed was also staged, and when Inside Edition sets upon the man himself, rolling up on and presenting to this frequent accuser apparent evidence that seems to support the accusations of fakery and cheating, Joey Greco would neither confirm or deny any specific allegations, such as whether the blood was fake.

I would prefer not to believe these revelations, as I then would need to accept that some of my favorite Cheaters episodes are no more real than professional wrestling. If Cheaters is scripted, then this means that the voyeuristic thrill we get in watching people being secretly captured on camera is based on a false premise, and that it is we, the viewers, who are being had, led on by actors, who knew they were on camera, playing a role. But how can a reality television program broadcast fiction and claim that it's the truth? The same Houston Press article reports:
According to a Federal Communications Commission spokesman, there's no law or regulation against presenting acted-out scenarios as reality on television.
In response to the quiz show scandals of the 1950s, when impropriety was uncovered in rigged game shows, Congress did pass a law, in 1960, amending the Communications Act of 1934, and preventing anyone from fixing quiz shows. Well, apparently, it's not illegal to portray scripted shows as "actual true stories filmed live", even as said program, to this day, claims nothing is staged and every broadcast episode starts out with language reiterating the show is not fake. So, on television at least, you can call it non-fiction and sell it as non-fiction, even if, the truth is, Cheaters is fiction.

Saturday, February 12, 2011

The Almost Perfect, Guilt-Free, Shrimp to Eat

Pandalus platyceros. Spot Prawns range all along the Pacific coast, but mostly in the North Pacific.

Courtesy of The Atlantic:
But one shrimp has it all: the spot prawn caught off the coast of British Columbia. The species is big, luscious, and caught in a completely sustainable manner. Its only drawback is that Canadians have recently awakened to these virtues, and devour most of the catch before it can be exported...Instead of dragging nets, spot-prawn fishermen use round, washtub-sized traps that operate on the same principle as lobster pots—prawns are lured in by containers of fishmeal and are unable to get out.
I remembered these live shrimp being offered for sale at New Sang Chong Market in Oakland Chinatown, so I went this morning and took some pictures:IMG_9845
IMG_9844

Sunday, January 23, 2011

Why You Should Learn Black English

Many of my friends are new parents now, married, in long-term careers, and looking to buy their second homes. As for me, I'm on my last unemployment extension, with no job in sight, have been single for decades, and I mutter to myself on the street like a crazy man. And I don't have a cellphone. What I do have, though, is the gift of gab, and I find myself befriending homeless people, just for the conversation. We humans need the company of other human beings, which is why it's important for me that I know the language of the street. What some call black English, ebonics, African American vernacular (Harry Reid racily termed it "negro dialect", before he had to apologize for the trouble he got in) is remarkably the same almost anywhere you go. In a pinch, black English helps me establish rapport and connect with everyday people I might meet, who remain important sources of information. This is true if the person you're looking at is starting out (or starting over) at the bottom, and may lack the peace-of-mind and sophistication we associate with the highly-educated, wealthy and the wise. Once you're out on the street, whether we like it or not, black English intrudes on our lives, sometimes unexpectedly. For instance, the distinguished Alfred Mann, a man I highly respect, had to do a double-take, at 2:05:Now, I'm not black, and you may not be, but I'm not white, either. There is a popular concept that really popular entertainers like Eminem, and Elvis, or comics like Lenny Bruce, either stole the language of black people or their language was stolen from black people:I think this notion is mistaken. By the same logic, since this piece was composed using the King's English, I must have stolen English from white people. I think an argument can be made that what is known on Wikipedia as African American vernacular English borrows heavily, if not outright steals, from the language of low-class white people from the South, many perhaps dirt-poor indentured servants.

If speaking black English is a crime, then may God forgive me. And now that America has a black president, it's high time Americans learn about black English. Barack Obama intuitively knows that you have to be likeable with regular people if you want to get things done. Like the President, I come from an elite school, but it took me 30 years of going to and from this earth, and up and down it, before I learned that I am no more elite than the guy digging through the trash for recyclable bottles and cans. If, by definition, most people are of average measure, wouldn't it be important to know how most people feel and live ? I think learning about black English, and learning how to pull off speaking it convincingly, is part of learning how to be ordinary, or, at least, appearing to be. These men have the right idea:

Top 5 Best Covers or Musical Examples of White People Speaking Black English
  1. Dynamite Hack - Boyz in the Hood


  2. The Gourds - Gin & Juice


  3. Jonathan Coulton - Baby Got Back


  4. Mickey Avalon - Waiting to Die


  5. Todd Rundgren - Bang on the Ukulele Daily
Honorable mentions should go to songs like Crazy Town - Only When I'm Drunk, which is a perfectly good rock band cover, but doesn't have that quirky cuteness that transforms the covers in my Top 5 into softened, almost folksy, American ballads that, despite their white-washed veneers, remain subversive at their heart. You may find yourself humming these seemingly harmless tunes without a second thought, such as the easy-listening, elevator music paean to the female derriere (complete with a singular quack of a duck) by Jonathan Coulton, or the amusing solo guitar riff at the end of Dynamite Hack's track, referencing moonlight howls by an addict who has acquired a large amount of narcotic:
Punk ass tripping in the dead of night.
Homie scored a key, he's gonna fly...
Punk ass, fly
along with the mutterings of the fiend in question: "They're ripping off everybody man, they're ripping off everybody", or the understated banjo-mandolin bluegrass cover, by The Gourds, of the 'G' Funk classic on the joys of consuming hard liquor and cannabis, whilst operating a motor vehicle on the streets of Los Angeles.

What are your favorite examples of white people speaking black English ?