Saturday, October 6, 2012

The incredible batch call of wkhtmltopdf

Like extra credit, this command line combined nearly everything I've done recently all at once. Within cygwin, I'm using find on a directory with the -exec option, and calling wkhtmltopdf on every file found. The only clunky thing about this method is that it makes .htm.pdf files which I have to rename to .pdf.

find . -name "D*.htm" -exec cmd /C "C:\Program Files\wkhtmltopdf\wkhtmltopdf.exe" -s Letter {} {}.pdf \;

The awesome trick was doing this in cygwin. For some reason, wkhtmltopdf wasn't running in cygwin naitive mode (it is a GnuWin utility in the form that I have it in), so I found from the below blog how to use cmd /C and I stuck the whole thing into the -exec of find and it somehow worked.

Yes, well, the downside is that I have to trim an extra .htm out of the pdf filename, I suppose that a real unix master would run the result of find through something else to trim the orignal suffix off before passing it into cmd /C, I should figure that out some day.

http://siddesh-bg.blogspot.com/2012/07/how-to-run-dos-commands-from-cygwin.html

Wednesday, October 3, 2012

IDL read csv file

My first search for this turned up more information about the function that is being used, read_csv.pro. However, all links are essentially printouts of the code, and hint that the first row must be a header row. I'm not sure if the version of this function that we have is exactly the same.

http://home.strw.leidenuniv.nl/~hoekstra/downloads/read_csv.pro

My problem is that my csv file has hexadecimal numbers, and read_csv just happens to be interpreting values with an E in the 2nd from the last digit incorrectly. I'd like it to just read in the entire file as strings and let me do the string to number conversion. There's a "STRINGS" keyword in the listing, but it's not clear how to use it. It looks like you just have to say strings=something, some examples seem to show strings=strings (it doesn't look like the /STRINGS nomenclature that goes with IDL operations).

Then, this forum thread says use readcol if you want to do everything by hand, or just use Readf or read_data_file which I guess will treat the csv file like an array:

http://www.rhinocerus.net/forum/lang-idl-pvwave/118138-reading-csv-file.html

how do I stop firefox from automatically starting on mac

So, it's really annoying how on this MacBook firefox starts up every time I log in. I have go over and click it to tell it to go to hell. Of course the controls for this sort of thing are all hidden on the mac. What is interesting is that there is a chorus of wailing on Google regarding this issue, replete with insinuations of malfeasance on Mozilla's part. Answers to other people's questions included where to find the startup controls so that it can be disabled there (it wasn't enabled there for me), how to click on the system tray icon to directly affect this setting (it wasn't set there either), to obscure bugs in unrelated software that was causing the problem (but... it's supposed to just work). The best links so far:

The basic suggestion:

http://support.mozilla.org/en-US/questions/738485

The forum thread where much smarter people post the obscure solutions that worked for them:

http://forums.macrumors.com/showthread.php?t=204670

Monday, October 1, 2012

Sienna DVD Player Remote and Headphones

Here are some places online to get the remote and headphones for the Sienna DVD player, if the one we buy doesn't have them:

This place seems to have them all, but doesn't specifically have one for the 2007-2010?:

http://www.audiovideo2go.com/toyota-sienna-2005-2006-dvd-remote-control/

Here are the headphones:

http://www.audiovideo2go.com/Toyota-sienna-headphones/

Toyota Sienna AWD Run-Flat Tires

So, it turns out that Toyota makes an All Wheel Drive version of the Sienna. The AWD version does not have a place for the spare tire due to the extra axles, so they sold this version with "Run-Flat" tires, which are supposed to be good for up to 100 miles when flat. Contrary to my expectations, these are not the foam-core tires, but just regular tires with thicker sidewalls, and they apparently barely work for the purpose intended. It doesn't seem as though they require special rims, and apparently regular radial tires will fit on the same rims as the run-flats. On the Penshare Sienna, they'd put plain Yokohamas on the back, but the front ones may still have been the run-flats; they were Bridgestone, and didn't say "RFT" on them as far as I could tell, but I didn't think to jot down the tire number so I could look it up.

Links:

http://www.siennachat.com/forum/89-2011-january-2010-3rd-generation-toyota-sienna/7897-new-tires-replacing-run-flats-nearly-new-2011-limited.html


http://townhall-talk.edmunds.com/direct/view/.f0e6c84

http://www.cargurus.com/Cars/Discussion-t29612_ds437434

http://news.consumerreports.org/cars/2011/06/more-run-flat-tire-wear-issues-on-2011-toyota-sienna-xle-awd.html

The run-flats for later Siennas are 18", earlier (like the 2007) are 17".

I looked up the tire in one of the photos of one of the Siennas posted online, it was Bridgestone B380 and found that yes these are run-flats.

Python convert to hex

In Python, the format string for printing 2-digit hex is %02x or %02X. You store binary data in strings, and print the ordinal of the array index of the string in question.

This forum thread has one low-noise response that gives good examples:

http://www.velocityreviews.com/forums/t350972-hexadecimal-conversion-in-python.html

Here is another very nice set of answers to the question in which the bytes from a "string" are being printed after being read in from a file. The keys in the following are using the hex(), using the ord() of the character, and alternate examples such as decode() and int(,16):

http://code.activestate.com/recipes/496969-convert-string-to-hex/

Day of Year calendar

Here is a very nice day of year calendar:

http://www.soils.wisc.edu/cgi-bin/asig/doyCal.rb

Remote Desktop to a mac from Windows

Summary: OS X has remote desktop built in (it's called VNC), you just have to set it up and then get a 3rd-party client to run on the Windows system. However, there seems to (as usual) be restrictions on how it works for the exact release of OS X that we're running on the MacBook.

There are several blogs and forum threads that recommend running TightVNC:

http://www.trickyways.com/2010/06/how-to-remotely-access-mac-from-pc/

TightVNC comes from here:

http://www.tightvnc.com/download.php

The problem that I encountered once I got everything set up has lots of Google hits.
I could make the connection to the remote mac, but then nothing would happen. Apparently there is something wrong with how our particular version of OS X implemented VNC, and remote logins require that no other users be logged in, including on the actual machine. Most people complaining about this problem had their VNC working prior to upgrading to OS X Lion and found that it was broken as a result:

http://help.edovia.com/kb/screens/screens-for-ios-and-os-x-lion

https://discussions.apple.com/thread/3190260?start=120&tstart=0

The quick workaround for me is simply to log out of my active session on the Mac and let the remote session be the only login. Apparently another app called RealVNC is also supposed to fix the problem, although I never got around to trying it.

http://www.realvnc.com/products/vnc/

Update: I gave TightVNC and RealVNC a spin using the above hints and it went pretty well. RealVNC still required that no other logins be active on the machine, so that didn't "fix" that problem. It has taken me a while to work out some kinks though with using VNC. The two biggest problems were that over my pathetic DSL at home the connection is agonizingly slow, and the problem of VNC only working if there are not other logins.

I found a bunch of hints to deal with the slowness. Primarily, I have to use TightVNC, which has the highest level of compression. It turns out that VNC is a surprisingly primitive system compared to something like X or Remote Desktop. It apparently ships desktop screenshots whole between the two machines (at whatever is the highest rate possible for the connection), compressing them as .jpegs and using further compression on the data channel. So, the best suggestion that I found was to set the desktop image to a plain color; given the above mechanism it is easy to see why this would help.

The following link had a bunch of suggestions for what to do about the slowness. The most interesting suggestion was to try to use "Remote Assistance", but that sounds like something that I don't have the administrative privs to do on my work mac. The same problem exists with other alternate software which requires installing a server on the mac. Lastly, apparently there's something called "UltraVNC" that is similar to the two clients that I have been using, but I've also seen negative reviews for it elsewhere:

http://superuser.com/questions/285250/vnc-on-windows-why-is-it-so-slow

Here is another great list of suggestions, most of which are for alternate VNC servers. Logmein is mentioned here as well:

http://superuser.com/questions/15337/how-can-i-make-vnc-faster

Here is the link where changing the desktop image was suggested. The comments here have other nice alternative software suggestions as well, inclulding Timbuktu:

http://hints.macworld.com/article.php?story=20050915061927686

Here's where it is revealed that with OS X you can't use the trick of setting the color resolution to 256 to speed up the VNC connection; the built in mac VNC server simply doesn't support this option and fails silently. The alternative sofware suggestions in this thread include VineServer and TeamViewer also mentioned in earlier links:

http://superuser.com/questions/28546/fast-vnc-from-windows-to-mac

Now, the problem with having to have the mac clear of other logins before the VNC connection can be made has been particularly troublesome because TightVNC occasionally just crashes, leaving my login intact on the mac but now no way to get in remotely. After a bit of searching, I found that it is possible to configure a user login on the mac to log out automatically if idle. It seems to be working; I have at least intentionally killed the TightVNC connection without logging out, and after the timeout period I connected back up to find the login prompt awaiting me. To my surprise, I also found the IDL program that was running at the time to be still up; I'm not sure how that worked.

Here's a nice tutorial on how to set up auto-logout:

http://www.ehow.com/how_4577940_set-mac-log-out-automatically.html

Too bad my screens didn't look like those in the above tutorial. The missing piece was probably a result of differences in OS X revision. It turns out that my system has a "lock" icon that I had to click to get to the "Advanced Features" screen:

http://support.apple.com/kb/PH4014?viewlocale=en_US

BTW, here are a few more links about how much Apple sucks for breaking VNC:

https://groups.google.com/forum/?fromgroups#!topic/macenterprise/UqUflFr3icg
http://apple.stackexchange.com/questions/54001/several-users-simultaneously-on-a-mac-mini