Getting a domain with a ccTLD that is restricted to residents

Getting a domain with a ccTLD that is restricted to residents

A ccTLD is a top-level domain that uses a two letter country code. These domains are often reserved for residents and businesses in the country they serve. For example, you can’t get a .br domain unless you live in or have a business in Brazil.

But what if your company is based in the United States and you want to target residents of another country? Or what if you want a vanity domain that uses a restricted ccTLD?

The solution is to use a trustee service. The trustee maintains a legal presence in the ccTLD’s country, and registers the domain on your behalf. Your contract with the trustee maintains your legal rights to the domain even though the whois will show the trustee as the registrant. This allows you to fulfill the requirements of the ccTLD local presence rules.

I use 101domain. There website is awful but they have just about any ccTLD you could possibly want.

The Ring of ccTLDs #2 by Grey Hargreaves used under the CC BY 2.0 license.

Read More

Getting browserconfig.xml out of your error logs

Getting browserconfig.xml out of your error logs

I’ve noticed a spike in 404s on several of my sites for browserconfig.xml. Turns out Windows 8.1 looks for this file automatically when a site is pinned to the start screen.

This file allows you to define several things, including graphics to use for various size tiles and also an RSS URL so you can update your readers when you have new content. Pretty neat. I doubt other browsers or OSs will pick up on it, but if you are noticing 404s for it in your logs, it may be worth the effort to throw a browserconfig.xml file together.

Microsoft conveniently provides a tool for doing this. It allows you to do the basics and will even resize your images for you. They also provide in-depth documentation on the file format in case you want to get more advanced.

I’m in the process of rolling this out to my sites, so no idea yet on whether the notifications will actually drive traffic, but it is so easy to set up that it is worth the initial effort.

Read More

A better CSS reset stylesheet

A better CSS reset stylesheet

If you aren’t a web developer then you may not know this, but browsers are a mess. Every browser picks and chooses how it wants to render the same HTML. For examples, some browsers don’t have any default margin on the body. Some do, but with varying amounts of margin. Internet Explorer is of course the worst offender, and there are many versions of Internet Explorer still widely used.

To get around these issues, web developers typically use what is commonly called a reset stylesheet. This CSS file resets all of the default styles for all the possible HTML elements, so that you have a blank slate to start with. They’re a bit of a pain to use because they require the web developer to then define what they want the styles to be for everything. For example, they typically wipe out padding and margins on all elements, so you have to set padding and margins on all elements if you don’t want them squished together.

Fortunately some smart people created something even better than a reset stylesheet: normalize.css. Instead of resetting all the default styles, normalize.css selectively sets reasonable styles only for the elements that need it. It keeps all the default styles that are already in use by the majority of browsers. You can get it for free here.

Read More

git: Ignoring files during development

git: Ignoring files during development

I use git a lot, and often find myself needing to make changes to a file that I absolutely don’t want to commit to the repo. For example, a default configuration file may be in the repo, but I want to change which database it is pointing to during development. Or maybe I’ll gut a CPU intensive method during preliminary testing, but I obviously don’t want the gutting method committed back to the repo.

Sure, I could stash these changes before and after every commit, but that can be a real hassle. What I like to do instead is use the assume unchanged feature.

To tell git to assume a file is unchanged, use this command:

git update-index --assume-unchanged 

To undo this, use this command:

git update-index --no-assume-unchanged 

A file that has been marked as assume unchanged won’t show up when you run git status. It won’t be added to a commit when you run git add -a. Pretty awesome.

If you need to figure out which files have been marked as assume unchanged, you can use this command:

git ls-files -v | grep "^[[:lower:]]"

The ls-files list with the -v option will show every file and its status, with lowercase letters for the status of assume unchanged files. The grep command will only show files that have that lowercase letter.

Read More

Block all AWS traffic to a server

Block all AWS traffic to a server

AWS servers are cheap and plentiful. Unfortunately this makes them the frequent source of screen scrapers. My servers aren’t running on AWS, and there isn’t any legitimate reason for an AWS server to be talking to my servers, so I decided to just block all AWS traffic.

You can get my AWS Blocker bash script on GitHub. It is free and public domain.

Amazon publishes a list of AWS IP ranges in JSON format. The bash script uses curl to download this file, then jq to parse it. It then adds each range to iptables, rejecting any connections made from an AWS IP.

The script is safe to run as many times as you want. It only takes a few seconds to run. The AWS rules are put in their own chain, and the chain is flushed before running. I’d recommend running the script as a cron.

Read More

Use BFG to completely remove a file from your git repo

Use BFG to completely remove a file from your git repo

I like to keep my blogs in git repos. For small blogs this works great, but for blogs with a ton of images this quickly becomes a problem. For example, my wife’s blog has 4GB of images. git isn’t really designed to handle that.

So I decided to take out the images. Specifically, I decided to exclude wp-content/uploads from her git repo. Just removing the images isn’t good enough, because they are saved in the history of the repo. For a quick and easy way to remove one or more files completely from git, use BFG.

These are the steps I took:

  1. Create a backup of my clone that has all the images in it. Always have a backup when doing something like this.
  2. Remove the files from git without deleting them locally: git rm -r –cached wp-content/uploads
  3. Add wp-content/uploads to my .gitignore
  4. Commit and push the changes.
  5. Download BFG. It is a jar so you’ll need java installed, too.
  6. For convenience, I created an alias in my .bashrc file: alias bfg=’java -jar /root/bfg-1.11.10.jar’
  7. Clone a bare repo: git clone –mirror git://example.com/some-big-repo.git
  8. Remove references to the images in the repo history: bfg –delete-folders uploads some-big-repo.git
  9. Purge the old files from the repo: git reflog expire –expire=now –all && git gc –prune=now –aggressive
  10. Push your changes into the remote repo: git push

The last step is to clone a fresh copy of the repo. You’ve modified the history of the repo, so you shouldn’t use any existing clones. Be careful not to lose your images! They aren’t in git anymore!

It is important to note that in step #8 you cannot use a full folder path. It won’t let you even if you try. So if you have something else called uploads or with uploads in the path that you’ve previously deleted, it’ll be wiped out, too.

It is also important to note that step #8 won’t do anything if you skip step #2. BFG makes the assumption that you don’t want to get rid of anything that is in your latest commit.

This also works great for removing sensitive information from a repo, for example if you commit a password to a public repo. BFG even lets you search and replace text, so you can simply replace an accidentally committed password with something else instead of deleting the files.

Read More