Humorous Videos
September 5th, 2010Things I can’t remember – HTML and CSS
August 31st, 2010I just stumbled upon this selector:
.preserveWS {
white-space: pre;
}
It lets you put spaces in text!
How stupid can you get?
August 27th, 2010Plenty.
A recent article in Flying on fuel management for aircraft stated that “Of course someone who believes air in a fuel tank can be magically turned into avgas probably believes in angels too.” Of course that brought out the nutjobs who were offended that Tom would insult them for believing in angels and unicorns.
James R. Miller even got his letter printed in the next edition. He was even willing to state publicly that “I’ve been flying for 60 years and have resorted to my guardian angel more than once in tight situations…”
James, if you think there are angels next to you in the skies helping you fly your airplane, I think it’s time to stop flying. You’re putting all of us at risk.
Things I Can’t Remember – PHP Cookies
August 24th, 2010This is a simple example of setting a cookie and then using it to display a different splash page each time someone visits the site.
PHP cookies are described at the PHP manual site. Two things to remember about PHP cookies. They must be set before any <html> or <head> tags. And they are read before the page is loaded—so you can’t read the cookie value the first time someone visits your site.
I put the following code into the definitions section of my header. I like to use variables for each of the parameters so that it’s easier to see what I’m changing. $c_name is the name of the cookie. Once it is set it can be accessed from any page on the site. $c_time is expiration time in seconds. In this case 30 days.
$c_path = ”; and $c_domain = ”; mean that this cookie is available everywhere on the site. This cookie doesn’t contain any sensitive information, it’s just a counter, so I don’t need to use https for transmitting and retrieving it. Setting $c_httponly to ‘true’ makes the cookie inaccessible to scripting languages and guards against XSS attacks.
The if statement checks to see if the cookie is already set. If not, it sets the value of $_COOKIE["spalsh_page"] to 0. Then it uses the parameters to set the cookie.
If there is a cookie already set, then I read the value, add one to it and update the cookie.
$c_name = "splash_page";
$c_time = time()+60*60*24*30;
$c_path = '';
$c_domain = '';
$c_secure = 'false';
$c_httponly = 'true';
if( !isset($_COOKIE[$c_name]) ) {
$_COOKIE[$c_name] = 0;
setcookie($c_name,0,$c_time, $c_path,$c_domain,$secure, $c_httponly);
} else {
$c_value = $_COOKIE[$c_name] + 1;
setcookie($c_name,$c_value,$c_time,$c_path,$c_domain,$secure,$c_httponly);
}
Next I’m going to access the counter and decide which page to display. $splashPage is an array of pages to include. The if statement checks to see if there is a cookie set. Cookie values start at 0 and go on forever. I use the modulus operator % to restrict the value of $whichPage to a value between 0 and $numPages. The require statement just looks in the array and serves up the appropriate page.
$splashPage = array (
"Deceiving",
"WellGolly",
"Combos",
"SlipIntoView",
"Checklists",
"Coartic",
"Crossword",
"Artic",
);
$numPages = count($mainPage);
if (isset($_COOKIE['splash_page'])) {
$whichPage = $_COOKIE['splash_page'] % $numPages;
} else {
$whichPage = rand(0,$numPages);
}
require_once("./splashPage/$splashPage[$whichPage].inc");
Things I Can’t Remember – REGEX
August 20th, 2010When using BBEdit I often want to see just the first part of a line. This REGEX expression has two parts. The first part looks for the first 75 characters and the second part looks for all the rest. Then I just replace the found string with the first part.
Search String: ^(.{75})(.*)
Replacement String: \1
The ^ says to start at the beginning of the line ($ is for the end). Then there are two patterns to look for. Each pattern is enclosed in parentheses. The first pattern looks for any single character (the dot). The number in between the braces {} says to look for the previous pattern 75 times. The second pattern looks for any single character repeated any number of times.
The replacement string is just the first pattern i.e. the first 75 characters of each line.
Spell Checker
August 2nd, 2010I halve a spelling checker,
It came with my pea see.
It plainly marks four my revue
Mistakes I dew knot sea.
Eye strike a key and type a word
And weight four it two say
Weather eye am wrong oar write
It shows me strait aweigh.
As soon as a mist ache is maid
It nose bee fore two long
And eye can put the era rite
Its rarely ever wrong.
I’ve scent this massage threw it,
And I’m shore your pleased too no
Its letter prefect in every weigh;
My checker tolled me sew.
Inserting special characters
July 28th, 2010When programming in Java, you can insert special characters by escaping their unicode values:
“ \u201C
” \u201D
Ʊ \u01B1
ǝ \u01DD
ɚ \u025A
What Were They Thinking – Summer 2010
June 25th, 2010I’d be curious to see what people on our streets answer.
What does a video showing how to transfer a woman have in common with a famous boxer?

My guess is that they mentioned the Hoya lift and that YouTube’s text to speech translators converted it to Hoya, and the only Hoya’s they could find were Oscar and Georgetown.
Mmmm… Tastes Like Chicken!
Visitors
June 25th, 2010Wandering around the yard on a rainy spring day.

Definitely not happy about having a predator near the nest.
Well Golly
Learn to Fly
Gas prices are way down so now is the time to get up in the air. This economical trainer is so easy to fly you'll be out on your own in no time!
Buy from Powell's.
Buy from Barnes & Noble.
Buy from Powell's.
Buy from Barnes & Noble.
Buy from Powell's.
Buy from Barnes & Noble.



