Determine your location from relative FM radio signal strengths

In this post, we’ll take a brief measurement of regular old FM radio stations and try to determine where we are. It’s like a GPS but with local FM transmitters instead of satellites. I did this just for fun. I wonder if it could be used for indoor location and stuff? It is nowhere near as accurate as GPS. But whatever.

calibrated_result1Reading FM radio signal power

The first step is to get a reading of all the nearby radio stations. I used gnuradio and a HackRF One software defined radio. A simple flow-chart that takes the FFT and dumps it to a file is all I needed. I had to throttle the I/O or else my computer would freeze. I used 16M sample rate to have as wide a bandwidth as possible.

The gnuradio flow-chart used to gather data
The gnuradio flow-chart used to gather data

The file sink saves the FFT results in 4-byte integers and just has one 1024-length vector after the other. In a few seconds, I had a 50 MB of data. I did all the post-processing in an external Python script.

Continue reading Determine your location from relative FM radio signal strengths

Home automation with Z-Wave, Home-Assistant, Aeon Multisensor, HUE lights, and a Raspberry Pi 2

I’ve always dreamed of having a “smart-home.” There’s just something cool about being able to flip switches and read sensors and have a program turn a light on when you open the door, but only if it’s dark. This post is about home automation.

UPDATE: I made a video demoing everything:

Continue reading Home automation with Z-Wave, Home-Assistant, Aeon Multisensor, HUE lights, and a Raspberry Pi 2

Why your 32nd birthday is a momentous ordeal

Turning 32 may not seem like a very exciting birthday, but it is! In fact, it is the most momentous birthday of all, because it’s the first time in your life that you can’t show your age on a single hand.

Counting in binary.

First, a refresher. Binary, (popularly known as the number system of computers which think in terms of ons and offs, as represented by ones and zeros) is base-2, whereas good old decimal is base-10.

This means that in the decimal system, we have:

One 0001 100
Ten 0010 101
One hundred 0100 102
One thousand 1000 103

Whereas in the binary system, we have:

One 0001 20
Two 0010 21
Four 0100 22
Eight 1000 23

Continue reading Why your 32nd birthday is a momentous ordeal

My new color-changing LED lights

My wife got me an early birthday present: Philips HUE Color-Changing LED lights! They’re incredible. Look:

Right now I’m controlling them with my tablet, which is fine for changing colors and setting light alarms. I can even control them from afar thanks to my VPN. I will soon hook them up to my nascent Raspberry Pi powered home automation system (using the open-source Home Assistant program) that will allow me to trigger them based on various events like motion, doors opening, weather changing, or whatever. The future is here!

Each bulb uses 9 Watts but makes the same amount of light as a 60W conventional bulb, so they’re very eco-friendly. Furthermore, since they’re LEDs, they should last for 15 years of normal use! They communicate with a little hub that uses the ZigBee protocol (like Bluetooth but lower power and lower speed, good for home automation stuff).

Downside: They’re pretty pricey. I expect their coolness to drive demand enough to bring supply up. Expect these bulbs for $10 in the next few years.


Sending and receiving Morse code with a laser and a Raspberry Pi

Sending and receiving text with Morse code light pulses across the room (or to your neighbor) is a fun and cheap project you can do on a Raspberry Pi or Arduino or any other microcontroller.  This post explains how I did it, and how you can do it too.

Laser blinking
It’s working!


The hardware is simple and cheap. Here’s my parts list:

  • Raspberry Pi B+ as the controller. This does the sending, receiving, and signal processing.
  • Photoresistor – Just a little guy that has variable resistance based on how much light is hitting it
  • A 220 Ohm resistor – to make a voltage divider with the photoresistor for reading the input signal
  • MCP3008 10-bit Analog-to-Digital Converter (ADC) – Since the RPi doesn’t come with an ADC, this is required for converting analog voltage from the photoresistor into a signal I can process on the RPi.
  • Laser module – to transmit with laser light. I got one from for like 3 bucks.
  • Breadboard, wires

You can learn how to use the ADC at this Adafruit tutorial. I decided to talk to the ADC with the RPi’s hardware SPI interface, which I had already enabled. I wanted to be able to go very fast. (You can alternatively do SPI off of GPIO ports with software, if you prefer.) The laser just hooks directly between a GPIO and +5V. Here’s the layout:

Wiring diagram
The wiring diagram

And what it actually looks like:

The actual laserComm hardware.
The actual laserComm hardware.

Continue reading Sending and receiving Morse code with a laser and a Raspberry Pi

Data acquisition and live-plotting over the network with a Raspberry PI and Python

Sensors are fun! I wanted to keep an eye on the temperature of one of my home physics projects and realized I needed a thermocouple and a convenient way to read it. This post is about how I got one and wrote a Python program to send the data from a Raspberry PI over the network to my laptop, which plots the results in real time.

Thermocouple in fridge
Thermocouple in fridge

I bought a K-type thermocouple for several dollars that ranges from -100°C to 500°C. The Seebeck effect that makes it work only gives microvolts per degree so I needed a good amplifier for it. And since I wanted to read it on a Raspberry PI (which only has digital inputs), I’d need an analog-to-digital converter (ADC). Conveniently, the MAX31855 does amplification and ADC and is like $15, so I got one. Sweet. There’s even a Python library for it that makes it easy to access. Double-sweet.

The MAX31855 thermocouple amp and ADC
The MAX31855 thermocouple amp and ADC

Continue reading Data acquisition and live-plotting over the network with a Raspberry PI and Python

My old flux capacitor project

Alright, this is an oldie, but ah… well… it’s and oldie where I come from. In 2005, I  had some healthy spare time and decided to build a flux capacitor. I posted the details on my old webpage. I just rewired a battery pack on it and it’s working fine so I figured it was time to get it back online again. So, here it is. How to build a LED flux capacitor.

The Concept

In the movie Back to the Future, Dr. “Doc” Emmett Brown completed his life goal of making the flux capacitor a reality. Here’s the story:

“I was standing on the edge of the toilet hanging a clock, the porcelain was wet, I slipped, hit my head on the edge of the sink — and when I came to I had a revelation! A vision! A picture in my head! A picture of this! This is what makes time travel possible! The Flux Capacitor.”

-Doc, Back to the Future

The Flux Capacitor
The Flux Capacitor

Unfortunately, I didn’t have room for the time circuits or nuclear reactor to generate the 1.21 jigawatts that the flux capacitor needs to travel in time so we’re going to have to go with the next best thing: A 30 LED sequencer!

Continue reading My old flux capacitor project

Reading out a Crookes radiometer (light-mill) with Python and OpenCV

Since I’m on a late 1800s physics kick, I’ve been staring at my Crookes radiometer a lot.

My Crookes radiometer, or light-mill
My Crookes radiometer, or light-mill

You might remember these from the hands-on museum. Today, these are just novelty items, but back in the 1800’s, there were actually scientific instruments that could quantitatively read out the amount of incoming radiation (like visible or infrared light). They were generally read out using a calibrated spinning disk with slots in it. It’s like when you have a fan spinning in a dark room, and you adjust a strobe light until it looks like the fan isn’t spinning. Then, if you know how fast the strobe is blinking, you know how fast the object is spinning. This is called a stroboscope.

Well, I don’t have a stroboscope. But I do have a digital camera and a computer. As it turns out, I can read the Crookes radiometer using that!

Continue reading Reading out a Crookes radiometer (light-mill) with Python and OpenCV

The modern era passed through a cathode ray tube

Or, why I built a cathode ray tube in a wine bottle.

I was leisurely reading Linus Pauling’s textbook, General Chemistry, the other day, and I found the history he threw in there with the science to be thrilling. For instance, I learned quickly that the Greek word for amber, elekton, forms the base of our word electricity, so named by William Gilbert in the late 1500s because the ancient Greeks knew that rubbing amber with wool would attract feathers and stuff. As a nuclear engineer whose job it is to make electricity, this was a fun revelation. Pauling continues to mix physical realities with the experiments used to prove them, and doing so, he quickly arrives at the cathode ray tube. After reading and thinking about it, I had another revelation. It turns out, I realized, that some large fraction of modernity, from the world order to modern health, the environment, politics, and the media passed through a cathode ray tube. Here’s how.

General Chemistry cover
General Chemistry by Linus Pauling

Continue reading The modern era passed through a cathode ray tube

Remote ham radio operation through a Raspberry Pi

This post is about how I set up remote operation on my ham radio through a Wifi network, over a VPN, and around the world using a Raspberry Pi, like this:


This could be useful for people who travel a lot and want to be able to use their rig while away. Or for people who want to set up their radio and antenna far away from where they actually live (e.g. apartment dwellers who have friends or parents who live in the boonies and wouldn’t mind you erecting an antenna). If you want to skip the VPN and just control your ham shack from your kitchen, that’s even easier.

I did this all with an ICOM-7100 all-mode radio, a Raspberry Pi B+, a Buffalo DD-WRT router/VPN server, and a laptop running Ubuntu 15.04. This post focuses on the radio control and networked audio but not on setting up the VPN.

Continue reading Remote ham radio operation through a Raspberry Pi

My first day on the amateur radio HF bands

I got into ham radio a few months ago and upgraded to a General-class license last weekend. This is a big step for ham radio people… the moment where you go from being able to talk to people ~30 miles away to being able to talk around the world. Anyway I went out and got a new 100W all-band, all-mode radio, an auto antenna tuner, a deep cycle battery, a 30A power supply, and a mini-Buddipole antenna. Woo!

I had a lot of trouble getting my first contact. I tried every night after work all week. I tried from Volunteer Park, my communal rooftop deck, and my friend’s roof on the 33rd floor of his building. I set the Buddipole up for 20m and heard people from the park but they couldn’t hear me. On my rooftop, I got nothing but S9 noise everywhere and couldn’t hear a thing. Same story from friend’s roof.

Well, I found that you can’t just use the settings that come in the Buddipole manual. Especially if you have the 8ft mast. It’s not high enough to do a 20m dipole efficiently (all RF goes straight up in the air. Read this whole book to understand). So you have to set it up as a vertical like this:

Buddipole as 20m vertical
Buddipole set up as a 20m vertical.

Continue reading My first day on the amateur radio HF bands

Installing the RF shield in a HackRF One

I recently got a HackRF One software defined radio (SDR) to go along with my new Ham radio hobby. I’m new to all this, but one of the first things I noticed was that I was picking up a lot of radio frequency interference (RFI). I had purchased a RFI shield as part of the kit but had to install it myself. This post shows how I did it.

Opening the HackRF enclosure

The first challenge is opening the enclosure. To do this, first take the bolts and washers off of each of the SMA antenna connectors. Now, go in above one of the connectors with a little screwdriver (maybe put electrical tape over it) and start popping up the enclosure. Eventually you will pop it all up.

Installing the RF shield

Now we have to solder the RF shield onto the board. There’s a dotted line that shows where it goes.

Here's where the RF shield will go.
Here’s where the RF shield will go.

Continue reading Installing the RF shield in a HackRF One

You can use open-source Linux for most stuff these days

Linux is an open-source operating system that you can download and install on your computer to complement (or even replace) your current operating system (Windows or MacOS). It started out when some guy wrote some code and gave it to the world community for free. It has become huge, and now provides the engine of Android phones and tablets, runs about 40% of the servers that make up the internet, and powers 97% of the world’s supercomputers. It’s a stunning success in the social open-source experiment.

For home use, it is just now ditching a reputation of being only for nerds, scientists, and hobbyists like me, with lots of headaches getting software and hardware working nicely with it. Really, I’ve been using it at home on my laptop since 2007 and it’s evolved to a point where I think it’s totally usable for most people. It also has a focus on privacy, security, and stability. Since the code is open (everyone can see and change how and why it works), there’s less mystery about what anyone is doing with your computer and more control to get it to do what you want. It was the speed and low-resource requirements that brought me to Linux originally, and it’s the quality and open philosophy that has made me a real proponent.

My desktop
My freshly-updated Ubuntu 15.10 desktop

Continue reading You can use open-source Linux for most stuff these days

Import precedence for different types of python extensions

I was doing some speed tests with cython in Windows and started wondering what the import precedence was between py, pyc, and pyd files (not to mention pyo). So I did a simple little test with two files, and just had a print statement in it and test2 just imported test1 (so it would create the pyc). I compiled with cython into test.pyd and then changed to print something else.

Conclusion: The pyd file was always imported if it was present. If it wasn’t there, then the new print statement from the new was printed out. I’m sure this is documented somewhere but I’m not sure where. The conclusion holds if there are “optimized” pyo files present as well.

Basic internet security primer

So with all the recent revelations about everyone spying on everyone, I decided to look into what it would take to get fairly secure communications capabilities so my stuff wasn’t just in the open. I became a cryptography dilettante, and it is pretty fun.  I have explained what I’ve learned to a few people so I figured I’d just write it all down here. It’s surprisingly easy and free to do.

Writing secure emails or transferring files securely

One basic thing you should be able to do securely is to send an email or file to someone that only they can open. To do this, you can use a free technology called Pretty Good Privacy, or PGP. Some nice free software that uses this is called the Gnu Privacy Guard. Go to and download the relevant files. If you’re on Windows, get gpg4win (be sure to install GPA when it asks), Mac users can use GPGTools, and Linux users can just get GPG and GPA (Gnu Privacy Assistant) from the repos. Step 1 now is to generate your public/private key pair. These are basically just really large numbers that are intimately tied together in a way that if someone encrypts an email or file against your public key (which you will give to them), then only he/she who possesses the private key can decrypt it. So you publish your public key far and wide (here’s mine) and keep your private key very secret and safe (and backed up on a USB stored in your safe). Anyway, just go into the GPA program and click Keys->New Key. This will generate your keypair. Protect your private key with a strong password (10+ characters, no dictionary words. And don’t do capital letter + lower case letters + numbers + symbols in that order. Everyone does that!)

Now that you have a keypair, just right click it and say export key. This will export your public key to a file. Email the file or publish it online or whatever to anyone and everyone. When they send you an email or file, they will encrypt to this public key. Meanwhile, have your friends do the same and then import their keys that they send to you (keys->import key).

To actually encrypt, just go to Windows->clipboard and type some juicy secret. Then click encrypt and choose who you want to encrypt it to. Finally, just email them the ciphertext. It’s best to use a text-mode email by the way, so do that (it’s an option in gmail, etc.). They will get it and they can copy and paste it into their GPA and click decrypt, enter their secret password (which unlocks their private key), and they’re off. Phenomenal. Files can go the same way, just choose window->file manager instead of clipboard.

a secret message
a secret message

Alright! Super easy. If you use Thunderbird to read your email, you can use the Enigmail plugin that seamlessly encrypts for you. Nice! If you want a web-based email account that has tightly integrated PGP and no ads, try out hushmail.

There are a bunch of other cool things you can do with PGP like electronically sign your messages. This is something that you put at the end of an unencrypted (or encrypted) message that someone can “verify” against your public key. If no one has tampered with the message and you wrote it, then this verification proves that it was you who wrote the message. So cool.

Chatting and browsing the web anonymously and securely

So, great. Now, what if you’d like to chat with someone online and not have it be read? That’s your right. One pretty easy way to do it is through something called cryptocat. This is a Firefox extension that allows you to very easily have fairly secure chats. You COULD just click the link and install it, but you should really use The Onion Router too, which anonymizes your web traffic as well. That way, whatever you do online cannot be traced back to you because it hops through a secure set of encrypted layers on different volunteer servers first. So, FIRST go to and install Tor and the Tor browser (there’s an android version too!). Then, open up the Tor Browser (which will automatically connect you to the Tor network), and then go to cryptocat and install the extension. Now you can open up a chat room and have a nice time chatting securely and anonymously. Excellent! You can use the Tor browser for anything else too.

Besides using Tor, you might want to stop using Google for many things. I started using DuckDuckGo, which doesn’t save your search history for hackers or rouge employees (or anyone else) to steal later. It’s not as good as google really, but it’s the principle that counts.

Security on your phone

If you have an Android phone, you can get these three cool apps that help with security. First is TextSecure, which allows you to exchange encrypted texts with anyone else who has TextSecure. It also stores your texts on your phone in an encrypted database, so if you lose your phone, no one’s reading your stuff. The same company makes RedPhone, which allows you to speak with anyone securely who has RedPhone. That’s totally sweet. I will admit that the voice quality in the case I used it in so far was mediocre. Finally, there’s Orbot, which is Tor for your phone, anonymizing your web traffic. Fun times.

Securely store files

If you want to keep a USB stick or a part of your hard drive that is encrypted (in case it gets stolen or something), the TrueCrypt tool is fantastic. It can even make a Hidden volume, where if you type a dummy password, dummy files show up but if you type the real password, the real files show up. And no one can prove the real files exist. That gives you what’s known as plausible deniability, a term coined by the CIA.

Encrypting with Truecrypt is different than with PGP because to send the file, the recipient would need to know the password. But how can you send the password securely? With PGP. So might as well just use PGP for the whole transfer.

If you’re a friend of mine who wants to try any of these technologies out with someone, just drop me a line and I’ll play along. I got a lot of this info from a reddit AMA, which you can read here.

Privacy is important, even if you have nothing to hide. Ok have a nice day!

Update: There’s a great collection of related information at this page.

The dramatic end of my ’97 Jeep

Note how much snow there was when I camped (under the car).

My dad sold me a ’97 Jeep for $1 in 2006. It had originally come from Kentucky via my older sister. He sold it to me because I was about to drive from Michigan to Idaho and I’d need a reliable vehicle. The Jeep carried me across the country, taking me to the northwest for the first time, where I saw Yellowstone, the Tetons, and my first tumbleweed.


Once in Idaho, I took it hiking and camping every weekend. Into the mountains, through small rivers, out rock climbing. The one day I woke up in a tent surrounded by 10″ of snow on a mountainside, it delivered me to safety. Since then, the Jeep and I have been through a lot together and as a result I felt a surprisingly close connection with a completely inanimate object.

The jeep on its way out of my life

On August 15 2012, 6 years since it entered my life, I watched the Jeep get towed out of my parking garage by a wrecker, all up on a dolly and everything. It was totalled.

So what happened?

One nice August Saturday night, I threw a big party at my apartment. A “moving out soon” party, even though I wasn’t moving out for another month. I went to Costco to get supplies and unloaded lots of stuff from the Jeep and took it up. Everyone came and it was lots of fun. The next day, I slept in and eventually went somewhere late in the afternoon. I was going to motorcycle, but realized I couldn’t find the garage door clicker. I checked in the Jeep, where I realized I must have left it while unloading that big Costco load. It was then that I noticed something peculiar: the seats were reclined! Someone had been in my car! Oh well, no surprise, people get in this garage all the time and mess around in people’s cars. They had punched out my window once to steal a $10 item so since then I just left my doors unlocked. Obviously someone had just hung out for a while. I didn’t see the garage door opener. What I did find, however, was an unfamiliar cell phone. I took it up to my apartment. I manually overrode the garage door and went about my business.

I’m blue da-buh-dee-da-buh-die

Scene: Tuesday night. I come rolling in from work on the motorcycle, late for my soccer game. I have to change quickly and get going. As I’m heading out, I notice something funny with the Jeep. At closer look, the radio is ripped out! And the interior is all spray painted blue! The dashboard is completely blue. The center console is opened and everything in there is blue. The carpet is blue. The trim is blue. Everything’s blue. The radio isn’t stolen. No, it is just dangling by some wires. Blue wires. What’s worse is that the ignition is all chewed up and mangled. There’s no way to get a key in. Someone tried to jack a ’97 Jeep with 193k miles. Mother fucker.

So the cops come out and spend an hour dusting for fingerprints. They ask me a bunch of questions and I give them the cell phone. “Have you pissed anyone off recently? Like, did you maybe cut someone off without noticing?” No, I tell them. Not that I can think of. “Any psycho exes or anything?” Well, maybe… but not this psycho. I tell them that the video will tell all. Once I get a hold of the building guy and look at the videos, everything will become clear. They agree and head out.

As I’m pulling some stuff out to take upstairs, a neighbor comes down and I tell him the story. “Hey is the spray paint blue?” he asks. “Because there’s a blue can of spray paint under this car!” I call the cops right back and they come pick up the can to take it to the lab.

Come on in
Who’d we let in? Oh well.

The next day, I got some video from the building guy. It showed a long-haired 40-year old guy buzzing everyone at the apartment at 3:30am Saturday night until someone let him in. He saunters into the lobby and props open the doors to the garage. Seconds later, a young couple emerges from the elevator (likely to see who they just buzzed in). They look around confusedly and point to the garage a few times and then close the doors. Now, the thing about my garage is that there has been a lot of trespassing, and so the building guy made it impossible to leave without a key. Surely that’s a fire code violation, but whatever. The effect was that this long-haired fellow was now locked in the garage.

Here’s a nice place to sleep.

The videos show him walking around a bit but not much more. I was disappointed and knew there must be more footage. I gave it to the cops anyway. The detective called and said, find more footage, this gives us nothing. I got the building guy to let me look for more details and I found them.

Bet I can make $5 of some light bulbs.

The guy had clearly slept in my car. He slept in there until about noon on Sunday! If only I had gone down earlier! Why was my party so good?! My neighbors even saw that there was a guy in there but didn’t know my number to call me and they were in a hurry so they just ran off without saying anything. He wakes up at noon and grabs a box of fluorescent lights and walks off. In doing so, we get a nice look at his face.

Where’s my phone?

But then the good stuff happens. 3:30pm Tuesday, here he comes! Walking in all cool. He opens the passenger door and rummages around for a while, probably looking for that cell phone! He doesn’t find it and starts walking out. But wait! He turns around and heads over to where he got the lights from. Grabs a can of spray paint from the paint shed, and goes back to the car to do the damage. Apparently he wasn’t satisfied with the customer service of my Jeep.

I’m an artist.

Now that it was obvious that the guy had my clicker (my fault for leaving it in the car… so stupid!), I was able to convince the building to change the code on the gate. Since my window had been punched earlier, I had comprehensive insurance on that old car (unheard of for ~200k miles!) so I got way more for the jeep than I could ever have sold it for. The detective is actually on the case and has some leads.

In fact, they’ve positively identified the guy with fingerprints on the spray paint can and are prosecuting on behalf of the insurance company. Justice will be served. I’m only a little worried that this vengeful bastard will be even more vengeful after the prosecution starts! Conveniently I’m moving in like a week.

Meanwhile I joined the rest of my Seattle brethren and got, of all things, a Subaru. It’s no Jeep, that’s for sure. And women have already ridiculed me: “Why don’t you just put a car seat in there too, hahaha!” But I just couldn’t justify the hilariously low gas mileage of the Xtera, which was really the only SUV short enough to fit a motorcycle in the same parking spot as it (essential in the city: Jeeps are incredibly short!). This thing will get me to the trail heads and the ski hill, and to be perfectly honest I haven’t used the Jeep for rock crawling since ’07.

Moral of the story: lock your doors, don’t leave garage door clickers in your car, don’t buzz people in your apartment at 3:30am who you don’t know, leave arbitrary cell phones where they are, and have comprehensive insurance.

The good new is, the only valuable things in the jeep were left untouched: the flux capacitor and the subwoofer my friend Karl gave me in 2002.

people crave community…through conflict?

The USA is divided in many ways. There are strongly-held dichotomies in all arenas, from politics to sports. People identify with liberals, conservatives, city people, country people, whites, blacks, red sox fans, yankees fans, geeks, jocks, the rich, the poor, kids, adults, skinny people, fat people, fashionistas,  involved people, apathetic people, 420-friendly people, 420-unfriendly people, singles, couples, etc. And many of these identity distinctions are somewhat surprisingly dear to those who hold them, often associated with instantaneous judgment of any opposing groups. Liberal city people don’t respectfully disagree with their opposition, they truly think that they are pure idiots! Particular religious people don’t turn the other cheek, they declare war on contraception! And it’s most obvious of all in sports. “Those a**holes on the other team are so evil and horrible that I just can’t stand it!” I actually know people who pack extra cans of gas when they drive through Ohio so as to not “support their economy” for this reason. (Don’t even mention the ref when he makes a call against my team! Complete imbecile!)

Within these groups, confirmation bias runs rampant. People surround themselves with like-minded peers, further pushing productive discourse into a neglected and forgotten corner. “You’re either with us, or you’re against us! And there’s no in-between,” we say.

I was having a typical conversation at work, discussing life after the next apocalyptic event. It occurred to me as we discussed our plans that the first few days after rule of law falls would be the scariest. People rioting through the streets, looking everything in sight, killing on a whim to get a pretzel or something; every man for himself. During this time, I plan to just hunker down with some PB&J and wait out the craziness. But after a few days, somewhat structured neighborhood alliances would form, enabling me to have a bit of trust in those around me. Instead of every man for himself, it’s now us vs. them. And in that situation, I’m feeling much safer. I can cooperate with people again and defend against the neighboring block when they decide to invade again, and so on. Hooray.

Snapping out of this dark fantasy, and thinking instead about our less dire identity complexes, I came up with the following hypothesis.

Humans need safety to survive, by definition. Community groups have historically offered a bit of safety against the roving hoards. As old structures (such as neighborhoods, small towns, and churches) decrease in dominance in the modern US, there is an equal and opposite force diminishing community. Naturally, we have a subconscious urge to regain some community, so we do it the old way, but in lieu of “real” danger, we fabricate enemies through fairly trivial mechanisms (think sports) and in doing so, recreate the good old feeling of being part of “us” where they, those bastards, are part of “them.”

If this is the case, then the natural antidote to cure our fabricated identity wars is to bring community back. Things like Facebook show how much we want it, but they are still pretty empty in terms of how well they satisfy our instinctual quest for safety. Everybody knows there’s something ridiculous about how pigeon-holed we have made ourselves, but we’re all in a kind of daze as to figuring out what to do with our ceaseless and unproductive arguing.

Others have argued similar points, but not quite for this reason. A book review I read in New Scientist of this book explained that this author claims that secular society needs religious institutions to be happy. There may be some truth to that, but trying to promote these ideas coming from an atheist group is just fanning the flames. It’d be nice to get some easy community going that is inclusive to both religious people and secular people. Maybe after cookies-and-punch hour we could all get together on Sunday afternoons and have community members give little talks about things they’re good at, or a news story they’ve been following closely. There could be like 10 rooms, and you can go from one to the other depending on your interests. The mechanics could host a “learn to change your own tire day.” If we could somehow institutionalize these kinds of gatherings, thereby giving people a little community, I think the ridiculous arguing would slow down, and we might feel better about ourselves.

how to fix: ctrl-c closes ipython within console2

Just FYI, I was having a problem with ipython 0.12 running within Console, where pressing Ctrl-C to cancel an operation in a Python would actually just close the whole ipython window! It was horrible, since before I reinstalled everything it wouldn’t do that. Anyway, there’s an email chain talking about this here, but it’s irrelevant to this particular problem, since I’m using mainline (non-dev repo) versions and don’t know what an ETS is.

Thankfully, there’s a very simple solution (assuming you made my same mistake). Rather than setting the console tab to C:python27scriptsipython.exe, instead set it to C:python27python.exe and Ctrl+C will give a KeyboardInterrupt and leave you in ipython, just like the good old days!

Building a python extension with Trilinos 10.10 on 64-bit Windows 7

Continuing the journey, the folks at work upgraded me to 64-bit Windows 7 and the Trilinos folks updated to 10.10. Needless to say, I had to rebuild. I can’t definitively say which of these steps is necessary but I can tell you that if you follow them, you can compile a C++ python extension that uses many aspects of Trilinos on this system. And not just a few packages from Trilinos either. In fact, I’m currently using all of the following:

  • Epetra
  • AztecOO
  • Anasazi
  • Teuchos
  • epetraext
  • Amesos

To do this, first run the trilinos cmake system without shared libraries. Then build. This builds things like epetra.lib. Now, go back and turn on shared libraries and build again, this time with shared libraries turned on. This builds the dlls, which I believe are required to build a python extension. If one of the ones you needs fails, just go in to Visual Studio 2008 and open up the Trilinos solution. Right click the project. Change from a static library to a dynamic librray. Change Use of MFC to “Use MFC if a Shared DLL.” Change Use of ATL to “Dynamic Link to ATL.” The rebuild the package. The DLL should be created.

Build trilinos shared library
VS 2008 options to build shared libraries

Once all the static and shared libraries are built, I didn’t even mess with environmental variables (being a grad student and all) so I just copied them all into the build directory of my Python extension. On import, it worked just fine. Amazing!

I have yet to try linking to MSMPI and running large reactor problems on Microsoft HPC but that will be coming someday.