Got it Back

I finally got my blog back online again, after a three-day struggle with a virus that keeps coming back. I feel like GoDaddy had to be at fault the last time, I had nothing but a fully-secured WordPress 3.5 on the server. To my knowledge, recent releases of WordPress are incredibly secure…

Connecting a Domain to a Subdirectory

Update: nginx is better. Shared hosting is terrible. Use DigitalOcean. :)

If you want to host multiple websites on one hosting server, especially if it’s a cheap shared server, knowing some basic URL rewriting is essential. This is how I’m running mine, on both my Apache and Microsoft IIS 7 servers.

The examples below direct (www.) to /domain2/.


Within the file .htaccess in your server’s root directory, include the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/domain2/
RewriteRule ^(.*)$ domain2/$1 [L]

Microsoft IIS 7

Within the file web.config in your server’s root directory, include the following:

<?xml version="1.0" encoding="utf-8" ?>
                <rule name="" enabled="true">
                    <match url=".*" />
                        <add input="{HTTP_HOST}" pattern="^(www.)?" />
                        <add input="{PATH_INFO}" pattern="^/domain2/" negate="true" />
                    <action type="Rewrite" url="domain2{R:0}" />
            <requestFiltering allowDoubleEscaping="true" />

CSS Shorthand

Learning CSS shorthand can save time and keep your stylesheets cleaner and simpler.  There are several ways to write the same styles, some more efficient than others.  For example, padding can be declared for each side like this:

padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;

Or, you can condense each of the sides into a single line:

padding: 5px;

This works great if you want the padding to be equal on each side, but if that’s not the case, you can follow this format:

padding: [top] [right] [bottom] [left];

Say we want the padding to be 5px on the top and bottom, and 3px on each side:

padding: 5px 3px 5px 3px;

This can still be further condensed, setting the top and bottom together, and both sides together, like this:

padding: [top/bottom] [sides];
padding: 5px 3px;

If you need to specify the top and bottom separately, but keep the sides the same, you can use this format:

padding: [top] [sides] [bottom];

This shorthand format works with border, padding, and margin. The easiest way to remember the order is that the list of units goes clockwise from the top.

Approximating the Area beneath a Curve Programmatically

Given any function in the slope-intercept form, whether linear or non-linear, the area between the curve and the x-axis between two points can be easily approximated with the Riemann Sum using a For loop.

This is a simple pseudo-code example, where Y1 is the function and Y1(I) is the value of Y1 at X = I:

N = 0
For (I, Left Limit, Right Limit, Step Interval)
    N = Y1(I) + N
Display N

To determine the step interval, use this:

Step Interval = (Right Limit - Left Limit) / Number of Steps

To improve accuracy, there are multiple ways of using this approximation, which distinguish between which end of each step to use.  To adjust the limits and intervals for the desired method, use this code:

If LRAM (using left end)
    Right Limit = Right Limit - Step Interval
End If
If MRAM (using middle of step, often most accurate)
    Left Limit = Left Limit + (Step Intverval / 2)
    Right Limit = Right Limit - (Step Intverval / 2)
End If
If RRAM (using right end)
    Left Limit = Left Limit + Step Interval
End If

For anyone wishing to have a complete program for a TI-83 or TI-84 calculator, use my Riemann Sum Program (dead link).

Please note that this is an approximation. You can find exact answers using integrals.

Chocolate Chip Cookies

Preheat Oven to 375°

Cream together:

  • ⅓ cup shortening
  • ⅓ cup butter
  • ½ cup sugar
  • ½ cup brown sugar

Beat in:

  • 1 egg
  • 1 tsp. vanilla

Stir in with mixer on low speed:

  • ½ tsp. baking soda
  • ½ tsp. salf
  • 1 ½ cup flour

Stir in with wooden spoon:

  • ½ cup chocolate chips

Drop by rounded teaspoons onto ungreased cookie sheet.

Bake 8-10 minutes or until cookies are light brown.

Remove from oven and let cool slightly on a cooling rack.