#WebsiteUpdate – change the look with just one click!

Plain and minimalist is good. But the ability to add colour to it all, with just one click is even better!

Just added the ability to change the whole colour scheme of my website with just one click. You’ll find a simple dropdown in the footer (at the bottom) of each page. Just choose a style and BAMM, everything changes! Will be adding more styles as I go along.

I used a template style-sheet and then drew up the colour pallets to use. The form sets a session variable that decides which colour pallet to apply. Simple.

CSS styling

Next steps? Change the whole layout, using the same method, instead of just the colours.

 

[Solution] Facebook Hacker Cup 2012 – Qualification round – Alphabet soup (letters)

Was bored so decided to optimize my solution a little bit more.

You can find the original solution here.

 

$file_content = explode("\n",(fread(fopen("input.txt",'r'), filesize("input.txt")));

$output = fopen("output.txt", 'w');
$hacker = array('h','a','c','k','e','r','u','p');

for ($j = 1; $j <= intval($file_content[0]); $j++){
for ($zzz = 0; $zzz < count($hacker); $zzz++){
$freq[$hacker[$zzz]] = 0;
}
	$word = strtolower(str_replace(" ","",$file_content[$j]));
	$len = strlen($word);
		for ($i=0; $i<$len; $i++) {
		  $letter = $word[$i];
		  if (in_array($letter,$hacker)){
		     if ($letter =="c") {$freq[$letter] +=  0.5;}
		     else {$freq[$letter]++;}
		}
		}
	$stringData = "Case #" . $j . ": " . intval(min($freq)) . "\n";
	fwrite($output, $stringData);
}
fclose($output);

 

Smallest solder I’ve ever done… PSP USB charging mod

I have a first generation PSP (PlayStation Portable) and after it’s charger over-heated and died I started using a variable adapter to charge it. Once while charging, I set the polarity on the adapter the wrong way around and well it burnt out the diode on the PSP circuit board!

So now I had a dead PSP because of a hardware problem. (Hint: I’m more of a software guy!)

After wasting a lot of time on google, I came across this one post on how to charge a first gen PSP via USB. Originally a first gen PSP does not support USB charging. All I had to do was solder a wire from the mini-USB port to the PSP power-port. Easy. Only that after opening up the case, it didn’t look so easy. And this is why:

For comparison, I took the photo next to a 5p coin. Yes that’s a 5 pence coin which is 18mm in diameter! It is the best and the neatest solder I’ve done so far without burning a hole through the circuit board or any other components!

 

[Solution] Facebook Hacker Cup 2012 – Qualifying round – Alphabet Soup

This was by far the easiest problem out of the three.

Here’s my solution, written in PHP. It reads a file called input.txt and outputs the results to output.txt!

UPDATE – a much more optimized solution here.

$filename = "input.txt";
$input = fopen($filename, 'r');
$theData = fread($input, filesize($filename));
fclose($input);

$file_content = explode("\n",$theData);
$test_cases = intval($file_content[0]);
$outputFile = "output.txt";
$output = fopen($outputFile, 'w') or die("can't open file");

for ($j = 1; $j <= $test_cases; $j++){
	$freq = array();
	$word = strtolower(str_replace(" ","",$file_content[$j]));
	$len = strlen($word);
		for ($i=0; $i<$len; $i++) {
		  $letter = $word[$i];
		  if (array_key_exists($letter, $freq)) {
			$freq[$letter]++;
		  } else {
			$freq[$letter] = 1;
		  }
		}
      if (!isset($freq['h']) || !isset($freq['a']) || !isset($freq['c'])
       || !isset($freq['k']) || !isset($freq['e']) || !isset($freq['r'])
       || !isset($freq['u']) || !isset($freq['p'])
       || (intval($freq['c'] == 1)))
                {
		$stringData =  "Case #" . $j . ": 0\n";
		fwrite($output, $stringData);
		}
	else {
		$counting = array();
		$letters = array('h','a','c','k','e','r','u','p');
			for ($z = 0; $z < count($letters); $z++){
			$var_name = "count".$letters[$z];
				if ($var_name == "countc"){
				    $$var_name = $freq[$letters[$z]]/2;
				    $counting[] = intval($$var_name);
				}
				else {
				    $$var_name = $freq[$letters[$z]];
				    $counting[] = intval($$var_name);
				}
			}
	$stringData = "Case #" . $j . ": " . min($counting) . "\n";
	fwrite($output, $stringData);
	}
}

fclose($output);

Download link: alphabet-soup

 

aPcBuild – because its technically not my first!

Technically I built my first PC 6 years ago. It was made from scrap parts from random old PCs I had lying around and any PCs that had been just given to me.

Didn’t have a proper case for it though, so it just sat on my desk with all parts lying bare. It looked something like this…

The specs were something like a dual core 1.8 GHz processor and 512Mb RAM with a 256Mb graphics card. Nothing amazing, I don’t even remember what the exact specs were.

Three years ago, I built my current PC that I’m using now. It was a budget build and total cost was kept under £400! Running Windows 7 Ultimate x64 and I do all photo-editing, web-designing and gaming on it! Not a gaming PC but runs them well.

The case is a Galaxy Black Mid Tower case with blue bubble lighting and clear side available here at ebuyer -> exactly what I wanted, cheap, some lighting and a side panel allowing for simple mods! for £35

Processor is an AMD Athlon II X4 620 -> a quad core 2.6 GHZ processor …great for < £70!

Motherboard is an ECS GeForce6100PM-M2 -> memory support up to 16GB however only 2 DIMM slots but < £60

RAM -> Kingston 4GB (2x2GB) DDR2 CL6 for around £50

A cheap DVD player/writer for £15 from ebuyer.com

Front panel card reader for £10

NVIDIA GeForce GT 440 1GB (DDR5) < £70

HDD1 WD Caviar Blue 500GB – 600 MBps – 7200 rpm < £65

Led strip lighting < £5 ebay!

Cabling for around £10

The DELL screen was given by a friend and the HP screen by another friend.

Mouse and Keyboard were just lying around?

Total cost of a beautiful budget build < £400

Since then I’ve added the following:

HDD2 WD Caviar Blue 1TB – 600MBps – 7200 rpm < £100

Slimline Widescreen Tablet = £60

 

It’s not the most powerful PC but it does the job and does it well! I use it mainly for web development, and all I use for web-dev is a local installation of Wamp Server and Notepad ++ Runs games pretty well on the highest settings, will put up benchmark stats if interested, but I’m not much of a gamer.

This allows me to cross off number 15 of my things to do before I die list.

 

#thetimecapsule.org – Become a part of Internet history!

thetimecapsule.org  was launched on 1st Jan 2012. The basic idea emerged from the fact that I was coming across a lot of things: a lot of events, individuals and corporations who change our lives everyday and help form the year!

So I decided to create a ‘time-capsule’. But then I thought, creating a time-capsule will mean that I only add the things I’ve come across, thus missing out on what other people found important, etc. So, that’s where my holiday project emerged from: to create a website which will allow people to add ‘profiles’ on things and people that help shape and form a year, every year. But how to limit it? Well the time-capsule is limited to a 1000 top-rated entries. So each user can add up to three entries (free user registration), and all the other users can vote on the entries. The 1000 highest rated entries will stay in the time-capsule. This does not mean that the other entries will be deleted. This just means that although they will exist online on the website and you will be able to direct-link to them, the time capsule for that year will only contain the top 1000 rated entries of that year.

The site was built from scratch, so there might be a few bugs here and there. Let me know on Facebook or Twitter.

Also I’m currently planning a version 2 of the site. So if you have any ideas or features that you think I should incorporate, also do let me know =)

Click here to visit thetimecapsule.org

This also completes number 11 of my things to do before I die list.