BetterTouchTool and Safari

EDIT: Mountain Lion seemed to have issues with this script, so download new version below or read more here: Safari New Window.

Few days ago I switched to BetterTouchTool from MagicPrefs because (1) MP somehow blocked clicks when MagicMouse was disconnected and I always had to quit the MP. And (2) BTT lets me configure the trackpad too.

BetterTouchTool lets you define tons of gestures for your Macbooks Trackpad, your MagicMouse and your MagicTrackpad. In addition to that it brings lots of new stuff to MacOS like Windows 7 like window snapping, window switchers etc…… Extensive explanation is at the BTT developer’s blog. I wanted to add a gesture (four-finger click) to bring up a new Safari window. BTT had Predefined actions to Open Application/File/Script… or Open URL. First of these unfortunately did not open new window, but instead activated one of the pre-existent windows (which I could do just by clicking the Safari Dock icon). The latter did bring up a new window, but I missed the chance to use Top Sites.

AppleScript to the rescue So I typed four lines in AppleScript and now have an action to pop up new Safari window:

tell application "Safari"
    activate
    make new document
end tell

I saved this as an Application to the /Applications folder just for faster startup and pointed BTT Open Application action to that file. Viola!

 

[maxbutton id=”3″]

 

MTS to MP4 converter

Following my previous post about iMovie and MTS I always had random trouble with my converter failing/hanging with some  MTS files. And when repeated for the same file – no problems. This way I couldn’t just set the converter to work with tens of files and go for a coffee – I always had to look for hangs and stop the process only to restart it again.

And after I had problems with QuickTime refusing to open the new .mov files and iMovie having no sound, I thought it to be prime time to revisit the script.
Read More »

Git reset –merge

Or how to reset a merge commit?

If just after a merge commit you recognized that it was actually “git rebase” that you wanted to do, then your friend is:

git reset –merge 14c1d90c3e

where the target commit is the one preceding the merge.

But when reset is not an option?

But if you found the faulty merge after several other commits (or after pushing to remotes), resetting is not so good idea or won’t work at all. In that case refer to How to Revert Faulty Merge in the HowTo.

FFmpeg steals input

I had a shell wrapper script to convert MTS files with FFmpeg, but somehow, when running on multiple files, only the very first one got converted.

Turns out that FFmpeg swallows the stdin from the bash script when it is run and therefore nothing remains in the stdin for the next iterations. To remedy this, I had to fake input to ffmpeg:

while read movie
do
echo "" | ffmpeg -i "$movie" -vcodec copy -acodec copy "$movie".mov
done

Without the echo command this would’ve ended after first iteration, regardless of the number of files in the input.

BTW, the above command is useful for turning MTS files into MOV files, while preserving the audio-video streams, for software that does not support MTS.

SVN vs Orwell

Not long ago I had to change history in GIT. Now I happened to commit to Subversion a revision, but forgot to limit the files to only relevant to the log entry and thus committed all changed files. Nothing really bad, but the entry was minor, compared to all the changes and I did not want those to go unnoticed in the log. I did not think one can take back files from an already committed revision, so I searched out for a solution to change the log entry. It turns out this is relatively simple, as the Subversion FAQ points out.Read More »

iPhone SDK private API

Today I got my Rivals.app rejected from AppStore because it used private API calls. Fortunately nowadays Apple lists the calls in the reject message to make it easier to remove them. I was unfortunate to be using:

  • addTextFieldWithValue:label:
  • textFieldAtIndex:

For anybody wondering about their app prior to submitting to AppStore here is a collection of popular private APIs:
http://www.drobnik.com/touch/2009/11/forbidden-fruit-apple-apis/