Password Protect a Directory in Apache 2

Filed Under (Web Development) by manatarms on 29-12-2008

Tagged Under : ,

For anyone who wants to do this, the steps are as follows:

  • Edit /etc/apach2/sites-available/default
  • Look for the line “AllowOverride” in the section <Directory /var/www>
  • Change the line from “AllowOverride None” to “AllowOverride All”
  • Change to the directory you wish to password protect
  • Create a .htaccess file. The contents of mine is shown below. The only truly important line is AuthUserFile. This parameter should contain the path to the file containing your usernames/passwords. You should be able to figure out what everything else is on your own.
  • Create the .htpasswd file in the directory of your choosing with the following command:
1
sudo htpasswd -c /path/to/.htpasswd username

My .htaccess file:

1
2
3
4
5
6
7
AuthUserFile /var/www/path/to/site/.htpasswd
AuthName "Please Log In"
AuthGroupFile /dev/null
AuthType Basic
<Limit GET POST PUT>
    Require valid-user
<Limit>

My First Moments with Haskell

Filed Under (Development, Parallel / Distributed) by manatarms on 23-12-2008

As of this moment, I have worked through section 4.5.2 of the very well written Yet Another Haskell Tutorial. What have I learned so far?

  1. How to use HUGS and GHC to play with and compile Haskell.
  2. The basics of arithmetic, pairs, tuples, and lists.
  3. The basic built in functions (map, foldr, foldl, etc.)
  4. How to create source files
  5. How Haskell treats types

What impressions do I have this far? Functional programming seems to be a pretty good deal in my eyes. The most appealing aspect is its base in real mathematics. All computer science algorithms are obviously based in some sort of mathematics, but with functional programming it seems that the good kind of mathematics becomes more apparent. This would be the type of mathematics that is translated almost directly to code with no worry about writing loops and other structures to manage your data.  A quick example of this would be the Fibonacci Sequence. Mathematically this looks like this:

X1 = 1
X2 = 1 + X1
Xn = Xn-1 + Xn-2

In Haskell it looks like:

fib 1 = 1;
fib 2 = 1 + fib(1);
fib x = fib(x-2) + fib(x-1);

or

1
2
3
4
fib n =
  if n == 1 || n == 2
    then 1
    else fib (n-1) + fib (n-2)

As you can see above, we have simply translated a recursive mathematical formula almost directly into code! That is powerful! Another functional programming feature used is pattern matching. Notice the fib 1, fib 2, and fib n from the first example? Whenever the code encounters a call to the fib function, it matches the parameter against 1,2, or n in order to determine which function to call. Sweet!

Maybe it’s just me, but the sheer mathiness of Haskell and functional programming makes me giddy! It makes me imagine a world where code is written correctly because it follows mathematics! Now that is exciting.

What’s the next big thing in parallel?

Filed Under (Parallel / Distributed) by on 03-12-2008

Tagged Under : , ,

I’m telling you it’s going to be functional programming. Myself, I am going to begin exploring Haskell, Erlang, and F# and I hope to document all of my little exploits and such here. I’ll learn a bit and share a bit. If I get really ambitious you may also see some F# code pop up here as well.