I created a script that is run via cron that backs up the database of one of my websites, gzips it, and emails it to me. It works great, but I like to use a text editor to search and replace the domain name, so that I can use it in a development environment. As the backup file has been getting larger, I’ve reached the point where neither Sublime Text or gedit will do a “Replace All” without totally freezing. Linux makes this a non-issue:
#search for production.com and replace with dev.com
sed -i 's/production.com/dev.com/g' ./production-dump.sql
#overwrite dev database
cat ./production-dump.sql | mysql -u username -ppassword database
If you want to make a database backup, it’s better to not use phpMyAdmin, because larger databases will cause that method of backup to fail. Instead, just use mysqldump, which should already be installed if mysql is installed:
mysqldump -u username -ppassword database | gzip > ./dumpfilename.sql.gz
gunzip < ./dumpfilename.sql.gz | mysql -u username -ppassword database
It’s a pretty common thing to find an app that doesn’t specify to MySQL the timezone that should be used when storing dates and times. Once you’ve fixed that, you may still have a bunch of dates and times that need to be converted.
Today I finally had time to take my forms offline. I’m too busy to take on new customers, and trying to estimate a time when I can schedule a new project is unreasonable. I have mixed feelings about this, but what else can I do?
I’ve used Linux for years, primarily Ubuntu Desktop and Server. Recently I had been purchasing computer parts, anticipating the building of my next computer. Last Monday I put it all together, and started in on loading my operating system of choice, Ubuntu 14.04. Moving forward, I then started installing the essential programs that I use. I really didn’t run into any problems, until I made a stupid mistake while adding myself to a group.
It’s not every day that one needs to search a multi-dimensional array for a key, and return the associated value, but a simple recursive function allows such an action. In a project I was working on recently, I needed to check the status of a record, but the status array was segmented into three main categories.
So I wrote a quick recursive function to handle the task. Please note, the function will only work if all keys are different. No two keys in the multi-dimensional array can be the same! Yes, I said it twice, but to emphasize that it matters.
I was working on a website this week where I wanted to use WordPress so the client could benefit from its CMS and blogging capabilites, but also wanted to use a PHP framework to handle some custom programming. Compared to WordPress, almost any PHP framework is going to be easier to do custom programming with. But what about routing? How will the website know what to route to the framework, and what to route to WordPress?