August 27, 2010 0

Dial numbers (incl. conference bridges) with Skype via Launch Bar, Quick Silver or others

By Max in Work at JBoss

I’ve been pretty happy with my previous Service Apple script to dial a specific conference call bridge, but as I started having to use more it got too annoying to add a script per specific numbers.

Now I’ve updated the script to be able to use directly from LaunchBar (or other launchers) as the dial action for contact book entries.

on dial_skype(num)
  set connect_wait to 10 (* seconds to wait before sending additional tones *)
  set dtmf_wait to 0.2 (* seconds to wait between sending DTMF tones *)
  set pause_char to "," (* character used to indicate a pause *)
  set pause_wait to 2 (* seconds to wait for a pause *)

  if num starts with "tel:" then
    set num to (text ((count "tel:") + 1) thru -1 of num)
  end if

  (* remove any spaces in the number otherwise Skype won't make the call *)
  set num to replace_string(num, " ", "")
  (* replace %23 with # since launchBar seem to force encoding of numbers *)
  set num to replace_string(num, "%23", "#")
  set parts to split(num, pause_char)
  set parts_count to count parts
  set phone_number to item 1 of parts
  if (parts_count > 1) then
    set dtmf_parts to items 2 through -1 of parts
  else
    set dtmf_parts to {}
  end if

  tell application "Skype"
    set active_call to send command "CALL " & phone_number script name "s2"
    set skype_call_id to word 2 of active_call
    delay connect_wait
    set bridge to "ALTER CALL " & skype_call_id & " DTMF "
    repeat with dtmf in the items of dtmf_parts
      repeat with tone in the characters of dtmf
        send command bridge & " " & tone script name "s2"
        delay dtmf_wait
      end repeat
      delay pause_wait
    end repeat
  end tell
end dial_skype

on split(str, sep)
  set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, sep}
  set AppleScript's text item delimiters to sep
  set parts to text items of str
  set AppleScript's text item delimiters to tid
  return parts
end split

on replace_string(str, fr, t)
  set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, fr}
  set temp to text items of str
  set AppleScript's text item delimiters to t
  set str to temp as text
  set AppleScript's text item delimiters to tid
  return str
end replace_string

(* for LaunchBar *)
on handle_string(s)
  my dial_skype(s)
  open location "x-launchbar:hide"
end handle_string

(* comment out for QuickSilver *)
(*
using terms from application "QuickSilver"
  on process text qsText
    my dial_skype(qsText)
  end process text
end
*)

Instructions for usage with LaunchBar

  1. Copy the above script and save it with Apple Script Editor in your favorite script location (I use DropBox to share scripts such as this between machines)
  2. Goto LaunchBar Action Preferences
  3. Set “Phone Numbers” action to the file you saved in Step 1.
  4. Use Launch Bar to find a contact’s phone number and press Enter.
  5. Skype should now start and dial the number.

You can also simply add the above script to a directory that your LaunchBar scans for scripts and use it via “Tab” on items; allowing you to use it on everything not just Address Book phone numbers.

Instructions for usage with QuickSilver

To use the script as an action for QuickSilver simply remove the comments from the lower block mentioning QuickSilver. How to configure QuickSilver to pick up the script is left as an exercise for the readers who have QuickSilver installed.

Instructions for Other Launch mechanisms

My previous blog shows how to embed a script like this into a Service menu entry, and if you use another launcher you just need to read their docs for how they want the script formed and apply it similar to what is done above for Launch Bar and QuickSilver.

Last Minute Comments about Phone Numbers

The script assumes the following about phone numbers:

  1. has to be in international format (i.e. +<number>) as otherwise Skype will not dial it.
  2. spaces are ok, but they are stripped out automatically otherwise Skype will not dial it.
  3. ‘,’ is used as a pause character and as the start of DTMF tones. Thus “+123456789,1234#” will dial +123456789, wait 10 seconds for connection and then send 1234# as individual DTMF tones with a small pause in between. Additional commas will give a 2 sec delay. You can see and change the values for all these pauses in the top of script.
  4. due to LaunchBar escaping ‘#’ with ‘%23′ the script replaces ‘%23′ in your number with ‘#’; this should not be a problem since ‘%’ is not a valid DTMF tone AFAIK.

Hope you will enjoy it as much as me, it saved me a ton of time and frustration when it comes to conference call dialing :)

Leave a comment if it works for you!

July 31, 2010 0

Converting thousands of WMA files to MP3

By Max in Java

I’ve been using a Mac Mini for a while now to run my media center
but recently I discovered that I actually had more than 8.000 songs in WMA
format that iTunes silently ignores when importing.

This blog is about how I managed to get that converted without too much fuzz.

UI Conversion tools

There are many various conversion tools out there for OS X, Switch being one of the better ones but it does not seem to handle massive conversions very well. The Windows version has a command line interface that could be used but its just too much hassle.

If you got small set of files to convert then Switch works fine.
Be aware that the latest Flip4Mac might cause problems for Switch, I had to use an older version (2.2.2.3) to make it work.

Because Switch and all other UI’s I tried for OS X did not work well for large scale conversions I decided to find a way to do it via a command line. This allows me to easily control it and in case something fails restarting it from where it stopped is much easier than any UI tool.

Converting (non-DRM) files via command line on OS X (excl. Tags)

Note: The following converts the files fine, but tags are not maintained! Just be aware of this limitation! Using LameXP described below seem to copy tags better, but that requires a Windows installation.

For command line conversion under OS X you need Lame+MPlayer installed; I got mine installed by
simply using MacPorts:

sudo port install mplayer

You might need to also install Flip4Mac in case there isn’t another WMA decoder available.

After installing mplayer, create this shell script which convert a single file, name it
convert.sh:

if (test -e "`dirname "$1"`"/"`basename "$1" .wma`.mp3"); then
 #echo mp3 $1 already exists
 test true
 else
 mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$1" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`dirname "$1"`"/"`basename "$1" .wma`.mp3"
 rm -f audiodump.wav
 fi

This script checks if a wma file given as input has a matching mp3 file in the same directory and if it has not it uses mplayer + lame to perform a direct conversion to mp3.

With the convert.sh script in place you can use the following command to convert all .wma files that does
not have a matching .mp3:

find . -name "*.wma" -print0 | xargs -0 -n 1 -L 1 -I {} ./convert.sh "{}"

The -print0 and additional arguments to xargs is what ensures filenames with spaces, weird quotes or non-latin characters gets properly quoted.

Then you should see console output for all the conversions and get all your files converted nicely. It took my laptop about 24 hours to churn through my non-DRM WMA files.

In case you bump into a file that cannot be converted then check if the file is actually valid and can play somewhere else (i.e. on a Windows machine or with iTunes with right encodings installed) – if it can play, but Lame will not then it is mostly likely because it is a DRM protected WMA. I had about 2.500 of those (yeah, I forgot to disable DRM when converting parts of my CD collection ;(.

Conversion of DRM protected WMA files (incl. Tags)

There exists many weird applications which doc’s state they can “break” the DRM encoding by letting iTunes play them and then record the digital output stream to write them to a virtual ISO image for then to convert them to mp3.

I tried many and most of them simply did not work out of the box or required massive tweaking to actually work but then the conversion took ages plus it was not very fault tolerent.

Therefore I decided to simply startup my Windows 7 virtual machine, Install LameXP and simply let it do all the work.

Again, I had many DRM files that needed conversion (2.500+) and adding them manually would take forever. Once again a little script made it much easier.

Create a file named check.sh with the following content:

if (test -e "`dirname "$1"`"/"`basename "$1" .wma`.mp3"); then
 #echo mp3 $1 already exists
 test true
 else
 echo $1
fi

Then use this script with the following one-liner:

find . -name "*.wma" -print0 | xargs -0 -n 1 -L 1 -I {} ./check.sh "{}" > needconversion.m3

Running this finds all files matching *.wma, passes them to xargs
in a way so there won’t be problems with quotes, spaces, etc. and then
for every single found file calls the check.sh script and writes
the result to the file “needconversion.m3u”.

All there is left then is to Add the “needconversion.m3u” to LameXP
and when it has spent a few minutes on importing it press the Encode
button and let it do its business. On my laptop it takes about 10 sec. per file, thus 2.500 files takes about 7 hrs.

Be aware that LameXP as many other conversion UI’s does not seem to cope well when you have many thousands files to convert, but it did though a good job with my 2.500 files at once. If someone know a good way to do similar conversion but via command line on windows I would love to hear.

Fixing Tags

To fix broken tags i’m experimenting with using Jaikoz which is a for pay Java app that uses MusicBrainz to match songs by acustic fingerprints. For now it looks to doing a great job of matching up the songs, but if someone knows how to copy tags from 6.000 WMA to their matching mp3 let me know :)

July 11, 2010 3

Calling conference bridge numbers with Skype

By Max in Work at JBoss

I like Skype, but one of the features it has always lacked is a way to directly call into conference call bridges.

With a little help from AppleScript I finally managed to make that happen:

on run {input, parameters}

 set phone_number to "+1......"
 set dtmf to "1234567894#,*1234#" 

 tell application "Skype"
 set active_call to send command "CALL " & phone_number script name ""
 set skype_call_id to word 2 of active_call
 delay 10
 set bridge to "ALTER CALL " & skype_call_id & " DTMF "
 repeat with tone in the characters of dtmf
 if tone contains "," then
 delay 2
 else
 send command bridge & " " & tone script name "s2"
 delay 0.2
 end if
 end repeat
 end tell
end run

Copy and edit the above, remember to set the phone_number and dtmf variables.

Note: the dtmf variable treat’s “,” as a 2 second pause to use for conf call bridges that are a bit slow :)

Save it as a Service and you can now directly call your conference line directly from any app via the Service menu.

Tags: ,

January 30, 2010 0

Migrating from Serendipity (s9y) to WordPress

By Max in Java

I migrated this blog from from Serendipity (s9y) to WordPress.

It turned out to be pretty simple to import s9y posts to WordPress with the s9y importer, but making sure the old links to posts and feeds turned out to be a bit trickier.

I found a blog post that outlined how to use .htaccess to solve some of these problems, but it included manually having to figure out which id’s that had become skewed during the import process. Luckily the SQL schema of both s9y and WordPress is pretty similar and easy to do queries against to generate matching .htaccess lines.

The following SQL queries is what I used to create a working .htaccess file for my migration, use at your own risk ;)

SQL for posts:

SELECT CONCAT( "RewriteRule ^archives/", s9.id,
"\-.*.html$ /index.php?p=", wp.id, " [L,R=301]" )
FROM `serendipity_entries` s9, wp_posts wp
WHERE wp.id != s9.id
AND wp.post_parent=0
AND s9.title = wp.post_title
ORDER BY s9.id

SQL for category feeds:

SELECT concat("RewriteRule ^feeds/categories/", s9y.categoryid,
 "\-.*.rss$ /index.php?cat=", wp.term_id, "&feed=rss2 [L,R=301]")
FROM `wp_terms` as wp, serendipity_category as s9y
where name = category_name

SQL for category:

SELECT CONCAT( "RewriteRule ^categories/", s9y.categoryid,
 "\-.*$ /index.php?cat=", wp.term_id, "[L,R=301]" )
FROM `wp_terms` AS wp, serendipity_category AS s9y
WHERE name = category_name

Once you have the output from these insert them into the following .htaccess file:

RewriteEngine On
RewriteBase /

## skewed articles
[Insert output for Posts]

## categories
[Insert output for Categories]

## category feeds
[Insert output for Categories feeds]

## handle defaults
RewriteRule ^archives/([0-9]+)\-.*.html$ /index.php?p=$1 [L,R=301]
RewriteRule ^archives/([0-9]{4,4})/([0-9]{2,2}).*.html$ /index.php?m=$1$2 [L,R=301]
RewriteRule ^archive$ / [L,R=301]
RewriteRule ^feeds/index.rss2$ /index.php?feed=rss2 [L,R=301]
RewriteRule ^feeds/index.rss1$ /index.php?feed=rss [L,R=301]
RewriteRule ^feeds/index.rss$ /index.php?feed=rss [L,R=301]
RewriteRule ^feeds/index.atom$ /index.php?feed=atom [L,R=301]
RewriteRule ^plugin/tag/(.*)$ /index.php?tag=$1 [L,R=301]
RewriteRule ^categories/(2)\-.*$ /index.php?cat=3 [L,R=301]

With that in place in the root of your WordPress installation those using your old s9y links should now be redirected automatically to the matching WordPress posts/feeds/categories.

Another useful post I found were about how to move WordPress between domains, which I needed because I intially installed it on wordpress.xam.dk but needed it to end up on blog.xam.dk and apparently WordPress thinks it is a good idea to stored absolute url’s in its settings.

Now if I could just find a WordPress theme that were both beautiful, simply and functional…still searching..

May 24, 2008 1

Rant about international airports, especially Geneva

By Max in Work at JBoss

The last 3-4 years I’ve been travelling alot to and from Switzerland and especially Geneva Airport.

I normally always take a trolley for my suitcase and carry on luggage since I realized that it makes my long flights much smoother not having strained my back or feet with moving around bulky and semi-heavy luggage (and no, four-wheeled luggage does not help since I still have to carry my carry on bag).

But lately Geneva did the most annoying thing. They started requiring you to put 2 CHF in to get a trolley.

I understand the reasoning about it since the airport probably feel that it is cheaper to let their customers put back their trolley instead of paying personel to pick them up.

But seriously, how many international passengers arriving in the airport will have an actual swiss franc coin in their pocket ? Bill notes maybe, but not coins! And even you have a coin you can’t get it back when you reach the “No trolleys allowed signs” since Geneva airport never bothered putting up trolley stations inside the airport where you can get your 2 CHF back!

End result: Tired international passengers will have to carry their luggage since they don’t have the coins, and local swiss passengers that have the 2 CHF will still leave the trolleys left and right since there are no sane place to get the 2 CHF back again….I guess those 2 CHF is now a tip for the personel Geneva airport couldn’t let go since there is still work for them to move the left over trolleys back to their origin.

Rant over – now ill continue wait for my flight ;)

January 16, 2008 6

This category is moving to in.relation.to

By Max in JBoss Tools and devstudio

In the future i’ll put my blogs about JBoss Tools/Developer Studio and related at in.relation.to.

First entry is already there, an updated version of “Making Eclipse look good under Linux”, see it here.

November 29, 2007 0

JBoss Tools & Developer Studio at JavaPolis

By Max in JBoss Tools and devstudio

JavaPolis is getting near and this year I’ll finally have time to go to it – yay!

If you want to hear about JBoss Tools and Developer Studio (or just meet up and try out the belgium beer) then come meet me in the JBoss/Red Hat booth or catch me listening in on some of the presentations that are related to the tooling:

Seam In Action with Pete Muir et.al.

Intro to Richfaces and JBoss JSFUnit with Stan Silvert.

See you there.

November 15, 2007 3

Jing – the best tool for reporting bugs for any UI!

By Max in Java

Jing is a tool for grabbing screenshots and screencasts on Windows and Mac.

That does not sound so new and exiting until you actually try and use Jing.

They made it so easy to do the screenshot and screencasts that everybody can do it without spending any more time than it takes to actually do the act you want to record.

Furthermore they provide a one-click sharing facility so the only thing you have to do is to paste the automatic generated url into your favorite products issue tracker to be able to let everyone see what the bug is about.

Jinq does not have many editing facilities so you can’t fix any stupid mistakes you did for e.g. a demonstration (I currently use Wink for that), but for quick’n'dirty grabbing a screenshot or recording a screencast nothing gets close to the ease and use of Jing!

I’m definitly going to recommend it to anyone that want to easily show a bug (or a cool thing) in JBoss Tools or JBoss Developer Studio.

Update: I realized I had written jinq instead of jing. That is now fixed ;)

November 14, 2007 0

Red Hat Developer Studio Candidate Release

By Max in JBoss Tools and devstudio

The candidate release of Red Hat Developer Studio is now available over at Red Hat.

The major news in this release is Seam 2 support together with over 300+ fixes and enhancements.

You can read more about those in the New and noteworthy pages.

Below is a small video, demonstrating the quick and easy setup of a Seam project in Red Hat Developer Studio.

November 8, 2007 31

Making Eclipse look good on Linux

By Max in Java

I have been bothered a long time by the “clumsy” look that Eclipse has on my Fedora box compared to how it looks on Windows and Mac.

Eclipse 3.3 running on Windows XP

Windows Sample

Eclipse 3.3 running on Fedora 6 (but looks very similar on other distros)

Windows Sample

Notice that the font size is bigger ( 10 vs 8 ) and that there is alot of extra spacing between elements (The package tree and problem view is much more compact on windows).

I tried changing the GTK themes but the issue prevailed – the themes doesn’t seem to adjust the fonts only the component “look”.

But with some help from my Red Hat friends on our tech-list I got some tips and ended up getting close.

The tweaks

Install Red Hat Liberation fonts which are free/liberated Windows fonts available for any OS and readily available in Fedora’s repositories so they are very easy to install via yum.

After they are installed I ran gnome-font-properties and used the following settings:

Application/Document/Desktop font: Liberation Sans, size 8
Window title font: Liberation Sans Bold, size 10
Fixed with font: Liberation Mono, 10

Font rendering: Best contrast (the others left weird artifacts, but mostly up to taste here I think)

Under details:
Resolution: 99 dpi (to avoid the letters to get too close, need at least 1 px between them ;)
Smoothing: Grayscale

Hinting: Full

Depending on your Eclipse font settings the above will be enough, but if you already have tweaked some settings remember to check your Font settings under Eclipse preferences and verify that you are actually using the System default or the Liberated fonts to get the smoother more compact look.

Eclipse 3.3 with Liberation font + tweaks

Windows Sample

Much better, but unfortunately GTK still thinks it needs to have 1-2 extra pixels between components. If anyone knows any tips on how to reduce that wasted space then please leave a comment ;)

(Now I just need to figure out how to get this more compact look into the distro…;)