Posts | Tags | Archive

YouTube subscriptions via RSS

The subscription feature on Youtube allows you to keep up to date with content that people upload to the site.

Since I use an RSS reader for every other blog or site that I follow, why not do the same for YouTube subscriptions?

Update

This method no longer works. The YouTube v2 API (which is what this method was using) was retired on April 20th, 2015.

To work around this, each channel must be subscribed to separately. See the RSS reader section on this support page.

The feed for anyone's subscribed videos is at the URL:

1
http://gdata.youtube.com/feeds/base/users/<userID>/newsubscriptionvideos

Where <userID> is either your YouTube account name or the long string of letters and numbers that can be found on the YouTube advanced settings page.

Try it out, it makes watching episodic content a breeze!

Warning

You'll have to have "Keep all my subscriptions private" unchecked on the YouTube privacy settings page for this to work.

This will allow anyone to access the RSS feed of your subscriptions at the url above.


Dynamic DNS client for Namecheap using bash & cron

In addition to running this website, I also run a home server. For convenience, I point a subdomain of cmetcalfe.ca at it so even though it's connected using a dynamic IP (and actually seems to change fairly frequently), I can get access to it from anywhere.

As a bit of background, the domain for this website is registered and managed through Namecheap. While they do provide a recommended DDNS client for keeping a domain's DNS updated, it only runs on Windows.

Instead, after enabling DDNS for the domain and reading Namecheap's article on using the browser to update DDNS I came up with the following dns-update script.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

# Abort if anything goes wrong (negates the need for error-checking)
set -e

# Uses drill instead of dig
resolve() {
    #dig "$1" @resolver1.opendns.com +short 2> /dev/null
    line=$(drill "$1" @resolver1.opendns.com 2> /dev/null | sed '/;;.*$/d;/^\s*$/d' | grep "$1")
    echo "$line" | head -1 | cut -f5
}

dns=$(resolve <subdomain>.cmetcalfe.ca)
curr=$(resolve myip.opendns.com)
if [ "$dns" != "$curr" ]; then
    if curl -s "https://dynamicdns.park-your-domain.com/update?host=<subdomain>&domain=cmetcalfe.ca&password=<my passkey>" | grep -q "<ErrCount>0</ErrCount>"; then
        echo "Server DNS record updated ($dns -> $curr)"
    else
        echo "Server DNS record update FAILED (tried $dns -> $curr)"
    fi
fi

It basically checks if the IP returned by a DNS query for the subdomain matches the current IP of the server (as reported by an OpenDNS resolver) and if it doesn't, sends a request to update the DNS. The echo commands are there just to output some record of the IP changing. Maybe I'll do some analysis of it at some point.

To run the script every 30 minutes and redirect any output from it to the syslog, the following crontab entry can be used:

1
*/30 * * * * /path/to/dns-update | /usr/bin/logger -t dns-update

With the script automatically running every 30 minutes I can now be confident that my subdomain will always be pointing at my home server whenever I need access to it.

Note

A previous version of this article used curl -sf http://curlmyip.com to find the server's current IP address. However, after curlmyip went down for a few days, I decided to take the advice in this StackExchange answer and use OpenDNS instead.


Remove an application from the cmd-tab switcher on macOS

At work, I use iTerm2 as my main terminal emulator. For quick access, I have it configured to drop down from the top of the screen when F12 is pressed.

Unfortunately, it also shows up in the application switcher, bumping up into the 'last used' position whenever it's activated and getting in the way. Since I already have access to the terminal via F12, there's no need for it to be shown in the application switcher as well.

Changing how an application behaves can be done by editing its Info.plist file. The key LSUIElement (according to the Apple documentation) "Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window."

To set this key, open the application's Info.plist at /Applications/[application name].app/Contents/Info.plist and add <key>LSUIElement</key><true/> after the first <dict> tag. The result should look something like this:

1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LSUIElement</key><true/>
    <!-- The rest of the plist data -->
</dict>
</plist>

Once the LSUIElement key is set to true, relaunch the application to see the changes.

Be warned that not only does this remove the application from the application switcher, it also removes it from the dock and stops it from showing the menu bar on the top of the screen.

© Carey Metcalfe. Built using Pelican. Theme is subtle by Carey Metcalfe. Based on svbhack by Giulio Fidente.