2015-09-24

Convert Unix Timestamps to useful Date Stamps from a pipe

I've found numerous times that I run into files that are in a format like:
[1443094172] [29058] SERVICE ALERT: imgserver03;Root File System;UNKNOWN;SOFT;1;ERROR: hrStorageDescr Table : No response from remote host '192.168.90.64'.
[1443094462] [29058] SERVICE ALERT: imgserver03;Root File System;OK;SOFT;2;Disk OK - / TOTAL: 15.748 Go USED: 19% : 3.019 Go

While I'm not that bad with reading timestamps... it takes some temporal awareness and when it's 6am and I haven't had my coffee yet, that's just too much cognitive power for me to conjure up. So I made the following script that takes info in from a pipe, looks for timestamps, and converts them over.


Save that in a file, chmod the file +x, and do something like:
cat mylogfile.log|./t2d

You can stick greps and such in there too. Just as long as the timestamp doesn't get corrupted, From the above output, I get:
$ cat mylogfile.log|./t2d
2015-09-24 07:29:32 [29058] SERVICE ALERT: dsfrcimg03;Root File System;UNKNOWN;SOFT;1;ERROR: hrStorageDescr Table : No response from remote host '10.93.90.64'.
2015-09-24 07:34:22 [29058] SERVICE ALERT: dsfrcimg03;Root File System;OK;SOFT;2;Disk OK - / TOTAL: 15.748 Go USED: 19% : 3.019 Go

I've also added this script in a public Gist on github.com: https://gist.github.com/thejml/7af9f4b56ef9b11e612f

2015-09-16

Replace OSX Yosemite "Photos" App with Something Better

I'm the proud owner of a fairly ancient Canon EOS Digital Rebel XT... I've had it for near 9 years now, and it's still working fairly well... but after moving to OS X I've found that the handling of the camera is less than optimal. Now, Keep in mind that the XT (and may of it's sisters) use CF cards. There's no CF Slot on a modern Mac (or any other computer for that matter), so short of getting and carrying around a CF->USB Adapter, I use the USB Mini cable that came with the camera. It's not failed me yet, and it continues to transfer well...

Until you plug it in to OS X Yosemite, when you get quickly acquainted with "Photos". Now, I've had my Mac a bit and that included using "iPhoto" prior to "Photos", but while I like iPhotos better in some ways and Photos in others, I've consistently thought "Why can't I just browse this camera in the finder?" or even "Why can't I just tell it to dump the photos on this camera to a folder so I can look through them... do they have to be in an Album?".

You see, the problem I've found with both Photos and iPhoto, is that it wants to manage and hoard ALL my photos. While this is a worthy goal, one that many other photo managers have attempted, it paints me into a corner and severely limits me for a few reasons:
  • I have about 300GB of Photos, so far. I have a late 2013 MBP Retina with a 256GB SSD
  • I'm only going to get more photos and those photos are only going to get bigger with higher megapixel cameras
  • I'd like to not be tied to a specific platform of organization, lest I decide to migrate later
  • I have a NAS on which I store my photos, and have configured offsite backup for multiple directories, both to another NAS at a relative's house, and to AWS S3 Glacier.
  • iPhoto and Photos don't really like operating over a network FS mount
  • If I import 8GB of photos, delete 6GB of the ones I didn't like (yeah, that happens sometimes), and check my free space, it still has 8GB used. In fact, neither of these programs really like to free space too much. Obviously it's so you can Undelete. You can also do cool editing in there, and they've got great Adobe Aperture fighting abilities. And it keeps copies of the original and each copy you make so you can revert and such. All this uses lots of disk space, and well, there's that darn 256GB SSD.
  • The put the photos in hard to find and browse to areas on disk
  • The "Show in Finder" and "Show Original in Finder" options for some reason, don't always work?!

Anyway, I could probably keep going. I'm not saying they're bad, but they're not really good either. Now, Maybe there's something good in the app store, though a quick glance didn't turn anything up... but really I just want my photos as flat files in a finder like any other normal OS. Well, after much googling I found this and decided to write it down in an easy to look up blog post.

  1. Connect camera
  2. Get out of that darn Photos/iPhoto app
  3. Hit ⌘+SpaceBar to bring up Spotlight, type "Image Capture" and Hit Enter when it finds it
  4. You should now see your camera listed under Devices, your photos on the right, and the ability to select them individually, or leave them all unselected and hit "Import All" at the bottom after changing the drop down to where you like.

  5. Most importantly, however, you can click the little icon in the bottom left that looks like a triangle in a window and find a hidden gem in the corner letting you define what happens when you connect this camera in the future. "Image Capture" means it will open this.


And there you go, you have now made this simple program, or another program of your choice come up. I've stuck with "Image Capture", as I've found that being able to say "Import to Folder", is basically what I wanted. I can then go through and work with those photos. In fact, if I'm not going to delete them from the camera, I can even exclude that from "Time Machine" so there is no trail if I decide they all suck.