Black and White Extension Icons in Chrome

While reading the Noodlesoft forums I stumbled upon the buzz which pointed me to Adrian Logue post about how to get Black and White Extension Icons in Chrome.
There are two things “wrong” with the post from Adrian:
  1. He is describing setting this up in an older version from Hazel which doesn’t has support for Pixel Width and Pixel Height (or at least I have them as options)
  2. He mentions that the size of the Extension Icons are 19×19.
To me it looks like that the size of the Extension Icons are NOT only anymore 19×19, my extensions have a lot of different sizes, starting from 16×16 and ending at 128×128.
So I did write up a quick applescript which checks for specific sizes and also if the image is a square.
Note: 128 x 128 is a size also being used by the Apps display in Chrome, so maybe you want to remove that value form the list.
The top part of the script is quite useful for debugging in the applescript editor and doesn’t matter when you run it in Hazel.

Poor Man’s Sanebox

Call me cheap… but you can’t call me lazy.

Update: I forgot to mark the messages in the folders read, I added that to the script.
While Sanebox  is a great way to manage your inbox and remove a lot of pressure it just doesn’t cut it for me with my 30 mails a day.
So I came up to recreate the issue I liked the most from Sanebox, moving mails aside and bring them back in focus later again.
You can use mail rules for this, the only problem is that osx mail will not run rules on other folders than your inbox. But I found a solution on c-command which boils down to run a rule with every incoming mail, but on other folders (and they even did it because of sanebox..)
So this is what I did..
I took the applescript from c-command and made some changes to support @SaneTomorrow and @SaneNextWeek. Also because I have an Exchange and an GMail account I implement a try and on error to either use Inbox or INBOX depending on which format the inbox is.
And here is the script:

Activate / De-activate VPN per AppleScript

Just got a good Deal for a VPN Provider to different countries to secure Wireless Connections via VPN Unlimited.

Link to deal , offers  expires 2014/08/22

I don’t want to keep it running by default so I created a short script to activate / de-activate the VPN via Keyboard Maestro.

Keyboard Maestro Editor VPN Switch

and here the script:

tell application "System Events"
    tell current location of network preferences
        set VPNservice to service "VPN Unlimited (Germany)"
        set isConnected to connected of current configuration of VPNservice
        if isConnected then
            disconnect VPNservice
            set onOff to "off"
            connect VPNservice
            set onOff to "on"
        end if
    end tell
end tell
return onOff

I now just need to figure out how to use more than one profile (the profile is auto configured via an app).

Still if this VPN Provider works to my satisfaction I guess I will subscribe longer after the first 3 years.

Can not convert \”22.5\” to number

While writing a script to get some information from top of the command line into applescript
and compare the numbers I stumbled upon a problem.
While top returns 22.5 applescript on my mac sees a number as 22,5.
The mac I use has german as locale, looks like the locale of the command line isn’t the same
and uses us notation.
So I created a short snippet to convert a string from 22.5 to 22,5 which can than be converted
to a number in applescript.
  on dotStringNumber2commaStringNumber(stringNumber)

       set resultNumber to ""
       set char_list to every character of stringNumber
       set char_list_length to count char_list
       repeat with x from char_list_length to 1 by -1
                 set current to ( item (char_list_length - x + 1) of char_list) as string
                 if current = "." then set current to ","
                 set resultNumber to resultNumber & current
       end repeat
       return resultNumber

 end dotStringNumber2commaStringNumber
I know this isn’t the best solution but I haven’t found a simpler one, perhapsmsomebody else knows.

Check if file is older than X days

Today I needed a rule in hazel which was able to check if a file was older than X days.

While there are some options in hazel like before this year, I mistrusted them to work in
the correct way and I wanted to do some more applescript.
So I wrote a quick applescript to check if the file modified date is older than X days and than
return a true.

-- Set the age of files that you want to keep
set keepDays to (360)
tell application “Finder”
set modDate to modification date of theFile
if modDate is less than ((current date)) - keepDays * days then
return true
end if
end tell
— File is younger than keepDays
return false