Friday, August 30, 2013

Windows 7 Remote Desktop with Dual Monitor

Works great! It seems that a key to getting it to work is to have both monitors on the local system set to identical resolution.

Here is a very nice write-up. This blog, like others, seemed to hint that this will only work if both system are "Ultimate" or "Enterprise", however, it worked well for me and my remote system was "Professional"

http://www.techrepublic.com/blog/windows-and-office/use-multiple-monitors-with-windows-7s-remote-desktop-connection/

One key not mentioned in the above link is to run the remote desktop app in /span mode, which seems to mean starting it in a cmd window with this command:

mstsc /span

This link goes into setting up the two monitors to be identical in size:

http://www.splitview.com/using-remote-desktop-with-dual-monitors-in-span-mode

Here's the same info from M$:

http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/windows-7-remote-desktop-with-multi-monitor/6bf0d5e3-644f-404e-baaf-ff2085e1c2c2

Friday, July 5, 2013

Python read file dates and rename files with datestamps

A piece of code that's so small that does so many things. Searches a directory for all files matching a pattern, gets the modification date of each file, and adds that plus a label to the file name. Uses glob to handle the searching, gets a list of matching files (may be empty if no matches, uses getmtime to get the mod time and formats it with time.strftime, uses split to dice up the original file name, and replace to slap on the label and time stamp and rejoin the new file name to the original path.

def RenameFiles(Directory, Label):

SearchString = Directory + '/pattern*'
tekfiles = glob.glob(SearchString)
for f in tekfiles:
create_date = time.strftime("%Y%m%d_%H%M%S",time.localtime(os.path.getmtime(f)))
pieces = f.split('\\')
new_name = pieces[0] + '/' + pieces[1].replace('tek','%s_pattern' % Label).replace('.','_%s.' % create_date)
os.rename(f,new_name)

Some links:

Shows use of os.rename, glob, and picking out pieces of a filename with array indexes (which I didn't use in the final code):
http://stackoverflow.com/questions/2759067/rename-files-in-python

Shows use of getctime and getmtime. It turns out that since my directory is full of copied files, that getmtime is more useful because the ctime of the copied file reflects its copy date (and can thus be later than the mtime):
http://stackoverflow.com/questions/10149994/with-python-how-to-read-the-date-created-of-a-file
http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python

It took a bit of work to figure out how to take the result of getmtime and format it into a string. The result in unix epoch seconds had to be converted to a time tuple using time.localtime so that it could be formatted using time.strftime. Some of that is shown in the previous links but I also read these doc pages:
http://docs.python.org/2/library/time.html
http://epydoc.sourceforge.net/stdlib/time-module.html

Shows use of glob. I was originally thinking of making a full-featured search like my own version of 'find', but it turned out that I only needed to search specific directories, so glob did everything I really needed:
http://code.activestate.com/recipes/499305-locating-files-throughout-a-directory-tree/
http://docs.python.org/2/library/glob.html

The link which gave me the genius suggestion of using nested replace() calls to do the two filename modifications simultaneously:
http://stackoverflow.com/questions/8687018/python-string-replace-two-things-at-once


Monday, June 3, 2013

The smallest keyfinder

A running log of my project to find a suitable keyfinder for Lisa. It needs to be useful for both keys and objects such as the cell phone and remote.

My first purchase was the "Click-n-Dig" brand, which is very nice. It has both stick-on and keyring style beepers, check. It comes with spare batteries for all compents, nice. However, the beepers are relatively large. In our case they are actually bigger than both the cell phone and the remote. And the dongle with the buttons to make the beepers beep is tiny; they've gone to a lot of trouble to make the colors and shapes of the buttons match the colors and shapes of the beepers, but there's no way to distinguish which beeper you've assigned to which object except to keep a separate list. Also, the battery covers have fallen right off of both the keychain beepers in the 4-beeper set that I got, and so far I've only found one.

http://www.amazon.com/Click-Receivers-Wireless-Keyfinder-Batteries/dp/B009JJJ7S4/

This Sharper Image one has a remote with spaces where you can write what each beeper was attached to, but the beepers are gigantic and the device apparently suffers from Sharper Image's reliability issues.

http://www.amazon.com/Sharper-Image-Wireless-Electronic-SI667GRY/dp/B0000A1OCM

This "EZ-Find" device seems to have it all; mini stick-on beepers, a way to select a beeper by assigned name, but the form function of the remote is just painful and absurd. I'm trying to like it, but I don't think that I can. Plus it has a price befitting such a complicated piece of electronics.

http://www.amazon.com/EZ-FIND-Item-Design-Electronic-Locator/dp/B004FVFGMW/

http://ez-find.com/faqs/

More as new developments arise.

Some asides:

This is an interesting idea using rfid tags, but it turns out to be pure vaporous concept and unlikely to ever actually exist:

http://www.yankodesign.com/2011/11/03/key-control/

Here's a version of the Click-n-Dig that has even more oversized beepers, plus the remote is huge:

http://www.amazon.com/Smart-Find-Remote-Control-Locator/dp/B0000X0YTO/

This "Find One Find All" concept is pretty neat, but the smallest stick-on remote that they have is the size of a credit card:

http://www.findonefindall.com/




Wednesday, May 15, 2013

Word 2010 keyboard shortcut to paste text only without formatting

When you paste using the right-click, you can select paste text only (which allows you to paste text using the formatting of the document that you are pasting into). Could there be a keyboard shortcut for this? Apparently yes, but it's not a simple keyboard shortcut, and there wasn't even an option before Word 2010.

The sequence is to use Ctrl-V to paste, which will paste using the undesired formatting of the text that you copied from. Then Word puts up that annoying tiny icon that blocks the text that you just pasted. Normally you would just hit ESC to make that thing go away so that you could work. At this point, push the Ctrl key and then let up on it, then press "t". The formatting of what wss just pasted reverts to the local formatting. Then click ESC.

Here's a link that explains this:

http://cybertext.wordpress.com/2012/11/21/word-2010-keyboard-shortcut-to-paste-unformatted-text/

Wednesday, May 8, 2013

Converting TAI time

For some reason, our flight system is using "TIA". This is a French time, called either "Temps Atomique International" or International Atomic Time. It seems to be a version of UTC without leap seconds.

Here a link that supports this description of TIA. It describes TIA as 35 seconds behind UTC, but a different link seems to indicate that this has jumped another second recently. Interestingly, TIA is 19 seconds *ahead* of something called GPS time:
http://digital.ni.com/public.nsf/allkb/C5BBF6AC7036CDAA8625733000668351

This link relates it all to Unix time, which is what I really care about. Apparently there's some problem?
http://cr.yp.to/proto/utctai.html

Here's an online display of UTC and TAI. This one claims a difference of 33 seconds which must be quite old:
http://www.csgnetwork.com/timetaidispcalc.html

Here's an IDL program for converting to TAI. It has a table that relates times within ranges to the leap second differences. It goes up to July 2012:
http://cow.physics.wisc.edu/~craigm/idl/down/tai_utc.pro

It turns out that the epoch for TIA begins on January 1, 1958 (compare this to Unix time epoch of January 1, 1970):
http://books.google.com/books?id=pFO6VB_czRYC&pg=PA20&lpg=PA20&dq=tai+time+epoch&source=bl&ots=wzgSlLC2SI&sig=t-yM2y6CvwdxcIAJqREDo88uRTA&hl=en&sa=X&ei=92aKUfK-LM7xqAHZ_4CgAg&ved=0CEwQ6AEwBA#v=onepage&q=tai%20time%20epoch&f=false

The Wikipedia page for TAI covers this, although densely:
http://en.wikipedia.org/wiki/International_Atomic_Time

Here's a page from a guy that has tried to resolve unix time and TAI. He discusses several problems and their solutions:
http://www.madore.org/~david/computers/unix-leap-seconds.html

This page on timescales is just nice:
http://stjarnhimlen.se/comp/time.html

So, it looks like I need to use seconds from epoch, but compensate for the leap seconds.

Monday, April 29, 2013

Python precision timing a loop with sleep

Here is my lovely timed loop, making use of suggestions that I'd already picked up earlier from several places. Since there's stuff in the loop that has an indeterminate run time, in order to make the loop start at the same interval of elapsed time every time, the secret is to count in increments of elapsed time from a start time taken before the first loop, and use while and sleep to wait until the next time interval threshold is crossed to do the next iteration (rather than just doing a single hard-coded wait, which will result in drift):


import datetime as dt

starttime = dt.datetime.now()
loopcount = 0
period = x #seconds

while([loop condition]):
[stuff that the loop does]
loopcount = loopcount + 1
nexttime = starttime + dt.timedelta(seconds=(period*loopcount))
timenow = dt.datetime.now()
while (nexttime > timenow):
time.sleep(0.1)
timenow = dt.datetime.now()

Here's a nice link that I found this time that shows how to do adding seconds to a time in python:
http://stackoverflow.com/questions/100210/python-easy-way-to-add-n-seconds-to-a-datetime-time

Thursday, April 25, 2013

StoopidTall

Everything I have been able to find online about this fun video:

The neatorama link:

http://www.neatorama.com/2013/04/24/STOOPID-TALL-145-foot-Bike/

The video on YouTube:

http://www.youtube.com/watch?v=bJXXckWLc0E

A great video with some of the same scenes except shot at ground level, with no music overlay (amazing silence):

http://www.youtube.com/watch?v=xh6tw6GcFyI

Some flikr postings from the ground:

http://www.flickr.com/photos/pyrokinetic/

The blog post on the topic by the same guy, with lots of good words:

http://blog.halbergman.com/2013/04/22

Links to the "apparently very underground" band that the music from the original video is: Listed as "Amoebaz - Rune!"

"The album is called "Nascence". It's very underground apparently." http://youmustlearn.us/2009/12/09/paint-the-town-rune/

http://www.mediafire.com/download.php?tdkgywegnmm

The guy's AMA on Reddit:

http://tinyurl.com/STOOPIDTALLAMA

A music video showing one of the guy's earlier tallbikes. This whole production is so Los Angeles that I feel like I'm back there:

http://www.youtube.com/watch?v=hTMrlHHVx8A