Skip navigation

Tag Archives: code

I wanted to post custom comments to my Facebook page using Facebook’s dialog. You need the Page’s UID to be able to post to it, and there’s no way in the Open Graph protocol to get the ID of a given URL. Here’s how you do it using the Javascript SDK and FQL:

function facebookGetIdForUrl(url, callback) {
    //see http://developers.facebook.com/docs/reference/fql/object_url/
    FB.api(
          {
            method: 'fql.query',
            query: "SELECT id FROM object_url WHERE url = '" + url + "'"
          },
          function(response) {
            callback(response[0].id);
          }
        );
}

facebookGetIdForUrl("http://facebook.com",
     function (id) {

        alert("Facebook ID = " + id);

    });

 

I just installed TextWrangler (the free version of BBEdit), and am SO GLAD to kiss Aquamacs goodbye.

TextWrangler is so great, it even has a built-in diff comparison and merge tool. The REALLY cool thing is that you can use it as an external diff program with Git!

Here’s how (thanks to Jotlab’s post on How to use FileMerge with Git as a Diff Tool on OSX for giving me the idea):

~/git-twdiff.sh:

#!/bin/sh
/usr/bin/twdiff --wait "$2" "$5"

Then, just tell Git to use your script as the external diff editor:

git config --global diff.external ~/git-twdiff.sh

At my office, the ISP blocks all SMTP servers except for theirs… problem is, for some reason my account can’t send email! So I have to end up using webmail (ick), or hack my way around it. It’s very handy to have an SSH server or two lying around. If you do, you can just create an SSH tunnel to your SMTP server, and send your email through that!

I wrote a quick little script to run when you find yourself in this situation: just make sure to run it with admin privileges. Your email client won’t even know the difference!

sudo ./smtp_tunnel.sh

smtp_tunnel.sh:


#!/bin/tcsh

cp /etc/hosts /etc/hostsBackupSMTP
echo "127.0.0.1 [your.smtp.server.com]" >> /etc/hosts
ssh [username]@[your.ssh.server.com] -L 25:[your.smtp.server.com]:25

#restore once the tunnel is broken
cp /etc/hostsBackupSMTP /etc/hosts

Copy Original To… (de-alias).plist
Download this file

I just wrote my first OnMyCommand droplet: “Copy Original To… (de-alias)”. Ever annoyed by the half-working aliases that the OS X Finder makes? Now you can just right-click any alias and copy the original file it points to to any folder! It’s nice because cp -R doesn’t follow aliases like it does symlinks.

You can download OnMyCommand here. It’s an amazing Finder plugin that lets you write your own scripts to run via contextual menu when clicking on files, etc. Finally someone tried to improve that poor excuse for a file manager. I’ve seen DOS apps that were better.