DSwain- The New Day

Wednesday, November 29, 2006

The Migration

Well folks, I've just about finished up my work on my website to begin running that as my blog. I'll try and keep a few more updates here I suppose, but for the most part, I'm going to begin working on moving toward my website as my blog. Don't get me wrong: if you're looking for a nice blogging website, this is a great place to go about it. It's got a real nice system, and the beta has improved speed and stability of things. Can't complain about that for sure. Like I said, I think the community is kind of lacking, but maybe that's just because I didn't explore enough; I'm not sure honestly. At any rate, Blogger is a nice thing to try out, so go for it if you're considering it. The only reason I'm changing is because I have a web server hosting my website and a system to now update it real easily, so why not?

If you're looking to check it out, here it is: swainnet.zapto.org

Alright folks, I have to go work in a few minutes, so that's about all for me. Take it easy.

Tuesday, November 28, 2006

The Confusion I Know as Myself

Every now and then, we all get to enjoy some pain, frustration, fear, stress. Some of us more than others, sadly. When I tend to get like this, it's neat that I try to justify my place in the world, or in a town, or as part of a persons life. I try and understand probably something that seems next to impossible to understand.

I also try my best to be empathetic if I can be. I don't like to blame people, so I try my best to see it from the other perspectives, whether it's another persons or another race's, I try and understand. Maybe there's just something I couldn't understand ever that they're experiencing, or things they have to do that I just simply can't add up. There's reasoning behind everything, so I try and find the way. The issue with this is that I end up repressing lots of feelings. Maybe not even that, but I just can't simply say them. It could be that I fear the consequences of my words, or maybe it's the fact that I can't really understand the other perspective always, if ever.

In times like those, I also try and figure out what I wish I was and wasn't. I've had moments like these where I end up changing drastically, and some moments have just come to teach me a little more of that thing I simply can never entirely understand. I have a few things that I wish I was and wasn't right now.

I Wish:
-I was a stronger person
-I was a smarter person
-I could have my way, at least this time around at least
-I could be comfortable again
-I could focus better again
-I could make things different, like the not so distant past
-I wasn't a stubborn and blind optimist
-I wasn't so nervous
-I wasn't confused about what to think or say
-I wasn't feeling slightly less happy everyday
-I wasn't feeling like I am these days

I find myself appreciating simple things like that. It gets hard to pile up things. Clothes, for example, get overwhelming to pile up on the floor. It starts like a small pile on the floor in the corner, and eventually starts to override. You keep tossing to the floor, and get more lazy with each throw since the pile has spread vastly across your room. Eventually, it becomes you room, and well you're stuck with cleaning up.

The same thing happens with how my feelings sometimes. One thing can happen, but I can let it go, or so I think. Maybe it just piles up in the corner. Each throw gets a little lazier because my mind has become consumed with too many things tossed aside. Eventually, I'm left with the task of fixing all those feeling I ever had and thought I let go. The basic way of putting it is, I'm making myself a fucking wreck.

Well, I must admit, this was a nice way to get that sick scared feeling out of my system. Or, at least a way. This all being said though, I think I need to just "keep on keepin' on." There's no chance, no time to stop and think about anything, or do anything, or feel anything anymore, so I suppose all I can do is keep rolling with time and see how things end up. However, I have confidence in my experiences as a human that the other side of the hill is always brighter. So, at this rate, I guess I'll just keep going.

I can't wait to see the sun shine again.

Saturday, November 25, 2006

Railroad Earth: Epic

I got to go see Railroad Earth again for the second time at the Whitney Chapel in Hackettstown, NJ. For those who don't know, Railroad Earth is a bluegrass band out of Stillwater, New Jersey and by far one of my favorite bands I've ever heard. A show like this is impossible to deny the terms "immaculate" and "epic."

I sadly forgot to bring paper to write the set list down. A few of the songs played were (in no particular order):

-Storms
-Mighty River
-Dandelion Wine
-Reuben's Train
-Elko
-Old Man and The Land
-Railroad Earth (self-titled song)
-Sing For Me

Along with several others. I didn't know any of the instrumental songs, but they were all very impressive either way. I've never seen such a dynamic band. When you watch one of the members play five different instruments in one night, well, you're just impressed. I've also never seen a band where basically everyone can sing. Johnny Grub, the bassist didn't, but everyone else did, including the drummer. It was incredibly lovely to listen to. I can tell you that it can easily make any hard times lighter and easier to handle.

All I can tell you is that if you get the chance, go see Railroad Earth. Even if you think you don't like bluegrass, just keep an open mind and go check out the show. Last year I didn't think I liked bluegrass either until I saw Railroad Earth. They will change your perspective entirely.

"Sing me those hymns we sang together
In that plain little church
Where the benches are warm
How dear to my heart, how precious the moment
We stood side by side singing a song"
-Railroad Earth: Sing For Me

Later folks.

Oh by the way, thanks to John for hooking me up with this link!
http://www.flickr.com/photos/kyrion/sets/72157594391394289/detail/



I had taken a few photos with my phone, but obviously it's not always an easy task to get the pictures off your phone for free, and they look like crap anyway, so here's some real nice photos from the show. Awesome stuff!

Friday, November 24, 2006

A Basic PHP/MySQL Chat Room

Dedicated to Melissa (http://lyfaraurelor.blogspot.com/) because she dedicated an entry to me!

Ever have an issue where you wanted to set up a live chat type of system for your website? More than anything, ever have a computer class where you couldn't talk to people without getting into some type of trouble? Pretty sad, I know, so I decided to try and come up with a solution for it. Here's what I have, so far. This is also a fairly good demonstration of what I've been working on for my senior project. The actual project is not as simple as this little hack is by any means, but it uses a ton of similar things I have been using for the project.

Firstly, this isn't some type of new ground I'm charting here. It's been done in the past. It seems like that a lot of people have used PHP as the chatting system, but many of them use a text file to store the messages, which is commonly known as a flat file. Since all I have been doing programming wise is PHP and MySQL for the past several months, I figured I should just keep with the trend and use MySQL as opposed to a flat file. If you wish to use a flat file to set up a system like this, I recommend you check out this article on phpbuilder.com.

Anyway, the idea is fairly simple behind it. I created three functions (it probably could be reduced to two, or maybe none depending on how you program.) I generally like functions, so I ended up with three. The first one was to retrieve the messages from the database which I named getMessage(). The second is a function called postMessage() which takes the postdata from the HTML portion of the website and then queries it into the database table. Finally, I have a postForm() function which helps regenerate the actual table to post. It helps avoid using HTML built into the PHP file, but I don't see why doing that would be an issue either since that's one of its strongest points. I did it to attempt to not write header information, but that didn't work out. Either way should work fine for however you choose to do it.

1. getMessage(): This is what the code for the getMessage() function looks like
function getMessage() {
#Establish connection to DB
$connection = mysql_connect('localhost', 'mysql_web', 'dbpass');
$database = mysql_select_db('chat');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}

#Get the last messages
$query1 = 'select messages from messages order by id desc limit 0,15';
$result = mysql_query($query1);
$rowcount = mysql_num_rows($result);

while ($output_array = mysql_fetch_array($result)) {
for ($i = 0; $i <= $rowcount; $i++) {
echo "$output_array[$i]";
}
}
}


This is probably about as complex of a function you'll have in this program. First, you need to establish a connection to the database. Now, don't quote me on this one, but I establish the connection per function. I believe this is necessary, but I am not sure. If it isn't, then obviously just remove the connection code out of your functions and add them outside of it so it will be read each time the script is run. If anything, it will help make your code look more consistent than anything, which is always important. Then, you'll see the variable $query1. This is the actual SQL query that's performed on the DB/table to gather the information, If you want to keep it simple, you can just make the query something like "select messages from messages" and that should work just fine. The other options I have are "order by id desc" which basically instead of reading the DB from top to bottom, will read it from the bottom to the top. Obviously this is optional for however you want to display the data. The other thing I did was create a limit within the query. Initially, I was trying to force PHP to limit the output of the data, which it was not happy about. I eventually stumbled upon a query which limited the output of it, and it works like a charm. The next two variables are fairly less complex than the query itself. The first one performs the actual query with the query you throw at it, and the other variable counts the amount of rows within the table. While I could have avoided this part and hard coded my limit into it, this allows for it to be changed on-the-fly since I'll only have to update the query string if I want to display more entries. The final loop is a bit intense for those not familiar with PHP and MySQL. I know it was for me at first, but over the past two months or so, I've become quite adjusted to it. Here's the break down of it, though. I'll try and keep it short if I can help it... First, we have the while loop. Basically, this says that while the array $output_array is still gathering information from the query performed before, that it needs to execute the code below it. To get the actual data per entry from the query is mysql_fetch_array(mysql_query('some query')). The code I have looks much more clear than this because I made sure to use variables for everything. It's good to try and maintain the peace in sanity, if possible. Within the while statement is another loop that's occurring; a for loop. What's happening here is that first, it initializes a variable ($i in this instance. It could be anything though. $i is a common coding practice in for loops). The variable is equal to zero. The next part says that while the variable $i is less than $rowcount (the amount of rows queried from the DB) to execute a certain line of code below it and then increment $i by one. So what happens is that this for loop is constantly executed while the other loop is still able to gather data from the query. In turn, while this is occurring, it echo's (prints data out) the values it gathers from the query. Each time that the loop is executed, it will print out each new line of data, thanks to our $i variable which increases each time the loop is run. Luckily, that's about as complex as it gets in this script. My description of it is probably very poor, and in turn makes it seem confusing, but really it's a fairly straightforward piece of code. The last two functions are even easier to understand.

2. postMessage(): This is used to post the new entry into the DB

function postMessage() {
#Establish connection to DB
$connection = mysql_connect('localhost', 'mysql_web', 'dbpass');
$database = mysql_select_db('chat');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}

#Gather the data from the POST variable
$message = $_POST['message'];

#Query the data into the DB
$query = "insert into messages values ('$message
', NULL)";
$insert = mysql_query($query);
if (!$insert) {
die('Error:' . mysql_error());
}

flush();
}


Once again, we first initialize our DB connection. Then what happens is we create a variable $message. This variable is used to get the data from the HTML form which I'll explain in a moment. As an aside, you can use $_POST['message'] as the variable name, meaning you don't have to create a new variable for it, but it makes it rather clear so it's probably a good practice to have. After this, we have another query for the DB to execute. This time, we're performing an insert into the DB. Now, you may or may have not noticed that the values here include a "NULL" declaration. Basically, the deal with that is that in my database, there is an ID column which fills itself in (with numerical values) to keep track of each entry. Since we can't insert data into this column, we simply insert a "NULL" statement into the code and it avoids it. This query will change per your DB! So, if you try my script out, be sure to update all of the queries and whatnot to fit your DB. Also, you may have noticed the
code in the query string. I use this to provide spaces between each entry. If this wasn't done, then the text output would basically look like a jumbled mess. I may have also been able to avoid hard coding this
in and insert it into the loop now that I think about it, but either method works.

Finally, after all that, the query is executed and inserts the data into the database and then calls flush() to clear the buffers out.

3. postForm(). This is used to enter and submit the data.

*Sorry, it actually made HTML out of the code I posted. Check out the chat.txt file to see the code*

This is a little bit complex, but to give you the general idea, this creates a little text box, a button which says "Send" and a "Reload" button. This is where you would enter the data and then execute the postMessage() function. Overall this function is basically just some common HTML, with the exception of the $PHP_SELF variable. This simply gathers the name of the file which is being executed without the need to hard code it in. The rest of the string says for the script to execute the postMessage() function.

Since this entry is getting massive, I'll stop it here for now. If you wish to take a look at the code, here it is. Now also bare in mind, there is still a lot of stuff that this script could use. For example, an auto refresh system would be great to figure out. I've seen some done in Javascript, but I would like to avoid having to do that, if at all possible. I'm not exactly in the mood to learn another language just for one function, so if somebody wants to write that or another PHP function for it, by all means do and please share! A login/authentication system would be good to implement with this code also. I may very well do that soon, since the basics are now working like I want them to. I'm sure other features could be tacked onto it also.

That'll be enough for now. If you want to see my script in action though, you can see it here. Take it easy folks.

Thursday, November 23, 2006

Happy Thanksgiving

Well I hope you all enjoy your holiday's very much! I know I will be trying to my best. I'll be thinking of a certain somebody most of time that, well, the only way I can describe my feeling for her is in a card she gave me for our anniversary: "Would you mind very much if I sorta had a little crush on you forever?" Haha =) I love it and her! But anyways, of course, always think about your families and such, even if there is 22 of them coming over into your house for it! Not my house, thank goodness. I'll be in South Jersey today... leaving in a little while for that, so that should be fun (I hope). At least there will be food! So, like I said, keep all your loves in track (friends, family, girlfriend and boyfriends [which really fit into both family and friends to some degree]) and enjoy yourselves! If you're a loser like me on the internet though, then you can enjoy reading and maybe filling this out for yourself. If you do, please share with me! I'd love to see what else other people fill in. Peace and love folks.

This is your life's soundtrack, chose a song for each scene that fits you.

Opening Credits: The Grateful Dead- Eyes of the World (a good live version, the studio one is too studio like)

Waking up/ getting out of bed: Phish- Bouncing around the Room

Getting Ready Scene : Bob Marley- Stir It Up

Car Driving Scene: The Grateful Dead- Alligator

High School Flashback Scene: The Grateful Dead- Saint Stephen

Nostalgic Scene: The Beatles- I'll Get You

Angry Scene: This one is tough... but maybe The Grateful Dead- The Other One

Agony, Painful Scene: The Grateful Dead- So Many Roads (7-9-95 version. Last time Jerry was alive)

Break-up Scene: Bob Marley- No Woman No Cry

Sad, Breakdown Scene: The Beatles- While my guitar gently weeps

Nightclub Scene: uhhh Dr. Dre- The Next Episode

Dance/Party Scene: The band name isn't coming to me, but Sandstorm

Buddy/Sidekick Scene: The Grateful Dead- Mason's Children

Missing Someone Scene: The Beatles- Blackbird

Contemplation Scene: This could be a few Dead songs: The Grateful Dead- Rosemary or The Grateful Dead- Crazy Fingers

Love Scene: The Beatles- Two of Us

Kissing Scene: The Grateful Dead- Blow Away

Relaxing Scene: Railroad Earth- Railroad Earth

Action/Fight Scene: The Beatles- Piggies (hahah I have no fucking clue for this one)

Victory Scene: Railroad Earth- Mighty River

Closing Credits: Railroad Earth- Seven Story Mountain

Sunday, November 19, 2006

Sometimes It's Hard To Let It Go

The title is inspired from a band called Railroad Earth. The song is called "Seven Story Mountain." Quite a neat little song. Today this song fits my mood I suppose. I think I'm beginning to realize that this is really almost like an ending to all things I have known for 18 years running.

Every year around this time, the Ledgewood Mall has the entrance of Santa into the mall. They have a variety of things to do, like a magic show, photo's with Santa, along with other things. One unique thing they do is have a sleigh ride every year. For the past five years or so, I've been basically managing this day long event. Granted, I don't do all of the hard stuff like drive the car, or prepare the car or order the company to come down or anything like that, but I just take tickets, talk to people in line, and help people load and unload. It's a simple thing really, but I think I finally realized how much things are going to change soon enough. It's the last time I will be doing it.

Something about this feeling makes me somewhat excited. On one hand, I feel like within the next six months or so, times will begin to change drastically. I look forward to being able to try new things, and I'm hoping that I'll have enough courage and openness to go and try new things. However, I also get the feeling that I'm leaving a lot behind. Maybe not a lot, just a little, but that little bit of something has worlds of comfort and value to me in it. I'm not always incredible with change, and overall I've been extremely happy the past two and a half years or so. I fear that maybe this change will be very drastic for me, and I'm not sure how I'll handle it.

At any rate though, I don't feel as if I should try and stop. It's like standing in a river and trying to reverse the current. Time won't bend to the strength of a virtual speck of dust in the universe, so maybe accepting it with no resistance will bring better results. I think that sounds right, I'll play this one out like I play most of them out: let happen what must happen. If something isn't right, or something needs to change, well it's changing for a reason, and I need to try and be optimistic about it all. It's always brighter on the other side of the mountain. Not to say that I'm on the dark side of life now at all, but sometimes things may be unclear.

Ah, here we are. Found the lyrics finally! =) From the Black Bear Sessions, here's "Seven Story Mountain":

oh lord, to see a light
but fail in strength to follow
. . sometimes it's hard to let it go

oh lord, to fail in heart
and each day grow more hollow
. . . sometimes i just don't wanna know

but the road that led me here
is begun to disappear
sometimes i wonder where i am

oh lord, to hear a voice
but let it fade & wallow
. . . sometimes it's hard to let it go

oh lord, to find the words
but keep them in & swallow
. . . one day the top is gonna blow

but the road that left me here
is begun to disappear
sometimes i wonder who i am

oh lord, to stumble blind
for years without knowing
. . . sunrise has burned my eyes again

oh lord, to crumble quiet
watching from the silence
. . . sunrise has burned my eyes again

it's a Seven-Story-Mountain
it's a long-long -life we live
gotta find a light & fill my heart again

it's a Seven-Story -Mountain
it's a long-long-life ahead
gonna find a voice & fill my throat again.
Thanks to the Yahoo group Earthboard for hosting the lyrics to all three albums (not including Elko, the recently released live album. Not much reason to have lyrics for that). Take it easy folks.

Thursday, November 16, 2006

Hmmm...

The new blogging system is "ready for me" according to Google. Figured I'd give it a shot and see what's different and what's not. So far, similar. I'm fine with that. Hopefully it'll be more reliable like it says, even though I still plan on eventually moving over to my website as a blog.

Anyways, I'll be honest, I've been in a kind of crappy mood this entire week. The weather's been poor and way too hot, I'm stressing myself out and being extremely paranoid, I can't seem to think straight or learn anything really well and I'm feeling a bit ignored. It's rather frustrating, but I guess we can't all have fantastic weeks. I've had a pretty school year so far, so maybe I'm just getting what I deserve for a little while.

The real neat thing about this week is that I've felt the most comfortable at work. I'm really not sure why, but I really have. I guess it just verifies that I'm distracted and doing something else other than just thinking about everything all in a giant sweep. Eh, whatever works I guess.

At least the weekend is coming. I'm hoping that this will turn out better than the week, but obviously life won't make me any promises. We'll see what happens.

On a brighter note, I almost have enough money for my new computer! That'll be real nice when I get enough for it. So close, yet so far haha. I'm thinking in about two weeks or so I'll be ready. Once that's done, I'm basically going to begin saving all my checks again in the bank since I've been doing really poorly with that recently.

Alright well, I guess I should go sleep or lay down now and try to relax a little bit. I'll be sure to write again soon. Later folks.

Sunday, November 12, 2006

Yet Another Four Day Weekend

I missed out on. Well, I guess not entirely considering I wasn't in school, but still. Thursday was no school and work, Friday was leaving really early for Clarkson. Clarkson was a very nice visit, to say the least. I was very entertained by Clarkson. The Clarkson Open Source Institute (COSI) is really amazing. I have yet to see anything like this at any other school I've visited. While I was there, they were installing a new $80,000 dollar IBM Blade server which was given to them from IBM to do Xen development. Epic? Indeed. The only thing I forgot to do was get a photo... I probably could have used it in my senior project. Oh well, thought.

Anyway, after that, I visited UVM the next day. I was disappointed honestly. The school was very nice, and the people were pleasant, so those were good things. I was disappointed in the fact that they didn't seem to care so much for the academics of the school, which is basically the point of school. Granted, I'm down with having a lot of fun, and that's important too, maybe even more so than working and things like that, but you have to have some work ethic. It didn't seem like they had much at all here. This is just my opinion honestly... an actual student may be able to tell you otherwise. For all I know, it could be great, but the open house gave me kind of a disappointing perspective on it. Oh well, though.

I don't have a ton to write about tonight. I've been hacking away at my senior project as much as I can this weekend. It's starting to shape up pretty nicely. Still a ton more to do, but it's really starting to feel more like an application as opposed to a series of files which kind of work together. I'm pretty happy with how it's shaping up. Once I get it working real well, I may write some stuff about how it works on here (or maybe on my website, if it's my new blog by then). I wonder what else I'm going to end up programming once I finish this project. It's basically been my entire programming life since September, so I'm not sure what'll happen once it's done. Well, I suppose I'll find out when I get there.

Ah, I can't wait to retire. Later, folks.

-dswain

Tuesday, November 07, 2006

Midterms

Man, lame.

Anyway, finished first round of midterms today. Computer Apps 2 and Physics... you guess which one was the challenger. Haha, well I think I did fairly well on each one, so I'm not too worried about anything.

Wow just found out a nice reason to use Firefox 2. My power just went off for a moment and came back on. Having the "restore session" option is a very nice thing. No more lost blog entries =) now only if they had that feature during my Modblog days! Sheesh, that would have been nice.

Back on topic though, tomorrow is my chemistry midterm. I'm pretty sure my other two classes are going to be simple compared to the chemistry midterm, but I'm not entirely sure. I'm taking a break from studying for a moment, or maybe I'll just call it quits for tonight. Not sure yet really. Anyway, I'm hoping for the best on it. I feel better now that I've reviewed, but I'm sure there's stuff I've missed. Oh well though!

So I'm looking into actually buying a video game system: the epic GameCube. I was playing it at a Wal Mart the other day, and it was a lot of fun. It's got some neats games out for it (Star Fox, Mario Sunshine, Mario Kart Double Dash, etc.) and the system/games are cheap. It's about 100 bucks for a new console and anywhere from 15-40 bucks for a game. Also another sweet thing is that the new Legend of Zelda: Twilight Princess comes out for both the Wii and GameCube, so that'd be worth it in itself. I haven't played many games at all recently, so it might not be a bad thing to get back into a little bit. With a GameCube also, I'll end up with a nice variety of games and for a reasonable price. Firstly though, I'm going to build my new computer, which I have just about enough money for now thanks to my latest check.

... I better start saving money again.

That's about all for me folks. Take it easy.

-dswain