Monday, March 11, 2013

When the axle just isn't long enough

Yesterday my in-laws took the 9 year old boy shopping for a new bicycle.  He's outgrown his current one and needed a bigger bike.  Since he's had some delays with all his medical issues, he still needs training wheels.

So they bought him a very nice bike and a set of training wheels.  I was assigned the task of putting the training wheels on the bike.  Now, the way you attach training wheels is that you typically remove the nut from each side of the back axle and in some manner attach the wheels to the axle and put the nuts back on.  But what do you do when the axle is not long enough on each side to accommodate the training wheels?

That was the question.  There are various types of training wheel configurations, they two most prevalent being a flat metal bracket as well as "C" shaped bracket variety.  Well, that's what the bike's owners manual explained, yet nothing about the length of the axle.  The kind they brought home with the bike were the "C" shaped ones which seem to require a little more axle space than the flat ones.

Ran to WalMart today at lunchtime with the hopes I could find a flat bracket set, but it didn't happen.  They had some cool looking Bell E-Z Trainer Wheels which are kind of spring loaded and claim to always allow the wheels to touch the ground and also allow the trainee to lean on turns.  But, they looked like they would require a lot of axle space, or more than a flat bracket pair of training wheels would.

So I did a little research today and came up with the following options. So here is what I learned today about what can be done when the rear axle isn't long enough on a bike to add a set of training wheels:
  • return the bike
  • get a longer axle, the axle is about $5, but not easy to replace, well, I've never done it.  We could probably remove the back wheel and take it to a bike store, not sure how much $ it will cost to have them do it
  • replace the nuts on the axle with thinner ones (even if we do this, not sure the training wheel brackets will fit)
  • teach them to ride without training wheels
I think I'm leaning towards the final option at this point.  I read a suggestion that you remove the training wheels and lower the seat so they can comfortably rest their feet on the ground. Then you let them push themselves around on the bike with their feet, the goal is to coast and learn to balance.  I think his old bike that is just a little too small will be the perfect thing to experiment with.

Sunday, March 10, 2013

Batch rename of folders in Windows

We used to back up all our digital photos to CDs and DVDs.  Now I have a Network-attached storage (NAS) device that I'm backing them up to (with a lot of other things) I wanted to get the photos from those CD/DVDs and get them on the NAS so I would have all the photos in one spot (well, I do back that up too, but maybe that's a topic for another day). So I spent some time copying them off the discs and putting them into a temporary folder on my computer planning to do one big copy to the NAS.

I figured out a while ago that I wanted to store my photos organized by time stamp.  So there is a folder for each year and inside that there are folders named in the format of  "YYYY-MM-DD".  The complication is that all the folders on those discs I mentioned were made before I decided on this convention.  Most of them were stored as "MM-DD-YYYY".  Now the main reason I like "YYYY-MM-DD" is because it sorts nicely, that's really about it.

So,  How do I name about 4 years worth of windows directories from "MM-DD-YYYY" to "YYYY-MM-DD" quickly?  Well, I wrote a batch file to do it.  Since I had all the folders I wanted to rename in one directory all I had to do was step through each one that matched the pattern I wanted to change, and issue the command to change them.

The problem is to rename something you need to know the old name, and the new name.  So I needed to be able to move the year. month and day part of the name around independently for each one.  Well, that's what I learned today.

The batch file I ended up with, which worked for the most part is here and nice and short:
@Echo on & SetLocal EnableExtensions
For /F "tokens=1,2,3* delims=-" %%I IN ('dir /ad /b ??-??-????')
       DO rename "%%~I-%%~J-%%~K" "%%~K-%%~I-%%~J"

To break it down, line one:
@Echo on & SetLocal EnableExtensions

Basically turns on "echo" so I can see what it is doing while it's working. The "SetLocal EnableExtensions" inherits the environment from the parent environment and keeps any environment changes I make local to this batch file and probably don't need it for this little run.

The second line is the complicated one:
For /F "tokens=1,2,3* delims=-" %%I IN ('dir /ad /b ??-??-????')

The first thing you see is the "For" loop, which lets me do the same thing over and over on a set of items. The set I want to step through is the Windows folders with the names I want to change.  The "/F" turns on file parsing (so we can muck with the names). The "IN ('dir /ad /b ??-??-????')" gives me that, basically saying give me all the directories (by running the "dir" or directory listing command with the "/ad" options which tell it to just list directories/folders) that have the name matching the pattern "??-??-????" (I'm not going to explain pattern matching :-).  The "%%I IN"of the "for" loop says when I'm in the loop, the item I'm supposed to be working on now is called (referenced by) the variable called "%%I".

Now the third line is what we do through each iteration of the loop:
DO rename "%%~I-%%~J-%%~K" "%%~K-%%~I-%%~J"

We simply run the Windows "rename" command and the syntax is pretty much current name first, then the new name you want it changed to.  Now we just need to explain all the gobbledygook in there.  That is where the "tokens" and "delims" file parsing features (that we turned on with the "/F") of the "for" loop come in.  They basically help you parse the items of the set as you step through them and this is how those two items break down:
  • "delims=" specifies a delimiter set, or what separates the pieces you want. Whatever characters you specify replaces the default delimiter set of space and tab.
  • "tokens=" specifies which tokens or pieces from each line are to be passed into the "for" loop body for processing.
You can look up all the syntax details, but to break it down the "tokens=1,2,3* delims=-" says the pieces I want are between each "-" (that's the "delims=-") and that I want the first three of them ("tokens=1,2,3*"). It automatically adds variables for me to use after the "%%I", putting the first piece I want into there, so that's why there is also a "%%J" (the second piece) and a "%%K" (the third piece).

Oh, you may have noticed the tilde ("~") in the names.  That's a variable modifier that basically means when you use what is in here, expand it, which removes any surrounding quotation marks ("").

So the "%%I" variable holds the MM, "%%J" holds the DD and "%%K" holds the YYYY.  So shuffling the order around using the rename command is basically saying here is my original directory name "%%~I-%%~J-%%~K" and here is the new name I want it to have "%%~K-%%~I-%%~J".

So, I put the three lines I started talking about way up at the top into a file called "renam.bat" and put it into the same directory where all the "MM-DD-YYYY" named directories were. Then I ran it by opening a "cmd" window and changing to the directory where all this stuff was sitting.  I ended up with all the directories renamed into the "YYYY-MM-DD" format.

The only glitch was that I had some directories named differently. Some didn't have all the digits of the dates, like "MM-DD-YY" or "M-D-YY", and they just didn't get processed.  Others were of the format "MM-DD-YY-Something" and those did get processed.  Luckily, that's what the asterisk in the "tokens" keyword is for, it tells it to keep anything after piece three as a part of piece three. So a couple of the names got slightly jumbled, but all those special cases were easy enough to fix by hand.  I didn't want to spend the time working on them in the script as there were only a few of them.

Of course there is probably several ways this could have been done, and probably some more elegantly.  But I learned something new (the "tokens" and "delims" stuff) and it worked, and it was quick because there were a lot of directories that needed to be renamed and now all my photos are copying to the NAS as I type this up.   So I'm happy.

To get it to work under Windows XP (Per the comment below) just make the "for" command be one line long.  Remove the carriage return before the "DO" and it works.  I just tested it on a XP VM.

For /F "tokens=1,2,3* delims=-" %%I IN ('dir /ad /b ??-??-????') DO rename "%%~I-%%~J-%%~K" "%%~K-%%~I-%%~J"

Thanks

Saturday, March 9, 2013

Balls better than planes

So, I learned this last night, not today, but it's my blog, so it still counts.

Went to a Cub Scout Pack meeting last night with my son (he's a Bear Cub) and they had a paper airplane meeting.  Last year they had to fold paper planes and got judged on distance.  We prepared this year by practicing a little folding before the meeting, but it was to no avail as they mixed things up a little.  This year it was a launching competition.

So they flipped over folding chairs, attached an cardboard cutout of an aircraft carrier to the side and stretched a rubber band between two of it's legs and put some boxes across the room.  The goal was to build some kind of flying machine that you could "Launch" and get it into the boxes.  They explained the rules to be that you could build whatever shape or design you wished and attach a paper clip in some fashion.  The supplies provided were paper, paper clips, scissors and tape. The scissors were not supposed to be used as part of the vehicle.

So we got busy and my son got a little frustrated so I helped him out.  I wasn't supposed to but I gave him some ideas on how to attach the paper clip and whatnot.  We started by flattening out the piece of paper he had crumpled up in frustration and then rolled it up so it looked like a straw (think "fuselage"), and applied some tape to hold it.  Then folded another piece of paper in to a wing shape and taped that on (think "wing").  Then taped on a paperclip to the bottom front. 

He tried launching it a couple times by catching the paperclip on the rubber band, pulling it back and letting go.  We adjusted the wings, but it would just crash and burn each time.  It would make it about half way to the target.

Next design was to fold up one of the paper plane patterns we had been practicing before the meeting.  We taped a paper clip to the bottom of that one, but it flew worse than the first one.

The Webelos were launching tiny planes across the room, they were flying all the way across the room.  The other Bears, Tigers and Wolfs were all doing about as good as my son.  I'll give it to him though, he kept trying to make adjustments to the first plane we put together and get that thing to fly.

Eventually the frustration won out, I could see it in his face from across the room.  He grabbed a new piece of paper, wadded it up into a little ball and started taping a paper clip to it.  I offered to compress the paper a little better and he said yea.  He wrapped it up nice and tight with tape.

Next up, he launched that "ball" and he just missed the target box.  he waited his turn and tried again, and bingo, right in the box.  He won for the Bears, as he was the first to hit the target.

He learned that sometimes the simpler the approach works best, and I learned once again that my son is smarter than I sometimes give him credit for being.

Friday, March 8, 2013

Blogger mobile app for android

Today I wanted to learn how to use the blogger mobile app for android. First I had to remember how to do screen grabs on my phone. Only took me a couple seconds.

The entire process seems straight forward. You open the app and hit "new post" (third image below) and start typing (in the fourth image below). You can save your work (floppy icon) or just toss it (garbage pail icon).

Here is were I wanted to embed some screen shots but it looks like it will only let me attach one image? Ah, no it looks like you can attach multiple images. When editing the post just hit the last icon at the top of the editing area, that looks like stacked pictures, to pull an image from what is on your device. I'm betting the camera image lets you take a picture. I just can't place them inline or arrange their order.  Hopefully they stay in order?

nope order seems almost random. 

After you have saved your post you are taken to the post list screen, second image below, you can also get there from the "posts" button on the main page (third image).  From there you can do actions on your lists of posts.  I've been able to save and re-edit this post a couple of times.  Going back to correct typos, add some text referencing the images and think about things. 

At some point html tags started appearing in with the text. Not quite sure when or why. (Looks like they show up if I edit the post from the view post screen, hitting the pencil icon from image one) They seem stuck here now and I need to delete them one by one.

My intent is to do this entire post from my phone. Looks like when I'm ready to post it I can just hit the right arrow icon at the top of image four.

From the post list screen (image two) there appears to be an option to preview the post. Lets get an image of that next.  So image ome is the preview.

Overall I think it works pretty easily.  Lets hit the post button and see what happens....

Thursday, March 7, 2013

Ghostery

I've been using Ghostery for a while now, I install it in every browser I regularly use on the desktop, mainly Chrome and Firefox.  And I guess today I learned I can install it in IE.  So that's what I did.

Ghostery basically blocks things used by web pages to track you, so someone can collect data on your online behavior.  It's easily configurable, so it's pretty easy to tweak on the fly.

When it's blocking something, it pops up a bubble that lets you know what was blocked.  When you are not blocking it pops up a bubble letting you what gets through. You can disable it on some sites, for the entire site, selectively on a page or just pause it from blocking anything anywhere.

You will need to tweak what it blocks on some sites since the "tracking" you want to block is sometimes allowing you to accomplish what you really want to do.  But you can pick and choose so you only disable the blocking of the items you need.  So if a web page feature isn't working, try pausing blocking totally or disabling some blocks one at a time to see if you can get it working.  I always try to let through the bare minimum of active tracking.

Normally I'll disable blocking on service sites I use.  I disable blocking on the logged in pages of my bank/credit union, credit cards, Gmail, Google Drive and most of the sites I need to be logged into for work, so it doesn't interfere with what I'm trying to do.  You can always play with it and try to block as much as possible, but sometimes I just need to get something done.  Do I need to disable it on these sites, I don't know.  I figure better safe than sorry and maybe that will be something I learn in the future for a blog post on another day.


Like I mentioned I've been using Ghostery in Chrome and Firefox for a while now.  I hardly ever use IE (only when I have to, and even then, I don't really have to) but today I learned that Ghostery was available for it and thought I would give it a shot (I don't mean to imply it just came out, only that I just learned about it).  The install went OK for the most part.  My anti-virus software flagged it when I tried to install it (it was a security risk because it was identified as a SecurityRisk.Downldr, which basically means when it is executed (the installer), it goes to a specific Web or FTP site, which the author created, and attempts to download files or update itself, and after download, it runs.  It told me it quarantined the file and deleted it, but part of the install was a restart of IE, where the process seemed to hang when it restarted and tried to run Ghostery.  After the restart I just hit the IE reload icon and it finished fine and took me through the setup wizard.  I'd walk you through the setup wizard, but maybe you should learn something on your own today?

I also like their logo: Ghostery The little "ghost" guy is pretty neat looking.  When you install it in a browser, that's what you see in your menu/icon bar (the little "ghost" guy).  When he's blue it's on and when he's grayed out, blocking is paused.

BTW - I've used the Ghostery browser on iOS/iPad, and it's OK, I don't love it, so a lot of the time I just get tracked and use Chrome.