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.

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.

  • Live comments - When you comment on a post, it instantly send the comment out, and anyone viewing the post is shown the new comment.  The text box immediately lets you write another comment, allowing a live, ongoing conversation.
  • Mobile Access - The Xusix layout has recently been redesigned from the ground up, and although it looks exactly the same on a desktop browser, it now optimizes automatically for netbooks, tablets, and mobile devices.
  • Direct Notifications - Users can now customize their notification preferences, with support for informing them of activity on their page through both email and text message, direct to all major U.S. carriers.
  • Photo support - Xusix now allows uploading an unlimited number of photos, and each supports a caption and its own live comment stream.  The entire photo gallery system is optimized to fit all screen sizes, from a Mac Cinema Display to an iPod touch.
  • Privacy Configuration - Control what groups can see basic information about you, and mark posts as private to only display them to people you follow.

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.