Monday, September 29, 2014

jargrep Bash Script

When I work with Java it can be handy to grep for a string in a JAR, so I have created an executable script called "jargrep".

#!/bin/bash
# Greps a jar file for a string.


if [ $1 ] ; then
  find . -name "*.jar" -a -exec bash -c "jar tvf {} | grep $1" \; -print
else
  echo "Usage: jargrep [string]"
  echo "  Example: jargrep \"string to grep for\""
fi

Create a text file called jargrep, copy the contents above, then run "chmod +x jargrep" to make it executable.

Friday, September 26, 2014

Bash Security Hole

There is a pretty serious bug in bash that you can read about in more detail in this article: http://arstechnica.com/security/2014/09/bug-in-bash-shell-creates-big-security-hole-on-anything-with-nix-in-it. In short, you are currently vulnerable and can test it by running this:

env x='() { :;}; echo vulnerable' bash -c "echo you are vulnerable"

If you see:

you are vulnerable

Then you are vulnerable. I tried it on all of my systems including OS X Mavericks and Ubundu!

Thursday, September 25, 2014

Review: Underwater Camera



Recently we took a vacation/work trip to Hawaii. How could that be work you ask. The Missus needed to get photos of things that can only be found in a tropical place like Hawaii. Shucks! Turns out Hawaii was less expensive than other tropical places so that's good on the bottom line. But we also needed an underwater camera. Housings for an SLR while awesome are expensive and overkill so we picked up a point and shoot underwater camera and I am super happy with it.



The choices were between the Panasonic TS4 and the Nikon AW110. At the time of writing this the Panasonic was $150 more than the Nikon so we went with the Nikon. I've used the Panasonic TS3 before and it's great but the Nikon holds its own at a much lower price. However, as of writing this they are virtually the same price on Amazon since it appears the price of the Panasonic TS5 has come way down in price from it's predecessor.

One really huge advantage to these cameras is there is no protruding lens. On a normal point and shoot when it is turned on a little motor will push the lens out. If you bump it every so lightly it will break off. I've had this happen more times than I can count. Be more careful you say. Well, that's true, but it's happened by accident every single time and with this camera you don't have to worry about it. All optical zoom is internal so no external moving parts!

In good light the pictures are very good. An SLR will always outperform it but in good light it's real close. Convenience is key. In dark rooms it leaves much to be desired but that's the same with any point and shoot. The speed at which the shutter release is pressed and the picture is taken is also very impressive and surpasses many regular point and shoots in the same price range or even the Canon G series. I had a Canon G but I sold it because I preferred the Nikon AW110.

My only complaint is the battery life. Buy a second battery.

Also when going in a pool with chlorine or in the ocean with salt water, before opening the doors to the camera to replace the SD card or the battery, fill a small bowl with fresh clean water and soak the camera for 30 minutes. This will keep the seals clean. Also you will want to oil the seals once in a while so they don't become brittle.

Update: Turns out we like it so much it's with us almost all the time over our SLR!

Nikon now has the AW120. It looks even better.

Wednesday, September 24, 2014

Random Numbers

Generating random numbers isn't the most straight forward. Here is the correct way to do it in C/C++:

Windows:

int randomNumber;

if (rand_s(&randomNumber))
{
    return randomNumber;

}
else
{
    //TODO error
}


Unix/Linux:

int randomNumber;
int fd = fopen("/dev/random", O_RDONLY));

if (fd > 0 && read(fd, &randomNumber, 4))
{
    return randomNumber;
}
else
{
    //TODO error
}

NOTE: On Linux don't call this too many times because the pool of numbers is limited.

Friday, September 19, 2014

Talk Like a Pirate Day

Friday, September 19 is International Talk Like a Pirate Day 2014.


Check out the Original Talk Like a Pirate Day website:

http://www.talklikeapirate.com/piratehome.html

I know this is one of my favorite holidays!

Thursday, September 18, 2014

Can you Depend on Cloud Solutions?

Cloud solutions are great. They usually are free, or pretty inexpensive for what you get. However you do give the company access to your data which is how they are making money most of the time. But my point of this post isn't too discuss the nuances of how the companies make money or whether you should give the companies your data for free in exchange for a useful tool. My point is should you even depend on them? Most of them are touting themselves as more reliable than your desktop and your own backup system. It's true that the best backup is the one that you do, but you also have to be able to get to your data. Obviously the choice depends on what you are putting into the cloud because of reliability of the service and the sensitive nature of the data.

If you are a student writing a term paper for instance, Google Drive, Apple iCloud, or Microsoft office 365 are all free and are very compelling. However OpenOffice and Apple Pages are also free, and if something goes wrong your term paper won't be bit dust.

What made me think of this is Apple just rolled out iOS 8, and in doing so upgraded iCloud to iCloud Drive. Brilliant because now it's more on par with Google Drive, however the fine print says that when upgrading to iCloud dries only iOS 8 and OS X Yosemite support iCloud Drive. Only developers are running Yosemite so this seems like a rather odd thing to do. So until Yosemite is out I guess I won't be using iCloud.

Apple Calendar Stuck in Unusable State after Changing Password

After changing my password for my CalDAV server I started getting this error: "The server responded with an error. The server did not recognize your user name or password for account "." Make sure you enter them correctly." Typing in the new password just displays the dialog again, but I was able to successfully fix this issue by resetting the Keychain. Go t0 > Utilities > Keychain Access > Preferences > Reset My Default Keychain It also works to remove all keychain entries for that specific server to be more selective about it. Note: I'm running Mavericks, but I've run into this with Lion and Mountain Lion.

Wednesday, September 17, 2014

I'm Still Here (and Alive)

I haven't posted in some time so a few readers (and friends) have contacted me to see if I'm still alive. I'm happy to report that I am alive and I'll be posting more often. The last few years have been, well they've been extremely busy and a lot of things have come up that have been, well, more important than this blog. But, that's about to change so stay tuned!