Archive for November, 2008

Mini Searches with Answers

Sunday, November 23rd, 2008

These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.

Any pointers/advice to help learn CPython source?
How is Python formed? How interpreter get imported?

ExcelWriter Question – How to Open Password Protected Excel File
If you ever need to open a password protected Excel file, or add a password to one using ExcelWriter in Python, here’s how:

xlapp = wn32com.client.Dispatch('SoftArtisans.ExcelWriter')
xlapp.DecryptPassword = 'MyPassword'
xlapp.Open(f)

mozdev.org – twanno
How to pull a Firefox tab into a new window (tab tearing)

Winpdb – A Platform Independent Python Debugger » About
Winpdb is a platform independent GPL Python debugger with support for multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb.

Tags: , , , , , , , , , , , , , , , , , , ,

Mini Searches with Answers

Tuesday, November 18th, 2008

These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.

in Electronics what’s the Difference Between a Resistor and a Heating Element? : AskReddit
Mostly me talking to myself in an empty Reddit thread, coming to terms with Ohm's law.

xkcd • View topic – Superconductor confusion
How Ohm's law applies to superconductors

Tags: , , , , , , , , , , , , , ,

Mini Searches with Answers

Wednesday, November 5th, 2008

These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.

How to access iframe in jQuery
$('#iframeID').contents().find('#someID').html();

Most efficient way to search the last x lines of a file in python – Stack Overflow
Good way to read the end of a file, or get the file size.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , ,

a MySQL Table of Zip Code Latitude/Longitude Coordinates

Saturday, November 1st, 2008

I was working on adding location awareness to GigBayes today and ended up making a table of zip codes and their coordinates. I figured it would be nice to share it with the world:

So here is a pre-made MySQL table containing US zip codes and their latitude and longitude (.zip 820K)

I got the data from here, and then deleted any zip codes which where missing coordinates.

You can also create this MySQL function to use for finding the distance between locations:

CREATE FUNCTION `earth_distance_miles`(p1 point, p2 point) RETURNS int(11)
RETURN
((ACOS(SIN(x(p1) * PI() / 180) * SIN(x(p2) * PI() / 180) + COS(x(p1) *
PI() / 180) * COS(x(p2) * PI() / 180) * COS((y(p1) - y(p2)) * PI() /
180)) * 180 / PI()) * 60 * 1.1515)

The formula comes from here.

You’d use the function like this:

SELECT earth_distance_miles(
(
SELECT location
FROM zip_code
WHERE zip = '06902'
), (
SELECT location
FROM zip_code
WHERE zip = '20905'
)
);

Which gives us 227 miles. A very reasonable answer.