Home

Wacky Research Journal

Recent Entries

You are viewing the most recent 25 entries.

13th September 2009

9:57am: VMWare on Ubuntu 9.04
I just installed VMware Server 2.0 on my Ubuntu 9.04 desktop, and let me tell you I am impressed. This is the best way to run windows programs from Linux.

Follow the directions here. It involves registering for free to get a license key for VMware Server, downloading the big file, and patching the installer. It's not actually difficult.

To get USB passthrough working, I had to edit my /etc/fstab file to add the lines:

usbfs /proc/bus/usb usbfs auto 0 0
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0

Then reboot to pick up the changes. Before I added those lines, I couldn't access USB devices from virtual machines, it would give an error message saying "Remote USB device error". With the change it works like a charm. I can even program my FPGA board from the virtual machine over USB without a hitch.

For the OS, I used my new MSDN account from work to burn DVDs of all my favorite Microsoft operating systems. We have a license to install any number of OSes for test and development work, we just can't use them in production or install Office on them.

It is surreal to put in a bootable disc and boot to install Windows XP from the virtual machine window. Once it's done, I installed VMTools. When you click on the link in the VMware control panel, it inserts a virtual CD-ROM that starts the Install Shield installer in the virtual machine. The tools help windows cheat to speed up graphics and user input operations. Very cool.

12th September 2009

9:53am: New FPGA development board
Yesterday I received my Altera DE2-70 FPGA development board from Terasic. I've been thinking about FPGA programming for a while, it sounds fun to design hardware. I went to the San Jose library and read a bunch of books on Verilog and VHDL. I had previously used Verilog for a class on computer architecture but hadn't seen VHDL before. Reading up on hardware tricks to make fast circuits made me excited enough to actually order the kit.

I chose the Altera DE2-70 on Tommy Thorn's recommendation. Tommy is the resident FPGA guru at work, he has done a bunch of FPGA projects before. The board is jam packed with features, it's very exciting. I also considered some dev boards that were cheaper that had newer chips but less extra stuff. But then I thought, the fun of FPGA development isn't designing a custom 128-bit CPU and then having it blink one led. The fun is designing a custom CPU and then programming it to generate techno music with VGA output and ethernet control.

The board is impressive. My biggest annoyance so far is that the Control Panel application doesn't work. I worked through the getting started guide and the programming manual, and couldn't get it working. At first I thought it was a driver issue since my main machine is Vista64. But then I tried again with a laptop that has WinXP32, and got the same behavior.

When I start control panel, it says "Fail to connect FPGA borad". Yes, with both a misspelling and grammatical mistake in the error message. Makes me think the error detection and handling might not be robust. When I click "Download" to program the board to work with the app, it looks like it starts programming for a second. But then it fails with a message about the NIOS batch file.

After banging my head on the problem for a while, I gave up and just tried programming the board with a test design of Tommy's. It worked! Very exciting. I can count clock cycles and turn on LEDs according to switches. If you are starting out on the DE2-70, I recommend ignoring the control panel application.

20th April 2009

1:23pm: NVIDIA and OpenCL
Woot, NVIDIA just did a pre-release of OpenCL. If you are interested in computing on the GPU, sign up for beta access, coming soon.

Yes, I am now a total corporate shill for my GPU overlords.

2nd February 2009

10:39pm: Diophantine equations
Diophantine equations are fun to solve. Tonight I've been tinkering with:
2^p y = x^2 + d

where p and d are small integers. The idea is to find integers x and y that make the equation work.

The general strategy is to do odd-even arguments and keep recursing and dividing by 2. For example, suppose p=4 and d=-1. You want to solve 16y = x^2 - 1. By looking at odd-even combinations, you can see that x must be odd. So let x=2z+1. Then 16y = 4z^2 + 4z. Divide by 4 to get 4y = z^2 + z. Now z can be even or odd, so you have to fork and try both. Try z is even: z=2w. Then 4y = 4w^2 + 2w. Divide by 2 to get 2y = 2w^2 + w. This means w must be even, so w=2v. Then 4y = 16v^2 + 4v, so y = 4v^2 + v. Hey, we got down to y so we now have a solution! The solution is y = 4v^2 + v, x = 8v + 1. Let's check it. When v=0, y=0 and x=1, which works. When v=1, y=5 and x=9, which works. You can backtrack and try z is odd to get more solutions. Fun!

I just wrote a little Python program to do all that automatically, it is very cute.

Where does the equation come from? I was looking for floating point numbers that are hard to round correctly when taking the square root.

27th November 2008

10:34pm: Comic Book for ZPL
Every programming language should have a comic book explaining what it's about. Here is ZPL's comic book.


21st November 2008

8:43pm: My New Job


I am pleased to announce that I have accepted an offer of employment from NVIDIA! I start Dec. 1.

My new job will be with the CUDA team. If you haven't heard of CUDA and GPGPU I encourage you to check it out. Wikipedia:CUDA is a high-level description. The idea is that modern graphics processors are like supercomputers. CUDA is NVIDIA's technology for letting users take advantage of all the computational power in NVIDIA's GPUs.

The really fun thing is looking at the applications people have used CUDA for at CUDA Zone. Just seeing the first page of projects makes me drool, and then I remember that there is a horizontal scroll bar that you can scroll to show all 145 projects. Yummy. I'll be working on the technology that makes it happen.

Yes, CUDA has Python bindings. And there is work being done to run Haskell on the GPU(!) There really is no excuse not to get excited.
10:33am: Bargaining for Advantage
As part of my impromptu education and research about negotiation, last night I finished reading Bargaining for Advantage by G. Richard Shell. It is the best nonfiction book I have read in a while. It is a good mix of negotiation theory, useful stories, and genuine insight. After having read it I am looking at the world in a slightly different way. Not many books do that for me any more. As a side effect it makes my own little "do I accept a company's offer for employent" negotiations seem positively mundane, although of course the outcome is very important to me. I highly recommend this book, even if you think you never negotiate.

26th October 2008

1:13pm: Drew Carey videos
Check out Reason.TV, produced by Drew Carey (he also appears in episodes). They are short video essays about various topics that give a reasonable libertarian perspective on the issue. I don't agree with everything they say, but the arguments are coherent and presented in a polished and nice way.

For example, the latest piece is on universal preschool. It answers questions such as why people would want universal preschool, who is supporting it, and the current state of universal preschool in the US. Then it talks about existing institutions that lose out with universal preschool and why it might not be a good idea.

I haven't thought about the issue too deeply, but my instinct is that it is a bad idea. We already have an official government office for Head Start. I would support expanding the role of Head Start or giving them more money rather than something like "universal preschool". I am supremely skeptical that universal preschool would "save money" somehow. I am much less skeptical that a program like Head Start that focuses on the most at-risk children and includes nutrition might actually save taxpayers money.

24th October 2008

11:44am: Ebbs and Flows of LJ
It's funny how posting activity ebbs and flows on LiveJournal. It's like the tides. It seems that at certain times of the year there are massively more or less posts than other times, but I don't really know why that would be.

Maybe it has to do with academic schedules? People get busy with schoolwork and have less time to post. But many of the posters on my friends list are not in school any more.

Maybe it is the weather? Maybe moods shift with the weather, and some moods are more likely to lead to LJ posts. But the weather is different in different locations, so that seems a bit odd.

Maybe it's me? Maybe I obsessively check LJ more or less at different times, and misinterpret the amount of posts I see as a general trend of posting.

3rd October 2008

9:53am: iPhone NDA lifted
Woot, Apple lifted their Draconian NDA for iPhone development. They broke the first rule of iPhone development: don't talk about iPhone development.

Rules of iPhone development:

  1. Do not talk about iPhone development
  2. DO NOT talk about iPhone development
  3. If someone writes an emulator or a video downloader, the development is over
  4. Only Objective-C developers
  5. One signing key to a developer
  6. No frameworks, no interpreters
  7. App review will go on as long as it has too
  8. If this is your first handheld application, you HAVE to develop for the iPhone

2nd October 2008

4:05pm: Prototype Programming in Python
There are two general models of object-oriented programming that I know about: class based and prototype based. Most popular OO languages like Java and C++ are class-based--you define classes and then construct new objects as instances of these classes. Other languages like Self and Javascript are prototype-based. You construct new objects by cloning old ones and then refining their attributes and behaviors. Wikipedia:Prototype-based programming.

Python is a class-based language. But, because so many things happen at runtime and are controllable by the programmer, you can actually change things up to do prototype-based programming. Here are the implementations I know about:

Kay Schluehr

Love and Theft

Eduardo Padoan

Logarithmic
2:26pm: Type is a type
What have they done? The horror! The horror!
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> isinstance(type, type)
True

26th September 2008

4:00pm: Dr. President
While reading some random news stories, I noticed that presidents are always referred to as "Mr.". Have any presidents gotten their PhD? Exactly one, my new favorite president, Dr. Woodrow Wilson. He created the Federal Reserve, doncha know. Wikipedia: Woodrow Wilson

22nd September 2008

8:27pm: NAT traversal
I'm playing around with NAT traversal (aka punching) in python, it is pretty hairy. The annoying thing is that any given computer I have access to is behind a NAT. So I can't do too much testing other than seeing, oh, it doesn't work yet. The most irritating thing is that NATs don't always support "hairpins". That means connecting to the public port on a NAT from outside is different than connecting to the public port from inside the LAN. Really annoying for testing purposes. If anyone knows specifics about NAT traversal I'm all ears.

21st September 2008

1:54pm: iPhone App ideas
A while ago I bought [info]wkfauna an iPhone. It has worked out well and is a lot of fun. So I've decided to become an iPhone developer.

There are many annoyances, such as only being legally allowed to use Objective-C and not other languages. And the $99 charge. And an NDA that may limit your ability to use open source code. Nevertheless, I'm sufficiently excited about making my own iPhone apps and sharing them with the world that I'm going to do it.

Any great ideas for apps? Some things I'm thinking of: simple music notation for doodling with melodies, a block game where you slide blocks and there are rules about which ones can be next to each other, simple spreadsheet that connects to webserver to be sharable with other iPhones and computers. Comments or ideas?

19th September 2008

11:46am: "The market" ≠ Dow
OH MY GOD, how many idiotic front-page articles do I have to read that say "the market is up/down" and then say what happened to the Dow? THE MARKET ≠ THE DOW. Repeat after me, the market ≠ the Dow. There are thousands of good indexes that track the total market using all kinds of weightings and selection criteria. The DJIA is not one of them. I haven't seen ONE ARTICLE that gave an indication of what the actual stock market was doing. What the fuck is wrong with newspapers? Are these people totally ignorant? It makes me despair for humanity.

16th September 2008

5:20pm: Python wart
So in Python tuples are immutable but lists are mutable. What about a tuple of lists? Er...
>>> x=([], [])
>>> x[0] += [1]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'tuple' object does not support item assignment
>>> x
([1], [])

Do you see what happened there? I tried to modify the first element of a tuple, so it gave me an error. But it also modified the first element of the tuple. I find this hilarious.

5th September 2008

5:27pm: What were Obama's grades?
The Libertarian VP candidate Wayne Allyn has a $1,000,000 challenge to Obama: he bets that his grades at Columbia were better than Obama's, despite the fact that Obama got into Harvard law and Allyn didn't. The idea being that it was affirmative action. I don't have any love for Allyn but I find the bet amusing.

2nd September 2008

9:18pm: Brioche recipe
Rich-Man's Brioche
recipe by Peter Reinhart, adapted to sourdough by Nathan Whitehead

Start with sponge:
1/2 cup active culture (1 dollop)
1/2 cup warm milk
1/2 cup flour
Mix and let sit for 1 hour or until bubbles start to form.

Dough:
5 eggs
3 1/2 cups flour
1 tablespoon sugar (original called for 2 1/2 tablespoons, I don't like sweet tastes)
1 1/2 teaspoons salt
1 lb unsalted butter
Add 5 eggs to sponge, mix on medium speed until smooth. All mixing is
done with paddle, not hook.
Add bowl of premixed dry ingredients: flour, sugar, and salt.
Mix on low speed for 2 minutes, make sure all flour is hydrated and mixed in.
Wait 5 minutes.
Turn to medium speed, slowly add 1 pound of butter at room temperature
in chunks of several tablespoons at a time.
Wait until each chunk is mixed before adding the next. Should take a
few minutes to get all the butter in.
Continue mixing for 6 minutes, scraping bowl sides every 2 minutes.
Line square pan with oiled plastic wrap. Put dough in pan, wrap with plastic.
Put in refrigerator (or into a large plastic bag and then refrigerator).

Shaping:
Take dough out of refrigerator, work while cold.
With a little flour, cut into 3 rectangles and then tightly roll up
into log shapes.
Put logs in loaf pans, sides of log should just barely touch sides of loaf pans.
Let proof 4 hours (should expand significantly, a bit more than regular loaves).

Bake:
Bake at 350 F for 40 minutes, internal temperature of 190 F.
Cool 1 hour.
Freeze unused loaves immediately in plastic freezer bags.

Serve:
Slice 1 in thick. Microwave frozen berries until warm and juicy.
Layer 1 slice, spoonful of berries and juice, 1 slice, spoonful of
berries and juice, top with whipped cream.

Variation:
Use 1/2 the butter, lower salt to 1 1/4 teaspoons. This is
Middle-Class Brioche.

12th August 2008

4:14pm: Play "Braid" Now
If you have an XBox 360 you need to play "Braid" now. It's available on the Live Arcade for $15.

The story is awesome and the puzzles are great. Figuring out some of the puzzles really reminded me of learning cool new math concepts.

7th August 2008

11:17am: Estimate Your Gender from Your Browser History
Estimate your gender from your browser history. It's a fun calculation, it shows the top sites you visit and the male-female ratio of visitors to those sites. I got a 76% male, 24% female estimate. My female sites were youtube and livejournal. My most male site was slashdot. Most of the others were mostly neutral but slightly skewed male (e.g. craigslist, NYTimes). Fun stuff.

6th August 2008

11:09am: Getting a Job
I'm applying for jobs in industry. Help me out! If you've worked somewhere fun that you recommend, let me know in a comment. I'm looking for tech jobs that perhaps involve some programming but that aren't code monkey positions, preferably in the Bay area. Right now I'm open to anything. Anonymous comments allowed.

15th July 2008

9:12pm: SWMixer released
I would like to announce the release of SWMixer, an advanced software
mixer for sound playback and recording. It is written entirely in
python. It uses NumPy array operations for fast performance and
PyAudio for audio playback and recording.

At the moment it is fairly untested. It works well on my computer
using a couple test WAV files I have created. Please test it out to
see if it works for you with acceptable performance. PyAudio is
cross-platform, so SWMixer should theoretically run on all major
platforms.

Grab SWMixer at:
http://pypi.python.org/pypi/SWMixer

The README file explains how it works a bit more and shows some
examples of how to use it, including using swmixer with pygame. Look
at the README file here:
http://code.google.com/p/pygalaxy/wiki/SWMixer

13th July 2008

9:13pm: PBF Comics
Just finished reading the archived comics of the Perry Bible Fellowship Comic. Lots of great funny strips. The navigation is a little unobvious, start here and keep pressing "newer" to read the archives.

7th July 2008

1:52pm: Multiple audio sources in Ubuntu
I am so impressed with the latest versions of Linux software, they make everything so easy. Right now I'm listening to internet radio using XMMS while simultaneously playing sound effects using pygame. The general trick is to select ALSA as your driver in all the applications you want to play simultaneously. Gotta love Ubuntu.
Powered by LiveJournal.com

Advertisement