Manchester 100 – Anyone??
Well the time is coming close to the Manchester 100, this is a bike event which takes place around Manchester, there are 2 routes, 100 miles and 100km. Strangely we've decided to go for the 100miles.
The route elevation can be seen below.
Building your own CMS in PHP
Well what can I say apart from...........don't!!
I've been coding my own for the past week or so, with a deadline looming and I'm hitting some major hurdles. Now you may ask why am I on here creating a post, well I just need 5 minutes away from coding and I'm thinking about making this blog a more active blog rather than 1 update per year.
I've based my CMS on the ever popular Code Igniter however I'm not sure whether this has hindered my development in any way. Am I being restricted by the fact I have to contain everything in controllers and views? Maybe, but then at the same time it has the ability to use templates without much arsing about and the SEO urls are always nice!
Working with phpBB password hashing
Well over the past month or so I've been writing a website (...and still doing it and wasting time writing this blog post...) and we chose to use phpBB to do the security and build our website around this database.
After spending a good amount of time hunting for information on how to encrypt my password and decrypt it I found some information which pointed out that it doesn't encrypt as this gives the ability to reverse engineer the values in the database but it has it's own hashing function.
After searching further I found the functions to be phpbb_hash() and phpbb_hash_check(). phpBB themselves have their own wiki which is very sparse on valuable information but phpbb_hash was there and helped me, however checking the hash was not so I have added this myself!
http://wiki.phpbb.com/Phpbb_hash_check
I recommend that if you do work with phpBB and using the functions available, try update the wiki if the information is not there so in the future when I go hunting for something it is there readily available
Facebull
Ok, I've now taken on another Facebook puzzle, this one is a little harder though.........infact its bloody difficult!! The whole point of the solution is to provide a cost effective way to produce "Facebull" using the listed machines. Each machine can change 1 ingredient into another, you are given a list of all machines and what they can do. You need to use the machines to the best cost and output the results.
The main issue is, the number of machines can be anything and the number of ingredients could be anything!!
The Calm After The Storm
Well we are all back from Cardiff all in one piece.......maybe a few bruises but at least no cuts!
The game appeared to be quite a good game and the Buccs went out on a 2-0 lead with 2 goals from myself. Unfortunately this was not to last and the Demons started to claw their way back into the game.
The game was played with the right atmosphere apart from a few little issues and a poor referee!! Too many daft calls for my liking, just the same from our home games!
I still cannot understand how I could be sent off for elbowing when my elbow was no where near the guy and I was skating away from him! (This was from our home game).
Saturday's game got no better for me, a guy stood on my stick and fell over........2 minutes for tripping! I pointed out to the referee the problem with this yet it was still 2 minutes ![]()
I thought I would get my own back and score another goal which I did, yet the dodgy referee with the dodgy calls gave it as offside which really pissed me off. It was a screamer of a shot and the keeper had no chance, and this was from the wrong side of the blue line!!
It got worse after the game, I found out 1 of the other 2 goals I scored was given to another player, how rude! So not only was I given 2 minutes for someone falling over, I lost 2 goals!!
The Count Down is On!
Well the count down is on, 1 day left in work before heading off to Cardiff for the 2nd leg of the ice hockey matches against Cardiff Demons. The home leg resulted in us winning 8-5.
Lets hope the away game results in another win, some how I think it might not due to the team not being so strong
Oh well, we can drown our sorrows on the night out.........drinking games galore!!
Facebook Puzzles (part 3)
Well the emails finally turned up!!
Dear submitter,
Thank you for your test submission of a puzzle solution to Facebook! After running your solution to hoppity (received on May 21, 2009, 9:44 am), I have determined it to be correct. Since your test has been successful, you are all set to try one of the other puzzles. Best of luck!
Sincerely,
-The puzzle robot
Both Hoppity & Meepmeep! scripts I supplied work
obviously after a fair bit of faffing about. I wasn't too sure about the Meepmeep! one as the description made me think it was a little too easy and maybe there was a hidden agenda, but there wasn't.
Your script had to accept an argument which was a file, this file would contain random crap. The weird bit was, this dat could be ignored and all you needed to do was output Meep Meep! Just a simple
echo "Meep Meep!";
2 puzzles down, 11 to go!
Facebook Puzzles (cont.)
Ok, so it looks like my solution didn't make it with the big guns at Facebook Puzzles.......I happened to miss off a very obvious but required line
#!/usr/bin/php from the top.......oops!!
I also believe I left in a line at the bottom of the script which called the function again, which instead of actually working threw up an error. Facebook don't actually tell you what is wrong, just a simple email saying thanks but no thanks. I've resubmitted my solution in the hope that it will work, if it does then I'll resubmit my Meepmeep! application and post my solution on here.
The line I left on the bottom was
hopit($i);
this has been removed and my solution sent is as follows:
#!/usr/bin/php
<?php
$file = $argv[1];
$open = file($file);
function hopit($number) {
for ($x = 1; $x <= $number; $x++) {
if (!is_integer($x / 3)) {
if (is_integer($x / 5)) {
echo "Hophop\n";
}
}
else {
if (is_integer($x / 5)) {
echo "Hop\n";
}
else {
echo "Hoppity\n";
}
}
}
}
foreach ($open as $line_num => $line) {
$result = trim($line);
if (is_numeric($result)) {
hopit($result);
}
}
?>
urmstonhockey.co.uk
My friend Andy has been playing hockey for quite some time now and I have started to become interested in it. It came a point where their domain renewal lapsed and well.........the site was pretty shocking to say the least. Andy was interested in learning PHP and I didn't have much work on my hands so I thought I would help him out a little.
We started off by Andy attempting a few designs but nothing was all too great so he came round to mine one night and we started off with the design. In the few hours he was here we managed to get the design completed and this is where the fun then started.....coding!
Again Andy visited me and we worked together on the coding, me showing Andy how things are done and Andy dictating what he wanted on the site lol. We added a lot of features, one of them was the results and league table page. Instead of creating the site to display stuff updated by Andy we thought about having the site read the information from fixs.co.uk which contains fixtures, results and league tables for all the Urmston Hockey teams. After a few bugs we managed to get a script which worked perfectly for all the teams.
you can find their site @ www.urmstonhockey.co.uk - no doubt you will hear more about the site in the future!
Facebook Puzzles
Well I happened to fall over the facebook.com puzzles page, basically it is an application within facebook which gives you puzzles to solve. These puzzles are only solvable by coding which they give you numerous languages to solve them with. The languages you can use are as follows:
- GNU C/C++ 4.2.3
- Ericsson Erlang 5.5.5
- GHC Haskell 6.8.2
- Sun Java 1.5.0_15
- INRIA OCaml 3.10.0
- Perl 5.8.8
- PHP 5.2.4
- Python 2.5.2
- Ruby 1.8.6
I myself have stuck with PHP as this is currently what I know best, however I would like to know Python and C++ a lot more!
I have attempted to complete the first 2 puzzles, these are Hoppity and Meep Meep!
Hoppity
The rules of hoppity are simple, my PHP script must be able to receive a file name via command line. This file will contain a numerical value which could contain spaces before or after it........I think new lines may also be included in this as well but I'm not too sure??
After you have the number, you must then count up from 1 to this number, for example 15. If the current number can be divided by 3 then you must output Hoppity. If the number can be divided by 5 then you must output Hophop. If the number can be divided by 3 AND 5 then you must output Hop. After each output there must be a new line (\n).
For example if the number was 15 then the following must be output:
Hoppity Hophop Hoppity Hoppity Hophop Hoppity Hop
The following lines would trigger the above outputs
3 (hoppity because 3 /3 = 1)
5 (hophop because 5/5 = 1)
6 (hoppity because 6/3 = 2)
9 (hoppity because 9/3 = 3)
10 (hophop because 10/5 = 2)
12 (hoppity because 12/3 = 4)
15 (hop because 15/3 = 5 & 15/5 = 3)
Yes this all seems simple yet you must code the script so that what ever number is given via the file will give the correct output.
My code is as follows:
$file = $argv[1];
$open = file($file);
function hopit($number) {
for ($x = 1; $x <= $number; $x++) {
if (!is_integer($x / 3)) {
if (is_integer($x / 5)) {
echo "Hophop\n";
}
}
else {
if (is_integer($x / 5)) {
echo "Hop\n";
}
else {
echo "Hoppity\n";
}
}
}
}
foreach ($open as $line_num => $line) {
$result = trim($line);
if (is_numeric($result)) {
hopit($result);
}
}
hopit($i);
I will talk about Meep Meep! another time.
