I got my first motorbike, a Honda CBR250RR about two months ago. I thought I’d compile this list of 5 things that non-bike riders probably don’t know about motorbikes.
- When riding a motorbike, you get covered in bugs
This obviously varies from place to place, in some areas you might face onslaughts of mosquitoes, flies or butterflies, whereas other parts of the world are relatively insect free. After riding 2,000 kilometers over 2 months, I have bugs spattered here and there on my riding gear, particurlarly on my helmet visor… imagine what is like for riders wearing open face helmets!
- Motorbikes are not just noisy for the sake of it
You might think that motorbikes are built intentionally just to annoy you in the early hours of the morning while your trying to sleep, but you would be ill-informed. Unlike the often aesthetic “phat” exhausts that have recently entered widespread car culture, the reason why motorbikes are generally loud, is two fold -
a) because they are built for performance - smaller exhausts reduce performance
b) so people in cars with blaring stereos can hear them!
- Car Drivers are known as “Cagers” in motorbike circles
The meaning is literally driving in a cage. That is, car drivers have a feeling of being in a secure haven while driving there “cage” around town, and as such sometimes neglect to consider other road users, particularly *cough* motorbikes *cough*. I suspect the second meaning is that being on a motorbike means being free with the elements, without the luxuries of windows, air conditioning and doors.
- There is virtually a science to riding in traffic
Driving a car is easy in comparison - you sit in your lane, you obey the road rules, and with a bit of luck you’ll never run into serious trouble. In comparison, there is virtually a science to riding a motorbike safely in traffic. Concepts such as lane positioning, watching other vehicles and avoiding oil and other hazards are integral to operating a motorbike on the road.
- Riding a motorbike gives one a unique sense of freedom
The best thing about motorbikes is when riding around, particularly through the bends, it gives one a great sense of freedom. The onus is on the rider to finely deliver throttle, braking and steering, with a much smaller margin for error than in a car. It’s just you, nature, and machine.
So there you have it. For motorbike enthusiasts, you might want to take a look at my pet project, Honda CBR250RR wiki, and stay upright. For car drivers, don’t forget about your fellow 2 wheeled road users!
Posted on 31 August '07 by Steve, under motorbikes. 1 Comment.
Today I wanted to make a tag cloud, but all my searching proved fruitless - so I decided to stop being lazy and just work it out myself!
For my example, first you'll need a database that stores the keywords / search terms.
The way mine works is every time a search is run, I check to see if the term has been searched before. If it has, I update the counter field + 1. If the term has not been searched for before, I insert it with a counter of 1.
Alternatively you may store every search individually and use the GROUP BY clause to determine how many times the search has been run.
My query looks like this:
PHP:
// don't forget to connect to DB first!
$terms = array(); // create empty array
$maximum = 0; // $maximum is the highest counter for a search term
$query = mysql_query("SELECT term, counter FROM search ORDER BY counter DESC LIMIT 30");
while ($row = mysql_fetch_array($query))
{
$term = $row['term'];
$counter = $row['counter'];
// update $maximum if this term is more popular than the previous terms
if ($counter> $maximum) $maximum = $counter;
$terms[] = array('term' => $term, 'counter' => $counter);
}
// shuffle terms unless you want to retain the order of highest to lowest
shuffle($terms);
Next we'll setup a bit of css. Feel free to adjust these as you see fit.
CSS:
#tagcloud {
width: 300px;
background:#FFFFCC;
color:#0066FF;
padding: 10px;
border: 1px
solid #FFE7B6;
text-align:
center;
}
#tagcloud a:link, #tagcloud a:visited {
text-decoration:none;
}
#tagcloud a:hover, #tagcloud a:active {
text-decoration: underline;
color: #000;
}
#tagcloud span {
padding: 4px;
}
.smallest {
font-size: x-small;
}
.small {
font-size: small;
}
.medium {
font-size:medium;
}
.large {
font-size:large;
}
.largest {
font-size:larger;
}
Finally we just want to loop through the array and display it with the appropriate css class.
PHP:
// start the output to the page
echo "<h3>Popular Searches</h3>
<div id=\"tagcloud\">
<div>\n";
foreach ($terms as $k) // start looping through the tags
{
// determine the popularity of this term as a percentage
$percent = floor(($k['counter'] / $maximum) * 100);
// determine the class for this term based on the percentage
if ($percent <20)
{
$class = 'smallest';
} elseif ($percent>= 20 and $percent <40) {
$class = 'small';
} elseif ($percent>= 40 and $percent <60) {
$class = 'medium';
} elseif ($percent>= 60 and $percent <80) {
$class = 'large';
} else {
$class = 'largest';
}
// output this term
echo "<span class=\"$class\"><a href=\"search.php?search=" . urlencode($k['term']) . "\">" . $k['term'] . "</a></span>\n ";
}
// close the output
echo "</div>
</div>\n";
And thats it! Hope this saves someone some time. Add your comments below!
Posted on 22 August '07 by Steve, under PHP. 38 Comments.
Q: What is a cron job?
A: A cron job is an automated task that runs on a linux server, similar to Scheduled Tasks on windows.
The main idea is that you can run a process without you or someone else manually setting it off - my first experience with cron jobs was when working with an online auction website. As you can imagine, an auction runs for a fixed time period. So lets say an auction runs for 7 days. What happens at the end of 7 days? The database says this auction is closed. If the auction did not sell, whether the reserve was not met, or their were no bids at all, then we want to automatically relist that auction.
There are two options:
a) run a process when a page load occurs... sucks because the page load is gunna take longer due to the extra processes occurring
b) run a cron job every x minutes, looking for auctions that have passed their end time, and either relist them or close them down permanently
I tend to code in PHP and MySQL, which means that I create a PHP file that does all the maintenance tasks required and I run it at set intervals. The cool thing is, if you want to be running different tasks at multiple times of the day/week/year, just setup multiple cron jobs.
Thats great, but how the hell do I setup a cron job?
I'm glad you asked!
If you are comfortable working with command line, then you might want to visit a site like this. If, like me, you have access to cPanel, life is much, much easier.
How to setup a cronjob in cPanel
1. login to cPanel
2. click on the cron jobs tab (near the bottom)
3. Select your time you want the script to run. The options are pretty straightforward. If you select Minutes > 30 that means the script will run at xx:30am/pm. You can also hold the Ctrl key to select multiple minutes/hours etc.
4. Enter the "command to run". For my purposes, I generally want to load a php file. It doesn't hurt to put these files outside of the public web folder "just in case". Something like this should do the trick on a standard cPanel/WHM server:
/usr/local/bin/php -f /home/myusername/scripts/ascript.php
The first part is the "path to php". You might want to ask your hosting providers what this is, if the above doesn't work. The second part is the absolute path to your file. By default on a cPanel server the structure is /home/your_account_username/ where you can modify everything inside your account folder. Generally contained in the account username folder is a www/public_html folder with your live web files.
Hope this is of some help - cron jobs are a breeze - once they are running as desired its fun dreaming up new ways to make them more and more sophisticated... after all, now the server is actively taking away the daily grind!
If you have any questions do not hesitate to ask below.
Posted on 15 August '07 by Steve, under PHP. No Comments.