Safe Destroy Callbacks in wxPython

October 7th, 2012

Say you’re writing a wxPython GUI, and you want a menuitem that spawns a popup frame, and that stays disabled until that popup is gone.

The obvious thing would be to do this.


self.popup_menuitem.Enable(False)
self.popup_frame = wx.Frame(self, wx.ID_ANY)
self.popup_frame.Show()

def destroyed_callback(e):
  self.popup_menuitem.Enable(True)
self.popup_frame.Bind(wx.EVT_WINDOW_DESTROY, destroyed_callback)

Disable the menuitem, spawn the popup, and reenable on destruction.

Problem: What if you close the parent window first?
That’ll also cause the popup to close. But by then, there’s no menu left to toggle because the parent’s gone. You may get a PyDeadObjectError, or the OS will step in to complain. Bad.
 
Read the rest of this entry »

Exotic Mechanics

May 11th, 2012

“Mechanical Principles” by Ralph Steiner (1930)

 
 
For more outlandish gear and pulley arrangements, there’s a book called “507 Mechanical Movements” (1896).
Loads of eye candy. Even pages are diagrams; odds are captions.
Read: Google Books
Download: Archive.org
Buy: Amazon

The Real CSI

April 18th, 2012

Frontline aired an episode last night on the rigour of forensics.

(Via Frontline – The Real CSI)
 
 
For a bizarro version of the narrative, see
Unreported World – Witches on Trial. It popped into my head both for the unquestioned healer experts and the unreliable witness fiascos that happen when physical evidence is off the table.

* To play that video, the official site irritatingly requires a login (bugmenot to the rescue), but the expandable text synopsis below it is thorough enough.
 
 
A previous CSI-related Frontline was more about rigor.

(Via Frontline – Post Mortem)

How Governments Have Tried to Block Tor

December 31st, 2011

If in doubt whether this duration’s worth sitting through,
watch 10:45-12:00.

Mitchell and Webb – Best Man

November 20th, 2011

Some inspiration from David Mitchell to get you through the holidays…

RancidMeat: The Dude

November 11th, 2011

screenshot
The Dude network monitor is like a combination of nmap, visio, and nagios to discover / identify network devices, make a graphical image to depict topology, and monitor open ports for service health. It runs under Windows, Linux Wine, and OSX Darwine.
 

 
* It doesn’t by itself plot geographical locations, but you can use a background image of a map and arrange things yourself.

RancidMeat: FreeRapid

October 31st, 2011

Freshmeat.net has changed its name, so this title’s gonna make less sense. *shrug*

screenshot
Y’know those websites that host files but make you wait and fill out a captcha? FreeRapid is a download manager that knows how to interact with 230+ of em, so you can do more interesting things than stare at a countdown.

It’s mainly for when you’ve got several urls to queue up, but apparently it can save Hulu and YouTube videos too.*

It’s updated relentlessly to keep up with those sites and fetches new plugins each time you start it.
 
 
If you start it with the ” --portable” arg, it’ll keep its config files in its own directory.
 
 
* To set a preferred YouTube video quality, dig through some menus… Options/Preferences/Plugins/youtube.com/options.

Tab-Delimited vs Line-Delimited

September 16th, 2011

Say you’ve got some text: tab-separated fields with newlines for records… (It’s what you get when you highlight/copy a block of spreadsheet cells, then paste into notepad.)

tabbed.txt:

A b c d
E f g h

 
 
… and you’d like to make it a vertical wall of text instead.

cat tabbed.txt | sed "G" | tr "\t" "\n" > lined.txt

The sed bit adds an extra blank line between records.
 
lined.txt:

A
b
c
d

E
f
g
h
 

 
 
That was easy enough. Now what about the reverse?
 
Read the rest of this entry »

Drag and Drop SSH Uploading in Windows

August 20th, 2011

I routinely upload stuff to an ssh server, and I wanted to do away with the clicks needed to start a gui client or keystrokes for commandline. So below the fold is a batch script that you can drop one or more files onto, and it’ll quietly call PSCP for each with no further interaction.

If course, it’s trivial to tweak the script to call any command you want against dropped files.
 
Edit (2011-08-26): Added dir recursion, added an exit code, and removed the -batch arg complication.
 
Read the rest of this entry »

Can We Turn Texas into an Asylum?

July 14th, 2011

It’s already got a big fence on the south side. Just run it all the way around and make it like “Escape from New York”.

This is why voting matters. Crazies are motivated, eager to collaborate overlooking galling details, and have no shortage of confidence. Even if you don’t particularly like a candidate (one that’d make a detailed convincing promise to do something you support), there’s still damage control to be done weeding out the worst ones.

Put another way: Crazies will vote reliably; if you don’t, they win.

Perry may well be one of the clever republican candidates, doing this stuff deliberately to court nutters rather than out of idiocy.

Of course this means primaries and local elections. They’ve gotta run their home state into the ground as a start.
 
 
* Bonus: Wikipedia says “[Amaterasu] is also said to be directly linked in lineage to the Imperial Household of Japan and the Emperor.”