{"id":1542,"date":"2013-01-01T16:16:02","date_gmt":"2013-01-02T00:16:02","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=1542"},"modified":"2015-04-09T08:05:28","modified_gmt":"2015-04-09T15:05:28","slug":"organizing-the-spice-drawer","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=1542","title":{"rendered":"Organizing the spice drawer."},"content":{"rendered":"<p>We try to keep our code clean and commented but every once in a while we do some maintenance that falls into what I call \u201cOrganizing the spice drawer.\u201d It\u2019s not something that has to be done and the amount of time lost by not doing it is small, but it\u2019s just one sign of a well organized shop. The same applies to our server, backups, and the office in general. This time of year is perfect for these endeavors because there\u2019s not usually much else going on.<\/p>\n<p><b>Log files<\/b><br \/>\nWe set up the server logs to automatically archive and then delete themselves so we don\u2019t have to worry about them. We do have some custom logging programs that write data to the MySQL database. They\u2019re not huge, but we\u2019ll never use more than a year\u2019s worth, so they get manually cleaned from time to time. I just deleted 45,000 records from one database.<\/p>\n<p><b>\/tmp<\/b><br \/>\nIt\u2019s a good idea to check what\u2019s in here from time to time. We has some session cookies that weren\u2019t being properly expired so we wrote a cron job to remove them. There were also some files created by a shell script that weren\u2019t getting deleted, so we adjusted the script to remove them.<\/p>\n<p><b>php.ini<\/b><br \/>\nEvery once in a while, it\u2019s a good idea to review the settings in the php.ini file to make sure you are happy with them. In our case, we were getting warnings from two deprecated commands, register_long_arrays and magic_quotes_gpc and we decided to turn them both to Off since we don\u2019t have any code that relies on them and the code that triggered the warnings is in WordPress. The WprdPress code works fine if the settings are Off.<\/p>\n<p><b>BAK files and databases<\/b><br \/>\nBefore we do any major change to a file or database we make a backup copy. These usually get deleted when we&#8217;re happy with the result, but sometime they stay around when they aren\u2019t needed any more. For the database, I make a complete dump of the database to a .sql file and then remove databases that are backups. If I ever need them, I\u2019ve got the backup in storage.<\/p>\n<p><b>Orphans<\/b><br \/>\nOur websites have been up since 1998 and we sometimes end up with files that are no longer referenced. If we suspect that a file is not used anymore we grep for its name in the web directory and if it\u2019s not found we put a line of code in it that writes to the server when it is referenced.<br \/>\n<pre><code class=\"preserve-code-formatting\">\n$refer=mysql_real_escape_string($_SERVER[&#039;HTTP_REFERER&#039;]);\nerror_log(&quot;Accessing Orphan File with referrer $refer&quot;);\n<\/code><\/pre><\/p>\n<p>If we reference it from one of our pages, the referrer will be our site. If not, then either it\u2019s being accessed by a spam-bot or another website that has an old link to us. Either way, we can then deal with it.<\/p>\n<p><b>Spambots<\/b><br \/>\nLately, spambots have been hitting just about every page with a submit button on it. They can\u2019t do anything on those pages but I\u2019ve started logging their attempts using the method described in <i>Orphans<\/i> above. If it\u2019s a real problem we may start requiring CAPTCHAs or simple radio buttons that default to &#8220;I am a robot, please ignore this request&#8221;.<\/p>\n<p><b>Error logs<\/b><br \/>\nWhen we updated to the latest version of PHP our database access method, PEAR, was deprecated. That generated literally thousands of error messages. Over time we updated the code, but there were still lots of errors generated for pages that aren\u2019t accessed that much. With so many error messages, it\u2019s hard to see real errors. So we spent a half day finishing off the update. Now the error logs only show the log messages that we want it to show and we can quickly check for errors.<\/p>\n<p><b>Wikis<\/b><br \/>\nWe have a wiki for office procedures, how-to&#8217;s for ordering supplies, adding users, version numbers for our products, etc. This is the kind of thing that can quickly become out of date if it is not updated regularly. A couple of times a year, we review the wiki and make updates for changes to our processes that were made, but didn&#8217;t make it into the wiki.<\/p>\n<p><b>Office Electronics<\/b><br \/>\nDo we really need 12 VGA monitor cables? Three turntables? The 12 year old computer that only runs OS9? The box of old hard drives\u2014the largest of which is 5GB? We don\u2019t keep a lot of stuff we don\u2019t use but things get shoved under desks and put in boxes on the bottom shelf and forgotten about. Every once in a while we make a big pile of stuff and take it to the electronics recycling center. I have yet to regret throwing away anything.<\/p>\n<p><b>Books<\/b><br \/>\nWe got rid of a complete shelf of books. I will never need the manual for Photoshop 4 or Flash 5. In fact, I haven\u2019t used a manual for years, relying instead on the web for the answers to most of my questions. My guess is next year the other two shelves of books will be gone.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We try to keep our code clean and commented but every once in a while we do some maintenance that falls into what I call \u201cOrganizing the spice drawer.\u201d It\u2019s not something that has to be done and the amount of time lost by not doing it is small, but it\u2019s just one sign of &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=1542\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Organizing the spice drawer.<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1542","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1542"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/1542\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}