Tag Archives: tricks

How to connect Apple TV to a hotel Wi-Fi network

Whenever my wife and I take an extended vacation I always bring along our Apple TV.

At the end of a long day filled with adventure and fun it’s nice to just snuggle up together and watch your favorite show on Netflix or rent a new release comedy.

I’ve found that hotel television is still so primitive and annoying. The on-demand movie rentals are limited and very pricey, the regular programming is usually in standard definition, and you’re forced to channel surf without a guide. Ain’t nobody got time for that!

When I book a hotel I always make sure there is free Wi-Fi and that they say there are “flat screens” in every room, this tells me that there must be an HDMI input on it somewhere.

Ah, but my Apple TV doesn’t have a browser! So when the hotel Wi-Fi splash screen pops up asking for confirmation that I “Agree to their terms of use” or to enter some sort of special login, I can’t.

It seems we’re left with no choice but to do some friendly hacking to circumvent this annoying speed bump! :-)

How It Works

This is a little networking 101 here, but I’ll explain it briefly in case you are really a beginner.

Every device that connects to the Internet has a unique mac address, or media access control address. It’s basically a serial number for your hardware and it tells the network who you are.

No, it has nothing to do with “Mac” computers built by Apple. If you’re still unsure what I’m talking about, please go and read this article first.

The hotel network works by validating your mac address and putting it on a whitelist so it can connect automatically in the near future.

The only problem is, you need a browser to do this, and Apple TV doesn’t come with a browser (so far).

How We’re Going to Get Around It

So here’s what we’re going to do.

First, we’re going to trick the hotel network to think that our Apple TV’s mac address is actually our computer’s mac address.

Then, we will use our computer to complete the browser authentication/checkbox/button/whatever they need so this address can be whitelisted.

Finally, we will change the mac address on our computer back to the original, and then reconnect both our computer and the Apple TV back onto the network.

Spoofing Your Mac Address

Note: These steps assume you are using OS X, sorry PC folks.

  1. Disconnect your computer and Apple TV from the hotel Wi-Fi.

  2. Open up your Terminal

  3. Get your current mac address using: ifconfig en1 | grep ether

  4. It will look something like this: 03:a1:04:d5:00:12. Save it somewhere safe, we’ll need it again later.

  5. Write down your Apple TV’s mac address, which you can find under Settings > General > Network > Wi-Fi Address

  6. Now we will spoof our computer’s mac address to be the one we just wrote down from Apple TV: sudo ifconfig en1 ether 28:cf:xx:xx:xx:xx

  7. Sanity check that our mac address has indeed changed: ifconfig en1 | grep ether

  8. Connect your computer to the Wi-Fi, open a browser window and complete whatever authentication it needs to connect.

  9. Disconnect your computer from the Wi-Fi.

  10. Repeat steps 6 & 7 to change your computer’s mac address back to the original one we saved in step 4.

  11. Reconnect both your computer and Apple TV to the hotel Wi-Fi.

And we’re in business!

Most networks will keep this mac address whitelisted for 24 hours or so. After it expires you’ll need to do this whole process again.

This may not be perfect for every situation, but it’s always worked for me. If it helped you, please leave me a comment!

Add prefixes to WordPress post types when a theme is activated

Recently, I had a real problem on my hands.

I had neglected to prefix the post type names in some of my themes, and as it turns out, so did another popular WordPress plugin. Long story short: this plugin became unusable when running my themes, and this did not make my users very happy.

It became clear that I needed to bust out some ninja moves to overcome this dilema.

The code below is the solution I drafted – maybe it will help you too. It’s a function that runs when the theme is in use, and rewrites the post type names in the database with any prefix you choose.

After the theme is activated the specified post types will be renamed to: fjarrett_acme, fjarrett_foo and fjarrett_bar.

Sadly, there is not yet a hook that will fire only when themes are activated/updated. The after_setup_theme action is a little misleading in that it fires when WordPress sets up the current theme, not when an admin activates and/or updates the current theme.

So, it’s basically firing with every load of WordPress when the theme is active. Someone first made a patch for this 3 years ago and it looks like it’s finally being revisited.

For that reason, this is by no means the most resource-friendly solution, but we are killing the script if the prefixed post type already exists – which requires an additional query – but this is crucial for two reasons:

  1. So we’re not attempting to update the database with every page load – after the original post types are given prefixes the database update will never run again.
  2. So other plugins/themes (like the one I was in conflict with) can be installed later, creating their blasphemous post type names, and we won’t attempt to rewrite them.

Hopefully this is helpful to you and your project in some way. If so, please tell me about it the comments!

How to hide your WordPress version number…completely

Did you know that your WordPress version number is visible to everyone?

As Matt Mullenweg rightly pointed out several years ago, simply hiding your WordPress version number is not enough by itself to stay protected from potential threats (you should always be keeping your WordPress installation up-to-date).

But perhaps you have a client who has specifically requested its removal or maybe you just like keeping things on the safe side, either way there are a lot of tutorials out there on how to remove it from various areas but none that I’ve found showing how to remove it from every area at the same time.

The WordPress version number appears in three areas:

1. Generator Meta Tag in the Header

<meta name="generator" content="WordPress 3.3.2" />

2. Generator Tag in RSS Feeds

<generator>http://wordpress.org/?v=3.3.2</generator>

3. Query Strings on Scripts & Styles

If a script or style does not specify a version number when enqueued, the current version of WordPress is used.

foo.js?ver=3.3.2

One Block of Code to Rule Them All

Just enter this into your functions.php file and your WordPress version will be safely hidden from the public.

However, there is one small caveat to be aware of when using this method: This function will check to see if the ver query string matches the WordPress version number, so if the version of the enqueued script happens to be the exact same as the WordPress version then its version string will be removed as well.

This will occur rarely (if ever), especially when the current WordPress version is a point release, such as 3.3.2.

The simplest way to require/include wp-load.php

If you want to use WordPress functionality in a PHP file that exists outside of your WordPress installation then you need to include wp-load.php. Perhaps you could call this “hooking into WordPress”.

Maybe you’re already using some sort of relative path method, like:

<?php include '../../../wp-load.php'; ?>

But this can create problems if directories change. You need a clean, dynamic way to get wp-load.php. So here is the simplest way to do it, with just two lines of code (place it at the very top of your file):

1
2
3
4
5
6
<?php
 
$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );
 
?>

Short and sweet :)

Disclaimer: This is intended for experimental and development purposes only. It is not advised to redundantly load WordPress on live production environments. But, why?