Microwave (n) A hand gesture used by a midget to greet others.

Hey, that midget over there just gave me a microwave.

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.)domain2.com to /domain2/.


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

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain2.com$
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="prosecure.tk" enabled="true">
                    <match url=".*" />
                        <add input="{HTTP_HOST}" pattern="^(www.)?domain2.com" />
                        <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:

Beat in:

Stir in with mixer on low speed:

Stir in with wooden spoon:

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.

No SMTP with GoDaddy

As the first letter in the acronym SMTP stands for simple, that’s what I was expecting when I decided to use the Google Apps SMTP server to send out notifications for Xusix. In the end, after three days of repeatedly rewriting the mailer functions, I discovered the reason nothing was sending.  GoDaddy shared hosting doesn’t allow SMTP connections. At all. They simply block anything that appears to be sent through that protocol, or uses a common SMTP port, leaving me to the only remaining option: using GoDaddy’s own mailer. The problem with this is that their spam filter is so aggressive, few messages ever make it through. And so, notifications on Xusix, although programmatically work, will likely never reach an inbox.

Xusix Updates

Our social network Xusix has been under development for quite a while now, and we’d like to introduce some of the neat things we’ve added in recent times.

All of these, and many other features are now available for free on Xusix. Sign up today!

For those interested in the technical side of the site, see xusix.com/current.php to list all of the in-depth statistics on our internal systems.

A new twist

About a month ago, I was working on a simple code project for school in some free time. It’s a web site that takes simple phrases and makes a song out of them, based on the 99 bottles of beer song.  I rediscovered the fun little script today, and you can see my song here. When you write a song with it, the URL that shows the song will always show your song, so you can send that link around to share it with anyone!

Local Fitness and Health

These links are dead now. I may or may not have the code for them somewhere, but so far I haven’t found any of it.

Billings Montana has a new place to go for health and fitness information! Inspired by the Let’s Move! Campaign by Michelle Obama, this new set of web sites helps you find up-to-date facts and resources for child obesity and general health at a local setting. Find local events and activities that you can participate in as well as local fitness centers and stores to provide what you need to get and stay healthy. Nutrition and exercise information is provided as well, and with the new Health Tracker system, you can keep track of your health easily online and on your mobile phone. This new great web service is developed specifically for residents of Billings, Montana, but works great for people anywhere!

Let’s Move Billings developed by Alan Hardman, Michael Siebert, and Tucker Downs.