Aaron M. Wright

17Mar/120

Wright’s Law Of Desktop Space

I wish to coin a new law. It is called Wright's Law Of Desktop Space. It states that as the size of a computer moniter increases, the number of open windows will likewise increase to fill the available space, thereby preventing any moniter from ever having enough viewing space.

Tagged as: No Comments
18Dec/112

Prevent The SOPA Bill

I have some scary news. There is currently a bill in Congress called SOPA that would give corporations far-reaching power to censor websites without due process. If any user posts copyrighted content on a site, this bill would allow the entire site to be shut down. If even one user posts a copyrighted image to Facebook, Facebook itself could be shut down. If even one video on YouTube uses copyrighted music, the copyright owner could have YouTube blocked.

This is bad news. With the economy being so bad in the US and the severe job shortage, the last hope for many people is starting a business. Business startups are also a driving force of innovation in this country. But the SOPA bill will make it more difficult for startups to launch, and innovation will be squashed. This is not an exaggeration. As the video below explains, many venture capitalists have said they would cut funding to many startups if this bill passes, effectively putting new startups at a standstill.

The SOPA bill would effectively censor the Internet in much the same way as China or Iran is able to censor the Internet. Even worse, that power of censorship would be in the hands of large corporations whose sole interest is profits, not the rights and freedoms of the people. This bill would take away free speech and block access to information in favor of corporate profits.

If Congress wants to get the US out of recession and back on the track to strong growth, this bill a disaster, and must be stopped. The video below has an excellent description of the SOPA bill.

So what can you do to stop this bill from being passed?

1. Watch the video above to get a better understanding of SOPA and how it would work.

2. Go to http://tinyurl.com/writetocongress and send an email to your representative in Congress.

3. Call your Congressman and express your concerns. A phone call will have far more impact than an email, so be sure to do both.

This bill must be stopped. The rights of citizens are at stake, and it will pass if we don't do something.

5Nov/110

Server Fix: .htaccess File Not Being Read

I was working on installing security certificates for a site I'm building now, and wanted to set up mod_rewrite to redirect users to https rather than regular http so they are forced to use a secure connection. This is a common use of mod_rewrite. The problem was that it was not working. I would put the rewrite rules into my virtual host declaration and it worked, but when I put them into a .htaccess file, they did not work. So my rewrite rules and conditions must have been fine, and I narrowed it down to the .htaccess file. (Actually, putting rewrite rules in the virtual host config is better anyway. This page explains why. But now I was curious to see why it was working one way and not the other, so this was more of an experiment than an actual fix.)

So I learned a great little trick to make sure your .htaccess file is being read, and it is so simple it's brilliant; simply put some garbage into the .htaccess file and try to create an error. If it creates an error, this tells you that your .htaccess file is being read, and that the problem lies somewhere else. So for an example, lets say my .htaccess file looks like this:

RewriteEngine On
RewriteCond %{HTTPS}  off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This is a standard use of mod_rewrite, which checks to see if HTTPS is turned on. If HTTPS is off, it redirects the user to the HTTPS version of the page. Simple enough. But it would not work from the .htaccess, so I added in my garbage to look like this:

RewriteEngine On
This is a bunch of garbage blah blah rabble
RewriteCond %{HTTPS}  on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

If the .htaccess file is being read, this should result in a "500: Internal Server Error" message. It did not, so that pointed me in the right direction to fix it.

Oh, and in case you found this page because you are having the same problem, in my case I had to tweak the virtual host configuration to set AllowOverrides to All. I restarted Apache, reloaded the page, and Boom! I got a 500 Server Error. Problem solved!

Another note: I had a previous issue with AllowOverrides and wrote up a solution here. It was in the context of using WordPress, but still applies, because the issue was with Apache itself. If you need more info about mod_rewrite, you might want to check that out.

-Aaron

30Sep/110

Adding Items To Navigation Menu – WordPress TwentyEleven Theme

Here is something that threw me off today. I was working on a blog using WordPress, and for this blog I decided to stick with the default theme and customize that, rather than installing a pre-built theme. The default theme is called TwentyEleven, and might look familiar to anyone who has played with wordpress. The issue I had was adding new items to the navigation menu, which only has a "Home" link by default. After poking around on the dashboard and not finding anything helpful, I went to the WordPress Codex and started exploring the code relating to the nav menu. It turns out, editing the nav menu is deceptively simple.

On the WordPress admin dashboard, if you click under Appearance -> Menus, you are taken to a page that should theoretically list the menus you have available to you-- or so you would think. But the first thing you notice is that it says nothing about a Nav Menu. What gives?

The solution is to simply create a new menu, and when WordPress loads, it will use this new menu, along with any links you want, and override the default navigation menu. To do that, follow these steps:

1. Go to the "Menus" page

I assume you are logged in to your admin control panel. Click Appearance -> Menus to get to the "Menus" page. As I stated earlier, you will notice that there are currently no menus available (unless you have already made some of your own). Don't worry about that, because we will make our own.

2. Create a menu called "navigation"

In the box that says "Menu Name", enter "navigation" (without the quotes). Click "Create Menu".

3. Choose "navigation" as your primary menu

Along the left side of the page, you will see a box called "Theme Locations", along with a drop down box called "Primary Menu". That drop down box should contain your new menu called "navigation". Select that and click "Save".

4. Add some links

If you go to your blog now and reload the page, you will notice that the navigation menu disappears entirely now. Thats normal, because we have no links yet, so WordPress does not display the menu at all. Go back to the "Menus" page on your admin panel, and add some links. For now, just pick any site and add it to the "Custom Links" box. Now click "Add to menu", and click "Save Menu". Now, if you go back to your site and reload the page again, the menu should re-appear with the new link you added. You did it!

From here, just add links to whatever you want, including custom links, Pages on your blog, or Categories on your blog.

As you can see, once you know how to do it, adding links is very easy. The trouble I had was because the interface within WordPress itself wasn't very intuitive, because the menu that was there on the page wasn't in my list of menus. Hopefully this tutorial will save you some time.

As always, if you need help, leave a comment.

-Aaron

3Sep/110

The Power Of The Command Line

In our modern world, the vast majority of computer users rely on the graphical user interface for their day-to-day computer use. If you mention the command line, most people give you a blank stare like you are stuck in the 1980's or something. But as most Linux users know, there is still power in learning the command line. A little scenario I had today proves it.

I was looking around for some recordings to learn Italian, when I came across the Radio Lingua Network My Daily Phrase recordings (these are a great series by the way). Each recording had a link to download that episode, but I wanted all of them so I could listen to them in my car on my mp3 player. One option would have been to go through all 100 episodes, click "Download episode", then click through and save it to my computer, then back out the starting page and do it again for the next episode. That would have been a pain in the ass.

My solution? I just wrote a script to do it all for me. I left clicked on the download link and clicked "Copy download location". This copies the URL of the mp3 file itself and its location on the server. I noticed that they were all in the same directory, and labeled in order. So all I had to do was hack together a short script that goes through the numbers 1 to 100 and add the episode number onto the end of the URL. Then that URL was plugged in to the wget command to download the mp3 file to my hard drive.

In fact, Linux has a command called sleep, which makes it wait a set amount of time before completing a command. This let me add in a little line of code to wait 30 seconds before downloading the next file. That way I let one download completely before moving on to the next one so I don't put too much stress on their servers. (See footnote).

Now, instead of going through 100 episodes and spending all day downloading files, the script took me all of 4 minutes to write (it was less than 20 lines of code). Now I can just let that go automatically while I eat some lunch.

And that is the power of the command line.

Edit (09/17/2011): As for the sleep command being used to avoid stress on the servers- I was reading about wget today, and it turns out wget has similar features built right in. The first is an option called wait, and looks like this:

wget -r --wait=10 http://example.com

The number is in seconds, so --wait=10 means wait 10 seconds before fetching the next file. Another option is to use --limit-rate=amount like this:

wget -r --limit-rate=10k http://example.com

This will limit the bandwidth to 10kb/second. These two options would have been a more elegant solution than the sleep command, but they all work.

Check out this link for more info about wget: http://www.gnu.org/software/wget/manual/wget.html

Filed under: Computers No Comments
27Jul/112

How To Fix a 404 Error When Using Permalinks In Wordress

I just installed WordPress on a new domain for a new site I am working on at SmashMoney.com, and had some trouble with permalinks working properly. When using the default link format in WordPress, the links on my blog worked fine. However, when I enabled permalinks, the links to my posts and pages all stopped working and resulted in a 404 Page Not Found error. I had the exact problem with this blog when I set it up, but forgot how to fix it. Then I re-learned it for the new blog, so I wanted to share it here so it is documented once and for all. So here is how to fix it:

Server Specs

These instructions are based on my server running

  • WordPress 3.2.1
  • Debian Lenny as my OS
  • PHP5
  • Apache2

It may change a bit based on your own setup.

1. Make sure mod_rewrite is up and running

Permalinks in WordPress apparently use the mod_rewrite module within Apache, so you need to enable that. It is most likely installed by default if you installed apache from the repositories, so now just enable it with this command:

sudo a2enmod rewrite

2. Enable overrides in Apache

On my server, overrides are blocked by default, so I had to manually enable that as well. To do that follow these steps:

1. Navigate to /etc/apache2/sites-available/<virtual host filename> where <virtual host filename> refers to the name of the file that defines your virtual host.

2. Open that file in a text editor and look for this line:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
allow from all

</Directory>

Now change that line so it reads:

AllowOverride All
Order allow, deny

3. Save your changes and close the text file.

3. Restart Apache

Now the only thing left to do is restart Apache. Run the following command:

sudo /etc/init.d/apache2 restart

4. Test It Out

If you haven't already done so, go into WordPress and change permalinks to whichever format you prefer. Remember to save your changes. Now reload the page you were on and the links should be working!

That's all there is to it. If you need help, leave a comment.

-Aaron

Filed under: Computers 2 Comments