Tech Tip: Multi-line Perl regex pattern match
Posted by John Minnihan - 18/06/09 at 09:06:53 amYesterday, I encountered an analysis issue that appeared to be resolvable with a simple pattern replacement technique.
Continue reading Tech Tip: Multi-line Perl regex pattern match…
Popularity: 24% [?]
Quick file & directory cleanup tools
Posted by John Minnihan - 15/06/09 at 06:06:19 pmEvery sys admin needs to quickly free up disk space from time to time, and here are two well-tested scripts I use for exactly this purpose.
The first is a simple command-line use of exec that uses find to construct of list of matching file names, in this case all gzipped tarballs, and then runs the rm command on them. The curly braces "{}" act as a holder for each file name from the list, and the trailing "\" is used to escape the ";", so that it is passed to find as a literal command terminator.
#find . -name *.tar.gz -exec rm {} \;
You may find (pun intended) that you need a slightly more sophisticated way to construct the list of things to remove. For example, to recursively delete all files & directories from an arbitrary depth in the file-system, except for special files or directories. To accomplish this, I use a small Perl utility I wrote that uses the File::Find module.
Here is the actual script I use generalized out with a fake $top and /some-pattern-to-exclude/. This script will crawl down (actually the direction that finddepth goes is up) a list of files & directories, and unless the pattern is matched, each file in the directory & then the directory itself is deleted.
How does this work? Pretty simple – the File::Find module loads some routines, one of which is finddepth. The first argument it expects is a routine to run against all files & directories found, starting at the location named in the second argument. The wanted routine is run on each element in finddepth’s list & you can use finddepth’s variables to make your wanted routine smarter.

Tags: tech tips, perl, sysadmin
Popularity: 3% [?]
Converting .DOC to .PDF. Is this difficult?
Posted by John Minnihan - 26/01/08 at 02:01:46 pmIf you are using a Mac running a recent version of OSX, the answer is No. In fact this is super easy and is available from inside Microsoft Word. If you run Windows, this feature isn’t available without an additional plugin from a third-party.
Continue reading Converting .DOC to .PDF. Is this difficult?…
Popularity: 2% [?]
Gmail, Apple Mail & the iPhone
Posted by John Minnihan - 17/11/07 at 11:11:42 amSince Gmail began supporting IMAP, setting up Gmail to work with both Apple Mail & the iPhone is a common need for those of us with both iPhones and new Macbooks.
I began using Gmail about two weeks and had noticed the inconsistencies mentioned in the below article, and was both pleased to see that the solution was so simple as well as slightly embarrassed that I hadn’t yet resolved the issue myself.
Here’s the HOWTO:
http://5thirtyone.com/archives/862
Tags: gmail, iphone, apple, mail
Popularity: 1% [?]
AJAX Logfile Tailer & Viewer
Posted by John Minnihan - 13/04/07 at 01:04:11 pmRecently I had a need for a simple logfile viewer for use in some stuff we have planned at Freepository. But this log file viewer had a few requirements that made it unique: it had to get the log file contents from the server in small chunks, not tie up the browser (such as an old-style synchronous request would do), and refresh in the browser without reloading the page.
I thought I could easily find one that someone had already written, but Google was not my friend. I found nothing even close, so I wrote my own. Here it is.
Working example: https://freepository.com/ajax-logtail-viewer/ajax-logtail-viewer.php
Continue reading AJAX Logfile Tailer & Viewer…
Popularity: 100% [?]
Tech Tip: Publishing iCal Calendar in Multiple Places
Posted by John Minnihan - 13/03/07 at 04:03:37 amRecently I had a need to publish a calendar in more than one location. Simple, right? Just use Google calendar, Boxes, or one of the other free services. Not quite. I don’t want to manage any users, nor give anyone direct access to an account that is hosting the calendar. I want to publish, not provide direct access to, the calendar.
Continue reading Tech Tip: Publishing iCal Calendar in Multiple Places…
Popularity: 11% [?]
A Powerful Custom Spamassassin Rule
Posted by John Minnihan - 19/02/07 at 04:02:04 pmTech Tip – Spamassassin Custom Rule
I had been inundated with so much spam lately that I added some custom rules to my spamassassin setup. These rules are added to your local.cf (don’t put them in /usr/share/spamassassion, as they’ll get overwritten with the next SA update). The single most useful one for me in this bunch is the LOCAL_RETURNED_MAIL rule.
Continue reading A Powerful Custom Spamassassin Rule…
Popularity: 18% [?]
Tech Tip of the Day: Quick file deletion
Posted by John Minnihan - 18/09/06 at 10:09:52 amHere’s another quick tip. If you have a large directory tree (hundreds or thousands of nested levels), and you need to find and delete a set of files from the tree, consider this one-line approach:
cd [target-dir-top-level];for i in `find . -name \*tar.gz`; do rm -f $i; done
Replace my pattern ‘tar.gz’ with one that matches the files you wish to delete.
Tags: freepository, tech-tip, shell scripting
Popularity: 7% [?]
Tech Tip of the Day: MySQL binary export
Posted by John Minnihan - 31/08/06 at 04:08:47 pmThis is a short and sweet tech tip. If you have binary data, such as images or zip files, stored in a mysql database, this technique will export those blobs (binary large objects) back to the file system.
Case:
Bugzilla attachments exist in mysql that now must be exported to another bug tracking system.
Approach:
Run this query
select thedata from attachments where bug_id='224' and mimetype not like 'text/plain' and mimetype not like 'text/hmtl' into dumpfile '/data/bug-224-attachment.zip';
for each bug that contains a binary attachment. You can extend this approach by writing a script that queries for all bugs with attachments, then acts only on those those that are binary attachments. Since you may wish to include the file type attachment in the dumpfile name, consider adding an additional loop that checks for the mimetypes that correspond to each of the various binary formats (jpg, zip, etc.). Pass both the bug_id and the mimetype into the filename that you create in the dumpfile.
Tags: freepository, tech tips, mysql
Popularity: 6% [?]
Tech Tip of the Day: mod_rewrite & AllowOverride
Posted by John Minnihan - 05/08/06 at 08:08:54 amRecently, an upgrade of the OS on the commavee server resulted in the blog post URLs failure to resolve. Earlier blog posts, with the date-and-post title formatted URL, were now unresolvable. This meant that every post in the search engines (and even the site itself) resulted in a 404 Not found error. It took a bit of investigation, but the solution was straight-forward.
Continue reading Tech Tip of the Day: mod_rewrite & AllowOverride…
Popularity: 16% [?]
Powered by WordPress and |
themesbase with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.
Found a new radio station in Denver today,