Monday, December 21, 2009

The Influence of the Stars

Right around the time I found out Brittany Murphy died yesterday, I finished reading Eating Animals by Jonathan Safran Foer. In an eye-opening piece on the 1918 Spanish flu pandemic (which killed more humans faster than any other disease, or any other anything, has before or since), the author goes into the history behind the word 'influenza':
Much like the virus it names, the word influenza comes to us by way of a mutation. The word itself was first used in Italian and originally referred to the influence of the stars - that is, astral or occult influences that would have been felt by many people at once. By the 16th century, though, the word has begun mixing and blending with the meanings of other words and come to refer to epidemic and pandemic flues that simultaneously strike multiple communities (as if the result of some malevolent will).
Reference: page 13 in Eating Animals.

Much like an Italian villager in the 1500s, I feel like the universe is conspiring against me, trying to prevent me from discovering more about three Asian American actresses in a movie with Brittany. I searched IMDB, on Google, and even posted a question on Yahoo Answers, all to no avail. So I ask you, Gentle Reader, what are the names of the actresses who portrayed Janet Hong and 2 other unnamed Asian female characters in the movie Clueless (1995) ?

Wednesday, September 23, 2009

how to import data into R and SAS

What is bio-statistics and how does it relate to me ? I am often asked this question, and now I think I may have an answer. With the advent of the Internet, we are now in the Age of Information, and when it comes to "statistical data analysis", a rather imposing mouthful, to quote a recent article in the New York Times (and I paraphrase):
In field after field, computing and the Web are creating new realms of data to explore - sensor signals, surveillance tapes, social network chatter, public records and more. We're rapidly entering a world where everything can be monitored and measured, but the big problem is going to be the ability of humans to use, analyze and make sense of the data. Strong correlations of data do not necessarily prove a cause-and-effect link. For example, in the late 1940s, before there was a polio vaccine, public health experts in America noted that polio cases increased in step with the consumption of ice cream and soft drinks. Eliminating such treats was even recommended as part of an anti-polio diet. It turned out that polio outbreaks were most common in the hot months of summer, when people naturally ate more ice cream, showing only an association. Computers do what they are good at, which is trawling these massive data sets for something that is mathematically odd, and humans do what they are good at and explain these anomalies.
To analyze statistical data, we use computer programs as tools to work with such information as biological data. Yet another recent article in the New York Times compares and contrasts two of these computer programs, R and SAS (and again I paraphrase):
SAS Institute (the privately held business software company that specializes in data analysis)'s namesake SAS has been the preferred tool of scholars and corporate managers. But the R Project has also quickly found a following because statisticians, engineers and scientists without computer programming skills find it easy to use.

So "Statistical Data Analysis" in the abstract sense is a formidable journey of a thousand miles, but the bite-size journey's first step involves importing a set of data into the tool (I'm assuming you already obtained, installed, and are running the software). For purposes of demonstration, I've created a data set using the actual previous year's receipts I had gathered and saved from each and every time I filled my car's tank with gasoline:
    18AUG2009  6 12.815 37.66
14JUL2009 12 4.340 11.8
28MAY2009 6 9.532 24.39
22APR2009 4 7.348 16.01
25MAR2009 2 5.509 11.12
15MAR2009 7 4.230 8.62
04MAR2009 3 11.989 25.16
21FEB2009 7 13.298 27.91
29JAN2009 15 13.989 27.68
03JAN2009 6 12.620 22.70
29NOV2008 16 11.239 20.78
25SEP2008 8 13.929 51.80
Note that on the tail end of the second line, in the last figure, 11.8, I omitted a zero ('0') when I was typing the data in. We'll come back to that later. I decided to record the following four fields for each time I filled the gas tank (all took place at Costco in San Leandro):
  1. date of purchase
  2. pump number
  3. quantity of gas obtained, in gallons
  4. cost of the transaction
In both tools, R and SAS, we will then divide cost by quantity and generate a fifth field, price per gallon.

To import a dataset into your software, you can either read from a file, or copy and paste it in (although for R, you will copy the data set, but you won't actually paste anything). The following scripts have been tested on R versions 2.8.1, 2.9.2 and SAS version 9.1.3 Service Pack 4.
  • To read data from a file within R and SAS:
    1. identify the path to the file containing your data set. Let's say the path is:
      if you're on Windows, the convention is to delimit or separate folders with a backslash, but this poses a problem for software that is trained to recognize tabs and carriage returns and newlines as '\t', '\r' and '\n' respectively. For reasons of cross-platform compatibility, if there are backslashes in your Windows path, add another one right next to it:
      or replace the backslash with a forward slash:
    2. at the command prompt, input and run the following incantations:
      • R:
        petrol_01 = read.table("G:/tpc247/petrol.txt", header=FALSE, col.names=c('date', 'pump', 'quantity', 'cost'))
        petrol_01$per_gallon <- petrol_01$cost / petrol_01$quantity
      • SAS:
        data petrol_01;
        infile "G:/tpc247/petrol.txt";
        input date_of_sale$ 5-13 pump_number$ 16-17 quantity 20-25 cost 28-32;
        per_gallon = cost / quantity;
        proc print data=petrol_01;
        title 'Unleaded gasoline purchase history for 1 year, San Leandro, California Costco';
  • To read data from computer memory in R and SAS:
    • R:
      1. copy and paste this into R, but don't actually run the incantation yet:
        petrol_01 = read.table("clipboard", col.names=c('date', 'pump', 'quantity', 'cost'))
      2. copy your data set, then run the previous incantation

      3. run the rest as you normally would:
        petrol_01$price_per_gallon <- petrol_01$cost / petrol_01$quantity
    • SAS:
      data petrol_01;
      input date_of_sale$ 5-13 pump_number$ 15-16 quantity 18-23 cost 25-29;
      per_gallon = cost / quantity;
      18AUG2009 6 12.815 37.66
      14JUL2009 12 4.340 11.8
      28MAY2009 6 9.532 24.39
      22APR2009 4 7.348 16.01
      25MAR2009 2 5.509 11.12
      15MAR2009 7 4.230 8.62
      04MAR2009 3 11.989 25.16
      21FEB2009 7 13.298 27.91
      29JAN2009 15 13.989 27.68
      03JAN2009 6 12.620 22.70
      29NOV2008 16 11.239 20.78
      25SEP2008 8 13.929 51.80
      proc print data=petrol_01;
      title 'Unleaded gasoline purchase history for 1 year, Costco in San Leandro, California';
Coming back to the omitted zero ('0') on the second line in our last figure, 11.8, you might find it amusing how finicky R and SAS are about what they eat. Putting this tutorial together gave me the opportunity to learn some valuable things about the two tools. Just like a toddler can be very picky about the food she feels like taking in her, feeding data to R and SAS and ensuring they digest the data correctly may require some forethought and planning. When importing the dataset into both tools from a file, I noticed that in:
  • R, if I didn't include in my incantation:
    header = FALSE
    I would find the first record in my dataset on file would be missing from my dataset in R
  • SAS, omitting the zero ('0') when I typed the following into my dataset, for July 14, 2009:
    14JUL2009 12  4.340 11.8
    did not pose a problem, as long as I ran a previous incarnation of my SAS script:
    data petrol_01;
    infile "G:/tpc247/petrol.txt";
    input date_of_sale$ pump_number$ quantity cost;
    per_gallon = cost / quantity;
    proc print data=petrol_01;
    However, I didn't like the resulting output in SAS. I have developed a preference for a specific way of representing dates that is 9 characters long and in a format that, to my eyes, is more easy to read. However, when I ran the aforementioned script on my data set, my dates were truncated:
    SAS fill gas tank dataset
    It seemed that SAS preferred data in columns to be 8 characters or less, or else it would truncate any value greater than 8 characters. So even though running my SAS script resulted in SAS correctly reading in my data, and there was no problem with my omitting the zero ('0'), I decided to modify the incantations in my script and specify the columns so that the dates in my desired format would not be cut off. When I did this, I noticed that data in SAS was different from the data on file:
    SAS fill gas tank dataset
    As you can see, the information from the fill_the_gas_tank event for 28MAY2009 has disappeared, and the line in my dataset on file:
    14JUL2009 12  4.340 11.8
    has been replaced in SAS with
    14JUL2009 12  4.340 2.00 0.46083
    I imagine SAS would read 11.8 and then be confused because there were no more numbers and I had told it to expect one more, but I can't explain how SAS computed a cost of 2.00. However, I can explain that the price_per_gallon of around 46 cents is simply derived from dividing 2.00 dollars by 4.34 gallons. The fact that the record for May 28, 2009 is missing leads me to conclude that when reading data from file, and your SAS statement specifies columns, SAS seems to expect values for the entire range of columns you specify. I've confirmed this phenomenon, of a missing record when you specify in your SAS statement the columns where values can be found, manifests itself in SAS only when reading data from file, and not from the copy and paste of data.
Other separators and delimiters

If you have commas separating your data:
    18AUG2009,  6, 12.815, 37.66
14JUL2009, 12, 4.340, 11.8
28MAY2009, 6, 9.532, 24.39
22APR2009, 4, 7.348, 16.01
25MAR2009, 2, 5.509, 11.12
15MAR2009, 7, 4.230, 8.62
04MAR2009, 3, 11.989, 25.16
21FEB2009, 7, 13.298, 27.91
29JAN2009, 15, 13.989, 27.68
03JAN2009, 6, 12.620, 22.70
29NOV2008, 16, 11.239, 20.78
25SEP2008, 8, 13.929, 51.80
In:When importing data into R or SAS, you need to look at your dataset, and tell R or SAS exactly what to expect, or your statistical data analysis software may complain.


Thursday, September 10, 2009

how to install a seat leash to prevent theft of saddle & seat post

Protect your bike from those who may see an opportunity to abscond with the valuable, quick-released perch for your peachy derriere.
a tempting target for a would-be thiefFoiled again! Thanks seat leash

Were anyone to happen upon this scene, look around and see no one watching, the thought might cross your mind to simply loosen the quick release and walk off with someone else's property like it was yours. The Great Recession created lean and mean times, changing the way Americans spend. With such general apprehension and fear, you can find some amazing bargains in the bicycle market right now. I decided to overcome my reluctance to spend and make the big purchase that, as an avid bicyclist, you might be saving for as well. My new second-hand bicycle is a lightly used 1997 Marin Team Titanium that has a quick release binder bolt for adjusting the height of the seat post.

Let's start by getting our vocabulary straight (thanks to Sheldon Brown for helping me put names to bike parts):
  • saddle (also called bicycle seat)
  • saddle clamp (also called seat sandwich)
  • seat leash (also seat security cable)
  • seatpost or seat post (also called seat mast, seat pillar, or seat pin)
  • stolen (also pilfered, nicked, or made off with)
  • Y hex wrench (also 3 way hex wrench. This is a tool, commonly seen in bike repair shops, that has the 3 wrench sizes to fit the socket heads on most modern bicycles. 'Hex wrench' can be used interchangeably with Allen wrench or L wrench)

To prevent your seatpost and saddle from being stolen, you will need:
  1. seat leash
  2. Y hex wrench
I tried numerous times to figure out a way to use a seat leash to secure my bicycle seat and seat-post, but the closest I got was a half-baked solution where I added the end-loop as an ingredient into the seat clamp mechanism, so that the clamp was gripping a combination of saddle rail and seat leash loop. This made for not the best grip on the saddle rails, and, while you were riding, the bicycle seat was prone to moving horizontally back and forth, a rather unpleasant event for any rider. The light bulb flashed atop my head last Sunday, September 6, at around 11:25am, when I stepped into the Missing Link repair shop and spoke with Andy Renteria, who told me it's possible to secure the saddle and seatpost to the bike with a security cable. He used his forefinger and thumb as an analog for the end-point loop of the seat security cable, and wrapped it around the saddle clamp, between the seatpost and the saddle rail. The breakthrough for me on how to secure your bike seat was using the saddle clamp itself as the focal point on which to anchor the endpoint loop:
Thanks Andy, at Missing Link repair shop

The seat security cable has end loop which uses the saddle clamp (I call it a seat sandwich) as a focal point. Also in the picture is my beloved Planet Bike Superflash Stealth Tail Rear Light


IMG_9880_rotated right


From start to finish:
  1. use the Y hex wrench, or any appropriate Allen or 'L' wrench, to remove the saddle
  2. insert one loop through the other and wrap your seat security cable around the seat stay, or any focal point that has stops and forms a closed area. Take care when wrapping your security cable around the seat stay that you avoid the part of the frame closest to the tire
  3. with the remainder of the bike security cable in your hands, visualize the saddle clamp itself as the focal point on which to anchor the endpoint loop, and affix said loop on the clamp
  4. now install (or rather, reinstall) the saddle into the seat clamp mechanism, making sure the seat leash end-point loop is between, and stopped by, the seat rail and the seat post.

Monday, August 24, 2009

how to use Google's mail server to send email

Just a little over 2 years ago I enrolled in a 3 month course from Wesley Chun in Intermediate Python, held in Los Altos Hills on the main campus of Foothill College. I found Wesley's lesson plan to be very challenging, but in my journey as a computer programmer since, one of the nuggets of wisdom I come back to is his lesson on writing internet clients. One small task he prompted us with was a valuable exercise on how to write clients that use the servers run by free email providers (yahoo, aol, hotmail, gmail). First, a little history on the instruction leading up to the in-class assignment... Why, I remember like it was yesterday (swirling, squiggly lines as harp strings are plucked & played by unseen angels should now be occupying your visual and aural landscape):

Internet Client programming
All internet clients are built on top of TCP

We talked about four internet clients: ftp, nntp, pop3, smtp
After covering ftp and nntp, Wesley began with an overview of email, how electronic mail as a system is complex and to operate it requires lots of working pieces:
  • Message Transport Agent
    • responsible for moving email, routing, queueing, sending of email.
    • sendmail, postfix, qmail, exim (unix)
    • exchange (windows)
  • Message Transport System
    • protocol used by MTAs to transfer email host-to-host
    • Simple Mail Transfer Protocol
  • Message User Agent
    • protocol used to get email from servers client-to-host
    • post office protocols
    • internet message access protocols
At one time, every desk with a workstation had an email server, but this framework was not scalable. Wesley talked about Python's poplib, and about the SMTP interface in smtplib:
  1. connect
  2. login
  3. send email
  4. quit
then he challenged us to write our own POP and SMTP clients.

As we go to press, the code below, tailored specifically to work with Google's SMTP server, was tested to work on Windows 2000 & Vista, and Debian Linux 5.0 (Lenny):
def use_gmail_smtp(te, tffn, ttfs, subject, msg_body):
from smtplib import SMTP
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
SMTP_server = ''
username = 'your gmail handle'
passwd = 'your gmail password'
msg = MIMEMultipart()
msg['From'] = tffn
msg['To'] = ttfs
msg['Subject'] = subject
server = SMTP(SMTP_server, 587)
server.ehlo() # see note below for Python 2.5 and 2.6 users
ssl_connection_errors = server.starttls()
ehlo_connection_errors = server.ehlo()
server.login(username, passwd)
server.sendmail('tpc247', (te, ), msg.as_string())
A primer for the acronyms in the use_gmail_smtp() argument list:
  1. te is the target_email, the email address where you want the message to arrive
  2. tffn is the_from_field_name, what you want the user to see in the From: field's name portion. To tffn, Gmail will append <>
  3. ttfs is the_to_field_string, what you want the user to see in the To: field, usually in the format:
    "Your Name <>"
A previous incarnation of the code behaved correctly on Python 2.5, but strangely enough, not on Python 2.6, because it called:
ssl_connection_errors = server.starttls()
resulting in the error:
Traceback (most recent call last):
File "", line 11, in use_gmail_smtp
ssl_connection_errors = send_server.starttls()
File "C:\Python26\lib\", line 611, in starttls
SMTPException: STARTTLS extension not supported by server.
It's a mystery to me why this error is only on the aforementioned version of Python, but switching the call out was the answer.

I tested my script on 3 different operating systems, each running at least two different versions of Python:
  • Windows
    • 2000: Python 2.6.1, 2.6.2
    • Vista: Python 2.5.4, 2.6.1, 2.6.2
  • Debian Linux 5.0 Lenny: Python 2.5.2, 2.6.1, 2.6.2
Other notes: when installing Python 2.6.1 on Windows Vista, for the first time ever I saw:
Please wait while the installer finishes
determining your disk space requirements
and then the installation would stall and never complete. The workaround is to open a command prompt, and type:
msiexec.exe -package <mypackage.msi> –qr

For you who would like to use gmail to send emails that look like they come from your workplace, you can now do so without the "on behalf of" that make you look less than authentic.


Thursday, August 20, 2009

Spanish Lesson 1, or Leccion de Español Uno

Thanks to Tim Goodman, two of my favorite television shows are Breaking Bad, and Dexter. Both take place in cities with a relatively large percentage of native Spanish speakers: Albuquerque, New Mexico and Miami, Florida. As someone who has made a living with associates who grew up speaking a different language, knowing the native tongue of your coworkers can serve as a social lubricant and engender a degree of respect and consideration from your bilingual colleagues when it comes time for a promotion, or, who to invite to that party. I was fortunate to walk into my first Spanish class at a young age, in my preteen years, and with the teacher talking very fast in her foreign language (then immediately in English to translate). From that point forth it was almost a settled matter: two years of Spanish in high school, the community college summer course in conversational Spanish, and two summer trips in Mexico to help erect a church in a small village near the border, were foundational events that made me want to build on that knowledge and spend time figuring out and understanding what exactly people were saying (sometimes about me).

For your benefit and mine, I have transcribed and translated two pieces of content where the characters are talking rapidly in a foreign language:

In this scene, Hank has just been promoted to a Drug Enforcement Administration tri-state task force based in Texas near the Mexican border. The three speaking roles are, in order of speech, Dean Norris as Hank, Todd Terry as the SAC (Special Agent in Charge), and J.D. Garfield as Vanco:

voy atravesar sobre esos bastardos como caca pasando pato, fijate (or fija te).
I'm going to run through those bastards like feces through a duck, you watch.

The two leads in this scene are Jimmy Smits as Miguel Prado (seated) and Michael C. Hall as Dexter Morgan. The shopkeeper Francisco is played by Rudy Quintanilla.

Olvida te, que ese pide lo de siempre
Forget it, that one always orders the same thing.

One might substitute "that one" with "he" but doing that wouldn't tell you the whole story. In context, the shopkeeper understands that Miguel is talking about Dexter, but the shopkeeper also would have known that in Spanish, he is el, but you use ese, meaning that one, when you point to someone, or indicate a person, you don't particularly care for.

Thanks to the lovely and pregnant custodian Sandra Barron, and to mi bibliotecaria preferida Patricia Medina, for the respective transcription and translation. I should also mention David Montgomery for the heads up about Scott Aaronson and the following piece of wisdom:
Why do native speakers of the language you’re studying talk too fast for you to understand them? Because otherwise, they could talk faster and still understand each other.

Saturday, August 15, 2009

Isabella at Disneyland, post 9/11

On July 21 and 22, my sister and brother-in-law took a trip to celebrate my beautiful niece turning the terrible 2. At the Magic Kingdom, the little princess explored a potential career as a freedom fighter in the war on terror.

21JUL2009TUE Disneyland
Marine Corps sniper (223rd Battalion, Mickey Mouse company) Monica Wickman-Mroch spots a possible jihadist and instructs Isabella, private-in-training, on the finer points of target shooting:
  1. Breathe in
  2. Breathe out
  3. Aim
  4. Squeeze
22JUL2009WED Dumpling House in Artesia, 1 of 4
The next day, at Dumpling House in Artesia, Monica Wickman-Mroch mulls a run for her assault rifle (not pictured) as my niece, in her dress blues, poses with my sister.

22JUL2009WED Dumpling House in Artesia, 2 of 4
Isabella discovers an affinity for this thing called 'cake'. Seconds before, she performed a visual sweep of the table for any sugar packets, her favorite IED (improvised entertainment device).

22JUL2009WED Dumpling House in Artesia, 3 of 4
Light, fluffy & sweet (don't think Isabella wouldn't hesitate taking your eye out with that fork!), cake is a refreshing change from the relentless battlefield stressors of people in costume, clowns, and tea cup rides.

22JUL2009WED Dumpling House in Artesia, 4 of 4
The life of a patriot can make a freedom fighter hungry for food and company, as evidenced in this photo, seated with (left to right) Monica Wickman-Mroch, brother-in-law Brian Moffat, my dad, step-mom & half-sister, and Walter Mroch.

Saturday, August 8, 2009

how to host and serve your audio files on Youtube

I recently created this video:


It's not really a video per se, more of a slide-show with narration. As we go to press, Youtube does not allow uploading of audio files, even if your song, radio program, or interview recording is in mp3, wma or wav file format. If you have aural content you'd like to share with members of the general public, and you'd like to use Youtube, you might as well have hit a dead end. However, there is a way around the restriction so that one of the most popular video sharing services can host and serve your file:
create a video with your audio file content as the soundtrack.
It's easier than it sounds. You'll need uMusic (free open-source software):
uMusic 0.3

If you have a set of photographs or images, and an audio file, you have all you need for uMusic to create a Windows Media Video (wmv) file which you upload to Youtube. However, to prepare your images for public consumption, you may want to give proper attribution to the owners of the photos, or enhance your brand by imprinting a visible watermark that lets users know about you. Also, your audio file may contain commercials, announcements, or something unrelated to what your audience may want to hear, so you'd like to edit your content to remove unwanted blocks of time and extract only what you desire. In either case, you'll need the following free tools, respectively:How to insert text into an image in Irfanview

First open the image in Irfanview
  1. Select an area, an outline rectangle, wherein your text will sit
  2. Select 'Edit'/'Insert text into selection'
  3. Type in your text
  4. 'Choose Font' and determine the proper font face, size and colorIrfanview_Choose Font
The negative about using this method is Irfanview doesn't give you a way to undo the text you insert into the outline rectangle. If you don't like the result, you have to start over at step 1.

If you're new to Audacity, we showed earlier how to use Audacity to edit an audio file


Thursday, August 6, 2009

how to use Audacity to edit an audio file

This tutorial covers how to use Audacity 1.3 beta, free open-source software, to edit an audio file. Because of patent restrictions, Audacity does not come with the ability to save your audio file as an MP3. After you install Audacity, make sure you install the free LAME encoder to enable Audacity to export to the MP3 digital audio encoding format.


Our goal is to extract only desired content from a larger audio file and save it all into a smaller audio clip. Let's say we desire audio content that is concerned with a single topic, in this case, who is at fault when a bicyclist collides with a car door:

The soundtrack to the video above is a clip that actually consists of two segments. Each segment consists of multiple smaller pieces. The first of two segments involves a caller named Sunny, the second a caller named Jim. Each segment is comprised of pieces that were first selected, roughly around two predetermined times denoting beginning and end, then copied into a new work area, where they were then sculpted (i.e., extraneous slices removed). Finally the pieces were ready to be set aside, each prepared for the task of joining into a segment. The segments were then merged into a clip, following the same process.

Here we begin with an hour-long audio file recently imported into Audacity:
Audacity_recently imported audio file
At this point I should note during this tutorial there will be prodigious use within Audacity of:
  • the keyboard space bar
  • the mouse left button
to determine during playback where the desired content starts and stops. Once you load the audio file into Audacity, click anywhere within the waveform of the file, and depress the left-click button to indicate where you want to start play. Press the space bar to start and stop.

To edit the audio content, we first make the rough cuts, then the fine cuts. When you've become well-practiced with Audacity, after this tutorial, you can skip the rough cuts, and use the zoom feature to make fine cuts from, say, an hour-long audio file. For now, since we're just getting acquainted with Audacity, we don't want to overwhelm the new user with zooming in & out and dragging the mouse across multiple views of the audio file.

Let's say that, from what my eyes and ears perceive, the first piece of our Sunny segment is from 11:32 to 16:39. Once you've identified the approximate beginning and stop points, the rough boundaries, train your eyes on the "Selection Start" and "End" boxes next to 'Audio Position':
Audacity_selected segment of audio file
Audacity_select start, end and audio position boxes
Note that if you click on the 'Length' radio button, the 'Selection End' box becomes a 'Length of Selection' box. As luck would have it, my mouse landed just 2 seconds before the estimated beginning of our desired content, and we make sure to end our selection on or slightly after what our ears had earlier perceived to be the stop of the track. Now that we have our first rough piece of our desired content segment, our next step involves using the analogy of finding a clean table or workspace to put our pieces of desired content for the purposes of sculpture and assembly into a single segment. Click on File/New and open a brand new Audacity window (for you users of audio editing software Soundforge, this is akin to creating a new stage). Now paste your copied audio content into the empty window. Notice that since the audio content in question is much shorter than an hour, you can easily select the slices you want to throw away, and delete them.

To wrap up this tutorial's editing portion, repeat the following steps for the other pieces of the segments:
  1. Open your audio content file and play it
  2. Note to yourself, or better yet, write down the start and end boundaries of your desired piece of content. Be ready with a pen and piece of paper to record where the start and stop points are.
  3. Click on File/New to create an Audacity window that you have purposed for sculpting and joining pieces of a segment
  4. Select, from the primary Audacity window, the rough piece of desired content; it's ok if you're off by a few seconds. Paste the copied content into the new Audacity window.
  5. Carefully sculpt the rough piece. Remove extraneous slices, such as dead air and fragments of unwanted content.
Once the pieces of audio content have been prepared, our concern is joining them into a larger segment. Go to your secondary Audacity window, and follow these steps from the Audacity website to splice two files together:
  1. Select the second file by clicking on its label (the area around the mute/solo buttons).
  2. Choose “Find Zero Crossings” from the Edit menu.
  3. Choose “Cut” from the Edit menu.
  4. Place the cursor by clicking in the first track, after the end of the audio.
  5. Choose “Paste” from the Edit menu.

At some point you might select some content in your audio file, and see now you're not able to cut, copy, paste or delete:
Audacity edit options not enabled
You notice the edit toolbar is not functional and will say "I'm not able to edit" or "Audacity won't let me edit", and ask "is the edit toolbar not enabled ?", "why can't I edit ?", or "how do I enable the edit toolbar ?". All good questions, seeing as how the options are grayed out, so you're unable to edit your audio file. There's a simple solution: make sure the playback is stopped.

Now that you have an audio file containing only what you want and need, you may like to know how to host and serve your audio files on Youtube.

Tuesday, July 28, 2009

while on my bike, I recently hit a car door

On a Tuesday morning, May 12, 2009, around 7am, I was bicycling on this stretch of road, just leaving North Oakland and crossing into South Berkeley:

View Larger Map

Traveling at a high rate of speed, I was on the right side of the road northbound on Martin Luther King Jr Way, having just passed Angel Light Books & Gifts. I crossed in front of the fenced playground area of Shelton's Primary Education Center (Since I wrote this, Shelton's moved, and the building is now occupied by American International Montessori) when suddenly a car door flipped open directly in front of me. My right shoulder caught the top of the door corner and my right pedal the edge of the lower door, and I was thrown off my bike, landing on my back in the middle of the street. After I heard a female voice ask if I was alright, I got up, dusted myself off, and took notice of the driver standing before me, dressed for an early summer morning and ready for work, possibly at the very school we had collided in front of; on the other side of the vehicle stood another woman, who may have been a passenger, dressed similarly and carrying her purse and some papers. I made sure I was ok, asked the driver if she was ok, and picked up my bike to inspect for damage. The African American female driver seemed genuinely concerned about my well-being, and I noticed that the tip of the lower metal edge of her car door was bent and protruding, having clearly been struck by something, which I later surmised had been the right pedal of my bike, the force of which had spun me around and thrown me out onto the street on my back. I seemed to be in one piece, though my bike had some minor damage; I was still in a hurry to get to Kinko's in downtown Berkeley to print out a document before riding into work. I felt embarrassed for not being more attentive to the parked vehicle immediately ahead of me and to my right, whether there were any occupants to worry about, and I remarked to the woman that I was ok, but that the repair to her car door would cost a lot more than the repair to my bike. I was operating under the assumption we were both at fault for the incident, and given the possibility in the back of my mind I might be held liable for any damages to the woman's car door as a result of my haste, I didn't see the need to exchange information with the driver. I remarked to both ladies that it was an interesting way to start the day, got back on my bike and rode off, noticing the slight wobble in my now out-of-true front wheel.

Over the next two weeks I saw a noticeable dark bruise appear on the upper part of my right chest where it had caught the car door's corner and felt severe pain in my right shoulder area whenever I picked up my bike and lifted it, or made certain motions with my right arm; luckily for me, gradually the sharpness lessened and over time the ache in my shoulder disappeared.

On Saturday morning, July 18, 2009 at 11:15am I was at Missing Link's repair shop to get my wheel trued. I asked the bike mechanic Bill about his summer plans for his two kids, then described the incident that led to my being in his shop, and was surprised to hear from him that the woman was almost surely responsible for the incident, that a driver is almost always at fault for a bicyclist being "doored". This idea was reinforced when on Thursday, July 23, 2009 I was listening to my favorite radio personality Len Tillem's noon to 1pm call-in radio show. A woman named Sunny called saying her daughter, who was driving, had opened her car door and a female cyclist had collided with the door, breaking her wrist. Sunny claimed the bicycle rider, a woman in her early 40s, caused the accident and so was liable for any damages resulting from the impact of the bicycle against the car door when her daughter opened it. Sunny explained her rationale for defending her daughter as not motivated by the expected protective instinct a mother might have for her child, but simply that the woman on her bike was riding too close to the vehicles. In her daughter's defense, Sunny, herself a cyclist, pointed out how some states have the door zone law, but in California there is unfortunately no such law, only a pending statute. Len seemed skeptical, saying Sunny's daughter, if she had just checked over her shoulder, would have seen the cyclist, and was in a better position than the woman on the bicycle to prevent the collision. Later, Jim, a retired California Highway Patrol officer, called in to confirm Len's initial assessment, saying that whenever a bicyclist hits a car door that opens into traffic, the person who opened the car door is at fault, quoting California Vehicle Code section 22517. In response to Sunny's rationale, Jim added that a bike rider is required to ride as close as possible to the right side of the roadway:

Thursday, July 23, 2009

determine your prorated share of the utility bill

Americans are scared, for these are lean and mean times, for anyone who has read the news, though we may be encouraged by signs that the economy has hit bottom and the downturn could be due for an upswing. With experts saying the unemployment rate is likely to go up past 10% before companies start hiring again, the sheer number of unemployed Americans in the middle of a jobs recession will likely provide the necessary heat to make people change their debt-accumulating, hypomanic ways. What I mean by "necessary heat" is, in a recent Lehrer News Hour segment analyzing the latest political events (concerning David Souter's retirement and Arlen Specter changing party affiliation), David Brooks offers a profound insight that, after turning it over in my head, I would tend to agree with more than not:
You don't change when you see the light. You change when you feel the heat.

Because this economic slump may be severe and prolonged, an article on how Americans need to start consuming again makes the following points:
  • We've gone from an age of entitlement to an age of thrift.

  • the American population, continually infused with immigrants, has self-selected for hypomania, i.e., a tendency to action, an appetite for risk, an endless belief in human possibilities

Ever since I turned 19 and left home for college, I've lived with other people (and still do). This has not only expanded my social repertoire, but saves me a lot of money. In the spirit of the age of thrift, you, former sole occupant of the 1 bedroom or studio apartment, now may be in a shared housing situation, via Craigslist, living with one or more mates in a room, flat or house. When it comes time for roommates to divvy up the gas and electricity bill by figuring out who owes what, one of the more difficult tasks to settle may be how to fairly apportion the amount you owe, given that the day you move in may be after the day the billing period begins (or the day you move out before the date the billing period ends). In either case, you may not feel it's entirely fair to divide the gas & electricity bill, which accounts for energy usage in the unit, evenly among you and your fellow tenants under the lease, because then you would be liable for days when you could not possibly have drawn power from the grid or gas from the line. Now, courtesy of my former housemate Kimberly Scott (now Kimberly Lightholder), who provided this formula to me after a bit of trial and error, here's a simple and easy way for you to fairly prorate your share of the utilities (assuming, of course, that there are no other issues involved in the fair split, or prorating, of the monthly bill, such as one or more flatmates' constant use of a high energy consuming device, such as the central gas heater, or an electric heater, air conditioner, mini-refrigerator, grow lights, and/or aquarium):

The test for this formula is, if you add up the amount that each person is calculated to owe, for all residents, that should equal the amount in the electric & gas bill.
  1. ascertain the number of billing days in the billing period. Let's call this b. For example, if your billing period is from June 7 to July 8, b should be 32 days

  2. count the number of days you lived in the residence. Let's call this a.

  3. determine the number of total billing days. That is, add up the number of days each person lived in the unit, for all residents. For example, let's say 4 people were already residing in the 5 bedroom house you just moved into:

    total billing days = b + b + b + b + a

  4. divide the bill amount by the total billing days. The quotient let us call k. k is what you will multiply by the number of days you lived in the residence in order to arrive at your prorated share:

    amount of power bill
    -------------------------- = k
    total billing days

  5. k * a = your prorated share of the utility bill

Saturday, July 11, 2009

Freebase Hack Day

today was my third time in the offices of Metaweb, which operates freebase. 80 of us met on the 4th floor of a building off of Hawthorne Street in downtown San Francisco to learn how to interact with freebase, a database of structured data which currently has 6 million topics (a topic is a thing in Freebase). Besides being a database, Freebase is also an API and development platform. In other words, you can use freebase as a source of information for your software, say, Microsoft Excel or Google Spreadsheet or MySQL database, but you can also issue commands to freebase and it will behave in a predictable way, and you can use freebase to create new kinds of software. Any given topic in freebase has one or more types assigned to it, e.g., Queen Latifah, when considered as a topic on freebase, has at least 3 types assigned to her: person, musical artist, film actor. A type in freebase has one or more properties, e.g., the musical artist type has at least 3 properties: genre, instruments played, music recorded.

Thuon Chen with Kirrily Robert, Freebase Community Director

When one lands on freebase, there is so much to take in it may seem overwhelming at first, and it took some time for me to wrap my head around it. When freebase finally made sense was when I spoke with a Metaweb employee, Alex Botero-Lowry, about our mutual interest. At the beginning of Hack Day, Alex announced in front of the group he was working on television data, specifically liberating the extraction of said data. My curiosity piqued, I approached Alex and said I believe we are living in the Golden Age of television. One of my favorite writers, Tim Goodman, expounds beautifully on the sheer number of high-quality, well written and expertly produced recent television programs in a very compelling piece he put together containing lists of exceptional series sorted into categories:


So if we wanted, we could ask Freebase to give us the list of episodes for a given tv program, sorted primarily by season number, secondarily by episode number:

  1. go to

  2. now we want to query the vast resources of freebase (imagine yourself face-to-face with a large machine with blinking lights). The most important things to know at this point are:
    1. the position of the blinking cursor within the query data structure, i.e., [{ }]
    2. the 'Tab' key
    If we wanted all the episodes for a given tv program, we would simply type in:
    "type": "/tv/tv_program",
    "name": "The Wire",
    "episodes" : [{}]
    If you click within the data structure for episode, [{ }], i.e., click in the area between the curly braces inside the square brackets, and press the 'Tab' key, you will get a set of properties for 'episodes', and you can find out such information as the person who was credited as the writer or director.
    freebase query editor

Just to give you a sense of how there's more than one way to get the same or a similar result in freebase, the following are two paths to our destination: for a given tv program, get all the episodes, in ascending order, categorized by season, in ascending order. Nick and Jason at Metaweb helped me formulate my first query, and the latter query is courtesy of Alex Botero-Lowry:
"type": "/tv/tv_program",
"name": "the sopranos",
"episodes": [{
"episode_number": null,
"season_number": null,
"sort": ["season_number", "episode_number"]
"name": "30 rock",
"type": "/tv/tv_program",
"seasons": [{
"id": null,
"name": null,
"season_number": null,
"sort": "season_number",
"episodes": [{
"name": null,
"id": null,
"episode_number": null,
"sort": "episode_number"

Tuesday, July 7, 2009

taking the police at their word

Confirmation hearings for Sonia Sotomayor's Supreme Court nomination begin next week, and I wanted to share an article on the Obama nominee's powers of persuasion in a previous ruling that hinges on her taking the police at their word, then asks how broad are the grounds for arrest; Sotomayor's ruling nullified the decision of a jury that saw a process rife with police abuse of power:

A semi-truck breaks down on an expressway, with about 4 feet of the trailer jutting out into the right-hand lane. Worried about causing an accident, the truck driver runs almost a mile to the nearest gas station, which has a payphone with an extra long cord attached to the receiver that, at the time, was being used by a man sitting inside his car.

The truck driver claims he ran up and told the man there was an emergency because his truck was jutting out onto the expressway. The man told him to find another phone. The truck driver repeats it's an emergency, the man swears at the truck driver, the truck driver hangs up the phone, and soon the man in the car (who turns out to be an off-duty police officer) has a gun pointed at the back of the truck driver's head. Eventually another officer formally arrests the truck driver.

The man in the car claims he was asked for the phone by the truck driver, but there was never any mention of an emergency, and that the truck driver hit him in the face with the receiver, at which point the off-duty police officer pulled out his gun, and made the arrest.


Thursday, July 2, 2009

where is journalism going ?

I find myself habitually navigating to one website ( for local breaking news and weather forecasts. Other fountains that I drink deeply from are The New York Times, Slate and The Economist. With the latter three, the content is more like steak and requires sitting down and more leisurely-paced chewing than the former, which is a bit like a quick bite of pesto and olive tapenade on toasted sourdough over the kitchen counter. Like most of you, I don't pay for what I read, and if you're like me, you feel a pang of guilt when reading of the troubles in the newspaper industry. Journalists need to eat, and the good ones usually need to go to college in order to speak, read and write well. Food requires money, and who will pay these journalists for their sweat and labor at the sites I mention if we all contribute nary a red cent for the carefully prepared content that we consume ? This was the question I struggled with as what a journalist friend said turned over in my head, specifically her lament that newspapers were "in a death spiral", with every single major national paper having "major, devastating layoffs".

After this sobering assessment, one would think newspapers really were going the way of the Neanderthal. To the contrary, Jack Shafer, Slate's editor at large, believes we may be entering the Golden Age of journalism. He compares what's going on now with the newspaper industry in 1938, when Mark Sullivan, a journalist, then 64, published his memoirs lamenting the state of his trade amidst all the upheaval caused by a new technology then coming into its own, the radio:
But just when you're ready to dismiss Sullivan as another doom and gloomer, carping about modern-era disappointments and disruptions, he zigs from the normal zag to find opportunity in the decline of newspapers. He writes:

Not only did the market for writing shrink. New means of expression, of conveying thought and facts and description and narrative, came into the world. …

I felt as if I were like one of those old monks, the scriveners, who continued to copy by hand long after printing had been invented. To young writers looking forward the lesson is as plain, and even more important, than to old writers looking backward. Learn the art of writing, of course, but learn also the art of the motion picture, and of the radio.


Friday, June 26, 2009

Michael Jackson is my Lord and Savior

For those who don't know, Michael Jackson's breakout moment came in 1983 when he performed at the Pasadena Civic Auditorium for the Motown 25: Yesterday, Today, Forever reunion. The moment the lights dimmed on his breathtaking solo performance, Michael Jackson was no longer just a multi-regional (not quite national) celebrity, but an international superstar, as well-known as Coca Cola, McDonald's, and Mickey Mouse the world over. No one had ever seen a person, let alone a scrawny young black man with a single white glove, move like that, sing like that, do that thing with his feet like that, and dance in a way that made you want to join him. Even though Michael was lip-sync'ing throughout the performance, it didn't matter, because the moment was his, and Michael Jackson was showing us the way:

On a personal note, I have actually suffered in the name of Michael Jackson. In grade school my parents enrolled me in a religious private school called Heritage Baptist Academy that to this day may still practice corporal punishment. Once a person in a position of authority determined you deserved to be punished, you were called as your classmates' eyes tracked you out of the classroom and into the principal's office, where usually one or two authority figures were waiting. You were told what you were being held to account for, that you were about to be spanked because the authority figure loved you, and then you had to stand, put your hands on the edge of a desk, bend slightly over, and wait for the adult, usually a teacher or someone in a position of authority, to swat you several times on your clothed buttocks with the flat surface of a large wooden paddle. Depending on who the authority figure was, the experience could be absolutely terrifying, or merely shameful. There was a teacher, Mr. Hilton, who we all suspected would smack your behind with the crack of a baseball bat because he was tall, strong, with glasses and hairy forearms, who proudly swatted his toddler daughter. Then you had to go back to class with a red face and watery eyes and try to make it through the day knowing everyone knew what had happened to you.

Well, one morning during recess I found myself trying to copy Michael Jackson's trademark moonwalk, and was spotted by a fellow student, who told an authority figure about my behavior. Soon I was called into the principal's office, and you know the rest of the story. As it was explained to me at the time, the figure of authority who was about to strike me was doing so because he loved me; Michael Jackson was a worldly figure, and moonwalking was dancing, and dancing is of the world, and since being worldly was a sure path to hell, and as Christians, in this world, we must behave as if we are not of the world, I would be punished for trying to be like Michael Jackson. Afterward, the authority figure prayed that God would teach me that the most dangerous way to be was like this worldly figure. In retrospect, it was probably good advice, since we all know Michael Jackson was reported to be involved in some very strange things, such as trying to buy the bones of the Elephant Man Joseph Merrick, hanging around with a chimp, sleeping with young kids in his bed, and trying to look like a white woman.

Thursday, June 25, 2009

yesterday I was laid off

so now I join the ranks of those without a corporate sponsor, the wretched masses yearning to breathe free in an air-conditioned cubicle. It's weird, when I had gainful employment, I felt bad for those who I expected would soon try to hit me up for a job. Now that I am one of the very same in-between jobs, I'm going to take this crisis-opportunity to build up my online references, so that when the economy does turn people will know me for something useful and, Lord willing, employable. One way to do this is to focus on what I do best. I have lots of experience using (installing, testing and submitting bugs for) statistical analysis software.

The following is my own personal take on installing SAS® 9.1.3 Service Pack 4 on Microsoft Windows Vista Home Premium. Apparently, as of today's date, June 25, 2009, there is no published solution on the web about how to get these two working together. SAS effectively tells you that it's impossible:

SAS does NOT support Windows Vista 32-bit Home Editions:
  • Premium
  • Basic

but, as No Limit Soldier Master P says, I got the hook-up !

For those who haven't even installed SAS 9.1.3 yet, follow this guide:

Of course, along with the SAS software you will also need a SAS license in text file format. Fortunately for me, this was provided by my educational institution, though the license you have may be out-of-date (for me, the license expired in 2008), in which case you'll see the following error:

The current date is past the final expiration date


SAS addresses this in their documentation; you simply need to "Renew SAS Software", which is a program that comes with the freshly installed SAS on your computer. Unfortunately, like yours truly, you are one of the losers running a version of Vista that isn't supported by SAS 9.1.x. What to do ? At this point you'd see the following error (or something like it):

Error: Update lock is not available, lock held by another process

First, you'd think that the words "Home Premium" in Windows Vista meant you didn't have to see or deal with B.S. like SAS not being supported. Then you turn that loser frown upside down - while thanking your lucky stars I was given the pink slip ("walking papers" as I like to call it) by my employer yesterday - because you can make everything right with the following procedure:

  1. right-click on "Renew SAS Software"
  2. select "Run as administrator"
For me, that seemed to be the piece I was missing.

This first blog post is dedicated to my friends Raymond Barglow and Janet Somers, my brother-in-law Brian Moffat, and in memory of all those recently unemployed or looking for work. Congratulations to my friend JJ Behrens on recently getting hired. On a sad note, my heart goes out to the memory of Michael Jackson, who died before I could publish this blog post, and whose much anticipated comeback will not be.