March 17, 2008

Ph34r the Gr33n





I have always loved the look of clovers, sitting in the grass during summer it is hard to miss them, so I was happy this morning to see google had them on the banner in honor of St Patrick's Day. Although I was not taking part in the alcoholic side of the holiday I was definitely wearing green today. Note: my favorite color is green.

Happy St Patrick's Day Everyone

March 16, 2008

School and Sleep Don't Mix

Recently I over heard someone saying that they rarely get 8 hours of sleep, which got me thinking that I also rarely get 8 hours as well. Normally sleep is around 11:45PM to 6:45AM so on average about 7 hours, which is not bad, but still leaves me tired in the morning, daylight savings did not help either. Luckily for me I do not have heavy physical activity in my daily schedule which helps reduce my sleep needs. Sitting in class, sitting at work, sitting at lunch, sitting doing homework and sitting in bed. Recently I have come to notice school does not help you stay physically fit, luckily going to school near mountains fixes that. Oh well, such is the life of a college student.

6 Hours and I am Sleepy
7 Hours if I am Lucky
8 Hours and I am Spoiled
9+ Hours and I am lazy.

I did a little research about why eight hours are recommended, because we always hear it, but why is it eight?
"Before the experiment began, the subject routinely got about six and a half hours of sleep. During the first night of the experiment he slept eight hours, the second night 10 hours, the third night 12 hours, and the fourth night 14 hours. Over the next several days, he began to reduce the number of hours slept, eventually falling to a steady eight hours and 13 minutes. This experiment was performed repeatedly with all types of people, with similar results, and this is where the recommendation of eight hours comes from."
Taken From Here...

There you have it, that is why they recommend eight hours of sleep, well I found it interesting at least.

March 9, 2008

PHP Thmbnail Function

I had whipped up a online photo album for the AMS website I am working on, however after photos where uploaded I realized that I was not using thumbnails, but instead the huge pictures, which on dial up would take years to load a large album. So I went looking for a good thumbnail function, sadly all the ones I found where way to complex for what I was trying to do. With no other options, I did some research and studied how the other functions worked an came up with my own simple version.


function makeThumb($im,$dest,$thumbwidth,$thumbheight)
{
$resizeResult = TRUE;
$imgResult = TRUE;

list($width, $height) = getimagesize($im);
$exttype = exif_imagetype($im);

$tim = ImageCreateTrueColor($thumbwidth,$thumbheight);

if($exttype == IMAGETYPE_GIF)
{
$image = imagecreatefromgif($im);
imagealphablending($tim, FALSE);
imagesavealpha($tim, TRUE);
$resizeResult = imagecopyresampled($tim, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $width, $height);
//header('Content-type: image/gif');
$imgResult = imagegif($tim,$dest);
}
else if($exttype == IMAGETYPE_JPEG)
{
$image = imagecreatefromjpeg($im);
$resizeResult = imagecopyresampled($tim, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $width, $height);
//header('Content-type: image/jpeg');
$imgResult = imagejpeg($tim,$dest);
}
else if($exttype == IMAGETYPE_PNG)
{
$image = imagecreatefrompng($im);
imagealphablending($tim, FALSE);
imagesavealpha($tim, TRUE);
$resizeResult = imagecopyresampled($tim, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $width, $height);
//header('Content-type: image/png');
$imgResult = imagepng($tim,$dest);
}

if($resizeResult != TRUE || $imgResult != TRUE){ return FALSE; } else return TRUE;
}


To use just call makeThumb("Location of Image", "Place to put thumbnail", width, height); Very simple, also it will return false if something fails inside. Remember to make sure the directory it is writing to has the permission to write set correctly or it will always fail.

March 7, 2008

Next Year's Apartment

Well that time has come again, the stressful period of choosing next years living space. I have gone from two person dorm room, to a quad apartment, to a multi floor quad apartment, however because two of my friends are graduating, I have to look for another place again. My roommate and I though that a two person apartment might be nice, however it is not quite that easy...

To get a two person apartment you need to sign up for the draw, which only has apartments that people are moving out from, thus a small number, where as there are a lot of people who covet these sweet living spaces. I got to the apartment draw and dealt with the paperwork, and had to sit and wait for them to start. There must have been around 30-40 sets of people looking for a two person apartment, where as there where only 10 apartments up for grabs. The order of people who get to chose one is based on our ranking numbers (age, year, credits and grade) Luckily for me I got to choose second! (Take that youngsters ^_^).



So I chose an apartment, which our resident director of the student apartments said was her favorite, I figure it must be good. Here comes the intresting part... I walk by the place and from what I can tell by the windows it looks like it had cathedral ceilings, the living room window had another window on top that was a triangle against the sloping roof, which made me very happy. However later that night I could see there was light downstairs but not upstairs? Hold on, so there is some kind of random painted and finished loft/attic with what looks like a door above the apartment, that does not appear on any plans. Um, what? Now I am interested, if I can find a way into this space, like the Attic access panel in our current apartment I will be very happy, it could even mean my own room!

Well this is all speculation for now, but it looks like next year will be very interesting indeed.

March 1, 2008

iBook Photo Frame



After fixing an iBook, my next plan was to change it into a digital picture frame. This is something that many people have done with every old laptop you can imagine. So I took the stripped down iBook, and completely disassembled the lcd screen, down to just the panel, and took some measurements for a frame. The closest frame I could find to the screen size is a 8.5 x 11 inch with a nice looking border. The screen fit well in this, but it would need a bit more room to fit the rest of the iBook. So a box that fits inside the frame was made and attached with screws to the sides. Small wood dividers hold the lcd in place, while adding some space for air flow. I also cut out the holes for various connections, air vents and for the optical drive. It all just perfectly fits snugly inside. The back cover is attached to the sides of the box by small blocks of wood, and puts some pressure on everything below it with. All it needs a quick paint job, probably black to match, but that is for another weekend.

The end result looks amazing. Another successful project, completed!

February 29, 2008

How to fix an iBook





Well I got another iBook from surplus for another dollar, which also was showing the same symptoms of the GPU having solder connection issues. Also once again by putting pressure on the chip and the board the LCD would turn on. However unlike the last iBook I tried this fix on, this one required less pressure to get the screen going, and would stay on at certain angles, so what ever was wrong with the solder was quite a bit less than the last iBook, which makes my life easier.

So, I grabbed the propane torch and set up the board by removing anything that would melt. This time, after doing some research of others attempts at this process, and found that a slow heating and cooling process is much more effective. So I heated for a minute at a low setting from a little distance, then heated at full for about another minute while watching the screen. At the start, the screen was a garbled mess, however soon the chip overheated and the screen did a weird blurring effect. This was normal and happened last time, so I backed off with the heat and allowed it to cool a bit, after a few seconds the chip started again, but was still not quite right, so I repeated the process. This time after backing off with the heat, the screen went to the blinking question folder that I was looking for. After getting this far, I let the chip cool on its own, which took around ten minutes. After it cooled correctly, I made sure the board turned on, and shook and slightly bent the board to make sure it was securely connected. My last attempt had several failed successes, which by bending the board showed it had not correctly reflowed the solder. However this time it was fully connected.

Ha, it may have taken two attempts to get right, but now I have a working iBook for my digital picture frame project, and as requested I have pictures of torch in action, which where missing from my other post, enjoy.

February 28, 2008

Space Invaders for your wall


I randomly stumbled upon Blik Surface Graphics who carry a set of wall decals that look like Space Invader sprites. Space invaders for the video game challenged is a simple game where you shoot aliens, using a little mobile cannon, before they get too low and invade the earth, or shoot you. There have been many renditions, but Space Invaders still remains one of the first arcade shooters.

I thought the decals where very cool, but I am a poor student and did not feel like paying the $12.50+ so I set out to make my own. Firing up AppleWorks I went to town with a bunch of black squares. They ended up looking like the real thing, so I was happy, and printed out the same number as the decal set would have. If you are feeling lazy and do not want to make your own, I have uploaded my set here for anyone to use.

The end result turned out rather nice, but now Matt says we need a Mario wall too, sounds good to me!

February 27, 2008

Tesla Coils are awesome

After building a vandergraph generator, which worked rather well, I have looked at making one of the many other high voltage static generators out there. I really want to build a wimhurst, and eventually will, however I really want a Tesla Coil, because they are amazing. They are so powerful the intense electric field around them can light up fluorescent bulbs from a few inches to a few feet away depending on the size. The one big drawback to Tesla coil is they need an outside power-source, usually a high-voltage transformer of some kind, as well as other electronic components, so in reality it is not quite a static generator, but still amazing machines! If I ever find plans for a simple low power one I will definitely start building it.

I love the video above because it demonstrates a simple Tesla coil very well, plus I can not stop laughing every time it starts up, creates a static buz, and then BOOM (At 00:24). This is the first one I have heard do this.

Other people have done amazing things with Tesla coils, such as adjusting the frequency to play music on them!

February 19, 2008

Coolest NERF gun yet




Many guys my age had a hoard of NERF guns as a kid, heck I still have a hoard, although I do not use them quite as much. Still after seeing the new NERF Vulcan EBF-25 on Gizmodo, I know this might be worth looking into. It looks like some kind of advanced weapon, except for the orange coloring. However that is to make it not look real enough to get a kid shot for carrying this around, which is understandable. Still any moder could do a great paint job and make this look beyond awesome. Oh course the biggest question raised by this NERF gun is if you can modify the chain to be longer then 25 darts. A chain of 200 or more would be very impressive indeed.

After looking at the picture for a while another thing came to mind. The Vulcan EBF-25 looks very much like the portable turrets in Halo 3. They both grab on the top, and fire from the trigger on the back. The tripod is very similar as well. The front of the gun is the only major diffrence. So was this inspired from the NERF team playing halo? Who knows, but what I do know is any one I show the Vulcan EBF-25 to wants it. Way to go NERF!

February 15, 2008

How to break an iBook


Well I am usually pretty good about not breaking things worse when I am trying to fix them, but today was not my day...

I had got an iBook off of surplus for a buck, however it did not have any video, after taking it apart and pressing on the graphics chip on the board I could tell its connections had come loose. Similar to the story here. So I set off on an adventure to try to fix it. After making a cup out of aluminum, I got a propane torch and started heating it. It worked well enough and came very close to working, but shifting the board still caused video problems, so I had the bright idea to put some pressure on it while heating.... BAD IDEA! The solder balls underneath got squished and fused together, rendering the logic board useless.... Sigh. There are times when you wish life had an undo, this was one of the times I wanted to use it. Well I will remove the solder and chip from the board and see if it at least starts, right now it turns on shorts and shuts off. However it would take inhuman skill to solder it back on correctly. Ah such a waste, well maybe I can sell the working parts online.

Note: The clamp was not tightened any further then to simply hold the cup and a small metal piece on the bottom together, plus give me a grip to hold on to, but that was still to much pressure.

Luckily there are more iBooks on surplus with the same problem, and because I am probably the only one crazy/stupid enough to attempt this again to try to fix them, I at least have a couple more tries at making a digital picture frame. Yes that was the original goal.

Oh well, now excuse me while I go beat my head against a wall.

February 12, 2008

Simple Flat File Database

I had recently been refused access to a sql database for a project, this I started looking for other options. After a little searching I stumbled across txtSQL, which is a very powerful but easy to use flat file database.

To start off download the latest release (2.2 final at the time of writing this). Then read the read me in the doc folder it will walk you through setting up the include files you will need as well as the database folder, by default called data. One you have these placed correctly just like with mysql you will need to connect to the database.


include('includes/txtSQL.class.php');
$sql = new txtSQL('includes/data'); // Location of the database files
$sql->connect('root', ''); // This is the default name and password
$sql->selectdb('XXX'); // XXX is the database name


This will let you connect to the database you want to use, I do recommend changing the password from its default. However there is no database or tables right now so you should add these.


// txtSQL created a new database named testDatabase
$sql->createdb(array('db' => 'XXX')) or die('Error creating txtSQL DB, txtSQL said: '.$sql->get_last_error());

// Create Table in new database
$columns = array(
'id' => array('type' => 'int', 'auto_increment' => 1, 'permanent' => 1
'name' => array('type' => 'string', 'max' => 50),
'email' => array('type' => 'string', 'max' => 50) );

$sql->createtable(
'db' => 'testDb',
'table' => 'testTable',
'columns' => $columns);


Now you have tables set up, unlike sql databases, this is all commands with arrays, so it takes a little getting used to, but is not to horrible to learn. Finally, you just need to manipulate the data.


// Select
$where = 'somthing = '.$_POST['something'];
$results = $sql->execute('select', array('table' => 'XXX', 'where' => array('0' => $where), 'limit' => array(1)));

// Grab first result
$result = $results[0]; // Just want the first result

//or use them all
foreach($results as $result) // Grab each row from the result
{
//... Do something
}

// Insert
$insertvalues = array( 'name' => 'matt', 'date' => '9/8/06' );
$sql->execute('insert', array('table' => 'XXX', 'values' => $insertvalues));


The rest delete and update are also similar, and you can find example in the documentation included.
Although txtSQL is not a perfect replacement for a real sql database it does work rather well. However it is suggested that is only be used with smaller database needs, otherwise stick to a real real database management system. Still for what I needed it to do I am quite happy.

February 7, 2008

Setting up web shares in Apache

One thing I wanted is the ability to share directories online other then having to make folders in my WebServ folder. So off I went to look up how to configure Apache to do this. As I expected this was not all that hard to do, you just have to add a few lines to the apache config file.

Just type " sudo vi /etc/httpd/httpd.conf " or use what ever editor you like, I like VI. then look for the section below...


#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule mod_alias.c>


Find place you like to put the info for your new shared directory, and add the lines below. The #"stuff" lines are optional, but it is a good idea to comment about what you are adding.


#Share via online
Alias /NAME OF SHARE "/PATH TO DIRECTORY/"

<Directory "/PATH TO DIRECTORY/">
Options Indexes FolowSymLinks MultViews ExecCGI
Order allow,deny
Allow from all
</Directory>


This will set up a new directory that you can access with http:/serveraddress/name of share. This worked quite well, however I still wanted to take it a step further. I could make a php index page that prevented access, however that would not give me quite the level of security that I wanted. Instead I looked for a way to secure a directory with Apache. First of you need to change the directory set up by setting it to...


<Directory "/PATH TO DIRECTORY/">
Options Indexes MultiViews (+ other things you want)
AllowOverride All
</Directory>


This make it look for a .htaccess file that specifies the access rules for the directory. You will now need to add this file to the directory you are sharing. In that file you need to add these lines.


AuthName "Name of Stuff Share"
AuthType Basic
AuthUserFile /PATH TO PASSWORD DIRECTORY/.htpasswd
AuthGroupFile /dev/null
require user ADD USERNAME


This sets up the directory, the last thing you need to to add a password file for it to reference to.
To do this, cd to the password directory you used above. Then type htpasswd -c .htpasswd "USER NAME" this will add a password file to the directory for the use name.

There you have it a new directory in Apache which requires a password to access.