June 4, 2008

Rounded Corners


A big trend with web design right now is rounded corners on most rectangles. This is understandable, because when I am doing woodwork I smooth the edges, it just gives it a much more finished look, compared to rough or pointy edges. Not to mention in an artistic sense it both keeps the users eye path from moving around as much and helps the page as a whole blend. Corners tend to point in a direction or cause a UI element to stand out. Of course this is all contingent on how the page is designed.

Still I have done rounded corners for other sites with a brute force method, with separate positioning for both Firefox/Safari & IE7 because they rarely are the same. It looked good, but was annoying to implement, and that was only two corners, four would be much worse. Luckily there are now some options that make the job much easier. However there seems to be a big debate on what is the better method to use. One is raw css positioning like I had done, more work, but the benefit is low load times, just what the corner images need. The other way is with javascript I found Nifty Cube, a very simple and easy to use javascript engine that does all the work for you. The problem is that it loads after the page, and takes a small chuck of the users processing to run. This was not that big a lose so I was happy with the results.

Check it out if you need round corners, still not perfect, in the fact that it only does solid colors, however the only issue I have had is that it draws the corners across the top and bottom, so you need to pad divs by about 10px for it to work out.

June 3, 2008

Google Fight

1...2...3...Fight, oh I mean search!

While looking up something for work, I stumbled apon GoogleFight, which lets you pit two search terms against each other. It is a goofy little web app, but fun to try out, if you run out of ideas you can use the list of funny or recent fights. It can be a little disturbing watching the last 20 fights because as you constantly refresh you can see the terms that people are using, some of which can be just plain wrong...

Just goes to show you there is always more to find online.

June 2, 2008

CSS Layouts

Now that I have started my internship/summer job redoing the Prescott Brokerage Website I have remembered just how much a pain it is to start a new CSS layout from scratch, not that it is not fun to get the elements positioned properly, but but when you are working, it is not professionally to spend several hours getting a basic template built when there are plenty of resources online. Luckily there are sites like Free-CSS that have a huge number of free CSS layouts that make the job so much easier.

Now when I am taking about CSS layouts I am not taking about the already finished ones, those are finished CSS templates, I am talking about the blank ones that simply have the placement all set to go. You should be able to do your own designs! You guys know who I am referring to... ^_^

May 22, 2008

iBook CD Drive Upgrade

WIth all the ibooks I bought off surplus this year I had a good pile of parts. My sisters iBook, one of the few I was able to fix off surplus, apparently only had a cd drive, but luckily for her I had a combo drive sitting in my pile. However I had forgot how annoying replacing the cd is. Anyone that has taken an iBook apart will tell you of how hard the process is, it still takes me an hour from start to finish, and I have been taking them apart off and on for over 5 years! Oh and I still do not think it is possible to take apart an iBook with out ether loosing or gaining a screw...

I had read online oh how, minus taking the case off, removing the cd drive was easy http://www.powerbooktech.com/knowledge,type-6.htm, however apparently this model is different from the 900mHz iBook my sister has. There is a top bracket that holds the drive in place as well. The only way to get around this is to...
1) Remove the plastic cover and slide it into the case (too hard in my opinion)
2) Remove the awkwardly placed mounting bracket on the side facing the LCD (which requires a but of flexibility but is doable)

Sadly this is the easy part, getting the replacement drive back in is the hard part. It is way to difficult to screw the mounting bracket back on after the drive is in, so I just put that on first, then carefully jammed it back into the slot in the frame, bending the metal tab a little to make it fit, but it was fine.

Well this is what makes me love iBooks so much, they are so secured and covered that they can survive a lot of abuse and keep going, but that still make it a pain to do any maintenance on them.

May 19, 2008

DDR Pad Controller

Well after about 4 years the pad controller board died. I should have expected this, because I am forcing the circuit to run under much higher resistance then the 2 inches of wire it was designed for, but still 4 years of heavy ues is pretty good. So it was off to staples to grab a new USB key pad. I personally like the Targus Keypads because they are simple and support more then one key press at a time, which is very important for the pad to work correctly.

After getting the keypad I brought it home and took a look at the circuit, it was quite a bit different from the version they had 4 years ago, mostly because it used small contact pad instead of the holes for leads like I was hoping. This was a small set back, however after ripping the contact holder off the board to get access to the solder points I realized that I was going about it wrong. There where some lead holes on the board, just not right there.

I got some very thin copper wire with the insulating coat, and soldered them onto the board. It took some careful placement to correctly solder the wires that where very close to either the contact on the top, or the other solder points on the bottom of the board. Still after an hour of work I had it working, and could test in StepMania that it was indeed working.

All that was left to do was correctly wire it back to the pad. Sadly this was a lot more complicated then I had hopped, because the way I had the old version was slightly different. But I quickly fix this problem and had a wiring diagram to use. All I needed was the up,right,down and left buttons so I have two main wires 4 and 5 that are contacted to the remaining wires to get the correct button press. I am not sure if did something wrong or just shorted something, because after I had it all working for some-reason when you press left and up or down both up and down are pressed. Luckily this does not interfere with game play, it is just a small anomaly.

There you have it, all the instruction you need to make your own pad controller, however I expect that Targus will change the board again before this one breaks, so I am sure I will have to go through this hassle again sometime in the distant future.

May 15, 2008

Black Light Fun



Well I am almost all packed and ready to leave school, after covering the live feeds at graduation. My roommate was also packing and found his black light bulb. After sticking it in his lamp he turned off the lights and we had a good laugh about how it changed the appearance of the room, and even better showed us how much we really needed to vacuum, because there was a good amount of sand scattered around the carpet. This intrigued me so I set off with an extension cord around the apartment to see if there where any interesting spots. We had not done anything to trash the apartment (we are good students), so anything I fond would probably be from the last people in the apartment. My results? Well the stove had a lot around it, but that was from grease splatter, which with all the cooking that goes on is not surprising. The bathroom was not too bad, just the toilet. The really gross finding was the couch, which had a single very defined stain, that in normal light was not there. All in all it was very cool, just if you are germ-a-phobic or very paranoid, I really suggest you do not do this! I can't wait to do this next year on the new apartment.

Oh, you know you want to check out where you live now to see what is really hiding, plus it looks very cool!

May 14, 2008

Java Simple Physics



Well with classes over, I wanted to at least do something with the year of University Physics torture I have endured. Thus I present Java Simple Physics. It is just a quick physics example that uses the kinetic and potential relationship to have balls with different gravity constants drop then bounce with no loss of energy. It took a few hours to get right, mostly because I either did not know what I was doing, or was over complicating things. I hope to slowly improve on this concept till I have a VERY simple physics engine. Hey, it can only help to have a physics engine laying around, one day I might actually need one.


import javax.swing.*;
import java.awt.*;

public class Physics extends Thread
{
private int worldx = 200, worldy = 900, worldtime = 15;
private JFrame frame = new JFrame();
private Ball ball,ball1;

public Physics()
{
// Set up frame
frame.setSize(worldx,worldy);
frame.setVisible(true);
// Make new ball
ball = new Ball(400,450,9.8,worldx,worldy,worldtime);
ball1 = new Ball(400,450,3.8,worldx,worldy,worldtime);
}

public void run()
{
while(true)
{
try
{
// Cover old draw with fresh screen
frame.getGraphics().fillRect(0,0,worldx,worldy);

// Move and paint ball
ball.move();
ball.draw(frame.getGraphics());
ball1.move();
ball1.draw(frame.getGraphics());
Thread.sleep(worldtime);

}
catch(Exception e){System.out.print(e);}
}
}

public static void main(String args[])
{
Physics p = new Physics();
p.start();
}
}

class Ball
{
private double gravity = 9.8, t;
private double x,y,v,a,m,dx,dy,dv,k,u;
private int worldx,worldy,dir=-1,width = 90;

public Ball(int xin, int yin, double g, int wx,int wy, int time)
{
// Set Constants
worldx = wx; worldy = wy-width; t = time;
// Reduce gravity to fit with drawing refresh rate
gravity = g * .02;

// Center ba;; on x axis
x = worldx/2 + width/2;

// Set varables
y = yin;
v = 0;
a = 0;
m=.8;

// Preset u and k values based on varables
k = (m * gravity * (worldy - width)) - (m * gravity * y);
if(k < 0){ k = 0; }
u = m * gravity * y;
}

// Catch and reverse
public void move()
{
// Calculate u and k
k += u - (m * gravity * y);
u = m * gravity * y;
//Find dv based on k = .5mv^2
dv = ((2 * k) / m) - v;

// Catch and reverse on k or u < 0
if(k <= 0 && dir == 1)
{
dir = -1;
v = v*(-1);
a = a*(-1);
k = 1;
u = m * gravity * worldy-width/10;
dv = -1;
}
else if(u <= 0 & dir == -1)
{
dir = 1;
v = v*(-1);
a = a*(-1);
u = 0;
k = m * gravity * worldy-width/10;
dv = ((2 * k) / m);
}

// Finalise new movement
y += ((1+dv)*dir)/t;

// Print out values when needed
//System.out.println("x:"+x+" y:"+y+" u:"+u+" k:"+k+" - dv"+dv*dir);
}



public void draw(Graphics g)
{
// Draw to screen
g.setColor(Color.GREEN);
g.fillOval(worldx - (int)x, worldy - (int)y - width/3, width, width);
}

}

May 4, 2008

Student Senate Issues

I rarely get into politics, especial with the student government on campus, however this year the student senate has been quite poor in my opinion. Normally, student government is for the students in majors that are not quite as time consuming as the science majors or some of the arts majors, and do not have a decent job to keep them otherwise preoccupied during the semester. You can see why I generally ignore what they are up to, because I am usually far too busy with school and work, and at the same time nothing they do really has any effect on me. Other then somewhat interesting requests for equipment from the department I work for on campus.

What has greatly annoyed me this year is the utter lack of sense that the senate in general (not everyone) has displayed in their attempts to deal with some of the issues we have had on campus this year. One of the main things was a majority of the senate actually wanting to charge all the students (aka me who was sleeping at the time) for the student rioting earlier this year. Then they create "Task Forces" to deal with these issues, but to my knowledge nothing has come from these decisions. Non of this really surprises because I have actually been in classes with a few members of the current student senate and the dedication to their class work was just as lacking as the senates current abilities.

Interestingly, this is not just my single opinion. I know quite a few people in the senior and junior classes, and most of us do not have any great affinity for the student senate. More the one of us has actually witnesses a member of the senate displaying their opinion of how they apparently deserve a superior status then their follow students. Of course this is not going to go unnoticed, and one of the more entertaining results is an article in the clock stating on the status of the student senate this year. I think it sums them up perfectly in one sentence...

"I hope that this letter speaks to the more sensible members of Senate, and uses next year to rebuild the bridges that they have burned in their unethical reign as perceived supreme lords of the University."

Full article => Student org speak out about Student Senate behavior. Please note that I almost never read the clock, their opinions on things are generally very different from mine, however this was actually interesting enough for a friend to mention the article to me. Now I am sharing it as well, enjoy!

April 9, 2008

Download files from terminal

I had come across a mp3 file online that would only load half way, or so I though. Apparently it wold load the whole thing but Safari thought that it was bigger than that, so it would never give me the option to download it. Frustrated after having it load a few different times I looked for a better solution, the Terminal! I figured that there must be some way to download file from terminal. I knew of wget, however that is not installed by default in 10.4, and I did not feel like downloading and installing the fink packages. Instead I found the cURL command...


curl -o "address"


The -o is for file output, see the curl manpage for more info.

April 5, 2008

PHP RC4 Encryption

One of the harder encryption problems comes when you need to encrypt something but need to also be able to decrypt it as well. I ran into such a problem recently in PHP. The regular simple methods such as sha1 or MD5 with a simple salt would not work because they are only one way, and to make matters worse the crypto modules I needed for a solution where not installed on the server.

Luckily I stumbled upon RC4Cript a simple php class that supports a simple RC4 encryption. Although RC4 is not exactly the safest encription Wikipedia, it was fine for simply securing the data I had, and I did not feel up to the task of coming up with a better solution. It took a while to get it to work because I was confused into thinking that I needed bin2hex() after encrypting it, however that is simply to give a more readable form, leave it as is when using the encrypted text in the decrypt function. Other than that, the source has an example that is pretty self explanatory.

April 4, 2008

Sonic CD in XP




After such a ridiculous week I felt like digging out my copy of Sonic CD. I had found this at a game store at home many years ago. It was one of the best purchases I have ever made, not just because the game is awesome, but because the soundtrack is in CD form so you can just pop the cd in a player and listen. Something I was ecstatic about finding out back when I was quite a bit younger and CD players where all the rage. Ah, that was a while ago back before IPods ever existed.

This was also one of my favorite sonic games because of two levels, wacky workbench, which had electrified floors which would shoot sonic to the ceiling for better or worse, and stardust speedway which was just long twist and runs with a awesome background and music. However after getting to the last level I was reminded of the one really horrible part in the game, the huge pit you must cross at the last level, which I always fall and die over and over again at.

If you even get a chance you grab this game take it, a great addition to a classic game collection, definitely better then the rather lame 3D attempts at a sonic games that have come out in recent years. 2D Side Scrolling FTW!

The game was coded for Windows 95/98 so you will need this patch to play it in XP however no idea about Vista.

April 3, 2008

Fortran 95 BattleShip


Because I want to try taking every programing the CS Department offers this semester was Fortran. Definitely not quite like the other languages I know, but after getting used to it, I can do almost everything I can with C short of graphics and some string manipulation. After some short homework assignments, we where given our first big assignment, two player ascii battleship. Simple enough to complete in the 4 weeks we where given. I decided however to up the ante and add a simple ai system for one player games. Nothing fancy, just a random seek, with a focus on areas when something was hit, sill very easy to beat every-time. Yet it was somewhat impressive and if nothing else made it easier to test the program because I did not have to play against myself everytime.

I have uploaded it here with the Mac and Windows compiled versions plus source.

Fortran was definitely not designed with games in mind, but as with most programing languages with some careful planing and a bit of force you can easily get around such constraints.