Blog :: Joseph Javier Perla

Stuff minimization framework.

I want to not own stuff. The things you own end up owning you. You often don't even realize it.

Moreover, this isn't merely excluded to stuff. A fundamental part of this world is our relationship with things, people, nationalities and other abstract entities. For example, I live in the United States, where fairness and equity in the law is highly prized. Because of Justice and the sixth amendment, I have the duty to serve on juries every once in a while. I was recently called for jury duty . My only permanent address, the only address I have for longer than a few months, is my parents' home address in Florida. So, I have to take a long not-vacation trip home at a specific time mandated by the courts in order to serve at the courthouse, and I seem to keep getting called every couple of years. This interrupts my flow, and forces me to do one thing where I would rather be, say, working or visiting someone.

But, day-to-day, stuff is the largest factor. Stuff controls your activities and creates errands that both suck up hours from your day and interrupt the flow which you spend so many hours to create. For example, you must wear clothes every day, which builds up in the laundry bin. This can cause a large, long laundry process which is quite cumbersome and annoying. It can take hours, and the flow is interrupted many times as you have to switch from wet laundry to dry at specific times. You have to wash and dust things. You must pack and store and rearrange every so often. Things break, then you have to find a repair man or replace it.

But there is freedom. Freedom from these things can help you. You can have the same, or greater, utility by eliminating key things bit by bit until you have optimized between stuff and happiness. You need much less than you think, just follow the Stress Minimization framework I developed to get to that point.

1. Get rid of closet litter that you never use.

Very often, you pick something up, and you want to throw it out, yet you think, maybe I will need this some day, then I will really regret it. You are operating on a regret minimization framework, so you hoard. I do too, except you can be more rational about it. How bad will it be if you throw it out and then need it in a few hours? Well, in a few hours, you can probably just take it out of the waste bin. A few days? Well, you can probably just go out to the CVS and buy a new one or a temporary disposable one for a couple bucks. Or, maybe a friend or neighbour has one you can borrow for an hour. Actually, the consequences are minor at worst.

More importantly, evaluate the likelihood that you will actually need it. This isn't a complicated guessing game; it is actually quite easy. Ask yourself 2 questions:

  1. Do you need it specifically for a specific event for which you have a planned date and time in the future? If so, it probably doesn't make sense to throw it out.

  2. How often did you use it in the last week? Last month? Last year? Last few years? Think about it, if you have played that board game maybe 2 times in the last 3 years, then you can safely give it away. On the next board game night, you can play somebody else's game or go bowling or something else. No loss.

2. Digitize.

Move everything over to a digital format. Take, store, backup, and share all of your photos digitally. Most modern cameraphones can take pictures that have acceptable scan-quality photos. Any documents or receipts you have, just take a picture with your phone and upload it to a backup server. Throw out the paper. You can always refer to it for information or print it out later. You can create a physical copy of paper as easily as a digital copy, so it should serve all purposes both informational and legal.

3. Unify your stuff.

Do you need both an X and a Y? What if you got one small Z and got most of the benefits of both in one small package? My iPhone 4 replaces numerous things I would normally need to keep. It replaces many notebooks and pencils and pens, a camera, photos of documents eliminate paper and file cabinets for archives, and so much more. Jeff Atwood agrees, it replaces his Nintendo, GPS, camera, browser, email client, mp3 player, HD video recorder, audio tape recorder, DVD player, ebook reader, watch, alarm, emergency flashlight, scanner, level, and ruler.

4. Use minimal things.

I have a 3 oz. green travel towel from Marmot that does as good a job as a thick towel yet fits into the palm of my hand. My Vibrams work just as well as normal shoes, yet they are flexible and can squish into small compartments in a bag as an afterthought. In fact, this is not a compromise at all, since they are even better for running than normal shoes, plus people compliment me and dig the cool style when I wear them around. Do you need a massive 5 pound laptop or a netbook or an ipad or just your phone?

5. Buy disposable things.

Do not buy quality things that are very expensive and which you want to care for. These will tie you down the most. My friend saved up to buy a Macbook Air. This can be over a $3000 device. A year out, now it runs dog slow (many seconds to open anything) and overheats constantly. He can't upgrade it, and he can't replace it because it cost so damn much. He has to buy expensive peripheral equipment to keep it safe, and he constantly has to worry about theft or damage. This is a prime example of the stuff you own owning you. I, on the other hand, spend on the order of $400 for a netbook. Buying one every year is twice as cheap as these expensive computers. Plus, they are better since the new ones I buy will end up being faster than the "fast" one by the second year, run newer software, and be cleaner. Maybe disposable (and sometimes reusable) recyclable paper plates and cups will work for you and end up being cheaper than a set of china. Investigate and experiment.

6. Do not buy new stuff.

Of course, if you need it, do so. If you are unsure, ask the 2 questions in part (1) and try to imagine yourself using the item every day. If it is a rare occurrence, or can be bought at that time, then do not purchase. Also, as things break or get used up or worn out, do not repair or replace them. Take your time. If after a few days or weeks you find that you can live just fine without the item, then you have a achieved a little bit more freedom.

After minimizing the stuff you own, you will find that you have much more freedom and flexibility to do what you want to do every day. Instead of being interrupted by errands, you will be able to work (or play) for 12 hours at a time non-stop. The first step is to remove the interruptions by removing your possessions.

14 days ago on August 22, 2010 at 3:41 pm by Joseph Perla in life


Weby templates are easier, faster, and more flexible

Weby Templates are used in production on websites that have garnered over 500,000 uniques a month. They are incredibly easy to work with. They are the "templates for lazy people". They have 3 main benefits:

  • easier
  • faster
  • more flexible

The main codebase is implemented in 100 source lines of code. Extensive libraries only add just a couple hundred other lines of code. It is simple. It ensures that all tags have closing tags. It is compiled and fast. It is unicode compliant and safe. You can be fully fluent within 5 minutes since it is just Python and a transparent library.

Easier

Writing with weby templates takes less than 3 minutes to learn. Below is a sample:



import weby_templates as weby
from weby_templates.templates.lib import html

@weby.template()
def index(p):
    with p(html.html()):
        with p(html.head()):
            p(html.title('Hello, World!'))
        with p(html.body()):
            p(html.h1('Hello, World!'))
            p(html.p('Please choose from the following items:'))
            with p(html.ul()):
                p(html.li('Lorem'))
                p(html.li('Ipsum'))
                p(html.li('Dolor'))
            with p(html.div({'class':'footer'})):
                p(u'About | Links | ... | ')
                    


<html>
    <head>
        <title>Hello, World!</title>
    </head>
    <body>
        <h1>Hello, World!</h1>
        <p>
            Please choose from the following items:
        </p>
        <ul>
            <li>Lorem</li>
            <li>Ipsum</li>
            <li>Dolor</li>
        </ul>
        <div class="footer">
            About | Links | ... | 
        </div>
    </body>
</html>
                    

Fundamentally, weby templates are based on 3 simple concepts.

  1. First, use Python to its fullest. Weby does not invent a new esoteric language for you to learn. You know enough useful ones already. For mature developers, using the full power of Python makes things obvious and intuitive. Moreover, the simplicity allows the core code of Weby Templates to be just 100 lines. Every template is just a function that returns a unicode string. A template is just a string, not a fancy programming language or a complicated environmental-variable dependent rigamarole. Just call any functino that returns a string.
  2. Second, we include a decorator to make building the string easier. @weby.template() is a decorator that adds a first argument to the function. This first argument is an accumulator, conventionally named 'p', as in 'print'. With it, you can basically print out each html element in the text. It can also work with the 'with' statement in Python to ensure that all tags are properly enclosed.
  3. Finally, straightforward helper libraries exist that make writing html or xml or using filters (functions that accept and output strings) easier. For example, the html library is extremely useful. Every html tag has an analogous function in the html library, as seen above. The first argument are the content words, and the second argument is a dictionary of the attributes. If the tag is in a with statement, then the first argument is just the dictionary of the attributes of the tag (since the contents are contained within the with statement. That's all of the documentation you need to be productive in the library.

This README is generated with Weby templates if you want more examples.

./README.py > README.html

or

./README.py | ./weby_templates/tools/beautifier.py > README.html

Faster

Weby templates are written in Python, and they compile to bytecode. Moreover, they utilize the complete Python stack, so you can use the Python debugger tools, source code checkers, and your normal build process.

You get the whole python compiler and optimizer speeding up your templates.

More Flexible

Weby Templates are just Python functions which return strings. It makes no other assumptions. That means that you can write HTML templates with it using the minimal HTML lib, or you can write standards-compliant XML with the XML lib, or you can write your emails, or you can write your own helper functions to generate documents in a custom format!

Also, unlike in other languages, writing filters and nested subtemplates or modules of arbitrary nesting or which take an arbitrary number of inputs is simple: just write such a function that returns a string, and optionally use the Weby Template decorator if that makes your life easier. Usually it does. Every filter is just a Python function that accepts a string and returns a string. How do you interface with this? How do you truncate? How do you pretty print? The answer is obvious and in the standard lib.

Just accumulate an object, or even just create a unicode string generator. Any function that returns a string will be a template. For example, each of many_hellos_* methods below are all valid, equivalent weby templates:



            import weby_templates as weby

            def many_hellos(num=10):
                return ('Hello, World!\n' * num)

            def many_hellos_redux(num=10):
                def many_hellos_generator(num=10):
                    for i in range(num):
                        yield 'Hello, World!\n'

                return u''.join(many_hellos_generator(num))

            @weby.template()
            def many_hellos_decorated(p, num=10):
                for i in range(num):
                    p(u'Hello, World!')
                
            @weby.template()
            def many_hellos_decorated(p, num=10):
                for i in range(num):
                    # raw function does not append newline
                    p.raw(u'Hello, World!\n')

            @weby.template()
            def many_hellos_decorated(p, num=10):
                for i in range(num):
                    # raw function does not append newline
                    p.raw(u'Hello, World!\n')




            # a sub-template (equivalent to Django filter, Django sub-templates, and Ruby helpers)
            # Since they are just functions, they can be nested, of course
            @weby.template()
            def add_greeting(p, thing):
                p.raw(u'Hello, %s!' % thing)

            # the main template, which calls the sub-template
            @weby.template()
            def many_hellos_subtemplate(p, num=10):
                for i in range(num):
                    p(add_greeting('World'))
        

FAQ

Q: I get this unicode error: "Always work with Unicode", what is this?

A: Weby Templates are unicode compliant.

I love Python, but Python 2.x made some poor assumptions when it comes to unicode compliance which some other languages like Ruby do not suffer from. It contains both str and unicode types, and their interaction can sometimes cause problems.

Python 3.x fixes this by only having one string datatype: unicode. This greatly simplifies everything, but most code is still on the 2.x branch. To avoid annoying and difficult to debug situations, Weby Templates always outputs unicode, and it only accepts unicode. It does not try to intelligently or magically deal with improper strings; magic like that is hard to debug. The developer will explicitly deal with that before passing strings to Weby Templates. Explicit is better than implicit.

As a tip, make sure you always use unicode throughout your app, and only encode/decode strings when you are inputting/outputting data to the world. For reading from files, use the 'codecs' package in the standard library. Make sure that you read and understand this excellent article about Unicode from Joel Spolsky.

Q: I like that Django Templates constrain me. It helps me ensure that I keep templates strictly within an MVC framework. Can I do this with Weby Templates?

First, since it is possible and even easy for some calls in Django Templates to have side effects, be aware that Django only provides the illusion of constraints. In fact, database calls and state mutation can be embedded in the calls. The template language merely encourages an MVC style which template writers often adhere to.

Second, in practice, we have used Weby Templates and similarly are encouraged to write in an MVC style due to the nature of the tool. Mature app developers naturally have no compelling reason to violate the MVC framework, when it makes the most sense. Moreover, arguments are passed explicity to templates in the function arguments, unlike in Django where they are implicit and unpythonic, and the structure of with statements and accumulator naturally encourage an MVC style separation. Finally, since sometimes bits of html are generated in views (links, messages, etc), you can use the same template library and filters to generate these snippets as you use in your templates. Thus, you don't repeating yourself and have less, tighter code. You do not need a separate file to generate a separate 1-line template, just add a 1-line function to your Python scripts.

21 days ago on August 15, 2010 at 11:06 am by Joseph Perla in technology, open source


Facebook is a Ponzi Scheme

Now that you know what a Ponzi scheme is, I will tell you how and why Facebook is a Ponzi Scheme.

Facebook posts huge revenues. In fact, they recently asserted that they are EBITDA profitable. This boosts both their respect in the world and their valuation. However, these returns, while real, are unsustainable. They exist and are sustained in the same manner that Ponzi schemes are. Facebook is a Ponzi Scheme.

Have you ever bought a Facebook ad? I have. I have talked to many, many people who have. We have spent hundreds, many have spent thousands or even more, experimenting with Facebook ads. They are worthless. Nobody ever looks at them, and nobody ever clicks on them. I just talked to someone who was trying to promote a book. He found it cost him over $100 in ads to sell one book. Moreover, as you increase your ad spending, people get used to the ads and just ignore them. So, your already low click-through rate goes down even further.

People go to Facebook to interact with their friends. It is fundamentally different from the ad platform that is Google. People go to Google to find something they need, which a good percentage of the time can in fact be solved by someone's ad. Facebook ads, on the other hand, annoy users. They yield no real profits.

But, then, how is Facebook so profitable? Are they lying? No. They are growing. More and more people get on Facebook, and more and more businesses hear about how many people are on Facebook. It seems like a huge opportunity. So each business individually and in turn experiments with Facebook ads. They spend hundreds or thousands or more on Facebook ads. At the end of the first run, they see bad ROIs. They tweak the ads and spend more money and try again. Nothing. So they stop, understanding that Facebook ads are worthless. Everyone I've talked to who has actually bought Facebook ads knows this. But, not everyone has bought Facebook ads yet. There are still more and more new businesses finding out about Facebook ads. As they grow, even more businesses give their money to experiment in destined failure.

Eventually, though, and this might take a long time, but it is finite, everyone will have tried Facebook ads and know that they are useless. Eventually, after 10 million businesses have invested $1000 each, and Facebook has earned $10 billion in revenue in total, then they will have run out of new customers and their revenue will dry up. A useless product is never sustainable. I wish I could short Facebook.

Now, it is possible that some extremely niche businesses have found limited utility from ads (say, BustedTees and social games may be the only ones). Also, Mark Zuckerberg might have a fit of brilliance andthen announce a revolutionary ad platform that somehow works on social networks. My guess is not. They haven't yet. What is clear from everyone I know who has advertised on Facebook is that it was a waste of money. Facebook promises big returns on ad spending, but delivers nothing. Yet, their value and growth continues because they can use that money to grow their user-base more and assert profitability (in this sense it's not quite entirely a ponzi scheme, but there is no closer idea). It's possible that they do not even realize that they are like a Ponzi scheme.

That's right, they may not even realize that their ad platform is completely useless because they always get new clients signing up and giving up their offering to the god of web 2.0 hype. They may be blind, as I used to be. They may be truly surprised when the supply of suckers runs dry.

More likely, in the end, they will get teenage girls to pay a monthly fee to host all of their photos. Of course, then the next Facebook (just as MySpace killed Friendster, and Facebook killed MySpace, so will NextFB kill Facebook) will offer the same services and be free and take over the "market." The cycle repeats itself.

24 days ago on August 12, 2010 at 4:34 pm by Joseph Perla in technology


Schemes

Many people do not understand the difference between a Pyramid Scheme and a Ponzi Scheme. They are very different. I believe the confusion lies mainly in that they are both Schemes and they both begin with P.

A pyramid scheme depends on the idea that you buy into something, but only get paid out when you convince other people to buy in under you or from you. Thus, you have a pyramidal structure. You sell to 10 people, they each sell to 10 people (100 total), and they each sell to 10 people (1000 total), and so on. Usually, the item sold is nothing substantial. This quickly becomes unsustainable, so the last suckers to join cannot sell to anyone else, so their money loses out and trickles up the pyramid.

A ponzi scheme is an investment vehicle that promises large returns. For example, I could tell you that I have a brilliant currency arbitrage. Instead of actually earning real returns, though, I convince new investors to invest new money. I use that money to pretend I have returns to the older investors. But now, I have to start earning returns for the new investors. However, that's easy to do because I can advertise huge returns and the old investors can vouch for me that I'm legitimate. Therefore, it's easy to convince new investors to come in with more money so I can keep pretending to have high returns. Usually, ponzi schemes are broken up by the government when they get too big, according to wikipedia.

I guess they are also similar in that they involve money and are not infinitely sustainable in that eventually you run out of suckers. But that's the definition of a scheme. Otherwise, it would be a legitimate investment since it would provide returns forever.

24 days ago on August 12, 2010 at 1:47 pm by Joseph Perla in entrepreneurship


Apple's amazing customer support system

Pick up your phone. Dial 1-800-MY-APPLE, 1-800-692-7753.

Listen to the automated system tell you that he can understand complete sentences. Shake your head in disbelief. There's no way this is going to work.

Say 'I want to know if I can buy an AppleCare protection plan for my Mac Mini I bought 15 months ago.'

Notice how it asks you if you are asking for personal or business use. Stare in disbelief as it responds instantly and without a long awkward pause. Listen to the quick and conversational, not slow and stilted, tone of the computer voice. Let it automatically send you to the AppleCare department where you have no wait to begin speaking to someone.

Best phone system ever. I understand that it is very limited, but it fools you well enough to be a pleasant experience. It's a big stepping stone to even more powerful interactive phone systems.

over 1 year ago on August 23, 2009 at 5:50 pm by Joseph Perla in technology


Poem #0

Ease, loose, lax cannot,
Cheeks and eyes they tie tight knots.
Happiness, I caught.

over 1 year ago on July 22, 2009 at 2:11 am by Joseph Perla in art


Hot Stock Tip #0

I’m very, very good at trading stocks. I do not gamble. I, literally, mathematically, like clockwork, always make money. I have not posted my Year 3 returns yet (I have for Years 1 and 2 ), but they are better than ever. I have surprisingly consistent annual returns in excess of 20%+ in all conditions: both boom times, flat markets, record-breakingly volatile markets, and now deep recessions. I will write about my 2008 returns as soon as I finish my taxes.

Right now, however, I do not have significant excess investment capital outside of my Roth IRA. My Roth IRA I use for long-term investments in which I do not trade in and out frequently. Therefore, I now sometimes see some trades which I may or may not have taken if I did have some capital. I want to share one idea I had today with you.

First, please note that this information is not to be construed as either an endorsement or a recommendation; as investment advice or as an offer to buy or sell securities of any kind. Please consult with your own advisor before using this information.

I read that Amazon just launched an online game trade-in systemGamestop dropped almost 14% upon the news.  I know Amazon. I love Amazon.  I have made lots of money off of Amazon recently.  But this will not affect GameStop’s sales in the long run.  As the analyst in the article notes:

GameStop has previously tested out online trade-ins, but with limited success because of the time consumers had to wait to receive store credit, Sebastian said. The retailer’s trade-in model is successful in part because it gives gamers instant gratification.

The best products have the best design.  They make customers fall in love with their simplicity and instant feedback.  Amazon’s mail in system offers none of that.  Netflix works because, with its queue system, you passively receive new content.  Amazon’s system requires quite a bit of active involvement before you receive game credits.

If anything, GameStop will receive extra attention because of Amazon’s offering.  It may even grow more quickly.  I would buy GameStop right now.

Of coure, I would also hedge against the market by buying a short or double-short (more leverage!) ETF like QID.  That way, you can buy into the pure alpha of GameStop, without exposing yourself to the crazy movements of the market as a whole which nobody in the world can predict or even understand.  I will write more about this later.

over 1 year ago on March 5, 2009 at 7:45 pm by Joseph Perla in finance, money


Labmeeting rocks

I want to tell you a little about Labmeeting.  I work at Labmeeting.  Actually, thinking about it, I have too much to say about Labmeeting.  I cannot tell you everything in one post.  I will tell you a little bit at a time as I think of cool things to talk about.  Let me tell you about our goals.

First, understand that science is broken.  Not in the traditional sense.  Science has not been speeding along the freeway and then suddenly tore a gasket and broke down.  No.  Science is puttering along reliably as it has for decades, centuries.  Exactly as it has been.  No faster.

Yes, scientists do an incredible job of being on the cutting edge of technology while simultaneously pushing that edge further and further.  Nevertheless, it takes between months and years to publish interesting results.  Labmates email cumbersome PDF’s back and forth.  Literature search tools frustrate even the most patient of users.  Conferences help disseminate knowledge quickly, but not when abstracts lose themselves amidst a shuffle of papers and when fellow scientists’ contact information evaporates. Publishers almost seem to try to restrict access to fulltext research articles, so much so that the government must force them to share knowledge.   Graduate students find professors and professors find grad students by pure luck, not by targeted searches.  Professors spend little time at the lab bench due to the skyscraper of paperwork required for modern research grants.

At Labmeeting, we are well on our way to solving all of these problems and many more.  Science operates best when people can develop good ideas securely and communicate good ideas rapidly.  We created a platform to do both like nobody has ever seen before.

Thousands of biomedical scientists, both at top US Universities and smaller ones around the world, already use and love Labmeeting.  We want to help all researchers communicate and work more efficiently so that they can focus on what they do best: science.

over 1 year ago on December 23, 2008 at 12:21 am by Joseph Perla in entrepreneurship, personal, science


Log Reader 3000

I wanted to show off another python script today.  I think it’s pretty cool.  It’s kind of like a very rudimentary version of something you might see in Iron Man.  And, of course, anything in Iron Man is cool.

I dub it Log Reader 3000.  It’s purpose?  It helps me monitor logs.  How?  Well, sometimes I need to follow a log in real time as it is written, but I can quickly get bored.  The log scrolls by endlessly while, very often, little new information spits itself out.  I can quickly lose focus, or at the very least, damage my vision after staring at a screen intently for extended periods.

Ideally, I want the log to simply flow through me, and if my subconscious notices something odd, then I can act on it.  If the log is read aloud to me, then I can work on other tasks and let my auditory memory and auditory processing take note of oddities on which I need to act.

So, I made a python script to read the log out to me as it is written. It is my first Python 2.6 script.  I take advantage of the new multiprocessing module built into the standard library.  I also use the open-source festival text-to-speech tool.

First, install festival.  sudo apt-get install festival in Ubuntu.  You probably want to set it up to work with ALSA or ESD sound.  By default, festival uses /dev/dsp, which means that you can’t use festival and any other program that uses audio (like Skype) at the same time.   Fortunately, and as usual, Ubuntu provides detailed, simple instructions to set up festival with ALSA: https://help.ubuntu.com/community/TextToSpeech .

Finally, just find an appropriate use case.  Note that most log monitoring applications would not be improved with Log Reader 3000.  If you just want to be notified of errors, you should have a program email you when an error appears in a log.  If you want to understand the log output of a program that has already run, understand that Log Reader 3000 is meant for live-running programs.  Yes, Log Reader 3000 can be modified to read any text file line-by-line.  But, you will find that reading ends up being much faster than listening to a slow automated voice, so I recommend that you just try to skim a completed program’s output with VIM.

So then why ever use Log Reader 3000?  It is useful for applications which fit all of the following criteria:

  1. you want to monitor a live running program
  2. and the debugging information is nuanced and you need a human to interpret it (i.e. it cannot be filtered programmatically) and/or you want to be able to intervene while the program is running to keep it doing what it ought to be doing in real time.

Applications:

  • Say that you are spidering the web, and what the spider should and should not be spidering is not yet well-defined, but a human knows, then the Log Reader 3000 can read aloud where the spider is, and the human can correct course as he or she notices the spider going astray.
  • Or, say that you are working on some kind of artificial intelligence.  Perhaps, the AI program can reason aloud and a human can correct or redirect the machine’s reasoning as it goes along.  I have no idea how or why an AI would do that.
  • Maybe you want to protect against bot attacks, but your aggressor is particularly clever and seems to avoid looking like a bot in all of the obvious ways.  You can pipe the output of your log into Log Reader 3000 and notice new kinds of suspicious patterns live while reclining in your chair or surfing the web.
  • You run a securities trading program.  You have numerous checks and double-checks to ensure that everything works correctly.  Nevertheless, you need to have a human monitoring the system as a whole continuously anyway, so you have Log Reader 3000 read aloud total portfolio value, or live trades, or trading efficiency, or fast-moving securities, or all of the above.
  • The lobby of your startup has a TV screen with graphs of user growth and interaction on the site.  You want to increase the coolness factor by having a computer voice read aloud some of the searches or conversations happening on your site live.
  • You make a living by selling cool techy art projects which blend absurdity with electronics.  You read aloud live google searches, or live wikipedia edits, or inane YouTube comments out of what looks like a spinning vinyl record.  Passersby whisper of your genius.

Once you have the application, just tail -f the log, parse out the parts you want the log reader to read (you can use awk for that, for example, or maybe a simple python script), and pipe that into the Log Reader 3000.

tail -f output.log | awk “{ print $1 }” | ./log_reader_3000.py

How does Log Reader 3000 work?  The main process reads in one line at a time.  As it reads in each line from stdin, it sends it to the processing queue.  The child process reads the last item in the queue (it discards the items at the top of the queue because those are old and we need to catch up with the latest output line) and then calls a function to say() the line.  The say() function simply uses the subprocess module to call festival in a separate process and then blocks until it is done saying it aloud.

Because having a computer voice read aloud a sentence takes a while, the log probably outputs many more lines than can be read aloud.  That is why a multiprocess queue is needed, and that is why Log Reader 3000 only reads out the most recent line which has been output, which is why it is most useful for specific applications.

Here is the script, log_reader_3000.py:

#!/usr/bin/env python2.6
import sys
import subprocess
from multiprocessing import Process, Queue
def say(line):
    say = '(SayText "%s")' % line
    echo = subprocess.Popen(['echo', say], stdout=subprocess.PIPE)
    subprocess.call(['festival'], stdin=echo.stdout)
def listen_to_lines(queue):
    line = 'I am Log Reader 3000.  The world is beautiful.'
    while True:
        while not queue.empty():
            line = queue.get()
        say(line)
queue = Queue()
p = Process(target=listen_to_lines, args=(queue,))
p.start()
while True:
    line = sys.stdin.readline()
    sys.stdout.write(line)
    queue.put(line)

over 1 year ago on November 21, 2008 at 4:33 am by Joseph Perla in art, hacks, technology


A Clean Python Shell Script

Guido van Rossum, the creator of Python, recently wrote a post on his blog about how Python makes great shell scripts, even (especially?) compared to shell scripts traditionally created in Bash and using purely shell commands.

Guido is absolutely correct.  Shell scripts birth themselves painfully from my fingertips.  Bash’s kludgy syntax irks my orderly sensibilities.  Typos frequent my unreadable scripts.  iffi?  Who invented this?

On the other hand, Python sticks to just a handful of language constructs, so the language does not force me to google how to create else statement every time I need to do it.  Python just makes sense.

One of the comments asks if Guido can show him some “really beautiful” python shell scripts.  I don’t mean to brag, and by no means do I think that my scripts in particular invite the light of the heavens to shine upon them, but I think I follow PEP 8 fairly closely and I pay attention to the brevity and clarity of my language.  I find that I can quickly debug my scripts because of their transparency at run-time and their concise self-annotating source code.

So, below I show a script which I call merge_branch.py. Do

chmod +x merge_branch.py 

so that you can run it from the command line with a simple ./merge_branch.py.  I alias it in ~/.bashrc.

alias mb='../path/to/merge_branch.py'

The script simplifies what I would have to do manually in git many times a day.  You see, git exemplifies a great version control system for keeping track of source code.  I create branches instantly.  This encourages me to work on bug fixes and new features separate from the main code base.  As others make changes, I can easily integrate their changes by merging the changed branch into my branch.  Git’s merge algorithm embarrasses any other I have ever used.  Some of Subversion’s merges still haunt my nightmares to this day.

So, git rocks.  Unfortunately, conflicts sometimes do occur.  So, the proper procedure for merging a branch needs to be followed carefully.  People are bad at doing things carefully. That’s okay.  We should spend more time on making mistakes being creative.  That is why we invented computers to do work for us.

For best results, merge the latest changes people made to master into your branch as often as possible.  Small changes incrementally will probably mean small merge fixes.  One big change will probably cause you major pains.  So, merge from master into your branch often.

If you use GitHub or another central repository with a number of other people, then you must do a number of things.  First, make sure that all the commits that you wanted to make are commited to your branch and that you didn’t leave any files out that you have not explicitly git-ignored.  This happens a lot in SVN and Git if you are not careful, and it is the greatest source of frustration for anyone who uses a system like this.  To human is to err, c’est la vie.  Then, git-checkout master.  Make sure that origin has the latest changes from your master.  Then git-pull the latest changes form origin (github) into master.  Then git-checkout your branch again.  Then git-merge master into your branch.  If there are any errors, fix them and commit, otherwise you are done.

Also, when you complete all the changes in your branch and all the tests pass, then you need to git-merge your branch into master and git-push it back up to origin (possibly github).  You need to follow the procedure above to ensure the latest master changes are included in your branch (preferably before you run the tests).  Then, you check out master, git-merge master into the branch (this will be clean since it should just be a fast forward because you already have the latest master).  git-push the changes to origin.  Finally, delete the branch that you just completed.

This tedium rotted my brain for weeks.  Finally, I resolved to write a script to solve the tedious parts, but bring possible errors to my attention if they occur.

Please let me describe to you a few features of the script.  First, I try to follow PEP 8 as much as I can.  I have read it at least times; you should too. Also, recite the Zen of Python every night before you go to bed.

Notice how I start the script with a shebang line which says /usr/bin/env python, the preferred way to start Python since it is most flexible.  For example, I can use Python 2.6, or my own local version of Python.

I use the logging module which is part of Python’s very large standard library.  Logging gives you so much for free.  For example, instead of commenting out print statements, just change the default logging level threshold.  Always use the logging module instead of using print for everything.  Always.  It’s as easy as import logging; logging.error(’…’).  Also, the logging.basicConfig(…) I use here is the same one I use everywhere.  Logging the time that a message appeared saves hours and hours when I debug long-running scripts.

Use the optparse module in every Python shell script you write (getopt is too weak and will end up being much, much less simple by the end of a non-trivial program).  Again, you get so much for free, like a -h help command.  The documentation for optparse explains how to do everything in detail.  Make sure you set the usage parameter.  Also, make sure you call parser.error() for input option errors instead of raising an exception yourself.

Write utility functions.  Use the power and simplicity of Python to your favor.  Here, I use call_command().  I use it throughout the script and it makes the code so clean and clear.

Finally, I like to put the main() function of scripts at the top.  That makes the most sense to me.  If I open a file, I want to instantly read what it does, not read what its utility functions do.  I put the utility functions below.  Of course, at the bottom, after everything else has loaded, I place the if __name__=”__main__” code and then call main().   This way, I can import this as a module (in, for example, py.test or iPython) to test the utility functions without running the actual script.  (warning:  Do not put anything except the call to main() at the bottom.  Otherwise, you may not realize under what circumstances you call main() and with what parameters.)

Here is the script:

#!/usr/bin/env python
import os
import re
import subprocess
import logging
import optparse

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(levelname)s %(message)s')

def main():
    usage = "usage: %prog [options]"
    parser = optparse.OptionParser(usage)
    parser.add_option("-m", "--merge-master", dest="merge_master",
                    action="store_true",
                    default=False,
                    help="Merges the latest master into the current branch")
    parser.add_option("-B", "--merge-branch", dest="merge_branch",
                    action="store_true",
                    default=False,
                    help="Merge the current branch into master; forces -m")
    options, args = parser.parse_args()

    if not options.merge_master and not options.merge_branch:
        parser.error('Must choose one-- try -m or -B')

    # Merging branch requires latest merged master
    if options.merge_branch:
        options.merge_master = True

    if options.merge_master:
        output,_ = call_command('git status')
        match = re.search('# On branch ([^\s]*)', output)
        branch = None
        if match is None:
            raise Exception('Could not get status')
        elif match.group(1) == 'master':
            raise Exception('You must be in the branch that you want to merge, not master')
        else:
            branch = match.group(1)
            logging.info('In branch %s' % branch)

        if output.endswith('nothing to commit (working directory clean)\n'):
            logging.info('Directory clean in branch: %s' % branch)
        else:
            raise Exception('Directory not clean, must commit:\n%s' % output)

        logging.info('Switching to master branch')
        output,_ = call_command('git checkout master')

        output,_ = call_command('git pull')
        logging.info('Pulled latest changes from origin into master')
        logging.info('Ensuring master has the latest changes')
        output,_ = call_command('git pull')
        if 'up-to-date' not in output:
            raise Exception('Local copy was not up to date:\n%s' % output)
        else:
            logging.info('Local copy up to date')

        logging.info('Switching back to branch: %s' % branch)
        output,_ = call_command('git checkout %s' % branch)

        output,_ = call_command('git merge master')
        logging.info('Merged latest master changes into branch: %s' % branch)
        logging.info('Ensuring latest master changes in branch: %s' % branch)
        output,_ = call_command('git merge master')
        if 'up-to-date' not in output:
            raise Exception('Branch %s not up to date:\n%s' % (branch, output))
        else:
            logging.info('Branch %s up to date' % branch)

        logging.info('Successfully merged master into branch %s' % branch)

    if options.merge_branch:
        logging.info('Switching to master branch')
        output,_ = call_command('git checkout master')

        output,_ = call_command('git merge %s' % branch)
        logging.info('Merged into master latest branch changes: %s' % branch)

        output,_ = call_command('git branch -d %s' % branch)
        logging.info('Deleted safely branch: %s' % branch)

        call_command('git push')
        logging.info('Pushed master up to origin')
        logging.info('Ensuring that origin has latest master')
        stdout,stderr = call_command('git push')
        if stderr == 'Everything up-to-date\n':
            logging.info('Remote repository up to date: %s' % branch)
        else:
            raise Exception('Remote repository not up to date:\n%s' % output)

        logging.info('Successfully merged branch %s into master and pushed to origin' % branch )
def call_command(command):
    process = subprocess.Popen(command.split(' '),
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    return process.communicate()
if __name__ == "__main__":
    main()

over 1 year ago on November 17, 2008 at 11:00 pm by Joseph Perla in hacks, technology


Mark Zuckerberg Wears My Sandals

mark zuckerberg

Valleywag reports that Facebook still has not started firing employees as every other Silicon Valley startup has. But, the most interesting part of the article lies hidden within the picture.

Mark Zuckerberg (the billionaire) wears the same sandals I do: old-school Adidas sandals .  I don’t know anyone else who wears them.

I just bought these Rainbows in Miami which are pretty nice.

over 1 year ago on November 15, 2008 at 4:15 am by Joseph Perla in news, personal


Ruby is a Ghetto

Zed Shaw (the creator of Mongrel) not long ago described how the Ruby on Rails community is a ghetto.

Working with both Python and Ruby now, I learn every day how much Ruby, too, is a ghetto.  Nobody documents anything (e.g. solr-ruby).  The few projects that have documentation do not document clearly or completely (Rails…).

Moreover, take Ruby’s standard package management system: rubygems.  A simple gem install uses up 600+ MB of RAM on my SliceHost machine.  But again, lack of documentation scars this project even more deeply.  Take a look at its Frequenty Asked Questions Page:

[I lost my internet connection while composing the answer to this question. Unfortunately, I now no longer recall what I intended to write. The answer (or at least part of the answer) is buried deep in the RubyGems mail archive. I’ll try to update this after a bit of research. Sorry for leaving this question hanging.]

Seriously, “I now no longer recall what I intended to write.”  For how many months has this lunacy been online?  Ruby is a ghetto.

over 1 year ago on October 26, 2008 at 11:14 pm by Joseph Perla in technology


Redesigned the Blog

Blog redesign now enabled. Looks cleaner, fresher. Plus, it has more stuff to do in the sidebar!

Here’s what the site looks like as of today:

over 1 year ago on September 18, 2008 at 8:43 pm by Joseph Perla in blog


Switch windows quickly

I want to avoid RSI.  So, I want to use the mouse as little as I possibly can while I focus on my keyboard.  Unfortunately, alt+tabbing between windows takes far too long and annoys me with how much I have to think to move between the windows.

I often have several windows open.  I want to switch between them very quickly.  So, I created a program using Python and Xlib that generates another program.

The program moves my mouse automatically to a specific location and then clicks automatically.

The program also creates a keyboard shortcut in Gnome.  So, I can type something like Alt+q which calls the program above, moves the mouse to a specific location, and then clicks.

Finally, the program also generates a program which, when called, opens up many windows at specific locations in a grid:

If I combine all of these programs, I can focus between windows very easily. I can move the mouse between 12 spots in a 4×3 grid using the keyboard letters Q,W,E,R, etc like below:

To move to the Top-Left window, I hit Alt+q, which moves my mouse to the top left and clicks, focusing the top-left window.  To move to the bottom right, I press Alt+v, then the mouse moves to the bottom right and clicks, focusing into the bottom right window.

Basically, when I’m programming, I never have to move to my mouse to switch between windows very quickly.  I can open up 12 files at once, and switch between them swiftly and deftly.  When you work on a large application, this becomes very useful.

I’ve open-sourced the program here: http://github.com/jperla/mouse-focus-shortcuts/tree/master .

over 1 year ago on September 18, 2008 at 8:19 am by Joseph Perla in hacks, technology


It’d be hilarious

As seen on Slashdot:
>Oh well. 1998 me is still pleased to hear this.

Is 1998 you still on the line? Warn him that Star Trek: Insurrection really sucks!

  • by Anonymous Coward on Monday June 23, @04:37PM (#23908891)

    That’s all you’d tell your 1998 self?!?? I’d tell mine to invest heavily in the DotComs so he’d lose all his money…it’d be hilarious like that time someone told me they were my future self and that I should invest heavily in DotCom start-ups and I lost all my money!


over 1 year ago on September 16, 2008 at 5:55 am by Joseph Perla in art


Kohl looking into telecom pricing practices

I have been saying for a long time that AT&T, Verizon, and others operate in a market with little real competition which allows them to charge ridiculous rates and have unfathomably bad customer service.  Finally, one senator begins investigations into their text messaging pricing practices which have increased by laughable amounts: http://mobile.slashdot.org/article.pl?sid=08/09/10/1845210

over 1 year ago on September 15, 2008 at 2:43 am by Joseph Perla in technology


Font Comic: Attempt #1

I love to read about others’ unique creations.  I love to get ideas from them.

By pure chance, I happened up on David Friedman’s excellent blog called Ironic Sans where he showcases designs both illustrative and mechanical.  He recently created a funny (punny) little graphic:

Darth Vader

It reminds me of XKCD, a beautifully simple yet intellectually esoteric webcomic.  David Friedman’s graphic above also reminded me of a typography exercise my friend Mason Simon recently created and posted on his blog:

Collapsed

I like these little designs so much.  In kindergarten, I never took to drawing and coloring like everyone else.  My sketches of people looked like pizzas more than faces.  I think I can do a decent job at making a font comic, however.  My attempt sits below.  It took me half an hour to figure out how to make the black rectangle border.  I ended up just making a solid black rectangle with a white rectangle on top.  I need to learn Photoshop/The Gimp.

Thank you Comic Sans MS, and the Beat My Guest font from Larabie Fonts.

over 2 years ago on July 28, 2008 at 1:27 am by Joseph Perla in art


Blackberry Theory of Email Apathy

The Germ Theory of Disease saved billions of lives from early deaths.  It identified a root cause, as well as solutions, to the population-threatening problems of contagious diseases.

BlackBerry

BlackBerry

Today, email apathy plagues the workforce.  Whenever you send someone an email and he or she never replies to you, realize that you have been slashed by the sharp sickle of email apathy.  Recently, I have noticed an upward trend of email apathy from business colleagues and others.  After each click of the Send button, I think, “is my message going to a person or a black hole?”

The simpleton would argue that the large increase in the amount of both real email and spam makes it very difficult for someone to respond quickly even to legitimate emails.  A busy person loses even important emails among the piles of clutter in his inbox.  Certainly, the amount of email plays a factor, in the same way that stress plays a factor in exacerbating symptoms of a disease.

Blackberry Theory of Email Apathy

I hypothesize that the recent boom in handheld email devices, embodied in the Blackberry, iPhone, and other such tools, cause much email apathy.  But by what process?

Nominally, the Blackberry intends to improve efficiency of communication by instantaneously notifying you of a new email as soon as the sender clicks “Send.”  In fact, the recipient does feel the Blackberry gently vibrate with every incoming email, but he lacks increased communication.  In practice, the Blackberry owner skims the email on a tiny screen, understanding very little of the intended meaning.  If the email requires urgent action, at best the sender receives a curt reply tapped out awkwardly on a tiny keyboard by two fat thumbs.

Very often, the Blackberry user mentally notes to himself that he should reply to or act on the email at some point soon in the future, and then he forgets.  The sender receives notification that the Blackberry user even received the email.  Communication informational content quickly approaches zero.

How do we cure Email Apathy with knowledge of the Blackberry Theory?  Proper Getting Things Done process.  Perhaps non-instantaneous email triaging.  Who knows.  Just please reply to my email.

over 2 years ago on July 26, 2008 at 3:57 am by Joseph Perla in science


Heart Rate

In PE in middle and high school, I always remember taking my pulse and having a very high resting heart rate relative to others.  I forget the exact number, but it might have reached 80 beats per minute or higher.  I always thought I counted incorrectly or double-counted.

I’ve started running and walking almost daily recently.  I feel better and more energized, especially after a run.  I would like to know if my overall health improved since I started about 4-6 weeks ago.  The first days, I could barely go around the block.  I would come back into the house and gulp down a gallon of water in between deep panting heaves.  After a couple of weeks I could run/walk a mile or two without gasping for breath by the end.  Yesterday, I estimate I ran/walked 5 miles (I know that I walk 4 miles an hour) without a problem.

So, in terms of endurance, my fitness improved.  But what about my heart rate?  I check yesterday and today.  It’s down to about 63 beats per minute.  I made a graph using a short Python script, pygooglechart, and the Google Chart API.  I will be plotting more data points every day:

Heart Rate

Lance Armstrong has a resting heart rate of 32 beats per minute!  On the other hand, some quick research online tells me that resting heart rate poorly correlates to fitness, although recovery rate would be a better measure.  I’ll start charting my recovery rate once I figure out how to measure it easily.

over 2 years ago on July 24, 2008 at 7:09 pm by Joseph Perla in hacks, life, personal


YCombinator Application Guide

YCombinator, a kind of mini-venture capital firm, invests tens of thousands of dollars ($$$) into very early seed stage start-up companies run by smart technology hackers.  They wanted to fund me in Summer 2008.

I applied to YCombinator two times.  The first time, when I applied with my friend Mason for the Summer 2007 round,  I arrogantly presumed that Paul would lavish on us praise and beg us to fly to California to work with him.  I spent no more than an hour on the application.  We had no passion in the idea we presented.  Our projects list hinted at nothing particularly remarkable or unique.  Our analysis of the idea and our competitors delved only into the shallowest parts of a deep lagoon.

The second time, when I applied alone in Summer 2008, in an inspired moment I sat down in Starbucks for a solid few hours to work on the application.  I strived for excellence, not perfection.  A few months prior, I had briefly glimpsed the semi-successful application of Liz Jobson and Danielle Fong.  I recalled their deep detail and thoughtful writing, so I imitated that kind of deep analysis which shows off one’s mastery of logic and breadth of experience.

I wish I had known how to write a good application the first time.  So, taking my cue from Brian Lash’s recent question on Hacker News, I helped him out.  I write here a slightly expanded version to help out anybody else who wants Paul Graham & co. to fund his or her startup.

If I were to advise myself in 2007, I would recommend that I write briefly but write a lot.  This advice seems contradictory, but I mean it in a very specific way.  My first application, I kept brief.  I did not want to swamp YC with a tome of text. I saved many of my accomplishments for the interview.  Do not do this.  Write, write, and write some more.  Write everything interesting and unique about yourself.  If you have doubts about a statement you made about a competitor, qualify it.  Don’t vacillate, but at the same time don’t seem shallow, ignorant, and inexperienced.

Of course, once you’ve written all that, you have a very long application.  Now, take out filler words.  Compress ideas that take up two sentences when you can use just one. If you waste two words in a sentence, delete the whole sentence and write it again from scratch.  If you see a phrase that you think an investment banker might use on his resume, nuke it.  Achieve a high density.  In my experience, the YC crew truly pores over these applications to understand all of the meat of it.  They do not skim your application when it has rich content.  Cut, cut, and cut some more.

Now, step back and look at your application.  If you have very little writing left, real content, then you may not be the best fit for YCombinator this year.  That’s okay.  It’s good you know now.  Take this year off and work on some interesting, hard projects that nobody has done before.  Bounce your idea off of the smartest person you know.  Hell, micro-test the idea.  Then, repeat this process.

Step back, look at your tight list of accomplishments.  If it’s long, that’s great, since reading something long but rich in content everyone loves to do.  The length indicates strength.  In my limited experience, I think this is how I made my application successful.

Here’s some of my application below (I elided some less relevant parts). I was accepted for Summer ‘08 2008 but decided to pass this time for a variety of reasons.

—————————————-

What is your company going to make?

I’m open to anything. Here’s one idea:

————–

Have you ever scanned a document before? How was that experience?

It was terrible for me, too. Everyone I have ever asked has agreed that it is physically painful. But, there is a solution, one based on understanding actual human needs. What is wrong with the scanners of today?:

* slow (takes time to heat up)

* slow (scanning at a high dpi takes a long time)

* complicated (please select the dpi, now select bla, now bal[sic]…)

* cumbersome (files generated at high dpi are huge, slow down system)

* cumbersome (OCR’ing a document is a whole other rigamarole)

What do people really need?  Simply a decent, readable scan of the document. This should be as easy as holding the paper up to face the monitor.

Imagine that.

I propose that I sell a device which is basically just a decent-resolution CCD chip with a special lens which connects to a computer (wired at first, but v2 wireless). Scanning a document is as simple as holding the camera up to a document and clicking. In my tests, scanning a whole text books takes 5-10 minutes. This is a game-changer. I’ve worked with an ip lawyer to file the provisional patent on this and a few other aspects of the designs.

[BY THE WAY, IF ONE OF YOU WANTS TO HELP ME BUILD THIS, I'M ALL EARS. I'M AN AI HACKER NOT A HARDWARE HACKER. OH, BY THE WAY, I USED A DIFFERENT IDEA IN THE INTERVIEW ROUND, NOT THIS ONE SINCE I'M SKEPTICAL OF THE MARKET FOR THIS PRODUCT AT THIS POINT. NEVERTHELESS, IT'S VERY COOL. I WANT TO BUILD THIS FOR MYSELF!]

For each founder, please list: name, age, YC username, email address, personal url (if any), and current employer and title or school and major. List the main contact first. Separate founders with blank lines. Put an asterisk before the name of anyone not able to move to Boston June through August.

….. [Be sure to put your blog here. Don't have a blog? Make one. Blog about whatever is on your mind. Blog about your hacking.

To be honest, an Ivy League pedigree probably helped.  Also, my computer science degree (as opposed to Economics or Business one) probably encouraged YC's faith in me.]

Please tell us in one or two sentences about something impressive that each founder has built or achieved.

Looking at some things in ~/projects folder: ……..

[Here I mention a few of my projects, with links to open source code, web pages, anything I can publicly show. I didn't spend more than one or two sentences describing any one project, but I listed many of my most interesting projects and why I worked on them. YC likes to see you working on real problems, so I talked about problems I solved for myself and for others directly

They want to see that you think creatively and that you actually finish things.

It goes without saying that you should list projects which uniquely describe you.  Building a toy language in Programming Languages class many people probably do.  Yes, it may have taken you a long time, and you may have learned a lot, but you do not necessarily stand out.  Writing a CAPTCHA solver to hack Digg few people do or can do.]

Please tell us about the time you, ljlolel, most successfully hacked some (non-computer) system to your advantage.

…… [I talked about my shotgun email to dozens of startups here in Silicon Valley which gave me the opportunity to meet a lot of cool entrepreneurs.  I'll probably blog about this at some point in the future.]

Please tell us about an interesting project, preferably outside of class or work, that two or more of you created together. Include urls if possible.

(see above) [I applied alone, so group projects inapplicable.]

How long have the founders known one another and how did you meet? Have any of the founders not met in person?

n/a [Again, I was a sole founder.]

What’s new about what you’re doing? What are people forced to do now because what you plan to make doesn’t exist yet?

(see above) Basically, nobody ever scans anything because it takes forever, doesn’t really do what you want (you just want a readable, small image and for the document to be searchable),

What do you understand about your business that other companies in it just don’t get?

Scanner manufacturers try to pack in the highest dpi they possibly can. They focus on resolution, when they should be focusing on the user experience. Speed is what they should optimize, but I see no scanner manufacturer doing that.

Who are your competitors, and who might become competitors? Who do you fear most?

HP, Xerox, etc, also ScanR, Qipit, Evernote …… [I go on to be brutally honest about the difficulty and vulnerability of my position as a hardware startup in a crowded field. Remember, you are writing for some very, very smart people. They want to see your analytical thinking skills here. They want to see you be realistic, not delusional.]

……. more questions, answer analytically deeply, answer honestly to the best of your ability ……

If you had any other ideas you considered applying with, feel free to list them. One may be something we’ve been waiting for.

…….. [I always think of new ideas and discuss them with friends. I chose 4 and listed them here. I crisply described each in no more than 2 brief sentences.]

over 2 years ago on July 20, 2008 at 10:37 pm by Joseph Perla in entrepreneurship, hacks, life, money, personal, technology


Steve Yegge Rules

I stopped writing in this blog once I realized that people actually read it.  I received a few comments in one technical blog post.  They pushed me over a cliff.  Instead of publishing whatever popped into my mind regardless of the quality of the idea or writing, I hesitated over every agonizing sentence.  Every word strangled me.  I began to engineer my very thoughts to match that post’s style and topic, but I often failed and quit.  I have 28 abortive drafts in WordPress.

I truly enjoyed clarifying my thinking through writing.  So, I will write more.  Perhaps I will write something tautologically wrong or use dirty slang.  Irrespective of the quality, I will write.

Incidentally, Steve Yegge inspired me to start writing again.  If you program computers, you will love Steve’s Drunken Rants.  With his 20 years of programming experience, he cuts down to the bone of programming problems and programming triumphs.  He writes thoughtfully and completely; the rants often span several thousand words.  He wrote them, he claims, while drinking wine during the time when he worked at Amazon.

Now, he works at Google and has a more current blog: http://steve-yegge.blogspot.com/ .  The newer rants also require serious time commitments to read, but each one imparts to me incredible insights.  For example, I now love JIT’s.

over 2 years ago on July 19, 2008 at 8:17 pm by Joseph Perla in blog


Games to play with just voice and memory

XKCD solves Ghost

The XKCD guy not long ago wrote about the game Ghost.  You start the two-player game Ghost by saying one letter.  Then, your opponent says another letter.  Concatenate the letters together, they should not form a word.  Continue adding letters to the concatenation of letters one by one until somebody forms a word and thus loses.

The XKCD guy uses the Ubuntu dictionary in /usr/bin/words and creates a short program to calculate the optimal strategy to play the game.  He solves Ghost and publishes the solution.  Since that game no longer yields interesting results, he asks at the end of his post for users to recommend new games that he can play just using voice and memory.  None of the offered games seemed very interesting or innovative, so I will offer my own:

My brother Mark and I have spent many hours in cars together through our lives.  To fight boredom, we have invented some open-ended games.  I will mention only the most unique one: the Doubling Game.  How about the Perla Doubling Game, yes.

Doubling Game Rules

Nobody can be confused by the simplicity of the Perla Doubling Game.  Two players play, although I can easily see any number of people playing.  One begins by saying, “2 + 2 = 4.”  The second player takes the summand and adds it to itself, thus speaking “4 + 4 = 8.”  The first player continues with “8+ 8 = 16,” and so on until a player asserts an incorrect sum and thus loses.

Importantly, the game does not encourage adversarial deceit.  Once the game reaches the hundreds of millions, the digits become more difficult to store in short-term memory. I can ask my brother what he last said as a summand.  We double-check the sums with each other cooperatively.  Minor slip-ups slide, since continuing with ever-larger numbers exercises the brain much more than starting over at “2 + 2.”

We enforce no time penalties.  When the two players match up in skill-level, they both spend all of their energy and about the same amount of time performing all of the sums.  One player sums because it’s her turn, the other sums to check the other’s answer.  And, cooperatively, you remember many digits together.

Variants

Yes, you can begin with other primes, such as “7 + 7″ or “53 + 53″ (exercise for the reader: why start with primes?).  But, once you reach a very high level, the summands become as simple (and as difficult) as the “2 + 2″ path.  Moreover, these numbers tend to repeat the same chunks of numbers no matter where you start.

Fun

The Perla Doubling Game taxes you mentally, passes the time, and inspires both a competitive and cooperative spirit (how high can you go?).  I highly recommend the game to any two smart, bored car passengers.

over 2 years ago on May 12, 2008 at 7:02 pm by Joseph Perla in games, math


TipJoy ingeniously simplifies and enables micro-payments

I have already written about my distaste for advertising.

Sometimes, however, these newspapers and blogs manage to make something of value. A particularly hard-hitting expose in a newspaper, or a particularly helpful guide in a blog, offers to people real value. Nobody can create this kind of content every day, or probably even every week or month. A subscription subsidizing the page-filling fodder misallocates wealth. I want to pay for the value more directly, not indirectly through ads.

Or, more commonly, a blog post provides for me a little bit of value. Not $50/month in value, but perhaps 50 cents/month. No payment system can pass around payments like that easily for the user, especially without ridiculously large credit card fees. How can I tell Michael Arrington of TechCrunch that his site I find useful sometimes? Combined with the millions of others who find his site just a little bit useful, he can make some money directly from us.

TipJoy.com

Fortunately, I think TipJoy solves many of these problems. The site only launched a few months ago, so it has to grow quite a bit before it reaches a tipping point. Nevertheless, TipJoy designed their product beautifully.

Registration

First, for new users, creating an account takes a few seconds. Just click on the TipJoy button, write in your email, quickly create a password, and finish up. No credit cards required. A new user signs up by tipping, integrating the first-use with registration. Ingenious.

They follow a model that bar’s use where you can set up a tab and pay later. Readers get drunk tipping blogs here and there all around, running up a huge tab. Users only pay once the tab gets large enough to justify the credit card fees. Their model differs from the bar, of course: just like the tips themselves, paying the tab is optional. Nevertheless, through this system, TipJoy encourages people to sign up easily, and only over time pay off their tabs.

Tipping

Second, once signed in, tipping takes just one click. No annoying confirmation steps required. No complicated questions about how much you tip. You get one choice: 10 cents. Of course, you can tip more if you want. This encourages readers to tip generously around many sites across the web. The tab builds up invisibly behind the scenes.

When I first read about TipJoy, I knew that it, or a model very similar to it, would take over the web. I think it will take time. However, I will support this service by putting it up on my blog. Maybe, one day, I will write a post that many people find just a little bit useful, and I can finally monetize this blog :) .

over 2 years ago on April 20, 2008 at 5:45 pm by Joseph Perla in entrepreneurship, money, technology


Make your own chimes

I just bought a Mac Mini.  I love it.  Apple spent a lot of time polishing OS X.

I configured OS X to create a chime, a 21-st century chime.  In the Date & Time settings, I selected it to tell me the time every hour.  At 6pm, a voice from the computer says, “It’s 6 o’clock.”  At 10pm when South Park comes on, it reminds me by saying “It’s 10 o’clock.”  The chime keeps me conscious of the time passing when I’m online.

I dual-boot Ubuntu on this Mac Mini.  Ubuntu, unfortunately, does not have this chiming feature. However, I set it up in minutes.  I installed festival, the free open-source text-to-speech synthesizer, as well as an American voice (I struggled to understand the British voice).

sudo apt-get install festival festvox-kallpc16k

Then, in crontab, I added one line:

0 * * * * echo "(SayText \\"Its`date +\%l` oclock\\")" | festival

Now I easily keep track of the time.

over 2 years ago on April 17, 2008 at 1:12 am by Joseph Perla in hacks, technology


How to check email two times a day

Tim Ferriss popularized the idea that you should limit the amount of time you spend checking email every day.  He espouses a philosophy of life called the low-information diet.  By following these guidelines, you get more done and, more importantly, feel less stressed.

One of his suggestions about email spread across the blogosphere very quickly because of its simplicity and practicality.  He recommends that you check email only twice a day (or preferably less often) and strictly adhere to that rule.  I started following these guidelines a few days ago, but I easily relapse.  Nevertheless, I do a few things to try to stay on the wagon:

  • Add a message to all outgoing emails:
EXPERIMENT: I will be checking email 2 times a day at 1pm and 6pm pacific time.
If you need me earlier, then please contact me below.

And of course I put my contact information below.  With this signature, I do not worry about missing out on important and urgent information or replies.

  • Delete all links, shortcuts, and bookmarks to GMail
  • Set up a script to automatically open up GMail at 1pm and 6pm every day.  In Ubuntu, I write just one line in crontab:
0 13,18 * * *  export DISPLAY=:0 && firefox https://mail.google.com/

Linux makes hard things easy.

over 2 years ago on April 15, 2008 at 9:02 pm by Joseph Perla in hacks, life, technology


Untenable advertising

Ads annoy me. Ads annoy everyone.

ads suck

More importantly, I cannot envision building a serious business which depends on these kinds of banner ads, or even text-link ads. But many websites do: TechCrunch, Project Wedding, Reddit, MightyQuiz, Justin.TV, Scribd, Loopt, and so on.

I use many websites online every week. Many provide a lot of value to me, they help me do my job more quickly or help me live my life more easily. They offer me so much value, I would even pay to use them. Some of these services include Google, Amazon, GitHub, Bank of America, Kayak, Craigslist, and a number of blogs like Slashdot, XKCD, and so on.

Except for Google services and the content creators (the blogs), I pay directly for the value these websites give me, given how little the services cost. The smartest ones all do. Kayak, for example, makes money off of the airline and hotel referral fees, not ads.

Unfortunately, many startups think that Google’s AdWords will be their sole source of revenue for their website.

Weakness

But, advertisements as a business model suffer from a fundamental weakness: advertisements indirectly monetize a website. Sometimes, the indirect monetization means that you make more money. Often, it means you make less.

Imagine you make a technically amazing product on your site. Nothing else exists like it. I sign up, and I notice that you provide an incredible amount of value to me. I would be willing to pay a large monthly fee for that. Instead, though, you monetize the website through advertisements. I never click on the ads. I visit to your site to use your product, not to buy chainsaws. You make no money off of my use. Even if I clicked on a few ads, you still make less money than if I paid a monthly fee.

That doesn’t work. You get none of the pay off from the value you provide me, while simultaneously actively annoying me. Project Wedding offers a good example. I would use Project Wedding to review, for example, photographers and find the perfect photographer for my wedding. The Google Ads at the top for random photographers who happen to pay for the ads do not help me; they only confuse me. A referral fee model makes more sense, or preferably an even more creative never-before-seen model.

The Quintessential Advertising model

Now, for a few kinds of websites, advertising makes sense. When I’m looking for a chainsaw to buy, I google “chainsaw” to find results, but I also see “chainsaw” sponsored ads on the right. That makes perfect sense; it directly provides me value. Google search exemplifies a great use of advertising. As Google’s customer, you watch Google continually provide us a better, more targeted service. It is the Yellow Pages model.

The Common Advertising Model

Advertising does not make sense in most other models. It does not provide value any other way, but it does annoy me. Nevertheless, I would use advertising if I started a company that built one class of product: products that provide little to no value. Examples include most television programs (think “reality” TV) and online games. People spend time watching random television shows to waste time and not think. These provide little (negative?) value. You have absolutely no opportunity to get people to spend money on your silly time-wasting flash game. You can, however, put ads along the side. With this kind of advertising, you transform your customers from the people playing the games into the advertisers. The advertisers pay you to reach out to these game-players, at the expense of the already-void user experience. Advertisers pay more.

Most magazines, newspapers, and blogs also fall into this category. Reddit and Digg as well. Little to no (to negative) real value offered. Newspapers and magazines offer nominal subscription fees, not because they cover the cost of the reporting–it probably does not even cover the cost of the ink– but because advertisers demand that they know real circulation numbers. Advertisers assume that if you pay at least a little, you probably read it and look at the ads. Because content creators cannot extract enough money from you directly into paying for all of the reporting and server overhead, they resort to becoming the servants of advertisers. Digg now displays (or at least recently used to) very annoying flashing ads.

Make something useful

But if I want to create something that depends on this kind of advertising, why do I want to create it in the first place? Why do I want to make something that nobody values, that nobody finds useful? For me, I cannot do that. I want to make something great, not a time-waster.

over 2 years ago on April 8, 2008 at 8:10 pm by Joseph Perla in entrepreneurship, technology


Stanford’s Entrepreneurial Thought Leaders Series (now on your iPhone!)

The Stanford Technology Ventures Program runs a well-developed incubator for tech businesses at Stanford University.

STVP offers some very cool resources free to the world. For example, I have been listening to their Entrepreneurial Thought Leaders audio podcast. The program brings in some of the greatest entrepreneurial forces in Silicon Valley today. Some of the speakers include

and so on.

While I was listening to Mike Maples and Ron Conway give their talks about angel investing, I had trouble following along and knowing who was saying what. I had subscribed to the talks through iTunes. When I visited the site, I noticed that they published videos as well, but in a Flash format, and not available as a podcast. I followed the videos much more easily.

So, in accordance with their fair use license, I decided to scrape the video metadata, download the video files, transcode them into an iPod-acceptable format, and republish them in a simple video podcast format. I now have scores of these talks in my iPhone and on my Mac Mini to view at my leisure.

Now, you can download them to your iPod, too. Just subscribe through iTunes or any other podcatcher.

P.S. I’ve open-sourced the code (AGPLv3), in case you ever want to make a podcast yourself.

over 2 years ago on April 5, 2008 at 7:43 pm by Joseph Perla in entrepreneurship, hacks, technology


Learn 100 digits of pi at lightning speed

Learn 100 digits of pi at lightning speed.

In a previous post, I wrote about the Secret to Pi.  I wrote about the method I used to learn 100 digits of pi in under an hour and remember them days later without extra practice.

While memorizing the digits of pi using this method, I realized that I was spending most of my time trying to think up words that would translate to the digits.  I tried to think of the longest word I could.  Sometimes I would screw up and use a word that did not translate to the correct digits.  I spent 2/3rds of my time just thinking of good words, images, vivid pictures.  It was hard and slow.

So, I decided to make a computer program to find the words and optimize everything for me.  I did, and I’m releasing the code under Affero GP.  Of course, all the code is PYthon2.5.  Please allow me describe it to you.  With the words precomputed, I can learn pi as quickly as I can tell a story!

At the top above, I linked to a page which I generated automatically using these libraries I’m releasing.

There are a few libraries.  They all require NLTK.  NLTK is an excellently-designed, well-developed, actively-maintained open-source natural language parsing library.  It has many (nearly 1GB of) corpora.

First, generate_nouns.py is a script.  We need to automatically generate a good, long list of concrete nouns for you to have strong images and remember the story of pi visually. It uses the CMUDict Pronunciation Corpus which is in nltk.corpus.cmudict.  It also uses the wordnet corpus in nltk.wordnet.  The script does some intelligent processing to filter out archaic words, curse words, and abstract nouns.  Run generate_nouns.py at the command line to create a nouns.csv file, or just download my copy in the repo.  50-75% are very good, concrete, vivid nouns for this purpose.  If you can help me get a higher percentage/more good nouns, please tell me.

Second, there is soundmap.py.  Soundmap.py is a library (import soundmap) that you can use to convert a word or phrase into the corresponding digits.  To be perfectly flexible, it loads a file which describes how to match which sounds to which digits.  I provided the sounds.csv file which is the one I use.  I haven’t tried to figure out what would be the optimal configuration yet, but maybe you can :) .  This also uses the CMUDict Pronunciation corpus (of course).  Call soundmap.convert_to_digits(phrase) to have it return a string of digits.

Finally, there is mapwords.py.  Mapwords.py is a library that takes in a string of digits (such as the digits in pi) and uses the nouns.csv list of nouns and soundmap.py to figure out the optimal sequence of words for people to remember that sequence of digits.  It also has a couple hundred digits of the famed constant inside the library: mapwords.pi.  Simply call mapwords.get_best_mapping(mapwords.pi) for it to return a list of words.

You can put all these together and quickly learn thousands of digits of pi.  Here’s a great page with many digits to throw into the program.

over 2 years ago on March 14, 2008 at 12:01 am by Joseph Perla in art, hacks, science, technology


The Secret to Pi

NEW: I created a website designed designed to teach you dozens of digits of pi in minutes using this secret method. If you want more digits, I also open-sourced the code.

Tomorrow, around the country, schools and universities will be celebrating the ratio pi (π).  Students and professors will eat blueberry pies, talk about math, and hold contests.  The pie-eating contests look like fun.


(photo by becw)

Another large part of the festivities are pi recitation contests.  In these competitions, students face off against one another attempting to see who can recite the most consecutive digits of pi starting at 3.14.  A number of schools have them.  The Daily Princetonian, from my alma mater, reported on a contest few years ago where one student recited a couple hundred digits of pi.  Harvard’s Crimson reported on a student last year who recited more than 1000 digits of pi in one sitting.  Even elementary school kids have these contests on March 14th.

Last year, FOX News interviews some students about the significance of these contests.  “Bryan Owens, an MIT senior, says the ability to recite pi is a sort of bragging right, a coin of the realm.”  Math geeks wear the number of digits of pi they know as a symbol of pride. Some people become obsessed: “In 2004 Umile read the digits of pi into a
tape recorder. He did it a thousand at a time and gave it a rhythm _
some numbers high-toned, some low. He listened to the tape constantly. This went on for two years. A two-year trance.”

Two years.  I say, a waste.  I know the Secret to Pi. I have learned 100 digits of pi in under an hour with perfect recall a day later.  That includes overhead of learning the secret, so now I can learn at the rate of 100 digits of pi every 20-30 minutes.

The secret:

First, you must leverage human psychology.  Understand that you can only remember so many things.  Furthermore, human beings evolved an incredible capacity for remembering some pieces of information, but not others.  We have a weak capacity for numbers, strings of digits.  They are unnatural.  However, we have a strong capability for remembering images, and a large number of images.  You can close your eyes and see your childhood home, even imagine walking through it clearly.  In particular, we remember vivid, unique images.  You will remember and recognize the picture above with the pied woman’s face, because you do not see that everyday.

You also have good short-term auditory memory.  That is why it might be easy for you to learn 10 digits of pi very quickly, since you just replay your auditory memory of the digits, but you forget them just a day (or an hour) later.  Stories and images, however, stick with you.  You can imagine most of Harry Potter’s long journey from beginning to end.  How do we take advantage of our natural gifts?

Simple.

  • Associate words and hard, concrete images with numbers.
    Take any word with a strong visual image. For each hard consonant sound in the word, associate a digit to that sound. Ignore the vowel sounds. Use the key that is on Tim Ferriss’s excellent blog post on the topic.
  • Associate the digits of pi with a list of words. [3.]1415 926 becomes TREADWHEEL BANJO.
  • Make a story with the words, in oder. Make it wacky. The more offbeat, the easier to remember. Imagine the story vividly.
    (Or use the method of loci; just don’t run out of locations!).
  • Recite pi: simply remember the words in order, then translate each word into the corresponding digits.

So, instead of trying to remember chunks of numbers, and how chunks of numbers relate to other chunks of numbers, you just remember a story.  Imagine you are on a farm, pushing a TREADWHEEL very hard with your own hands (for some reason, remember the zanier the easier to remember;  the droll is forgettable).  You’re sweating from the work, but the sweet farm fresh air keeps you going.  Suddenly, somebody comes in playing a BANJO, playing your favorite song.  And so on.

Instead of imagining a story, you can use the method of loci. This method involves imagining vividly a location you already know very well, such as your home.  Imagine walking through, very clearly, and identify objects one by one.  For example, imagine your kitchen.  You start walking in, the first thing on your left is a CLOCK, then a CUTTING BOARD, then a REFRIGERATOR, then a MICROWAVE, etc.  Finally, associate each word in your list of words with each word in your kitchen, in order.  So imagine a TREADWHEEL CLOCK, then a BANJO where you can cut vegetables like a CUTTING BOARD.  Now, to recite pi, just imagine walking through your kitchen.  You will first see a CLOCK, but you will also immediately think of a TREADWHEEL.  Then you take a step and see your CUTTING BOARD, reminding you of BANJO.  You can use this method to remember any kind of list.

Finally, use the key to translate a word into the sequence of digits in pi.  TREADWHEEL is 1415, and BANJO is 926, so those are the numbers in 3.1415926… And just continue on that way.

Not only do you learn the digits more easily, but also you remember them for weeks without a refresher, and re-learning becomes an easy game of recalling the story just once for a few minutes.

Moreover, this method is overall less taxing on your brain.  You use up less of your mental space (although I think you have more than you will ever need).  To memorize 100 digits of pi, you need only remember 1 story, composed of 40 words, instead of 100 digits.

Finally, learning to recite pi this way becomes useful for remembering other numbers or lists of numbers.  If you ever have to remember a very long number, just break it up into a few words and remember those.

I want to demistify pi memorization.  Although people may treat it that way, it is no more a measure of real intelligence than the SAT or Stanford-Binet.  You can learn a few hundred digits of pi tomorrow morning, go to a pi recitation contest, and blow everyone out of the water.  When people say how smart you are, just tell them you how easily you learned hundreds in a few hours, and how they can too.

over 2 years ago on March 13, 2008 at 11:25 pm by Joseph Perla in hacks, science


Sympathy

Guess who:

Please allow me to introduce myself
I’m a man of wealth and taste
Ive been around for a long, long year
Stole many a mans soul and faith

And I was round when Jesus Christ
Had his moment of doubt and pain
Made damn sure that Pilate
Washed his hands and sealed his fate

Pleased to meet you
Hope you guess my name
But whats puzzling you
Is the nature of my game
I stuck around St. Petersburg
When I saw it was a time for a change
Killed the czar and his ministers
Anastasia screamed in vain

I rode a tank
Held a generals rank
When the blitzkrieg raged
And the bodies stank

Pleased to meet you
Hope you guess my name, oh yeah
Ah, whats puzzling you
Is the nature of my game, oh yeah

I watched with glee
While your kings and queens

Fought for ten decades
For the gods they made

I shouted out,
Who killed the Kennedys?
When after all
It was you and me

Let me please introduce myself
Im a man of wealth and taste
And I laid traps for troubadours
Who get killed before they reached Bombay

Pleased to meet you
Hope you guessed my name, oh yeah
But whats puzzling you
Is the nature of my game, oh yeah, get down, baby

Pleased to meet you
Hope you guessed my name, oh yeah
But whats confusing you
Is just the nature of my game

Just as every cop is a criminal
And all the sinners saints
As heads is tails, Just call me Lucifer
cause Im in need of some restraint

So if you meet me
Have some courtesy
Have some sympathy, and some taste
Use all your well-learned politesse
Or Ill lay your soul to waste, um yeah

Pleased to meet you
Hope you guessed my name, um yeah
But whats puzzling you
Is the nature of my game, um mean it, get down
Woo, who
Oh yeah, get on down
Oh yeah
Oh yeah!
Tell me baby, whats my name
Tell me honey, can ya guess my name
Tell me baby, whats my name
I tell you one time, you’re to blame
Ooo, who
Ooo, who
Ooo, who
Ooo, who, who
Ooo, who, who
Ooo, who, who
Ooo, who, who
Oh, yeah
Whats me name
Tell me, baby, what’s my name
Tell me, sweetie, what’s my name
Ooo, who, who
Ooo, who, who
Ooo, who, who

Ooo, who, who
Ooo, who, who
Ooo, who, who
Ooo, who, who
Oh, yeah

over 2 years ago on March 6, 2008 at 3:48 am by Joseph Perla in art


Books
E-mail
Buy me stuff

Favorite Posts

YCombinator Application Guide
Telecommunications
Font Comic: Attempt #1
Returns year 2
Why Plant Rights?

Popular Posts

Facebook is a Ponzi Scheme
Capturing frames from a webcam on Linux
How to Ace an IQ Test
A Clean Python Shell Script
Learn 100 digits of pi at lightning speed
BankOfAmerica.com > Mint.com

Recent Posts

Stuff minimization framework.
Weby templates are easier, faster, and more flexible
Facebook is a Ponzi Scheme
Schemes
Apple's amazing customer support system
Poem #0

Categories

Follow

More...