MapIt program to launch Google Maps

September 30th, 2011

I was tired of copying an address, then opening a new tab and then going to http://maps.google.com and then pasting the address, and hitting return.

So I’ve written a program that will automatically open a new browser window pointed to Google Maps at whatever text is in the clipboard. Now I just copy the address, hit Win+R to bring up the Windows “Run” dialog, and then type “mapit”. Instant map.

You can also type “mapit <type address here>” to run it from the command line.

Download the Windows Executable (6.2 MB, big since it’s a compiled Python script)

 

Download the Python script (2 KB)

The Python script should work with Python 2 and 3, and on Windows, Mac, Linux (but I haven’t tested it on Mac & Linux yet).

Here’s the code on github: https://github.com/asweigart/mapitpy

JavaScript Cipher Wheel

September 21st, 2011

I’ve created a web version of the Caesar Cipher wheel using JQuery and CSS sprites.

JavaScript Cipher Wheel

I also have a Pygame version and Windows executable of this.

Nobody Cares About a Few Million Nanoseconds

August 19th, 2011

Note: This article originally appeared on my programming book’s blog.

A Clever Programming Trick…

If you need to swap the values of two variables, this usually requires a third temporary variable (that is, if you’re not using a language like Python that supports the a, b = b, a syntax.) It looks something like this:

temp = a;
a = b;
b = temp;

But if these are integer variables, there’s a nifty trick to save yourself a little bit of memory. You can use arithmetic instead of a temporary variable:

a = a + b;
b = a - b;
a = a - b;

If the integers on your platform are 32-bits, your new swap will save four bytes of memory.

NOBODY CARES ABOUT FOUR BYTES OF MEMORY. (more…)

Do you have free will?

July 21st, 2011

Another t-shirt design I made. I threw it up on my Zazzle store for the cheapest possible price.

Vampire Numbers Visualized

July 19th, 2011

Vampire numbers are fairly interesting. Vampire numbers are numbers whose product contains the same digits as the two vampire numbers. For example, 21 x 60 = 1260. The two vampire numbers (called “fangs”) must be the same length and both cannot end with a zero. A longer example is 68088 x 45321 = 3085816248. You can find out more about these numbers on Wikipedia.

It’s fairly simple to write a program to calculate vampire numbers. I was somewhat bored and went ahead and wrote one up. Download the vampire number generator.

I’ve gone ahead and calculated all of the vampire numbers up to five digits. You can download the full text file of vampire numbers here (zipped, it’s about 1.06 MB). The nifty thing is, if you plot these numbers on an image with the two fangs being the X and Y coordinates, you get a pretty interesting image. This image is 500×500 pixels and covers the range of 0 to 100,000. Each pixel represents a 20×20 range of numbers. The more dense this area is with fangs, the darker the pixel is colored in. The 0, 0 origin is in the lower left. The final image has an interesting pattern:

Next Page »

Powered by WordPress