May 2008 Archives

National spelling bee sample test

| | No TrackBacks

My national spelling bee effort. Apparently, this would have been a really good score.

Your score is 25. Congratulations! With a score like that, you could have qualified for the Quarterfinals.

WordMy Spelling
beignetvenier
pinyinpinyin
illegibleillegible
Caribbeancaribbean
homagehomage
cygnetcygnet
harassmentharassment
loquacityloquacity
Pyrrhicpyrrhic
intermittenceintermittence
eideticeidetic
tremolotremolo
Appaloosaappaloosa
epilepsyepilepsy
mustardmustard
altogetheraltogether
avariceavarice
misciblemiscible
syringesyringe
galimatiasgallamadeous
cacoetheskakaouithes
nonpareilnonpareil
midriffmidriff
sinecuresinecure
guernseyguernsey
yetiyeti

Cheat sheets

| | No TrackBacks

Cheat Sheet: All Cheat Sheets in one page

The Manual.su's project. All cheat sheets, round-ups, quick reference cards, quick reference guides and quick reference sheets in one page. The only one you need. Cheat sheets on all things computer:

  • languages (C#, python, Java, MatLab, Perl, ruby, HTML, CSS),
  • operating Systems (Debian, Linux, Solaris, Windows),
  • search engines (google, Yahoo),
  • web browsers (FireFox, Internet Explorer),
  • SQL (Sybase, SQL Server, Oracle, MySQL),
  • email (GMail, Yahoo mail),
  • programs (PhotoShop, vi, emacs).

Trackback spam

| | No TrackBacks

Wow, I had no idea the trackback spam situation was so bad. I decided to check the comments on my site today: no comments. I checked my trackbacks: 555 trackbacks, 554 of them automatically marked as spam. And the other one was spam, too.

In checking the sources, I found one stand out website for sourcing spam links to my site: weebly.com. The site purports to be an easy-to-use blog provider for the non-technical person, but that's not even the start of the story. Weebly.com appears to be the favored starting point of porn spammers. Here are the blogs at weebly that deal with only a specialized porn topic: seven sites all using this specific phrase. Most other blog sites have no hits on this phrase. Looks to me as if this is the preferred location for trackback spammers.

John Cleese's apology from A Fish Called Wanda

| | No TrackBacks

This is what a real apology should sound like. Of course, Otto has the advantage here of hanging Archie out a window by his ankles at the time, and not everyone will have this edge when requesting an apology.

Archie: All right, all right, I apologize.

Otto: You're really sorry?

Archie: I'm really, really, sorry. I apologize unreservedly.

Otto: You take it back?

Archie: I do, I offer a complete and utter retraction. The imputation was totally without basis in fact, and was in no way fair comment, and was motivated purely by malice. And I deeply regret any distress that my comments may have caused you, or your family, and I hereby undertake not to repeat any such slander at any time in the future.

Otto: Ok.

An amazing presentation of data

You've never seen data presented like this. With the drama and urgency of a sportscaster, statistics guru Hans Rosling debunks myths about the so-called "developing world."

Dev 102

| | No TrackBacks

I came across this website the other day. It has a fair amount of interesting programming information, mostly about C# and .NET development.

There are a couple of links on Firefox plugins ([Five more FireFox plugins...], [Five FireFox plugins...]) that I liked:

  1. [GreaseMonkey]
    Allows you to customize the way a webpage displays using small bits of JavaScript.

  2. [ColorZilla]
    Advanced Eyedropper, ColorPicker, Page Zoomer and other colorful goodies

  3. [Poster]
    A developer tool for interacting with web services and other web resources that lets you make HTTP requests, set the entity body, and content type. This allows you to interact with web services and inspect the results.

  4. [JavaScript Debugger]
    Venkman is the code name for Mozilla's JavaScript Debugger. Venkman aims to provide a powerful JavaScript debugging environment for Mozilla based browsers.

  5. [X-Ray]
    See the tags on a page without viewing the sourcecode.

  6. [CSSMate]
    Inline CSS Editing Evolved.

  7. [FireShot]
    FireShot is a Firefox extension that creates screenshots of web pages. Unlike other extensions, this plugin provides a set of editing and annotation tools, which let users quickly modify captures and insert text and graphical annotations.

  8. [Web Developer]
    Adds a menu and a toolbar with various web developer tools.

  9. [ViewSourceWith]
    Open page source, CSS and JS files, modify content, view server side pages, etc.

  10. [FireBug]
    Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

I can't admit to having used them all, partly because I upgraded to FireFox 3.0 this week and very few of these plugins are compatible -- only FireShot and ViewSourceWIth are. I am most excited to add FireShot and FireBug. I'll have to wait for the FF 3.0 version of the latter.

[2008-06-15: Firebug for Firefox 3.0 has finally been released.]

I also really liked a couple of other short articles:

Wi-Fi Detector Shirt

| | No TrackBacks

Just when you realized that you could not live without a t-shirt with a built-in graphic equalizer that responds to sound comes the next geek t-shirt: one that detects 802.11 wi-fi signals and displays the strength of the signal.

[Show-off t-shirt from x-treme geek] $29.95
[Wi-Fi detector t-shirt from ThinkGeek] $29.99

US State Quarters

| | No TrackBacks

I'm collecting the US state quarters. I am missing only three two quarters from the Philadelphia mint: Arizona, Alaska, and Hawaii. The Denver mint is a different story. I am missing these:

Missing Denver mint quarters
YearStates
1999 Pennsylvania
2001 Rhode Island
2003 Illinois, Missouri
2004 Michigan, Iowa, Wisconsin
2005 California, Oregon, Kansas
2007 Montana, Wyoming
2008 New Mexico, Arizona, Alaska, Hawaii

In New York, the quarters in circulation are overwhelmingly from Philadelphia. By my estimate, the Philadelphia coins are 90% of the state quarters and Denver are 10%, so collecting Denver coins is much harder.

I have extras of these Philadelphia quarters available for trading: Iowa, Illinois, Pennsylvania, Kansas, and New Mexico. I've noticed that these coins are encountered less frequently than other Philadelphia mint coins. Please contact me if you are interested in a trade for a coin I don't have.



2008-06-04: found WY, MT, PA, MO, and KS.




2008-06-09: traded for IL, IA, and RI. I now need only Denver mint coins for Michigan, Wisconsin, New Mexico, Arizona, Alaska, and Hawaii plus Philadelphia mint coins of Arizona, Alaska, and Hawaii.




2008-07-01: traded for Michigan and Wisconsin. I now need only Denver mint coins for New Mexico, Arizona, Alaska, and Hawaii plus Philadelphia mint coins of Arizona, Alaska, and Hawaii.




2008-07-24: traded for Arizona. I now need only Denver mint coins for New Mexico, Alaska, and Hawaii plus Philadelphia mint coins of Arizona, Alaska, and Hawaii.




2008-07-25: I got Arizona-P in my change. I now need only Denver mint coins for New Mexico, Alaska, and Hawaii plus Philadelphia mint coins of Alaska and Hawaii.




2009-02-09: Somewhere along the line, I got Alaska and Hawaii Philadelphia coins. I need Alaska-D, Hawaii-D, and New Mexico-D to complete the collection.

Topical NYC links

| | No TrackBacks

Racing the Planet

| | No TrackBacks

So Lori is in China and Mongolia as a medical volunteer for the Racing the Planet event, Gobi March, which is a "seven-day, six-stage, 250-kilometer footrace across the Gobi Desert of China." The race takes place in Xinjiang Uygur province, 4000 kilometers west of Beijing. The race site is in the extreme northwest of China, close to Kazakhstan, Kyrgyzstan, Tajikistan, and Pakistan.

Father Ted clips

| | No TrackBacks

Another page with associated sounds from my previous website. Not everyone's cup of tea, but I miss Father Ted.

The lottery project

| | No TrackBacks

Another project I did several years ago that deserves resurrection is the Lottery Project, in which I make an estimate of the revenue from a single jackpot of the MegaMillions lottery.

Pretty code

| | No TrackBacks

Thanks to several google-translated Japanese Movable Type blog entries [makotokw, kazuno, and tadateto], I've finally figured out how to hack MT to get python code pretty-printed. (To read these Japanese articles, I recommend searching using google and then pressing Translate this page.) The code is downloaded from google and the original idea was from Thomas Guest.

To get this to work, you have to do four things:

  1. Add google's prettify.css stylesheet to your header page template
    <link rel="stylesheet" href="/mt-static/css/prettify.css" type="text/css" />
  2. Add google's prettify.js JavaScript to you header page template
    <script type="text/javascript" src="/mt-static/js/prettify.js"> </script>
  3. Get your body.onload to call prettyPrint()
    <body class="mt-main-index layout-wtt" onload="prettyPrint();">
  4. Mark the sections that you want pretty-printed
    <pre class="prettyprint">

The third step is the most involved. You have to change three templates:

  1. Page
    <MTSetVar name="body_onload" value="prettyPrint();">
    <MTIfCommentsAccepted>
        <$MTSetVar name="body_onload" value="prettyPrint();individualArchivesOnLoad(commenter_name)"$>
    </MTIfCommentsAccepted>
  2. Entry
    <MTSetVar name="body_onload" value="prettyPrint();">
    <MTIfCommentsAccepted><
        $MTSetVar name="body_onload" value="prettyPrint();individualArchivesOnLoad(commenter_name)"$>
    </MTIfCommentsAccepted>
    
  3. Comment Preview
    <MTSetVar name="body_onload" value="prettyPrint();individualArchivesOnLoad(commenter_name)">
    



2008-06-27: Did I say three templates? I meant five. Here are two more templates to change:

  1. Search results
    <MTSetVar name="body_onload" value="prettyPrint();">
    
  2. Archive index
    <MTSetVar name="body_onload" value="prettyPrint();">
    

RefDesk

| | No TrackBacks

RefDesk is a phenomenal collection of links to every imaginable sort of reference work:

  • google front-ends
  • dictionaries
  • encyclopedias
  • news sources
  • news photos
  • news videos
  • business and people searches
  • everything else

It is an improbably large page of links categorized to be useful. Via [ aldaily ]

Movable Type and Webhosting4life.com

| | No TrackBacks

If you are using Movable Type and using WebHosting4Life.com as your ISP, you will not be able to get comments and trackbacks to work until you turn off the WebHosting4Life setting, Security Guard. If, whenever you post a comment on your blog, you get this error message:

Webhost4life Application Firewall Alert

Your request triggered an alert! If you feel that you have received this page in error, please contact the administrator of this web site.

Then you need to do this:

  1. Login to WebHosting4Life.com
  2. Go to Security
  3. Select Security Guard
  4. Set to OFF

It took me three weeks of googling this before I put in the system request and got this fixed. I hope you find this posting sooner.

The Secret Science of Price and Volume

| | No TrackBacks

The Secret Science of Price and Volume: Techniques for Spotting Market Trends, Hot Sectors, and the Best Stocks is yet another book on trading that I came across at Amazon. I'm familiar with looking at price and volume and I've seen top-down methods of stock selection, but I haven't seen a really integrated method. In particular, I haven't seen something that gives a good idea of where the market is heading, and that's one of the things this method relies on:

  • Gauge the sentiment of a market to determine if the trend is bullish or bearish, and whether a possible high or low is nearby
  • Evaluate breadth, volume, and momentum in order to identify triggers to enter the market
  • Find the best performing sectors that are aligned with the market
  • Select the strongest stocks within those sectors

Sell & Sell Short

| | No TrackBacks

I saw Sell & Sell Short at Barnes and Noble the other day. Naturally, I returned home and ordered it from Amazon.

I've shorted a couple of times, but I think that I have to do it more often to make money in all markets. There aren't a lot of good books out there on shorting, so I am looking forward to working through this.

Here are some topics covered in the book:

  • How to control risk by linking the placement of your protective stop with your money management and position size
  • Where not to put your protective stops
  • Why using moving averages as profit targets works well in the early stages of an upmove
  • Why channels or envelopes are better targets when you are riding a trending stock
  • How to use support/resistance areas for profit targets and stop losses in long-term position trades
  • How to adjust your targets when market conditions change or your stock blows through the initial profit target

NYC Ultimate Frisbee groups on Yahoo

| | No TrackBacks

Some Ultimate Frisbee Yahoo groups I subscribe to. NYC-centric.

[nycpul]
[nograssforyou]

Technical Yahoo groups

| | No TrackBacks

Here are a couple of technical groups I subscribe to:

[AltDotNet]
[win_tech_off_topic]

Money Flow Index and other technical indicators

| | No TrackBacks

The descriptions of technical analysis algorithms are a bit annoying. They are written to calculate a single point, assuming a programming model that is non-vectorized. I really don't get why the algorithms are so poorly described.

Take this description of Money Flow Index as an example.

First off, this:

MoneyFlowIndex = 100 - (100 / (1 + MoneyRatio))

is the same as this:

MoneyFlowIndex = 100 * PositiveMoneyFlow /  (PositiveMoneyFlow + NegativeMoneyFlow)

or even:

MoneyFlowIndex = 100 * PositiveMoneyFlow / TotalMoneyFlow

Now we have a formula which works even when NegativeMoneyFlow is zero.

We have just two concepts, PositiveMoneyFlow and TotalMoneyFlow:

pmf = sum(mfi for mfi, reti in zip(mf, returns) if reti > 0)
tmf = sum(mf)
MoneyFlowIndex = pmf / tmf

where:

typ = [ (p.high + p.low + p.close) / 3 for p in prices ]
vol = [ p.volume for p in prices ]
returns = [ (typ[i] - typ[i-1]) / typ[i-1] 
    for i in range(1, len(typ)) ]

Okay, we turned a price series into typical prices, created daily returns and money flows from the typical prices, produced the positive money flow and total money flow, and finally got the money flow index. What did it buy us to do it with series like this?

Lots. The original algorithm totally glosses over the fact that we don't want a single money flow index -- we want a time series of money flow indexes. All of the basic series are viewed through a window, and windowing like this makes the basic algorithm really inefficient. The Positive Money Flow for the range 0..n differs in only two places from the range 1..n+1 (pmf[0] drops and pmf[n+1] is added) but a naive implementation will sum the series as if there were no overlap. To do this properly, we need series that have partial sums.

If you want to add up the m-sized windows on data of size n, you can optimize by creating a series that is the running total of the data seen so far and subtracting element[x] from element[x+m] to get the x'th window. You will iterate from 0 to n-m inclusive, giving you n-m+1 windows of size m. Here is how you make your running total:

def runningTotal(series) :
    result, s = [0], 0
    for ss in series :
        s += ss
        result.append(s)
    return result

Then we can write a summedSeries() function:

def summedSeries (series, length) :
    s = runningTotal(series)
    for i in xrange(len(s) - length) :
        yield s[i + length] - s[i]

and rewrite the Money Flow Index function like this:

pmf = ((mfi if reti > 0 else 0) 
    for mfi, reti in zip(mf, returns) )
return [ 100.0 * pos/tot for pos, tot in 
    zip(summedSeries(pmf, n), summedSeries(mf, n)) ]

Now we have an optimized function that works on price and volume time series and returns a Money Flow Index time series. And once you get your head around python, it even feels right.

[ mfi.py ] [ msft.csv ]

Technical analysis library

| | No TrackBacks

I had a brief look at the C++ source for TA-Lib: Technical Analysis Library today. It's an open source project I mentioned the other day. It may well be good code, but reading through it is really hard sledding. It's evidently all machine-generated, and I can't work out where the source is. (If I have the choice of reading machine-generated C++ or the source, I'll choose the source.)

But it's not a dead loss. The documentation on the associated site is pretty strong and gives good references. In particular, there are links to FM Labs, and I like the descriptions given of TA algorithms there.

I'm also intrigued by the Technical Analysis Programmer's Toolkit. I'll download a demo and report back on its suitability.

More open source financial applications

| | No TrackBacks

Open source projects that do technical analysis, portfolio management, and FIX. See also [Open Source Trading Systems]

[TA-Lib: Technical Analysis Library]
Technical analysis library with indicators like ADX, MACD, RSI, Stochastic, TRIX... includes also candlestick pattern recognition. Useful for trading application developers using either Excel, .NET, Mono, Java, Perl or C/C++.

[QuickFIX]
QuickFIX is the world's first Open Source C++ FIX (Financial Information eXchange) engine, helping financial institutions easily integrate with each other.

[FIX4NET]
A 100% pure .NET Financial Information eXchange (FIX) protocol library. Includes a TCP/IP engine, messages (4.0/4.2/4.4), and message database.

[nFIX]
nFix is a 100% native .NET object orientated FIX (Financial Information eXchange) API and engine.

[OneUnified.GeneticProgramming]
A C# implementation of a Genetic Programming method for optimizing a financial trading strategy. Most code designed for use with SmartQuant's QD/OQ products, but key code can be extracted for use in other projects.

[PortfolioLib]
A free/open-source C++ library for financial portfolio management. At its core, it aims to represent a collection of financial instruments as defined by QuantLib, called a Portfolio.

[ScreenFire.Net Financial Charts]
ScreenFire.Net Financial Charts is a financial market charting API for the .Net framework. It is a sub-part of the TradeWeapon project here at sourceforge.net. It will focus on prividing financial market charts like OHLC, Candlestick charts and Scatter

Technical Analysis Using Multiple Timeframes

| | No TrackBacks

Last night, I bought this book. There are several very positive reviews of the book from Brett Steenbarger and Charles Kirk, two traders I really respect:

In Technical Analysis Using Multiple Timeframes, Brian Shannon takes the reader through the essentials of technical analysis and then illustrates how to integrate those into a coherent trading methodology. From the phases of stock movement to price/volume relationships and risk management, Brian brings his topics to life with concrete and practical illustrations and explanations. This is an excellent resource for all technically-oriented traders; anyone who has enjoyed Brian's video insights on the Alpha Trends blog will surely appreciate the way he synthesizes those lessons in this book.

Brett N. Steenbarger, Ph.D.

and

When Brian contacted me awhile back to read and provide a review of his new book Technical Analysis Using Multiple Timeframes, I couldn't have been more excited. Brian has been blogging about stocks for a long time and his video chart presentations are a unique offering that many find useful. His intense passion for the market and deep love of the game itself is evident in everything Brian does and shares with his readers.

In my opinion, Brian's book is an excellent resource because he is great instructor. Unlike many books on trading written by traders who frankly have a difficult time explaining their methods, Brian shows his skills by breaking down relatively complex ideas in a straightforward manner. Ultimately this makes his book particularly good for traders who are just starting out on the learning curve and those who've found other trading books too complex or difficult to implement in the real world.

Charles Kirk

I hadn't heard of Brian Shannon before but I am really looking forward to getting my hands on this book.

Financial industry publications

| | No TrackBacks

All 120 Crayon Names, Color Codes and Fun Facts

| | No TrackBacks

Lifted from a friend's website.

All 120 Crayon Names, Color Codes and Fun Facts

Using Amazon FPS

| | No TrackBacks

CodeProject article on using Amazon FPS [Amazon Flexible Payment Service] in .NET. Uses WinForms, ASP.Net and C#.

Task Scheduler Class Library for .NET

| | No TrackBacks

Get that job at google

| | No TrackBacks

CHESS tester for multithreaded code

CHESS is a tool for systematically testing multithreaded code. Given a concurrent test, CHESS systematically drives the test along all possible thread interleavings. It uses model-checking techniques to explore effectively the enormously large state space of interleavings and provides quantified coverage guarantees. CHESS can check for assertions, deadlocks, livelocks, and data races. On finding an error, CHESS can reproduce the thread interleaving that exposed an error. CHESS is research tool developed by Microsoft Research.

House medical reviews

| | No TrackBacks

I came across this website a long time ago. If you are going to watch House, you have to read PoliteDissent to hear a medical opinion of the show. It's the best of a number of sites that rate House.

Hulu

| | No TrackBacks

Wow, this is so great. Hulu, a website I had not even heard of until today, has TV shows streamed over the internet. For most people, this would be no big deal. I have no cable, though, and use the TV only for watching DVDs.

Right now, I am catching up on House episodes which I would otherwise have to wait until, oh, September, to see on DVD.

House's Head (Part 1 of 2)

I will derive!

| | No TrackBacks

A one-link YouTube post. Student talks through his calculus problems, set to Gloria Gaynor's I Will Survive.

So I thought back to calculus,
Way back to Newton and to Leibniz
And to problems just like this.
And just like that when I had given up all hope,
I said, "Nope! There's just one way to find that slope!"

And so now I -- I will derive.
Find the derivative of x position with respect to time.
It's as easy as can be
Just have to take dx/dt.
I will derive --I will derive.

[I WIll Derive]

Alexa top 500 sites in US

| | No TrackBacks

This list is a bit surprising. I'd expect all of the sites to be familiar to me, and there are certainly one I don't use and have never heard of: live.com, photobucket.com, go.com, rapidshare.com, adultfriendfinder.com (just to pick on sites in the top 25).

[Alexa top 500 sites in US]

CIA textbook on evaluating intelligence

| | No TrackBacks

Psychology of Intelligence Analysis

The articles are based on reviewing cognitive psychology literature concerning how people process information to make judgments on incomplete and ambiguous information. I selected the experiments and findings that seem most relevant to intelligence analysis and most in need of communication to intelligence analysts. I then translated the technical reports into language that intelligence analysts can understand and interpreted the relevance of these findings to the problems intelligence analysts face.

Functional programming how-to

| | No TrackBacks
A tour of Python's features suitable for implementing programs in a functional style.

How to Tell if a Rally Is Real

| | No TrackBacks

The New York Times on signals for a real rally:

  • willingness to buy speculative (small-cap) assets
  • strength in sensitive sectors, like technology and consumer discretionary
  • strengthening dollar

Updated Three Little Pigs

| | No TrackBacks
Wherein the three little pigs diversify their portfolios to withstand market stresses.

Life as a Disney character

| | No TrackBacks
An ex-Jack Sparrow spills on life at the Magic Kingdom.

Writing strong arguments

| | No TrackBacks
Following Paul Graham's article How to Disagree on the hierarchy of arguments, CreateDebate.com has published How to Write Strong Arguments.


A Map for Saturday

| | No TrackBacks

This is a 90 minute DVD about the backpackers' life. Lifted from Cool Tools:

Don't watch this documentary unless you are ready to quit your job. It's about the joys and woes of long-term traveling. It's impossible to watch this fun film and not confront the fact that you are here instead of there, out on the road, soaking up the mysteries of the world, with all-you-can-eat $3 dinners and $5 rooms, backpacking around the world for a year, as the filmmaker himself did. This kind of vagabonding is more a state of mind than a state of motion. Something weird happens when you travel longer than 10 days, and that wonderful transformation (which no one can explain to their family when they return) is what this superbly written, fabulously edited, deeply personal and wonderfully likeable documentary is all about.

BedandBreakfast.com

| | No TrackBacks

BedandBreakfast has a database of 28,000 B&Bs worldwide, including nearly 6,000 that can be booked through the site -- with photos and expanded descriptions.

Unusual Hotels of the World

| | No TrackBacks

Unusual Hotels of the World lists 127 lighthouses, prisons, caves, and other unique places to spend the night.

Google blog search

| | No TrackBacks

Google has a special page for searching blogs.
[blogsearch]

Weber 87886 Chimney Starter

| | No TrackBacks

Barbecuing is occasionally complicated by unreliable charcoal bricks. Sometimes they don't start even when you douse them with that nasty kerosene fire starter. I'm expecting that this low-tech solution from Weber will work better. It's basically a custom-made chimney for igniting charcoal bricks. The coals draw air from the bottom and the fire spreads up the chimney.

2008-07-17: I've been using this product for two months now and I have a few comments to add:

  • No liquid fire starter required
    Or recommended.
  • Intensity
    Within a short period, the fire is consistently red-hot. The coals are amazingly hot throughout.
  • Ease of starting
    Every time I have used this, I've had one-match fires. Just one match was needed to get it started. You put two sheets of newspaper in the bottom and that's enough to get the coals started.

Recently, I was given a programming problem for a pre-interview job screen.

Implementation
  • Create a class which implements either the C# or Java interface
  • Implement the two methods defined in the interface. FindMaxValue should return the single highest integer. FindTopNValues should return a list of the highest 'n' values in the source list
  • Any assumptions or design choices made during the implementation should be documented.
C# interface
namespace Test
{
   public interface IFindTopValues
   {
      int FindMaxValue(int[] values);
      int[] FindTopNValue(int[] values, int count);
   }
}
Test cases
  • Describe the test cases which you would implement for this class.

Here's the solution I produced. It uses a C# generic PriorityQueue class. Have a look -- it's useful, reusable code.




Update (2008-05-15): I noticed that Julian Bucknall had a change to his priority queue that ordered entries by priority and time of entry. I decided to update my code to provide the same ability.

Grammatical pet peeve: the reason is because

| | No TrackBacks

Recently, a friend wrote about our Ultimate Frisbee field and said:

the reason we moved the field to the dust bowl was because of the uneven nature of the south part of our field (23 words)

I have a real problem with this construction. It uses a noun clause ("the reason we moved the field to the dust bowl") as the subject of the sentence and tacks on the very weak "was because" to express the idea. "The reason ... was because..." is never necessary nor advisable. There are many more direct alternatives, such as:

we moved the field to the dust bowl because of the uneven nature of the south part of our field (20 words)

or even:

we moved the field to the dust bowl because the south part of our field is uneven (17 words)

So far we've removed 6 words from a 23-word sentence. I might even go for:

we moved the field to the dust bowl because the south field is uneven (14 words)

but really, I have a problem only with "the reason ... was because."

KMN, KMN, KMN: Language that makes you say OMG

| | No TrackBacks
A great article on teenagers' use of language picked up from the web and text messaging.

Language that makes you say OMG
Teens are letting emoticons and other forms of chat-speak slip into their essays and homework.


Sometimes it is hard to tell the difference between a person LOLing and crying -- but I am definitely weeping. The cause for my earth-shattering depression is an April 25 Pew Research Center study that polled 12- to 17-year-olds on their attitudes about writing. A heart-stopping 38% said they let chat-speak -- such as LOL (for "laughing out loud"), ROFL ("rolling on the floor laughing"), BRB ("be right back"), TTYL ("talk to ya later") -- slip into essays and homework.

I propose a new chat term: KMN. "Kill me now."

The author is a tutor at 826 Valencia, [wikipedia] an amazing community teaching effort covered in this enormously entertaining and inspiring TED talk by Dave Eggers, Once Upon a School.

Firefox ClickOnce extension

| | No TrackBacks
The FireFox ClickOnce extension allows Firefox to run a .NET ClickOnce application. ClickOnce is a Microsoft application deployment technology.

[softwarepunk]
[Mozilla]

Google RSS reader

| | No TrackBacks

Google has an RSS reader.

Cheap Broadway theater tickets

| | No TrackBacks

Broadwaybox.com is my preferred website for searching for Broadway tickets. Tickets there are substantially cheaper than from the box office, there is no waiting outside, and there are no subscription costs for the service.

Backfilling content

| | No TrackBacks

So I've finally backfilled content from early 2004 to the present. I eventually did get all my content out of notepad.yahoo.com, format it as a Movable Type import file (including getting the separators, date format, and unix newlines correct), and uploaded it to my blog.

Of course, the content is pretty poorly formatted, so it will be months before I have it in a truly usable format. Until then, it's all here.

Tabor map

| | No TrackBacks

I'm still back-filling old material. I can see from the IIS logs that people still come here to check up on Tim Tabor, so here are the links to Tim's projects:

Ti-Kwon-Leap

| | No TrackBacks

When I am having a bad day, I turn to The Frantics' Ti Kwan Leap. At one point, I had the Boot to the Head sound associated with incoming mail or something in Windows. Very satisfying.

Downloading from notepad.yahoo.com

| | No TrackBacks

I have a lot of content in notepad.yahoo.com -- links, articles, etc. I'd like to download it, format it programmatically, and post it to my blog. I'd like to do this in python, and I've already tried HTTPBasicAuthHandler and urllib2 with no success -- I get HTML that asks for login, rather than HTML that shows my notepad entries.

Here's what I have tried:

import urllib2, base64
username, password = 'hughdbrown@yahoo.com', '?'
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, username, password)
auth_handler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)

req = urllib2.Request('http://notepad.yahoo.com/')
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
req.add_header("Authorization", "Basic %s" % base64string)

handle = urllib2.urlopen(req)
print handle.read()

Does anyone have an idea of how to get into notepad.yahoo.com to download notes?

[2008-05-08]

I got email from Alex Angelopoulos who had this recommendation:

Actually, I used WSH because I'm most used to it, even though it was Python that initially got me excited about scripting. I also _write_ about admin scripting, and the usual name of the game is "what can you do with the bits already in the box?"

That said, what I'm doing could easily be translated into Python using its COM interop. All I do is automate the browser. This is of course dramatically more resource-intensive than curl, but it means that any ugly bits of the page are handled exactly the way the browser handles them, and the job changes from a lot of parsing and submission-handling to selecting elements by name or id and then setting values or invoking actions.

I've attached a demo of it so far. It logs in, then takes the first page - presumably listing all of the notes - and returns the URLs for each and every note. It's possible to push this farther, of course, actually walking through the notes and grabbing the content of each one.

Notes on the demo:

(1) It's VBScript. I know, don't say it. : / However, I correctly cased object properties and methods so translation should be straightforward if you want to Pythonize. The only terminally ugly bits should be the setAttribute methods; those are both arguments and should be parenthesized in more rational languages. To run the demo as-is, you need to modify the username/password, and then I advise running from the console WSH host cscript so you don't get lots of popups for the URLs.

(2) It uses hardcoded username/password which I've set topside (and will likely make into commandline arguments in a better version).

(3) If you haven't done IE automation before, note the little readyState wait loops. You need to wait for IE to finish each navigation event, and in the case of complex documents, it's also necessary to wait for the document to render.

At this point, I'm not certain what you _really_ want to do from here - or if the browser automation approach isn't feasible for some reason. What I particularly like about this approach, though, is that you can work with objects instead of text, and it's always guaranteed to work with pages designed to the "Well, it worked in Internet Explorer..." spec.

Alex

And he provided WSH code:

username = "yyyyyyyy@yahoo.com"
passwd = "xxxxxxx"

Dim ie: Set ie = CreateObject("InternetExplorer.Application")

' Initial navigation needed to stabilize IE
ie.Navigate("about:blank")
Do Until ie.readyState = 4 : WScript.Sleep 100: Loop

' Show IE for debugging; can be hidden once it works.
ie.Visible = true

ie.Navigate "http://notepad.yahoo.com"

Do Until ie.readyState = 4 : WScript.Sleep 100: Loop

Dim doc: Set doc = ie.Document

Set usernameNode = doc.getElementById("username")
usernameNode.setAttribute "value", username

Set passwordNode = doc.getElementById("passwd")
passwordNode.setAttribute "value", passwd

' There's only one form, but it doesn't have an id -
' so we get by tagname and treat it like a collection...
'Dim body: Set body = doc.Body
Set forms = doc.Body.getElementsByTagName("form")
For each form in forms
	if form.getAttribute("name") = "login_form" then form.submit()
next

' we're navigating in to the folders.

Do Until ie.readyState = 4 : WScript.Sleep 100: Loop
Set doc = ie.Document

' Apparently the document builds after the browser is technically
' finished navigating. So we wait until the document readyState
' "complete" - yes, it's a text state, not a flag...
Do Until doc.readyState = "complete"
	WScript.Sleep 100
Loop

Set table = ie.Document.getElementById("datatable")

Set links = table.getElementsByTagName("a")
for each link in links
	WScript.Echo link.href
next
[2008-05-09]

And that reminded me that I have used WatiN, a .NET library ostensibly for testing GUIs but really ideal for screen-scraping HTML pages -- particularly because it has Intellisense. So I wrote a program using WatiN that does everything:

using System;
using System.Globalization;
using System.Collections.Generic;
using WatiN.Core;

namespace YahooNotepad
{
  class YahooLink
  {
    private string url, folder, title;
    DateTime dt;
    public YahooLink(string url, string folder, 
      string title, DateTime dt)
    {
      this.dt = dt;
      this.title = title;
      this.url = url;
      this.folder = folder;
    }
    public string Url { get { return this.url; } }
  }
  class Program
  {
    static DateTime hackParse(string dateStr)
    {
      string[] ds = dateStr.Split(new char[] { ' ' });
      string[] datePart = ds[0].Split(new char[] { '/' });
      string[] timePart = ds[1].Split(new char[] { ':' });
      int year = 2000 + int.Parse(datePart[2]);
      int month = int.Parse(datePart[0]);
      int day = int.Parse(datePart[1]);
      int hour = int.Parse(timePart[0]);
      if (ds[2] == "pm" && hour > 12)
        hour += 12;
      int minute = int.Parse(timePart[1]);
      DateTime dt = new DateTime(year, month, day, 
        hour, minute, 0);
      return dt;
    }
    static bool processPages(IE ie, Queue<YahooLink> notes)
    {
      Table table = ie.Table("datatable");
      //    Skip the <HT> row
      for (int i = 1; i < table.TableRows.Length; i++)
      {
        TableRow row = (TableRow) table.TableRows[i];
        TableCell href = (TableCell) row.TableCells[1];
        Link link = (Link) href.Links[0];
        TableCell folder = (TableCell) row.TableCells[2];
        TableCell date = (TableCell)row.TableCells[3];

        DateTime dt = hackParse(date.Text);
        Console.WriteLine("{0} (in {1} on {2}): {3}",
        link.OuterText, folder.Text, dt, link.Url);
        YahooLink yl = new YahooLink(link.Url, folder.Text, 
          link.OuterText, dt);
        notes.Enqueue(yl);
      }
      try
      {
        ie.Link(Find.ByText("Next")).Click();
        return true;
      }
      catch (Exception)
      {
        return false;
      }
    }
    [STAThread]
    static void Main(string[] args)
    {
      string userName = "hughdbrown@yahoo.com";
      string password = "?";
      string website = "http://notepad.yahoo.com";
      using (IE ie = new IE(website))
      {
        try
        {
          ie.TextField(Find.ById("username"))
            .TypeText(userName);
          ie.TextField(Find.ById("passwd"))
            .TypeText(password);
          ie.Button(Find.ByValue("Sign In"))
            .Click();
        }
        catch (Exception)
        {
          //    Carry on -- probably already logged in
        }

        Queue<YahooLink> notes = new Queue<YahooLink>();
        while (processPages(ie, notes))
          ;

         foreach (YahooLink yl in notes)
         {
           ie.GoTo(yl.Url);
           TextField tf = ie.TextField(Find
             .ById("charCountTA"));
           Console.WriteLine(tf.Text);
         }
         ie.Link(Find.ById("Sign Out")).Click();
       }
     }
  }
}

There are a couple of hacks:

  • The DateTime parsing failed on 4/30/08 for no apparent reason, so I just hacked up a quick-and-dirty date parser for American-style dates.
  • If you are already logged in to notepad.yahoo.com, it skips the extra log in by catching a throw exception.
  • Yahoo seems to find it peculiar that I am looking at 2000 notes and pulling them all down. It raises a security warning sometime after I have pulled down a few hundred. Maybe I'll have to add a call to sleep().

Comments and tracebacks

| | No TrackBacks
I'm sure this will be hard to understand, but I am still working on getting comments and tracebacks working. I wrestled with getting Image::Magick installed; no luck. Then I worked on getting reCaptcha installed just so I could have some captcha provider in my list. That was impeded by my FTP client hanging up, but once I restarted that, it was fine. So now I don't know what the problem is:
  • reCaptcha is listed as a plugin
  • reCaptcha is selected as my CAPTCHA provider
  • Comments are set to Immediate approve comments from: Anyone
  • Registration is set to Anonymous comments with Require E-mail Address for Anonymous Comments set
  • Web Services setting has a Type Key value obtained from SixApart
  • Entire website has been rebuilt
  • I've followed all the instructions on Adding reCAPTCHA to Movable Type
You'd think it would be fine. So I'll be waiting here for someone to post a comment on how to fix this -- no wait.

MT snafu

| | No TrackBacks

For the past 36 hours, my blog has allowed me to create new content and to preview it, but not to actually be able to see it generated in static HTML files. I finally discovered today that I brought this on myself when I inadvertently set Movable Type to use background publishing.

See the bit where it says that a cron job is needed to do the actual publishing? So if you don't actually have such a cron job, you'll get the result I did: no material published.

But I really think that, notwithstanding that I don't actually read and write Perl, I should have been able to figure this out. The leading clue was that the system log started to report that source code was missing for using TheSchwartz.pm, which even I could see was some sort of multithreaded load-balancer thingee.

Introductions

| | No TrackBacks

It's about time I posted a photo or two so you can get a sense of what I am up to. Here are some recent snaps from my spring ultimate frisbee league games. I'm the one with the dubious fashion sense.

For the score
Throwing

Cargo cult programming

| | No TrackBacks

I was going through some old web material and came across my links on cargo cult. The idea, originally developed by Richard Feynman, is that people develop a false idea of causation and do the wrong things to try to produce the desired effect. Cargo cult programming has become a common expression in software development to describe "a style of computer programming that is characterized by the ritual inclusion of code or program structures that serve no real purpose." [wikipedia]

  • Wikipedia on cargo cults

    A cargo cult is any of a group of unorthodox religious movements appearing in tribal societies in the wake of Western impact, especially in New Guinea and Melanesia. Cargo cults sometimes maintain that manufactured western goods ("cargo") have been created by divine spirits and are intended for the local indigenous people, but that white people have unfairly gained control of these objects. Cargo cults thus focus on overcoming what they perceive as undue 'white' influences by conducting rituals similar to the white behavior they have observed, presuming that the ancestors will at last recognize their own and send them cargo. Thus a characteristic feature of cargo cults is the belief that spiritual agents will at some future time give much valuable cargo and desirable manufactured products to the cult members. In other instances such as on the island of Tanna in Vanuatu, cult members worship Americans who brought the cargo.

    Based on the above definition, cargo cult is also used in business and science to refer to a particular type of fallacy whereby ill-considered effort and ceremony takes place but goes unrewarded due to a flawed model of causation.

  • Cargo cults in Melanesia

    The island's John Frum movement is a classic example of what anthropologists have called a "cargo cult" -- many of which sprang up in villages in the South Pacific during World War II, when hundreds of thousands of American troops poured into the islands from the skies and seas. As anthropologist Kirk Huffman, who spent 17 years in Vanuatu, explains: "You get cargo cults when the outside world, with all its material wealth, suddenly descends on remote, indigenous tribes." The locals don't know where the foreigners' endless supplies come from and so suspect they were summoned by magic, sent from the spirit world. To entice the Americans back after the war, islanders throughout the region constructed piers and carved airstrips from their fields. They prayed for ships and planes to once again come out of nowhere, bearing all kinds of treasures: jeeps and washing machines, radios and motorcycles, canned meat and candy.

  • Richard Feynman on cargo cult science

    I think the educational and psychological studies I mentioned are examples of what I would like to call cargo cult science. In the South Seas there is a cargo cult of people. During the war they saw airplanes with lots of good materials, and they want the same thing to happen now. So they've arranged to make things like runways, to put fires along the sides of the runways, to make a wooden hut for a man to sit in, with two wooden pieces on his head to headphones and bars of bamboo sticking out like antennas -- he's the controller -- and they wait for the airplanes to land. They're doing everything right. The form is perfect. It looks exactly the way it looked before. But it doesn't work. No airplanes land. So I call these things cargo cult science, because they follow all the apparent precepts and forms of scientific investigation, but they're missing something essential, because the planes don't land.

Sleep machine: Sound Oasis S-550-03

| | No TrackBacks

Okay, so this is my favorite sleep sound machine. A few of the things that make it so good in my view:

  • the sounds don't repeat very quickly
  • the sound quality is good
  • you can add cards to extend the system
  • there is a great big button to turn it on and off (as opposed to many machines that have combination volume and on-off)
  • the sound can be played for a set time (30-, 60-, or 90-minutes) and it automatically shuts off
  • the sound fades out gradually
SleepWellBaby has the best prices: the unit for $49.95 and the extension cards for $14.95. I got these cards:
  • Rhythms of the Sea Sound Card
  • Wilderness Journey Sound Card
The built-in sounds are pretty good without resorting to expansion cards. My wife is partial to the summer night sounds whereas I prefer the ocean surf.

Word Aligned

| | No TrackBacks

This is a recent favorite weblog. I first found it when I was looking up the maximum subsequence problem -- how to find the longest positive run from a series of positive and negative numbers. It's the sort of thing you'd be interested in if you were checking portfolio returns.

I learn a lot every time I go to this site, particularly about coding in python. I really liked recent entries on itertools.groupby():

import itertools
import operator

city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'), ('Anchorage', 'AK'), ('Nome', 'AK'),
 ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')]

a = itertools.groupby(city_list, operator.itemgetter(1))

print [ (state, ",".join(i[0] for i in it)) for s ]

Some favorite articles:

NullScript: The language about nothing

| | No TrackBacks

I'm moving my old website over, and the first order of business is to put up the popular old content. And what's more popular than NullScript, the language about nothing?

Technical aside: since my website was upgraded to a new server, none of the NullScript links has worked because IIS appears to reject any file that begins with NUL*. So I renamed all my NullScriptx.* files to NScriptx.*. I expect that my incoming links will all be broken. At least google will patch this up in time.

And apparently, you can't even title an entry with Null*.

Resume

| | No TrackBacks

First thing: post my resume. Google, do your thing!

Current resume

We're in business

| | No TrackBacks
Wow, after a heck of a lot of fiddling around with IIS and Movable Type settings, I finally have a website that does two things:
  • does administrative stuff like adding and publishing entries and
  • shows a page to the public at-large.
Wahoo!

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Archive

This page is an archive of entries from May 2008 listed from newest to oldest.

April 2008 is the previous archive.

June 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.