tag:blogger.com,1999:blog-308093782024-03-13T15:03:32.795-07:00Andy's BlogA mish-mash of stuff on productivity, frugality, and gadgets.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.comBlogger104125tag:blogger.com,1999:blog-30809378.post-50672781629997969382014-03-15T07:25:00.001-07:002014-03-15T07:25:05.589-07:00Fixing can't print to shared Canon LBP 6000 in Mac OS XIn successfully installed a Canon LBP 6000 on my Mac Mini and was able to print to it. I then turned on printer sharing and shared it. I was able to see the shared printer listed on my Macbook Air, but when I tried to print to it over the network it would say processing for a long time, and then switch to paused. When I checked the printer status on the Mac Mini, there was no sign that the print job had ever been received.<br />
<br />
Long story short, it turns out that the problem occurred because I had previously connected the LBP 6000 to the Macbook Air by USB and installed the Canon CAPT driver for the printer, and for some reason this caused the Macbook Air to assume the printer was directly connected when I tried to use the remote printer. You can see that this is happening by going to Apple->About this Mac->System Report and then looking at Printers, and then looking at the URI entry for the remote printer. For remote printers the URI should be something sort of like this:<br />
<br />
<br />
<div class="p1">
dnssd://LBP6000%2FLBP6018%20%40%20Zihuatanejo._ipp._tcp.local./</div>
<div class="p1">
<br /></div>
<div class="p1">
If a previous installation of the Canon CAPT driver on the computer you are trying to print from is causing problems the URI will look something like this:</div>
<div class="p1">
<br /></div>
<div class="p1">
URI: cnbma://localhost:59687</div>
<div class="p1">
<br /></div>
<div class="p1">
In other words, the system somehow thinks the remote printer is actually directly connected, so it tries to send the job to a local resource and it eventually times out.</div>
<div class="p1">
<br /></div>
<div class="p1">
What worked to resolve the problem was to delete the Canon CAPT printer driver from the Macbook Air, reboot, and then add the remote printer again.</div>
<div class="p1">
<br /></div>
<div class="p1">
On the computer that you are having trouble printing remotely from open Finder and select Go > Go to Folder and then type</div>
<div class="p1">
<br /></div>
<div class="p1">
/Library/Printers/Canon</div>
<div class="p1">
<br /></div>
<div class="p1">
and press Go. If you see a CUPSCAPT folder it means the Canon driver was previously installed. Delete all the CUPSCAPT folders.</div>
<div class="p1">
<br /></div>
<div class="p1">
Also, using Go > Go to Folder, type</div>
<div class="p1">
<br /></div>
<div class="p1">
/Library/Caches/Canon</div>
<div class="p1">
<br /></div>
<div class="p1">
and press Go. If you see a CUPSCAPT folder, delete it.</div>
<div class="p1">
<br /></div>
<div class="p1">
Also go to /Library/Printers>PPDs>Contents>Resources and delete all Canon files (don't remember how they are named, but the start with C something).</div>
<div class="p1">
<br /></div>
<div class="p1">
Then reboot the computer and then add the remote printer again.</div>
<div class="p1">
<br /></div>
<div class="p1">
For more information, <a href="https://discussions.apple.com/message/21229377#21229377">see this forum thread where I found this solution</a>.</div>
<div class="p1">
<br /></div>
AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-48937277815655486282014-01-21T06:30:00.001-07:002016-01-13T15:44:38.286-07:00Using autofs to fix a number of issues with using AFP network shares in Mac OS XMy wife and I share a Macbook Air with Mac OS X Lion using fast user switching. We both work with files stored on an AFP network share from our family Mac Mini using the MBA. We were running into the following issues with this setup:<br />
<div>
<ul>
<li>The network share ("family-network-share") from the Mac Mini would frequently get dropped and have to be remounted manually. Often the original mount point stealthily persisted in /Volumes (not shown in Finder, but shows up when you do an ls in Terminal) so that when you remounted the share it got the name family-network-share-1 (as shown with ls in Terminal), which broke any applications or scripts that used the share.</li>
<li>If one of us mounted the network share it would show up under Volumes (and on the desktop) for the other user, but it would be unaccessible to the second user (as indicated by a red circle badge on the mounted share in Finder) because permissions were restricted to the person who originally mounted the share.</li>
<li>When the second person mounted the share it would show up in Finder and the desktop as a second instance of the share with the same name, but in Terminal it got the name family-network-share-1 because the /Volumes mount point was already taken by the first user. This made it impossible to have any scripts or applications use the network share because you couldn't be sure what its path would be for a particular user.</li>
</ul>
<div>
After a lot of googling around, I came up with the solution of using autofs to set up separate permanent mounts of the network share for each user in a location other than /Volumes. What autofs in Mac OS X lets you do is set up virtual folders that automatically connect to the specified network share whenever an application tries to use the folder. Because the connection is on demand it (so far) never drops. Because I set up separate autofs mounts for each user the name of the share mount point is reliable and you can point applications and scripts to the share mount point with confidence.</div>
<div>
<br /></div>
<div>
The <a href="http://images.apple.com/business/docs/Autofs.pdf">documentation for autofs can be found here</a>. It is a little obscure, so here is a quick and dirty tutorial.</div>
<div>
<br /></div>
<div>
Open up the existing system auto_master file using sudo:</div>
<blockquote class="tr_bq">
sudo nano /etc/auto_master</blockquote>
<div>
Then add an entry at the end with the name of your (soon to be created) mount map file</div>
<blockquote class="tr_bq">
/- auto_my_mount_map_file</blockquote>
<div>
You can apparently name this mount map file anything you want, so don't feel you have to copy the arbitrary name used here.</div>
<div>
<br /></div>
<div>
Then create your mount map file in the /etc folder using sudo nano</div>
<blockquote class="tr_bq">
sudo nano /etc/auto_my_mount_map_file</blockquote>
<div>
And in that file add a line for each network share you want to automount giving the mount point first, followed by the network share path and credentials, like so:<br />
<blockquote class="tr_bq">
/Users/andy/family_share_mount_point -fstype=afp afp://username:password@share_local_IP_address/family-network-share</blockquote>
</div>
<div>
This is all on one line; ignore how Blogger wraps it.<br />
<br />
Then load the new mount map file by reloading autofs like so:<br />
<blockquote class="tr_bq">
sudo automount -vc</blockquote>
The first thing you are going to do is look for the new mount in Finder, and when you do that you will think it didn't work because it won't show up in Finder. However, it is working, as you can demonstrate by navigating to the new folder in Terminal:<br />
<blockquote class="tr_bq">
cd /Users/andy/family-network-share </blockquote>
<blockquote class="tr_bq">
ls</blockquote>
After you do that, go back to Finder and voila, now it shows up. My theory is that autofs doesn't bother to mount the network share until some program tries to use it. To avoid the problem of the folder not being visible in Finder after a reboot I wrote a two line BASH script to cd to the share folder and then list its contents using ls, and then put that script in each user's login items under System Preferences - Users and Groups.<br />
<br />
UPDATE 2016-01-13:<br />
<br />
After coming back from a long trip and setting up our network again from scratch, I was having trouble getting this to work. The specific issue was that one user, or both users, would be locked out of the mount point for the network share because the owner of the mount point was randomly (at least I couldn't detect a consistent pattern) being changed to root by the system. This problem appeared to go away after I took the following steps:<br />
- I put the mount points one more level down in the directory structure, i.e. instead of /Users/andy/my_mount_point I made it /Users/andy/Famly_shares/my_mount_point.<br />
- I did not create the mount point manually, I just put it in the auto_my_map_point file.<br />
- I very excluded the parent folders of both users' mount points from Spotlight (System Preferences -> Spotlight -> Privacy). It can be confusing because privacy exclusions set by both users seem to show up in both user's Spotlight settings, and it shows only the final folder of the excluded path, but if you hover over the folder name for a few seconds a tooltip shows up with the full path. My reason for trying this was that autofs creates a mount point when a user tries to access the mount point, so maybe Spotlight indexing activity was causing the share to be mounted as root and locking users out.<br />
- I reactivated my old login script that changed directory into the mount point (see above) even though under El Capitan the mount point showed up without it. Once again, my theory was that the first user to access the mount point wins, so the login script to go into the folder hopefully prevents some root process from getting there first.</div>
<div>
<br /></div>
<div>
</div>
<div>
<br /></div>
</div>
AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com1tag:blogger.com,1999:blog-30809378.post-88007883981316003522013-10-23T05:19:00.000-07:002013-10-23T05:19:41.896-07:00Setting up Mac OS X Snow Leopard as an Apache, MySQL, PHP (MAMP) web serverWhen my old Ubuntu on a laptop web and file server died I decided to set up my Mac Mini with Snow Leopard as its replacement rather than finding another old laptop and building a new Linux server on it. I was afraid setting up an Apache, MySQL and PHP stack on Mac OS X would be complicated and messy, but it turned out to be pretty straightforward thanks to some good guides on the web.<br />
<br />
My first step was to follow this how-to from the "Coolest Guides on the Planet" website:<br />
<br />
<a href="http://www.coolestguyplanettech.com/how-to-install-php-mysql-apache-on-os-x-10-6/">Install and configure Apache, MySQL & PHP on OS X Lion 10.7 and 10.6</a><br />
<br />
Then I followed another guide by the same person for setting up phpMyAdmin:<br />
<br />
<a href="http://www.coolestguidesontheplanet.com/installing-phpmyadmin-on-mac-osx-10-7-lion/">Installing phpMyAdmin on Mac OSX 10.8 Mountain Lion & 10.7, 10.6</a><br />
<br />
I then went ahead and imported the backup of the database for my home-brewed web apps into MySQL using phpMyAdmin, and copied my PHP files into the web server directory and tested my apps. I quickly ran into a problem where apps that had been working for years starting throwing fatal errors (sorry, I didn't write down what they were). After poking around on the web I discovered that the MySQL installer you download from Oracle has STRICT_TRANS_TABLES turned on by default, which can cause problems for apps developed on Ubuntu because STRICT_TRANS_TABLES is turned off by default in Ubuntu. I followed the directions on this blog post to turn off STRICT_TRANS_TABLES and then everything worked:<br />
<br />
<a href="http://stanlemon.net/2013/03/23/mysql-strict-mode-on-os-x/">MySQL Strict Mode on OS X</a><br />
<br />
After that, everything worked great.<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-39039975881323247482013-10-23T04:56:00.001-07:002013-10-23T04:56:08.083-07:00What I learned about file sharing and permissions on Mac OS X Snow Leopard when I set it up as a file server for multiple usersFor years I used an old laptop running Ubuntu as a combination web server and file server. It died a few weeks ago, and rather than find another old laptop and building another Linux server I decided to just set up my existing Mac Mini with (non-Server) Snow Leopard as a file server that my wife and I could access. Because it didn't "just work" I thought I would write down what I learned in the process. I have no idea how much of this is true for later versions of Mac OS X, so your mileage may vary on later versions.<br />
<br />
My first thought was to see if I could get it to "just work." I plugged an external drive with the family files into the Mac Mini, turned on file sharing in System Preferences - Sharing while logged in as me, and then designated the top level folder on the external drive as a shared folder, and then in the Users box in System Preferences - Sharing I gave read and write permissions to my wife and I, and no access to Everyone. I went and tested accessing the shared folder over the network as both myself and my wife, and everything seemed to work. Great! But then, just out of paranoia, I tried accessing the folder over the network without entering a username and password, and discovered that anyone on the network could not only see the folder and its files without entering a username and password, anyone on the network could modify any of the files. WTF? After a lot of research and poking around I finally figured out the following.<br />
<br />
<b>1. In Mac OS X Snow Leopard external drives have the property "Ignore ownership on this volume" turned on by default on the drive's Get Info screen, and when that is checked any and all users, including guest or nobody, are treated as the owner of every file and folder on that drive.</b><br />
<br />
I guess this is so that if someone plugs a USB drive into a Mac with multiple user accounts then all the users on that computer can access it. Which seems reasonable enough, until you bring file sharing into the picture:<br />
<br />
<b>2. If you share a folder on an external drive that has "Ignore ownership on this volume" turned on then anyone on the local network can mount that folder, and read and write to every file in that folder, without entering any credentials and regardless of what permissions you set on the folder or its files.</b><br />
<br />
My theory is that Mac OS X file sharing relies entirely on the basic Mac OS X permissions system to control access to folders shared using file sharing, so if the "Ignore ownership on this volume" box is checked for an external drive, and you designate a folder on that drive as a shared folder, then Mac OS X concludes that since ownership is ignored on that drive no credentials are required to read and write to files in the shared folder.<br />
<br />
The obvious next step was to uncheck "Ignore ownership on this volume" for the external drive and try sharing the folder again, with permissions on the "Get Info" dialog for that folder set to Read & Write for myself and my wife, and No Access for everyone. The group "staff" appeared on the list, but there was no "No Access" option for staff, so I left it at "Read only." After I did this the shared folder was no longer visible to people who connected to the machine without entering credentials, so one issue was solved.<br />
<br />
Now that I had the shared folder on the external drive locked down so only my wife and I could access it I proceeded to test reading and writing files as myself and my wife. Here is what I observed when the "Get Info" permissions for the shared folder were set to Read & Write for both my wife and myself, the staff group was set to "Read only" and the everybody group was "No access":<br />
<ul>
<li>I could open and modify existing files, and save new files.</li>
<li>My wife could open existing files I had created, but couldn't modify them.</li>
<li>My wife could save new files, but I couldn't modify any new files she created.</li>
<li>Looking at Get Info for a file created by one user showed that that user had Read & Write privileges, staff had Read only, and everyone had Read only.</li>
</ul>
<div>
Some more reading and poking around revealed that:</div>
<div>
<br /></div>
<div>
<b>3. In Mac OS X permissions set for a folder using "Get Info" or the System Preferences - Sharing screen are not inherited by either files or sub-folders in that folder.</b> In other words, if Joe and Jane both have Read & Write permissions to a shared folder, and Joe saves a file on the shared folder, then Jane will be able to read the file (as part of the group everyone) but she will not be able to modify it because Joe is the owner of the file.</div>
<div>
<br /></div>
<div>
This situation was obviously undesirable for a shared folder where you want multiple users to be able to work on documents created by other users, so I went back to researching and poking around. What I discovered is:<br />
<br />
<b>4. In the non-Server version of Snow Leopard the only way to set inheritable permissions for a shared folder is by setting ACL permissions using the chmod command in Terminal.</b><br />
<b><br /></b>
Turns out Mac OS X has two different permissions systems, POSIX (the traditional *nix permissions system) and ACL (Access Control Lists). There is no way to set inheritable permissions for a folder using POSIX, but it can be done with ACL. Here is a article about the basics of ACL:<br />
<br />
<a href="http://www.techrepublic.com/blog/mac/introduction-to-os-x-access-control-lists-acls/1048">Introduction to OS X Access Control Lists (ACLs)</a><br />
<br /></div>
<div>
I won't try to explain the ins and outs of setting ACLs in Mac OS X in this post, but after a lot of research I discovered that the way to give multiple users inheritable read and write permissions to a folder is set up a new group, make your users members of this group, and then run the following command in terminal:<br />
<br />
<i>sudo chmod -R +a "group:my_new_group allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" /Volumes/my_external_drive/the_folder_I_want_to_share</i><br />
<br />
See the chmod man page for the details on the syntax for this command. If you don't run this as sudo then ACL permissions will *not* be set on files and folder you don't own, which can lead to confusing problems for users. The -R option means recursive, so the ACL will be set on all sub-folders and files.<br />
<br />
A file or folder can have multiple ACLs piled one on top of another, which the operating sifts through using some order of precedence. This can lead to confusing problems for users. One easy way to start fresh with ACLs on a folder is to run this command which recursively removes all ACLs in and under the folder:<br />
<br />
<i>sudo chmod -RN /Volumes/my_external_drive/the_folder_I_want_to_share/</i><br />
<br />
Then run your chmod command to set fresh ACLs for the folder.<br />
<br /></div>
<div>
After I set up inheritable ACLs for my wife and I's group on the shared folder we were both able to read and write to files created by one another, like you would want in an environment where people are working on things together.<br />
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-65494319633403862502013-10-20T05:37:00.000-07:002013-10-20T05:37:00.730-07:00How to find deep sky objects for newbiesI took up amateur astronomy last year, and at the beginning I had a very hard time finding deep sky objects like galaxies, globular clusters, etc with my new telescope (an Orion XT8). Now that I have figured out how to quickly navigate to faint fuzzies I thought I would write down my method for other beginners.<br />
<br />
Here are the tools you need for my method:<br />
<ul>
<li>Telescope.</li>
<li>A 9x (or close to it) right angle correct image finderscope (RACI) with crosshairs.</li>
<li>A green laser pointer (GLP) finder (preferred) or a red dot finder</li>
<li>SkySafari+ on iOS (you could use some other apps or a star chart instead).</li>
</ul>
<div>
And here is how you do it.</div>
<div>
<ul>
<li>Turn on Night (red) mode in SkySafari+ and dim your screen so it won't ruin your night vision.</li>
<li>In the SkySafari+ settings adjust what magnitude stars get displayed so that the sky shown in SkySafari+ looks looks like what you see looking up. If SkySafari+ shows a lot of stars that are too dim for you to see on the sky it will be very hard to navigate, so you have to get it matched up to what you can see.</li>
<li>Look up the deep sky object in SkySafari+ and center it on the screen.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-W8Pb8Bc2dpI/UmKIe9-BWZI/AAAAAAAAC5c/E6jPZgoTXgg/s1600/IMG_0137.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-W8Pb8Bc2dpI/UmKIe9-BWZI/AAAAAAAAC5c/E6jPZgoTXgg/s400/IMG_0137.PNG" width="400" /></a></div>
<ul>
<li>See what constellation the deep sky object is near in Sky Safari+, and then find that constellation on the sky. Move your telescope so it is roughly pointing towards that constellation. No need to be precise yet.</li>
<li>Look up at the constellation and get oriented to the stars in constellation.</li>
<li>Go back to SkySafari+ and mentally make a simple shape (line, triangle, or polygon) using your deep sky object as one corner and the nearest stars as the other corners. Coming up with this shape is the key to the whole process, so find a simple pattern and commit its shape to memory. I find that for some reason it helps to mentally verbalize the pattern, i.e. mutter to yourself something like "a long skinny triangle with the deep sky object at lower corner of the base"</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-RZY3GqgNCZQ/UmPApPVwKfI/AAAAAAAAC5s/NdxUoJnOuGk/s1600/IMG_0137_with_triangle.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://1.bp.blogspot.com/-RZY3GqgNCZQ/UmPApPVwKfI/AAAAAAAAC5s/NdxUoJnOuGk/s400/IMG_0137_with_triangle.PNG" width="400" /></a></div>
<ul>
<li>Move your telescope and place your red dot or laser beam so that it makes the same simple shape on the sky. Look back and forth between SkySafari+ and the sky and tweak your telescope position until the proportions and angles of your simple shape match between the sky and SkySafari+. The key to this technique is that your brain is naturally good at recognizing when two shapes look the same, so go back and forth until the match looks as good as you can get it.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-BmOwMqOnt1U/UmPCeMnFaoI/AAAAAAAAC54/PR3ZZSHujYI/s1600/using_laser_pointer.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="252" src="http://4.bp.blogspot.com/-BmOwMqOnt1U/UmPCeMnFaoI/AAAAAAAAC54/PR3ZZSHujYI/s400/using_laser_pointer.png" width="400" /></a></div>
<ul>
<li>Once you have the telescope positioned so that your red dot or laser beam makes the same shape with surrounding stars go back to SkySafari+ and turn on the 5 degree crosshairs:</li>
<ul>
<li>Tap the upper right hand corner of the screen. This will open up a dialog that looks like this:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-jUyz7PILgGo/UmPEB8IMmcI/AAAAAAAAC6E/6IMR7W7ih-g/s1600/sky_safari_view_dialog.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://3.bp.blogspot.com/-jUyz7PILgGo/UmPEB8IMmcI/AAAAAAAAC6E/6IMR7W7ih-g/s400/sky_safari_view_dialog.PNG" width="400" /></a></div>
<ul>
<li>Tap the "Rings" button under 5 degrees. This will place a 5 degree wide crosshair on the screen.<br />
</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-tBF-4q55SVs/UmPErK-ikxI/AAAAAAAAC6U/1YOXtRhXhd0/s1600/view_dialog_with_5_degree_ring.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-tBF-4q55SVs/UmPErK-ikxI/AAAAAAAAC6U/1YOXtRhXhd0/s400/view_dialog_with_5_degree_ring.PNG" width="400" /></a></div>
<ul>
<li>Tap anywhere on the screen to exit the dialog.</li>
</ul>
<li>Center the crosshair on your deep sky object in SkySafari+, and then zoom in until the edges of the crosshair touch the edge of the screen. Now SkySafari+ is more or less displaying what you should see looking through your right angle correct image finder scope (plus or minus a degree or two).<br />
</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-uOmEfLx242k/UmPEaVGiEuI/AAAAAAAAC6M/_a7B8MlRLBE/s1600/five_degree_ring_expanded.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-uOmEfLx242k/UmPEaVGiEuI/AAAAAAAAC6M/_a7B8MlRLBE/s400/five_degree_ring_expanded.PNG" width="400" /></a></div>
<ul>
<li>Now that you have your finder scope in the right area you need to get oriented to the stars visible in the finder scope. Look back and forth between your finder scope and SkySafari+ looking for single stars and/or simple patterns of brighter stars (like triangles, lines, or simple polygons) that you can find in both views. Don't worry about the deep sky object for the moment, just look for one or more star patterns you can find in both views. Be patient if at first you don't find any matching patterns and resist the temptation to move the telescope to look around; it often takes a few looks back and forth for a pattern to jump out at you. In this case there is a single very bright star that can be used as one calibration point, and two distinctive triangles of stars that can be used as others:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-8Eck51YjreY/UmPIE67k8cI/AAAAAAAAC6g/2rF1DGtxeZU/s1600/five_degree_ring_expanded_marked_up.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-8Eck51YjreY/UmPIE67k8cI/AAAAAAAAC6g/2rF1DGtxeZU/s400/five_degree_ring_expanded_marked_up.PNG" width="400" /></a></div>
<ul>
<li>Once you have identified one star or star pattern you can see in both SkySafari+ and your finder scope tweak the position of your telescope until that patterns sit in the same relative position in both your finder scope view and SkySafari+ crosshairs, i.e. if the pattern is near the edge in the upper left in SkySafari+, move the telescope so it is near the edge in the upper left in the finder scope.</li>
<li>Now that you have your finder scope view more or less synced with your SkySafari+ view, repeat the earlier process of making a simple mental shape (triangle, line, etc) using your deep sky object and nearby stars in SkySafari+. Once again, coming up with the mental shape is key, and it may help to verbalize the shape under your breath.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-osYfa2YBO98/UmPI8Z5zUoI/AAAAAAAAC6o/ckDmX-VQ4Pc/s1600/five_degree_ring_expanded_final.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://1.bp.blogspot.com/-osYfa2YBO98/UmPI8Z5zUoI/AAAAAAAAC6o/ckDmX-VQ4Pc/s400/five_degree_ring_expanded_final.PNG" width="400" /></a></div>
<div>
<br /></div>
<ul>
<li>Move your telescope to make the same simple pattern with the finder scope crosshairs standing in for the faint fuzzy.</li>
<li>Look through the telescope eyepiece; your deep sky object should be visible. Globular clusters and open clusters should be pretty easy to spot. Many galaxies and nebulas are very faint and look like almost invisible wisps of milkiness. Don't expect to see bold color images like you see in pictures.</li>
<li>M108 in Sky Safari:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-KNjBCgbaBdU/UmPMobi47bI/AAAAAAAAC60/kZZg23t-qlA/s1600/m108_in_sky_safari.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://1.bp.blogspot.com/-KNjBCgbaBdU/UmPMobi47bI/AAAAAAAAC60/kZZg23t-qlA/s400/m108_in_sky_safari.PNG" width="400" /></a></div>
<div>
<br /></div>
<ul>
<li>What M108 might look like through the eyepiece:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-YO2LdCCZDS8/UmPMwuLWtuI/AAAAAAAAC68/r7zLkpU0xuk/s1600/m108_through_eyepiece.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="246" src="http://3.bp.blogspot.com/-YO2LdCCZDS8/UmPMwuLWtuI/AAAAAAAAC68/r7zLkpU0xuk/s400/m108_through_eyepiece.png" width="400" /></a></div>
<div>
<br /></div>
</div>
<div>
</div>
AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-17158591114090036482013-06-19T11:45:00.001-07:002013-06-25T09:52:07.960-07:00Thunderbird "Work Offline" stops working after deleting an accountI was using Thunderbird (v14) to work with two different IMAP accounts. I recently shut down the first account (as in the first IMAP account I added to Thunderbird), and wanted to get Thunderbird to stop trying to get mail from that account on startup, when checking mail, and when going to "work offline." I tried just deleting the account (Tools -> Account Settings -> Account Actions -> Remove Account), which worked to delete the account from Thunderbird, but after that Thunderbird suddenly stopped downloading messages from the server to work offline with my remaining account. I would click the "work offline" icon, and it would go offline, but when I tried to open a message Thunderbird would say that the message contents had not been downloaded from the server. I played around with the Synchronization & Storage settings to no avail. Here is what ended up working for me to solve this.<br />
<ul>
<li>I restored the prefs.js in my profile directory from a backup. This got me back to where I had been before I deleted the first account, and back to the original problem of getting Thunderbird to not check for mail on the deactivated account.</li>
<li>I found this forum thread on the topic of getting Thunderbird to not check an account for new mail:<br /><a href="http://forums.mozillazine.org/viewtopic.php?f=39&t=635510&start=15">http://forums.mozillazine.org/viewtopic.php?f=39&t=635510&start=15</a></li>
<li>I followed one person's advice from the thread to delete the deactivated account from the "mail.accountmanager.accounts" value in prefs.js (while Thunderbird was shut down) like so:<br />Before edit (account enabled):<br />user_pref("mail.accountmanager.accounts", "account1,account2,account3");<br />after edit (account disabled):<br />user_pref("mail.accountmanager.accounts","account3");</li>
<li>Note that figuring out which account is which in prefs.js takes a little scavenger hunt because the server information is saved under "identity" and then the identity is linked to the account. I figured out that my deactivated account was listed in prefs.js as both account1 and account2 (go figure).</li>
<li>I then also edited the value of mail.accountmanager.defaultaccount in prefs.js so that my remaining IMAP account was listed as the default account, like so:<br />user_pref("mail.accountmanager.defaultaccount", "account2");</li>
<li>After I did this Thunderbird stopped trying to check for mail on my deactivated account, and, at least initially, successfully downloaded the contents of all my messages when I chose "work offline."</li>
<li>However, later in the day kept having intermittent problems with message bodies not being downloaded for use offline. Sometimes it would work, sometimes it wouldn't, and I couldn't detect a pattern.</li>
<li>I did some more Googling and found an <a href="http://kb.mozillazine.org/Offline_folders">article called "Offline Folders" on Mozillazine</a>. I used the Config Editor (Preferences/Advanced/General/Config Editor) to change two settings discussed in the article:<br /> - I changed mail.imap.use_status_for_biff from true to false.<br /> - I changed mail.server.default.autosync_offline_stores from false to true<br />According to the article this combination forces Thunderbird to download messages for offline use whenever you open it.</li>
<li>After I made that change it seemed like Thunderbird was downloading messages for use offline whenever I connected to the server, not just when I clicked the "work offline" icon. Also, sometimes when I went offline messages would still not yet be downloaded. So I set mai.server.default.autosync_offline_stores to false again.</li>
<li>I noticed that mail.accountmanager.accounts somehow got account1 back, so I deleted account1 from that.</li>
<li>I also noticed that server2 had offline_stores set to false, so I set it to true, even though server2 is no longer used.</li>
<li><br /></li>
</ul>
<div>
<br /></div>
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-60275407119584077442013-05-08T10:04:00.002-07:002013-05-08T10:04:44.148-07:00How to get directions from Google Maps into Gaia Maps for iOS so you can use them offlineI wanted a way to download directions from Google Maps onto an offline mapping program on the iPad so that I could use the iPad for navigation even when I don't have my cellular service. I have an iPad with 3G, but because I am a tightwad I only turn the 3G service on when I am on long trips. Also, we go plenty of places with little or no cell service out here in the west, so even if I wasn't a cheapskate I would want this capability.<br />
<br />
It turns out that it is not that hard transfer directions from Google Maps into Gaia GPS as a route (not turn-by-turn directions, sorry) that you can view as a colored line on the map. These days my favorite iOS offline maps app is <a href="http://www.gaiagps.com/">Gaia GPS</a>. It can do offline street maps (Mapquest using Open Street Maps), satellite view, and topo maps.<br />
<ul>
<li>Sign in to Google on your computer browser, since you will need to work with the "My Maps" feature in Google Maps.</li>
<li>Go to Google Maps and get directions to the place you want to go.</li>
<li>At the bottom of the list of directions click the "Save to My Maps" link</li>
<li>Select "Save to a new map" from the drop down that asks which map you want to save to.</li>
<li>You will be taken to your new map in My Maps.</li>
<li>Find a link called KML on the left sidebar, just under the title of your map, and click it.</li>
<li>This will open a save file dialog for a KML file. Save it to your desktop.</li>
<li>Now transfer the KML file from your computer to your iPad.</li>
<li>One way to transfer the KML file to Gaia GPS is via email.</li>
<ul>
<li>Email the KML file to yourself.</li>
<li>Open the Email on your iPad and open the attachment using Gaia GPS.</li>
</ul>
<li>Another way to transfer the file is via iTunes </li>
<ul>
<li>Plug your iPad into your computer</li>
<li>Go to the tab for your iPad in iTunes and click the Apps button to get to a list of your apps</li>
<li>Find Gaia GPS in the list of File Sharing apps</li>
<li>Click the Add button at the bottom of the file list for Gaia GPS. This will open a dialog where you can select your KML file.</li>
<li>After you have selected your KML file in iTunes, open Gaia GPS on your iPad. It should pop up a dialog saying there is a KML file waiting to be imported and asking you if you want to import it now. Do so.</li>
</ul>
<li>Once you have imported the KML into Gaia GPS it won't automatically show up on the map. You have to first tell Gaia GPS to display the route on the map.</li>
<ul>
<li>Go the the Saved screen in Gaia GPS</li>
<li>On the Saved screen click the button on the top left for saved routes (it looks like two amoebas with stringy appendages)</li>
<li>Your KML file should be listed at the top of the list of routes with an on/off switch next to it. Turn it on.</li>
<li>Go back to the Map screen in Gaia GPS and your route will show up as a colored line. </li>
</ul>
</ul>
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-47182099297869878612013-05-08T09:56:00.000-07:002013-05-08T09:56:17.174-07:00How to keep a Costco six pack of romaine hearts from going badThe big drag with many Costco fruits and veggies is that unless you have a huge family or a restaurant you aren't going to use all of the big quantity Costco sells before it goes bad. I have, however, found a way to make the romaine hearts Costco sells in six packs last for weeks:<br />
<br />
<ul>
<li>Fill your sink with cold water and put the romaine hearts in to soak for about 30 minutes. This re-hydrates them.</li>
<li>Let the romaine hearts dry for about 20-30 minutes after you soak them.</li>
<li>Put each romaine heart in its own gallon sized zip loc bag, removing excess air before you seal, and then put them in the refrigerator.</li>
<li>Every few days eyeball all of the bags and remove any leaves that are starting to brown. Typically the leaf on the bottom starts to brown after a few days, maybe because the weight of the romaine heart is resting on it.</li>
</ul>
<div>
I have no idea whether or not this is considered a good practice from a food safety point of view, and I also have no idea whether or not this ruins some aspect of romaine lettuce that foodies feel passionate about. I do know that I have been doing this for months without getting sick and that the lettuce is still fine by my standards after up to three weeks.</div>
AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-44146005200005589792013-03-14T09:45:00.000-07:002013-03-14T09:45:15.376-07:00How to escape from the View designer in MS SQL Server Management Studio (SSMS)I started working with SQL Server, and MS SQL Server Management Studio about a year ago, and I quickly got frustrated with the View designer module. If you click on "New View" in the object explorer, or if you right click on an existing View and choose "Design," it opens up this multi-pane view designer with a graphical representation of the View on top, followed by some table listing the View elements, followed by the SQL for the view formatted as nearly impenetrable blocks of code. For simple Views the View designer was fine, but for complicated Views I came to hate working with it. I especially hated the fact that if I tried to format the SQL in a more readable layout, the View designer would throw out my formatting the next time I opened the View in Design mode.<br />
<br />
I finally decided that there had to be a better way, and thanks to some discussions on Stack Exchange (natch) I pieced together the following:<br />
<br />
<ul>
<li>You can edit a View in plain SQL, and have your layout and formatting preserved when you save, by doing the following:</li>
<ul>
<li>Right click the View</li>
<li>Select Tasks -> Script View as -> ALTER To -> New Query Editor Window</li>
<li>Make your edits in the resulting Query Editor window</li>
<li>Hit Execute when you are done to save your changes. The ALTER TO command replaces the current version of the View with your edited version.</li>
</ul>
<li>You can quickly clean up the brain dead SSMS formatting of the SQL of existing Views using the free <a href="http://poorsql.com/">poorsql.com</a> website. You block and copy the ugly SQL into the window, choose from various formatting styles, and then the site instantly prepares a properly formatted version of the SQL.</li>
</ul>
<br />
<br />
AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com1tag:blogger.com,1999:blog-30809378.post-8270312125432052212013-02-20T06:05:00.000-07:002013-02-20T06:05:00.313-07:00How to make an inexpensive magnetically mounted green laser pointer finder for your telescopeI wanted to start using a green laser pointer (GLP) as a supplement to my 9 x 50 finderscope on my Orion XT8 telescope, but I didn't want to spend a lot of money or time on it, and I didn't want to deal with drilling any holes in my optical tube assembly (OTA). I wanted the GLP finder because while the 9 x 50 finderscope is great for zeroing in on a faint fuzzy once you are in the right area, getting to the right area can be a pain with a Dobsonian.<br />
<br />
I was able to find a very inexpensive (less than $10) green laser pointer on Amazon. There are more expensive varieties out there, but I figured that at such a low price it wouldn't be the end of the world if it didn't work well. As it turns out, the inexpensive GLP has worked fine for a while now.<br />
<br />
But how to mount it on my Orion XT8 telescope? I didn't want to spend money on a real mount, and I didn't want to deal with drilling holes in my telescope (I know it's not really that big of a deal but I just wanted to avoid it if possible). Inspired by the way Apple uses magnets to secure things like the iPad cover, I looked on Amazon and ordered a package of 50 1/4" x 1/10" Neodymium rare earth magnets for less than $10.<br />
<br />
When the magnets arrived I confronted the fact that I still didn't have a plan for exactly how connect them to the GLP. After mulling over a few possibilities that I rejected because they felt like too much work, I hit on the idea of simply taping four of the magnets to a popsicle stick using black electricians tape, a pair at each end, and then rubber-banding the GLP to the opposite side of the popsicle stick, like so:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-UpNCM84cnlM/USTJZsq8ftI/AAAAAAAAC38/U21ZokvqDGs/s1600/ghetto_GLP_finder.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="127" src="http://2.bp.blogspot.com/-UpNCM84cnlM/USTJZsq8ftI/AAAAAAAAC38/U21ZokvqDGs/s400/ghetto_GLP_finder.png" width="400" /></a></div>
<br />
<br />
Then it was time for a test drive. I was apprehensive about how hard it would be to align the GLP, but I quickly discovered that it was pretty easy. Just click the GLP on the tube, look through my 9 x 50 right angle correct image (RACI) finderscope, wiggle the shining laser beam back and forth until I see it in the finderscope, and then put the beam more or less close to the crosshairs. Using this method it takes literally only about 2 seconds to align the GLP. For vertical (for lack of a better word) alignment of the beam I just wedge stuff as needed between the GLP and the popsicle stick.<br />
<br />
I quickly became addicted to using the GLP. It makes it a breeze to get the telescope pointed to within a degree or two of the target, and from there I use the RACI finderscope to hone in on it. No more contorting myself to get to the right spot behind a red dot finder, and seeing where a big green laser beam is pointed on the sky is a lot easier than correctly placing the red dot on an inexpensive red dot finder.<br />
<br />
When winter came along I found another advantage to a magnetic GLP mount: it makes it easy to keep the GLP warm. I discovered that my GLP quickly dims when it gets cold, so to keep it usable I keep it in my pocket (or when it is really cold inside my pants against my skin) until I need to use it. Then I click it on the tube, quickly align the beam using the RACI finderscope, use the beam to put the telescope on the target, and then pop the GLP off and put it back in my pocket.<br />
<br />
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-127187780539903912012-10-25T10:08:00.000-07:002012-11-02T05:33:31.814-07:00Recursively copy all PDF files from a directory tree to a single directorySomeone gave me a bunch of PDF files spread out through multiple subdirectories and I needed to get them all into a single directory.<br />
<br />
In Mac OS X (and probably Linux) this will scan through the directory specified and its subdirectories and copy all of the PDF files to the target directory:<br />
<br />
<blockquote class="tr_bq">
find /Users/joedokes/Desktop/source_directory -name "*.pdf" -exec cp {} /Users/joedokes/Desktop/target_directory \;</blockquote>
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com2tag:blogger.com,1999:blog-30809378.post-31332503668217877032012-09-20T07:53:00.000-07:002012-09-20T07:53:31.070-07:00How to export a table as a SQL script using Microsoft SQL Server Management StudioI come from the PHP-MySQL world, so I am used to being able to quickly generate a backup of a table as a SQL script (CREATE + INSERT) using the easy to find Export function in phpMyAdmin. When I had to use SQL Server for a project I was a bit puzzled when I couldn't find a similar feature in Microsoft SQL Server Management Studio (MS-SSMS). However, a bit of Googling revealed the (cumbersome) solution:<br />
<br />
<ul>
<li>In the Object Explorer in MS-SSMS right click the database that has the table you want to export.</li>
<li>Select Tasks from the right-click menu.</li>
<li>Select Generate Scripts from the sub menu, which will open a pop-up called Generate and Publish Scripts.</li>
<li>Click Next on the Introduction screen, which takes you to the Choose Objects screen</li>
<li>On the Choose Object screen select the "Select specific database objects" option</li>
<li>Expand the Tables object by clicking the little plus sign</li>
<li>Select the table(s) you want to export</li>
<li>Click Next, which takes you to the Set Scripting Options screen.</li>
<li>Choose where you want the output to go (file, clipboard or new query window)</li>
<li>Click the Advanced button, which launches a pop-up window called "Advanced Scripting Options" with a list of options</li>
<li>Scroll down to the "Types of data to script" option, which is at the very bottom of the set of options called "General."</li>
<li>Change the "Types of data to script" option from "Schema only" to "Schema and data." This is what will make the SQL include the data from the table.</li>
<li> Click OK to close the Advanced Scripting Options pop-up.</li>
<li>Click Next on the Set Scripting Options screen.</li>
<li>Click Next on the Summary screen where it says "Review your selections." This is what triggers the actual export of the table.</li>
<li>Click Finish to close the Generate and Publish Scripts pop-up.</li>
</ul>
<br />
There, was that so bad? Well, yes, it was a lot of clicking for something that people probably do relatively frequently, but that is Microsoft for you.<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-60608546883305865122012-06-18T09:28:00.001-07:002012-06-18T09:28:15.954-07:00How to simulate the MySQL group_concat function in MS SQL ServerThe issue: I am writing a web app to track agreements where each agreement can have one, or multiple, account numbers associated with them, like so:<br />
<br />
Agreement No. 1: Account Numbers = XYZ-123-123-123; XYZ-123-123-456; XYZ-123-123-789<br />
Agreement No. 2: Account Numbers = XYZ-123-123-333<br />
Agreement No. 3: Account Numbers = XYZ-123-123-123; XYZ-123-123-789<br />
<br />
<br />
I quickly decided to store the account numbers in a separate table so that each agreement could have a variable number of account numbers associated with it:<br />
<br />
Agreement_Account_Numbers table<br />
Agreement_ID Account_Number <br />
1 XYZ-123-123-123<br />
1 XYZ-123-123-456<br />
1 XYZ-123-123-789<br />
2 XYZ-123-123-333<br />
3 XYZ-123-123-123<br />
3 XYZ-123-123-789<br />
<br />
But then I ran into the problem of how to display all of an agreements account numbers in a table listing a number of agreements. I wanted an SQL query that would return one agreement per line, with all of the account numbers for each agreement concatenated in a single field. In MySQL this would be easy: do JOIN query with the agreements table linked by Agreement_ID to the on the agreement ID and then GROUP BY Agreement_ID and use the group_concat function to concatenate the Account_Number field. However, for this project I have to work with MS SQL Server and it apparently does not have any such function. Googling around led me to this excellent question on stackoverflow:<br />
<br />
<a href="http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005">Simulating group_concat MySQL function in MS SQL Server 2005?</a><br />
<br />
It
took me a while to sort out which answer to this question was easiest to implement, so I
am writing down what worked for me for my own future reference. Here is what I ended up with:<br />
<br />
SELECT<br />
Agreement_ID,<br />
STUFF(<br /> (SELECT '; ' + Account_Number<br />
FROM agreement_account_numbers<br /> WHERE agreement_id = a.agreement_id<br /> FOR XML PATH (''))<br /> , 1, 1, '') AS Account_Numbers<br />FROM Agreement_Account_Numbers AS a<br />GROUP BY agreement_id<br />
<br />
The result of this query is:<br />
<br />
Agreement_ID Account_Numbers<br />
1 XYZ-123-123-123; XYZ-123-123-456; XYZ-123-123-789<br />
2 XYZ-123-123-333<br />
3 XYZ-123-123-123; XYZ-123-123-789<br />
<br />
This query uses a sub-select clause to retrieve all of the account numbers for each agreement by linking the Agreement_Account_Numbers table back to itself (by giving the table the alias "a") and then putting sub-select results in a string using the MS SQL Server specific command FOR XML PATH (''). Then the STUFF function replaces the first character in the sub-select result string with a zero length string ('') to strip off the leading semi-colon that would otherwise be in front of the first account number.<br />
<br />
The command is actually FOR XML with the PATH option specified, and then the tag to surround each row specified to be nothing (''). I tried figure out exactly now FOR XML works, and what the PATH option means, but as usual I found the MS documentation to be completely cryptic so I just accepted that it works.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com4tag:blogger.com,1999:blog-30809378.post-67960796060007657482012-06-13T07:29:00.001-07:002012-06-13T07:29:14.464-07:00Always Google your problem firstIf you have a problem that you don't know how to solve, or you need to do something you don't know how to do, the first thing you should always do is just google it. There are web pages and/or discussions describing how to do or fix just about everything these days, and a large part of the time you can get specific instructions from experts just be googling whatever it is you want to do.<br />
<br />
For example, this morning I wanted to put a list of file names from a directory into a document. Instead of asking someone how to do it, or poking around and trying to figure out how to do it, I just googled "mac os x get copy list of file names to clipboard" and one of the top results was specific instructions on how to do just that.<br />
<br />
Another example. The other day my spouse bought some fresh corn, and we wondered if you could microwave it instead of boiling it. We googled "microwave corn" and had specific instructions in seconds (it works great; I am never boiling another ear of corn).<br />
<br />
This tactic works especially well for computer issues. If you get an error message, the first thing you should do is google it. The majority of the time you will have the solution in seconds.<br />
<br />
You can stumble your way through a complex project that you have no idea how to do by using this tactic for each little step. I taught myself how to write web applications in PHP-MySQL this way. <br />
<br />
Many people don't know this trick, so once you know it you can impress your friends and family as an expert on just about everything by using this tactic to instantly finding solutions for their problems.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-13743064203447988412012-06-08T07:45:00.002-07:002012-06-08T07:45:36.595-07:00Don't get it until you really need itThe principle: Don't create or buy something until you know from actual practice exactly why you really need it.<br />
<br />
This is also known as <a href="http://c2.com/xp/YouArentGonnaNeedIt.html">"You Aren't Gonna Need It"</a><br />
<br />
When people are starting on some endeavor they often put significant effort or money into buying or making things that they think they will need. However, when it comes time to actually using these things it often turns out that you don't really need it after all, or it's not nearly as useful as you thought it would be, or you need something very different than what you thought you would need. And all the time, money and effort put into acquiring the thing turns out to be wasted.<br />
<br />
On the other hand, if you wait until you know from experience that you actually need something, you can acquire exactly what you really need, and you will know how badly you really need it, which will give you a good idea how much time or money you should spend on it.<br />
<br />
<br />
An example from hiking. I used to spend a lot on hiking boots because I thought I needed them because, by gosh, everyone else used them so they must be neccessary. Then I experimented with hiking in tennis shoes and sandals, and found that it was more comfortable, I got zero blisters for a change, I suffered fewer twisted ankles, and it was cheaper. I would have been much better off if I had started out hiking in just whatever shoes I had, and <i>only purchased different shoes when and if I experienced actual problems</i>.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-68766037612134233482012-05-18T04:59:00.001-07:002012-05-18T04:59:20.217-07:00How to get MS SQL Server nvarchar() field to sort correctly using ORDER BYI had an nvarchar field in MS SQL Server that wasn't sorting correctly when I did an ORDER BY on it. For example, 10 would be put before 9 if I sorted ASC. It turns out that MS SQL Server considers the position of each character in the field in sorting, and since the field is nvarchar (variable width) the digits of a number are not in consistent positions in the field. I found the solution in this post on stackoverflow.com:<br />
<br />
<a href="http://stackoverflow.com/questions/4397604/order-by-clause-for-nvarchar-column-in-sql-server">Order By Clause for NVARCHAR column in SQL Server</a><br />
<br />
The specific code is:<br />
<br />
ORDER BY RIGHT(REPLICATE(N' ', 50) + the_column_you_want_to_sort_by, 50)<br />
<br />
What this does is virtually add enough leading whitespaces to each entry to make the column look like a fixed width column for the purposes of the query.<br />
<br />
<br />
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-60192593739131423882011-12-13T07:51:00.000-07:002011-12-13T07:53:03.462-07:00How to get a route from Google Maps on to an iPad so you can follow it offlineI wanted to find a way to download a route from Google Maps onto my iPad 3G so that I could follow the route on a map offline. I know that with the iPad 3G data plan turned on you can just use the Maps app to find and follow directions, but I am a frugalista and I like to keep the 3G data plan on my iPad turned off except when I am on long trips.<br />
<br />
Here is the procedure I worked out, which requires that you own the $3.99 (as of Dec 2011) MotionX GPS HD app.<br />
<ul>
<li>Go to Google Maps and look up directions to the place you want to go.</li>
<li>At the bottom of the directions click the Save to My Maps link.</li>
<li>Go to Google My Places (fka My Maps) and select the map with directions you just saved.</li>
<li>Click the KML link to download a KML file of the directions to your computer.</li>
<li>Go to <a href="http://www.gpsvisualizer.com/">http://www.gpsvisualizer.com/</a> select the KML file to upload and pick GPS format for the output and click Go.</li>
<li>Email the resulting GPX file to yourself.</li>
<li>In Mail on your iPad open the email, tap the attachment, and select open in MotionX GPS HD app.</li>
<li>This will open the MotionX GPS HD app where you can complete the import of the GPX track.</li>
<li>This will just import the track into the MotionX GPS HD app. You need to separately download OpenStreetMaps for the relevant area in MotionX GPS HD in order to have the maps available offline.</li>
</ul>
This doesn't give you turn by turn directions, but it does give you a simple line on a map that you can follow while offline.<br />
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-64336719348453046602011-11-10T05:39:00.001-07:002011-11-10T05:49:58.158-07:00How to manage iOS Newsstand subscriptions auto downloadsThe screen where you manage automatic download settings for subscriptions in the new iOS Newsstand is hard to find (at least it was for me!) Here is how to get to it on your iPad, iPod Touch, or iPhone.<br />
<br />
<ul>
<li>Tap on the Settings app to get to the Settings screen</li>
<li>Scroll down list of settings until you see the icon for the Store and tap that</li>
<li>There will be a section of the Store settings called "Automatically download new content when on Wi-Fi" and all of your Newsstand subscriptions should be listed there with an on/off slider for each one.</li>
</ul>
Incidentally, the wording of this screen seems to imply that automatic downloads of subscriptions only happen when on Wi-Fi (i.e. not on cellular), which I hope is true because one issue of the New Yorker would blow more than half my cheapskate 250 MB cellular plan. <br />
<br />
<br />AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-76418246181920253712011-11-02T05:05:00.000-07:002011-11-02T05:05:17.422-07:00Save money using Google Voice plus a prepaid cellphoneA lot of prepaid mobile phone plans charge you only for the minutes you actually use, and if you don't use a lot of minutes each month it can save you a lot of money (I spend on average less than $10 a month on my T-Mobile prepaid service). If you get a Google Voice account, and set it up to ring not only your prepaid cell phone but also your home and office phones, then you can give everyone your Google Voice number as your mobile phone number, but answer calls to it on your house or work phone when you are not on the road.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-82320232792756332272011-10-11T15:58:00.003-07:002011-10-11T15:58:41.318-07:00How to prevent sessions from expiring too quickly on PHP applications<br />
<div class="storycontent">
When I started using sessions for authentication
in a PHP web application I discovered that users were being logged out after a
very short time. After some research I discovered how sessions work in
PHP.<br />
A unique session ID is stored on a cookie on the users computer.
When the user connects to the server the server looks for a file with
that unique session ID in its temp folder, and if one exists it pulls
variable values from that file. Every time any user connects to the
server and starts a session the server generates a random number and
then looks at some settings in php.ini to determine whether or not to
clean out the temp folder. When it cleans out the temp folder it throws
out session files older than the session.gc_maxlifetime setting in
php.ini (set in seconds). In order to enable keeping users logged in for long periods I
set session.gc_maxlifetime = 1814400 in the php.ini.<br />
<br />
This works on MAMP installations also. Just edit to /Applications/MAMP/conf/php5.3/php.ini <br />
</div>AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-59435445508179749232011-10-11T14:25:00.001-07:002011-10-11T14:25:14.281-07:00How to configure Apache in MAMP to only be accessible from the machine it is installed onFor a number of reasons I wanted to run a web application locally on my MacBook. After some research I decided that the path of least resistance was to install the <a href="http://www.mamp.info/en/index.html">free MAMP app</a>, which runs an Apache-MySQL-PHP stack on a Max OS X machine without having to do a complex install process. I got my web app working on MAMP pretty easily, but then I discovered that other machines on my local network could also access the web app if they connected to the right port of the IP address of my MacBook. That isn't a problem when I am at home or work, but I didn't want the web app exposed when I was on public networks like at a coffee house or the library. After some research I discovered the solution was to edit the /Applications/MAMP/conf/apache/httpd.conf file to change:<br />
<br />
Listen 8888<br />
<br />
to<br />
<br />
Listen 127.0.0.1:80<br />
<br />
This did two things. It changed the port that MAMP uses from the MAMP default of 8888 to 80 (the normal web server port) and specified that only traffic from the local machine would be accepted. After I made this change and restarted the Apache server I was no longer able to access the web app from other machines on the same network.AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-78400778675348699572011-01-25T06:55:00.000-07:002011-01-25T06:55:25.787-07:00How to automatically mount external hard drive at boot in Ubuntu Lucid LynxI have an external USB hard drive connected to my Ubuntu laptop home server that I used to store MythTV recordings and videos. Ubuntu would mount this USB drive to the mount point I had created when I logged in as my regular user, but not at boot. I wanted the drive to automatically mount at boot so that after a power failure, or a reboot, I wouldn't have to log in as a user in order to have MythTV work. After doing some research using Google I tried the following:<br />
<ul>
<li>After logging in as my regular user to make the USB drive mount, I ran <code>mount</code> in a terminal which gave me a listing of all the mounted disks and their mount settings. I copied down the mount settings for the USB drive and noted which device the USB drive was mounted as (sdb1 in my case).</li>
<li>Then I ran <code>ls -l /dev/disk/by-uuid</code> which gave me a listing of the UUID of each mounted partition and I copied down the UUID for the sdb1. This is the unique identifier for the USB drive.</li>
<li>Then I made a backup copy of the fstab file: <code>sudo cp /etc/fstab /etc/fstab.bak</code></li>
<li>Then I opened the fstab file in an editor: <code>sudo nano /etc/fstab</code></li>
<li>Then I added a line to the bottom of the fstab file like this, putting a tab between each value, and using the UUID I noted, the filesystem type I noted, and the mount options I noted:</li>
<li><code>UUID=07955830-0d54-443c-bdba-f111121f6bd3 /media/myth_data ext4 rw,nosuid,nodev,uhelper=udisks </code></li>
<li>Then I rebooted and the disk was automatically mounted without me having to log in.</li>
</ul>AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-9216847941692658252011-01-03T06:23:00.004-07:002011-01-03T06:43:59.349-07:00A Mac OS X app to wake a Mac and then open screen sharingI have a Mac Mini hooked up to our TV and stereo as a HTPC which has a hard-wired Ethernet connection. To save a bit of energy I have it set to go to sleep when it isn't used. My wife wanted to be able to play internet radio stations over the stereo, but she didn't want to have to turn on the TV, get a keyboard, etc. just to start one playing. I showed her how to use one program to wake the Mac Mini, and then how to launch screen sharing through Finder, but it was a lot of clicking. So I started googling for a way to set up a one-click icon that would (1) wake the Mac Mini, and (2) then connect to it by screen sharing.<br /><br />As to waking the Mac Mini, I found this page that gives an Automator workflow to send the wake on lan magic packet (which will only work if the target computer has a hard wired Ethernet connection) and also open screen sharing:<br /><br /><a href="http://forums.plexapp.com/index.php/topic/7463-wake-sleeping-mac-with-applescript-and-automator/">Wake sleeping Mac with AppleScript and Automator</a><br /><br />The guts of this is <a href="http://forums.dealmac.com/read.php?4,2751523">a PHP script written by Mark Muir</a> to send the magic packet that wakes the sleeping computer. The version of this PHP script at the link has comments explaining how it works. Since I have zero experience with Automator I decided to adapt this to be an AppleScript. Here is what I ended up with:<br /><br /><code>on run<br /> set command to "/usr/bin/php -r " & quoted form of ("$mac = \"a4:6a:19:d8:d2:24\";<br />$ip = \"10.10.10.255\";<br />$mac_bytes = explode(\":\", $mac);<br />$mac_addr = \"\";<br />for ($i=0; $i<6; $i++)<br />$mac_addr .= chr(hexdec($mac_bytes[$i]));<br />$packet = \"\";<br />for ($i=0; $i<6; $i++) /*6x 0xFF*/<br />$packet .= chr(255);<br />for ($i=0; $i<16; $i++) /*16x MAC address*/<br />$packet .= $mac_addr;<br /><br />$port = 9;<br />$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);<br />socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);<br />socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);<br />socket_close($sock);<br />")<br /> do shell script command<br /> delay 3<br /> tell application "Screen Sharing"<br /> open location "vnc://MyComputersBonjourName.local"<br /> end tell<br />end run</code><br /><br />To use this yourself do the following:<br /><ul><li>Make sure screen sharing is configured on the target computer and verify it works when you manually connect from the source computer. </li><li>Go to the target computer and open Network Utility and look up the Hardware Address of the target computers Ethernet network interface. Change the $mac value in the Applescript to be this value. </li><li>Look up the Bonjour name of the target computer (System Preferences -> Sharing : Computer Name) and substitute it for MyComputersBonjourName in the Applescript.</li><li>Change the $ip value in the Applescript to be the IP address of your router with 255 substituted for the last digits. For many people this would be 192.168.1.255. Also, 255.255.255.255 should work.</li><li>Open AppleScript Editor on the source computer (the one you want to connect from) and paste the script in it and then click Compile and then click Run to test it. It should wake the target computer and open screen sharing for it.</li><li>Save the AppleScript as an app by selecting File -> Save As and then picking application as the file type in the dialog box.</li><li>Double click on the app to verify it works.<br /></li><li>Drag the app to the Dock or wherever you want it to live.</li></ul>AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0tag:blogger.com,1999:blog-30809378.post-64193774506132156302010-12-15T05:05:00.000-07:002010-12-15T05:05:56.002-07:00How to run a Python script from Mac OS X FinderHere is how to run a Python script from the Finder:<br />
<br />
<ul>
<li>Make this the first line of your Python script "#!/usr/bin/env python"</li>
<li>Change the extension of the script file to ".command" i.e. my_python_script.command </li>
<li>In Terminal make the Python script file executable by running "chmod +x my_python_script.command"</li>
<li>Now when you double click the Python script in Finder it will open a terminal window and run.</li>
</ul>AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com1tag:blogger.com,1999:blog-30809378.post-64570171984916880932010-12-08T05:53:00.001-07:002010-12-08T05:55:02.233-07:00Checklist for making a home file, print and web server using Ubuntu and an old laptopA couple years ago I did <a href="http://skillfulness.blogspot.com/2008/11/creating-home-web-and-file-server-with.html">a detailed set of posts on turning an old laptop into a Ubuntu file, print, and web server</a>. That laptop started having hardware problems so I decided to decommission it and replace it with another recently retired Dell Inspiron 1521 laptop. Here is a checklist of all the steps I did to convert the Windows Dell Inspiron 1521 laptop into a home file, print, and web server. If you are new to Linux you should read my original posts since this checklist assumes you have done stuff like this before.<br /><ul><li>Downloaded and burned CD for Ubuntu LTS 10.04 standard desktop</li><li>Installed Ubuntu standard desktop 10.04 on Inspiron 1521. I followed the prompts and used the default options.</li><li> Wrote over existing Windows file system rather than doing dual boot.</li><li> After Ubuntu was installed I started Synaptic and updated packages</li><li> Installed openssh-server and samba using Synaptic</li><li> Opened terminal and ran sudo tasksel to start program that offers a number of options for installing groups of packages for different functions.</li><li> Selected install LAMP server and followed prompts to install.</li><li> Using Firefox on new server I went to truecrypt website, downloaded latest Linux version (7a) to the Desktop, extracted file, double clicked it, and followed the prompts to install Truecrypt.</li><li> Edited /etc/network/interfaces (sudo nano /etc/network/interfaces) to make computer use fixed IP address by adding:</li></ul><blockquote>auto eth0<br /> iface eth0 inet static<br /> address 10.10.10.123<br /> netmask 255.255.255.0<br /> gateway 10.10.10.1</blockquote><ul><li> Rebooted new server to put new static IP address in effect</li><li> sudo aptitude install ntp (ntpdate was already installed)</li><li> Set up mount points for encrypted external hard drives:</li><li> sudo mkdir /media/encrypted1</li><li> sudo mkdir /media/encrypted2</li><li>Changed owner of mount points to match what smb.conf will use for them </li><li> sudo chown nobody:nogroup /media/encrypted1</li><li> sudo chown nobody:nogroup /media/encrypted2</li><li> Created directory for my custom scripts for new server: sudo mkdir /home/andy/scripts</li><li> Mounted new server as volume on remote MacBook using MacFusion (SSHFS)</li><li> Copied backup of custom scripts over to new server from MacBook</li><li> Checked ownership and permissions of custom scripts and changed them as needed. </li><li> Ran my custom script to mount truecrypt volumes (/media/encrypted1 etc)</li><li> Made these changes to /etc/samba/smb.conf (sudo nano /etc/samba/smb.conf)</li><li> workgroup = MYWORKGROUP</li><li> removed semi-colon before interfaces = 127.0.0.0/8 eth0</li><li> removed # before security = user</li><li> Added these under Share Definitions</li></ul> [public]<br /> comment = Public Share<br /> path = /media/encrypted1<br /> read only = No<br /> force create mode = 777<br /> force directory mode = 777<br /> force user = nobody<br /> <br /> [backup]<br /> comment = Public Share<br /> path = /media/encrypted2<br /> read only = No<br /> force create mode = 777<br /> force directory mode = 777<br /> force user = nobody<br /><br /> [pictures]<br /> comment = Public Share<br /> path = "/media/encrypted1/Documents/My Pictures"<br /> read only = Yes<br /> guest only = Yes<br /> guest ok = Yes<br /><ul><li>sudo adduser spouse</li><li>sudo smbpasswd -a andy</li><li>sudo smbpasswd -a spouse</li><li>Rebooted new server</li><li>Ran custom script for mounting truecrypt volumes</li><li>Mounted samba share from remote MacBook and opened file to make sure everything was working properly.</li><li>sudo aptitude install phpmyadmin</li><li>From remote MacBook browsed to http://10.10.10.123/phpmyadmin and logged in as user root</li><li>Using phpmyadmin created a new user and gave this user all possible privileges on the MySQL database. </li><li>sudo adduser www</li><li>sudo nano /etc/apache2/sites-available/default</li><li>Changed the DocumentRoot value to /home/www/public and saved the file</li><li>Restarted Apache: sudo services apache2 restart</li><li>From remote MacBook did SSHFS mount as user www using MacFusion</li><li>Copied all html/php files from backup to /home/www</li><li>Used phpMyAdmin to create new user web_app_user with all data (but not structure or database administration) privileges. This is the MySQL user used by the web apps.</li><li>Used phpmyadmin to create new MySQL databases with same names as were used on the old server (including wordpress).</li><li>Used phpmyadmin to go into each database and then import the SQL file backup of that database.</li><li>Edited /etc/php5/apache2/php.ini to change session.gc_maxlifetime = 1440 to 1814400 (this prevents web app users from being logged out of web app shortly after they sign in)</li><li>Edited blank /etc/apache2/httpd.conf to add "ServerName myserversname". This prevents the annoying "Could not reliably determine the server's fully qualified domain name" message when you start apache2.</li><li>Restarted apache: sudo service apache2 restart</li><li>Tested that web applications work.</li><li>Got crontab setups from old server by doing contab -e as all users that had crontabs and writing down what was there.</li><li>Changed permissions on custom scripts that would be run by different users via crontab: chmod a+rwx scriptname.sh</li><li>Created logs directory in /home/andy: chmod -R a+rwx logs </li><li>Tested all backup scripts on new server.</li><li>Setup crontabs on new server using crontab -e</li><li>Configured CUPS for printer (not sure all of this is necessary)</li><li> sudo nano /etc/cups/cupsd.conf</li><li> In <location> , <location admin=""> and <location admin="" conf=""> and <policy default=""></policy></location></location></location></li><li> add:</li><li> Allow all</li><li> Commented out "Require user @OWNER @SYSTEM" where ever it appeared except for administrative tasks.</li><li> Changed:</li><li> Listen localhost:631</li><li> to:</li><li> Listen 631</li><li> Added the line: DefaultEncryption Never</li><li> sudo service cups restart</li><li>Browsed to 10.10.10.120:631 from remote machine</li><li> Add printer</li><li> Select HP LaserJet 1012 (HP LaserJet 1012), not the 1012 printer with USB in the name.</li><li> Name: HP_Shed</li><li> Description: HP LaserJet 1012</li><li> Location: Shed</li><li> Select Model: HP LaserJet 1012 - CUPS+Gutenprint v5.2.5(en)</li><li> Select default default options</li><li> Select modify printer just created</li><li> Click Select Another Make/Manufacturer</li><li> Select Make: Raw</li></ul>AndyfromTucsonhttp://www.blogger.com/profile/15757189063918646808noreply@blogger.com0