Programming


Programming December 13th, 2007 by HMTKSteve

Last night I needed to edit a few lines in a php file on one of my sites. I loaded up my ftp client and grabbed a copy of the file onto my local machine.

Not paying attention I just double-clicked on the file and it opened up for editing. After changing a few lines I saved it and put it back on the server, overwriting the previous copy. That is when all hell broke loose!

My site started acting wonky and blank pages were showing up in some areas but not in others. That is when I looked a little closer at the file on my desktop and noticed the notepad icon.

I quickly opened the file in one of my code editors and fixed the problem.

The key point here is that unless you are using a Microsoft IDE product DO NOT use a Microsoft text editing program (Word, Wordpad, Notepad) to edit a php file. when those programs save a file they throw a bunch of non-standard characters in there that cause problems.

Internet and Programming and Technology June 15th, 2007 by HMTKSteve

The Sunfire v20z is a pretty astounding little server. Dual Opterons and a fantastic service processor in one rack unit.I now have a dedicated server. Yup, it's all mine! which also means the problems are all mine too.

"What kind of problems," you ask?

Well, I moved the first site over last night. It is a low traffic blog so I figured that would be the "testing" site I would use to make sure everything on the server is working the way it should be.

Setting up the domain and doing the DNS work was simple enough. I built a domain template and a user account. I fiddled around with the Plesk control panel. I built and destroyed databases. I built and destroyed domains. I was having fun just playing with all the power at my disposal!

"What kind of problems," you ask again?

Setting up the domain and DNS entries was very easy. Moving all of the files over via FTP was also easy. Creating the database and populating it from a backup of the old database was also easy. Trying to figure out why the site is slower than a snail is not so easy.

The site in question uses WordPress. According to Wordpress.org all I need to do to move to a different server is move the files and make any db changes in the config file. No problems there, so why is the site dogging?

I loaded up some basic html files into another directory and everything works fast.

I put another php/mysql program in a different directory on the server and it also worked fine except for one file that would not load. I think that may be related to WordPress and the mod_rewrite rules in the .htaccess file because something similiar happened on another site I own.

So now I'm sitting here scratching my head and wondering why the WordPress install is taking 30-45 seconds between page loads.

This may be a long weekend for me.

image from flickr user plutor used under CC license

Internet and Programming April 30th, 2007 by HMTKSteve

This applies only to super users who have db access rights. This feature should not be abused. It should only be used in cases of harrasment.

A problem that sometimes arises is that of users sending nasty-grams via PM to each other. Unlike some forum software, vbulletin does a good job of keeping private messages private.

If you find yourself in a situation where you need to know the contents of a private message the following two SQL queries can be performed in the back-end of the vbulletin admin area.

Code:

select * from vb3_pmtext where fromusername='USERNAME'

The above code snippet (change USERNAME to whoever you are searching for) will pull a listing of all PMs sent by a user.

Code:

select * from vb3_pmtext where touserarray like '%USERNAME%'

The above code snippet (change USERNAME to whoever you are searching for) will pull a listing of all PM's sent to that user.

Once again, these two commands are very powerful and should only be used when the need is great. Remember, your forum community places a good deal of trust in you, it is up to you to keep that trust by not abusing the privacy of private messages.

Internet and Programming March 22nd, 2007 by HMTKSteve

If you run a web server that uses a database such as MySQL then you should be doing backups, often.

When I was in charge of the web server for Kenzer and Company we used a 7-day rolling backup system. This system insured that, in the case of a problem, we had several days worth of backups to fall back on.

This proved very helpful as we once lost our forum database right before the nightly backup job. This resulted in the most recent backup file to be useless and the previous nights run was used to restore the database.

#!/bin/sh

/bin/cp /usr/home/website_name/backup/database_name.6.gz
/usr/home/website_name/backup/database_name.7.gz
/bin/cp /usr/home/website_name/backup/database_name.5.gz
/usr/home/website_name/backup/database_name.6.gz
/bin/cp /usr/home/website_name/backup/database_name.4.gz
/usr/home/website_name/backup/database_name.5.gz
/bin/cp /usr/home/website_name/backup/database_name.3.gz
/usr/home/website_name/backup/database_name.4.gz
/bin/cp /usr/home/website_name/backup/database_name.2.gz
/usr/home/website_name/backup/database_name.3.gz
/bin/cp /usr/home/website_name/backup/database_name.1.gz
/usr/home/website_name/backup/database_name.2.gz
/bin/rm -f /usr/home/website_name/backup/database_name.1.gz

/usr/local/bin/mysqldump -f -database_password --result-file=/usr/home/website_name/backup/database_name.1 -u databse_username --databases database_name
/usr/bin/gzip /usr/home/website_name/backup/database_name.1

If you look at the code you will notice that the backup directory is not public_html where your html files go. It is very important to keep your online backups in a directory that is not public!

It is also important to download your backups after you make them to insure against a server losing it's hard drive. You could put a secondary drive on your server and map it to /perm_backups and have this same chron job copy the file there as well. Either way you need to keep your backups stored in at least one additional place to insure against a hard disk failure.

    To use the above cron job

  • website_name - the name of your website directory on the server. If you run multiple sites on the same server each one has it's own directory.
  • database_name - the name of the database.
  • databse_username - the database account used to run the backup. This account only needs read access to the database.
  • database_password - the password for the account used to run the backup.

That is about it. Be sure to give the file a name backup_job.sh and add it to your cron jobs. Yes, the file does need to be executable to work!

Links and Programming February 28th, 2007 by Digg

Both refer to their clients as 'users', offer the first one for 'free' and have 'Asian' connections. Hmmm... is there some cross-over here?

I found this by using StumbleUpon and thought I might Digg it as well. There are some similar entries on Digg but this one is a little bit longer.

If you like it Digg it or leave a comment. If not you can always bury it.

As a software developer I get a kick out of this, mostly because it's all true!

read more | digg story

Internet and Programming February 21st, 2007 by HMTKSteve

I recently moved my blog from Serendipty to WordPress. During this long process I ran into a brick wall.

I had been intending to reuse all of my old URLs and place the new blog in the exact same place as the old blog but I encountered a problem.

The Serendipity blog allowed me to use some special characters in the url, this is something WordPress will not do. This was not a major issue as there are ways to have Apache rewrite URLs for you.

The big problem had to do with the fact Serendipity creates a URL with "index.php?/" in it. WordPress does not like the "?" in a URL.

I looked and looked all over the web but everywhere I went told me to put the URLs into a .htaccess file and reroute them that way. I tried that and... because of the "?" all links were being redirected without the argument that followed the "?".

So, if someone followed index.php?/cool-article or index.php?/not-so-cool-article they would all be dumped at the main page for my new blog! The redirect was redirecting the index.php request and ignoring everything else.

Being the resourceful programmer that I am I did some digging and found some PHP code that I could use that would grab the argument, remove any forbidden characters and redirect the reader to the right post.

Here it is, use it if you need it. Just to be sure to change the hmtk.com reference!

<?php
$page = basename($_SERVER['QUERY_STRING']);

$page = str_replace(',', '', $page);
$page = str_replace('+', '', $page);
$page = str_replace('!', '', $page);

       $new_url = "http://www.hmtk.com/archives/" . $page;
       header("Location: $new_url");

?>

Programming November 21st, 2006 by HMTKSteve

No, I'm not being held hostage by Russian web hackers!

For the past few years I've been "selling" some character generation software for the HackMaster RPG from Kenzer & Company.

I've recently become more involved in other things, one of which is building an addition to my home.

Because of this, I no longer have the time to work on HMTK.

I would like to release the source code in an open source format so that others may continue where I left off. At the same time I do have some bills to pay so I can't just open source right away.

This is why I'm going with the ransom system.

Here is how it will work. Once this blog makes $4K USD from advertising, donations and affiliate sales I will release the full source code for HMTK/wxHMTK on the main site as a download.

As people make changes to the code and send them back to me I will incorporate them into the project and make them available for download.

It's been a wild ride getting to this point but I can't devote the time and energy to the project any longer.

This may not be the best solution, but it is the best one I can think of.

I will provide monthly updates starting in December.

Thank You.

Programming and Technology October 22nd, 2006 by HMTKSteve

Ever have a program in X go wrong and blank your screen? This handy Linux tip should help.

The other night I was trying to get some fan-sub anime to play on my Linux box but it was encoded in xvid and I did not feel like taking the time to check which player was setup to play xvid avi files.

Instead I used trial and error to play the file through each of the media player programs I had installed.

Then, while running VLC I tried to go full screen and everything went wrong.

My screen went blank but the audio was fine. Nothing I could think of was working to get me a menu.

I took a deep breadth and thought about it.

In Windows you would hit Ctrl-Alt-Del to bring up the proccess manager screen and try to kill a run-away application that way, but what about Linux?

So I hit Alt-F2 to bring up a new terminal and logged in as myself. I then ran "top" to see what was running on my system. There it was, "xvlc," the guilty party!

With top running you need only hit "k" and enter in the proccess ID to kill it.

I killed it and hit "Alt-F7" to return to my x-windows.

There you have it.

If you get stuck with a run-away proccess you need only open up a terminal and run "top," then use "k" to kill it!

I hope this helps!

Next Page »


Top Blog Lists      Computer and Video Game Blogs -  Blog Catalog Blog Directory

86 queries. 0.549 seconds.