Programming


Programming September 14th, 2009 by HMTKSteve

Ever have one of those days where you find yourself copying and pasting a ton of HTML code into your Wordpress install? You're making excellent progress moving data over and you feel real proud of yourself. Then something goes wrong.

The something I am referring to happened to me this evening. See, I never use the visual editor in Wordpress but tonight, after pasting several hundred articles, I went to look at the site and was horrified to see that all of my work had been copied into the visual editor and not the HTML editor!!!

Yes, I was viewing wordpress posts that were showing pure HTML to the viewer!

Being technically inclined I knew that there was no way I would spend the next hour copying from the visual editor and pasting into the HTML editor for each post. Instead I used my brain and logged directly into the database and ran the following two queries:

UPDATE wp_posts SET post_content = REPLACE(post_content,'&lt;','<')
UPDATE wp_posts SET post_content = REPLACE(post_content,'
&gt;','>')

This simple little bit of code goes through the entire wp_posts table and replaces the HTML code for the opening and closing HTML brackets with the brackets themselves for all post content.

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.

Programming December 13th, 2007 by Stephen

OSLO, Norway & TUEBINGEN, Germany--(BUSINESS WIRE)--Trolltech®, the leading cross-platform software development company, and KDE e.V. today announced a technical collaboration on the development of Phonon, a cross-platform multimedia framework that makes it simple for programmers of all experience levels to incorporate multimedia functionality into their applications.

Phonon was initially developed by the KDE community and will be part of the upcoming KDE 4.0 release. Trolltech has now extended Phonon so it can be used on all major desktop operating systems, including Windows® and Mac® OS X. Additionally, Trolltech is contributing its code into the KDE source code repository and has licensed it under the LGPL.

Phonon makes it easier than ever before to include multimedia playback in C++ applications, and most operations can now be accomplished with very little code. The original code for Phonon included a single, Xine-based backend that worked only on UNIX and Linux platforms. Trolltech has created additional backend implementations for GStreamer on Linux, plus backends for Windows and Mac OS X.

Trolltech will incorporate Phonon into the company’s upcoming Qt® 4.4 release, currently scheduled to be released at the end of Q1 2008.

By developing Phonon components within the globally accessible public KDE source repository, Phonon developers are able to watch and participate in the development of Trolltech's Phonon back-end code and library code contributions. This also allows the community to evaluate and provide input into the work being done by Trolltech’s internal development team. KDE, in turn, benefits by having Trolltech's employed developers contribute to the ongoing development and maintenance of Phonon, freeing KDE developers to work on other aspects of the desktop. . This is a marked change from how open source libraries are usually integrated into commercial products, which has typically involved pulling snapshots of the open source code into the commercial product. Additionally, the Windows and Mac OS X backends will enable KDE4 applications running on these platforms to include multimedia functionality.

About KDE

KDE is an international technology team that creates integrated Free/Open Source Software for desktop and portable computing. Among KDE's products are a modern desktop system for Linux and UNIX platforms, comprehensive office productivity and groupware suites and hundreds of software titles in many categories including Internet and web applications, multimedia, entertainment, educational, graphics and software development. Building on the cross-platform capabilities of Trolltech®'s Qt®, KDE4's full-featured applications run natively on Linux, BSD, Solaris, Windows and Mac OS X.

About Trolltech

Trolltech® creates cross-platform application development frameworks for desktop and mobile device innovation. Trolltech's software increases the appeal of our customer's desktop applications and devices while reducing their risks and software development costs. Trolltech's technologies accelerate the evolution of software by unleashing the creative power of the developer.

Trolltech software is the foundation for thousands of leading products worldwide, many from Global 2000 companies. Trolltech is a second-generation open source company, with a dual licensing business model that supports open source values and methodology in a profitable, sustainable business. The company is listed on the Oslo Stock Exchange under the ticker symbol TROLL. For more information about Trolltech, please visit http://www.trolltech.com.

Trolltech, Qt and Qtopia are registered trademarks of Trolltech ASA. All other trademarks are registered trademarks of their respective owners

Programming September 28th, 2007 by Stephen

Have you ever had one of those days when you receive so much traffic from a particular site that you need to redirect that traffic to a cached copy of your content? If you can gain access to your .htaccess file than you can implement this very quick bit of code

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} (example.com) [NC]
RewriteRule myarticle.html http://www.cacheserver.com/myarticle.html  [R,L,NC]
</IfModule>

The above short code snippet will allow you to send all traffic that comes from example.com looking for myarticle.html to the alternate location of cacheserver.com/myarticle.html. This little bit of code can come in very handy when a particular social media site is sending a ton of traffic to your MySQL/PHP site causing it to crash.

You do not even need to send it to another server. If you simply create a static page on your existing server (I like to use a cache directory) you can send the traffic there. In all honesty it is far better to serve the cached copy from your own server than to send it elsewhere.

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

Programming May 28th, 2007 by Stephen

You need to be a programmer to understand these:

0001. No matter how many times you call an "X" no one gets jealous.
0010. Using the same line over and over again always works!
0011. Accurate comments make everyone happy.
0100. If something is not working correctly you can always change the source code.
0101. Programs don't get offended if you let your friends play with them.
0110. When you write a useful function you can add it to all of your programs.
0111. You can write a program to take input from multiple sources without complaining.
1000. You can not run a program for years and it is always ready when you want it.
1001. You can play with more than one program at the same time.
1010. Programs don't complain when you use "helper" programs.
1011. Programs exist to serve YOU.
1100. No one goes to jail when they kill a program.

Yes, I'm numbering these in binary.

That is my short list, I hope you like them and feel free to add your own in the comments.

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!

Next Page »


ss_blog_claim=50369052f04070d4855a2cf2adc3eab6 ss_blog_claim=50369052f04070d4855a2cf2adc3eab6
Top Blog Lists      Computer and Video Game Blogs -  Blog Catalog Blog Directory

94 queries. 0.276 seconds.