yuwei.net.nz | Bits of what I am doing

CAT | Programming

Sep/09

13

Xnet Dashboard Widget 0.1

Xnet is one of ISPs in New Zealand. Personally, I am enjoying use their services. However, there is one thing that I dislike after I changed to use Safari instead of Firefox. Since I am using Xnet’s FUSION plan, I would like to know how many data I have used (of course, how much I have spent). The disappointment is Xnet only provides Windows widget and Firefox extension usage monitor. In my case Mac + Safari, there is no way to keep myself up to date of data usage. At the end, I decided to write myself a usage monitor dashboard widget.

By browsing the Windows widget, I found the information I need, for example, query link and data encryption. There is not much point to go under the hood to explain the code. So here is what the widget looks like.

Xnet Usage Monitor Widget Front

Xnet Usage Monitor Widget Front

And the preferences (Back side of the widget)

Xnet Usage Monitor Widget Back

Xnet Usage Monitor Widget Back

For those of Mac users who are using Xnet as well, try it out. Download. If you found any bug, you are welcome to report it in the comment area.

No tags

When using applications like twitter, there is a limit on number of characters can be entered. Sometimes, there are long website URLs that is not going to fit into such limit. This is where sites like tinyurl comes in. They shorten the URL. However, to browse to their site to copy/paste the URL and copy the shortened ULR is too much.

Here is an Applescripts I coded up to do that automatically.

– get current safari page url
tell application “Safari”
set linkurl to the URL in document 1
end tell

– query and parse
set command to ¬
“curl –stderr /dev/null \”http://tinyurl.com/create.php?url=” & linkurl & “\” | grep ‘http://tinyurl’ | awk -F ‘|<\b>|\”‘ ‘{print $2}’”

– get tinyurl
set tinyurl to (do shell script command)

– copy to clipboard
set the clipboard to tinyurl

It will get the tinyurl for current Safari page and copy it into clipboard. After running this script, the shortened url can be easily paste to any application by simply type Cmd+V.

No tags

Theme Design by devolux.nh2.me