Posts

Showing posts from May, 2011

Cars 2 trailer, in LEGO

ZOMGWTFBBQ! I'm *almost* through in my LEGO City Space collection (just one more set!). Will this be the next one? PS. Yesterday's post was my 666th. Just saying.

Paean to the letterpress

(I missed the smell of ink and the sound of rolling presses. Heidelbergs, Bodoni and Blueback are personal favorites. I loved the way I can lay out pages on a grid, and then mess it up by extending beyond the column guides {the old technician laying out the leads always threw a fit!}. Photogravures were "cutting-edge" and novelties. {Yes, Pagemaker was still in its infancy when I started, and I didn't want anything to do with Ventura Publisher.} {I'm showing my age...:P}) Letterpress from Naomie Ross on Vimeo .

Customize fatal error messages in Perl CGI apps

We all know Carp and CGI::Carp, and they're quite useful when catching errors in your apps. But, the messages are butt-ugly, sorry to say. CGI::Carp to the rescue. It has some nifty functions that can be used to make the error messages friendlier. To set a custom message when fatal errors are encountered: use CGI::Carp qw(fatalsToBrowser warningsToBrowser set_message); ### Custom fatals browser message BEGIN { sub handle_errors { my $msg = shift; my $err_mail = "Error%20message:%0A%0A\ -------------------------------------------------------------------------------%0A\ $msg%0A\ -------------------------------------------------------------------------------%0A"; my $err_msg = " \ Encountered an error: \ $msg \ Click here to send a report. \ "; print($err_msg); } set_message(\&handle_errors); } (Side note: The mailto URI scheme has some great extensions as well.)

Robot Sunday: "I'm doing Science and I'm still alive"

(Okay, technically, GLaDOS is *not* a robot but an AI, but this is still cool.)

Roll your own package, RPM repo, part 2

(Part I, building the package , is over here .) Part II. Create the repository Prepare the environment in the server where the repository will be stored. Note : All commands from hereon, unless otherwise stated, are by root . mkdir -p /srv/RPMS/{i386,i586,x86_64,noarch} Add the package created from Part I . cp ~username/builds/RPMS/noarch/this-package-1.0-0.1.noarch /srv/RPMS/noarch/ Generate the repository metadata. createrepo -v /srv/RPMS Sign the metadata and add the repository key. cd /srv/RPMS/repodata gpg -ba repomd.xml gpg -a --export key-id > repomd.xml.key Add as an installation source. (In this case, I'm using SuSE zypper .) Add the key to the trusted keyring. zypper service-add -t YUM file:///srv/RPMS alias Test by installing the package. zypper in this-package

Roll your own package, RPM repo, part 1

(This is more a note to myself than anything else. Surely, there are lots of references out there on the net... ;)) Part I. Build the package Prepare the build environment. mkdir -p builds/{BUILD,RPMS,SOURCES,SPECS,SRPMS} Add the sources to be built. mkdir builds/BUILD/this-package-1.0 && cd builds/BUILD tar czvf ../SOURCES/this-package-1.0.tgz this-package-1.0 cd .. Write the spec file using the skeleton below. vi SPECS/this-package.spec %define _topdir /home/username/builds %define _sourcedir %{_topdir}/SOURCES %define _builddir %{_topdir}/BUILD %define logmsg logger -t %{name}/rpm Name: this-package Version: 1.0 Release: 0.1%{?dist} Summary: Summary goes here Group: Group/goes/here License: GPL URL: Not required Vendor: Company you work for, probably Distribution: Group for specific distribution Source: %{name}-%{version}.tgz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release...

Remove version numbers from package names

/bin/rpm -qa | sed 's/-[0-9].*//' is wrong . Use this instead: /bin/rpm -qa --qf "%{n}\n" Mad props to ssatoh and rhonda . That is all.

Check printer status via SNMP

So we're asked to monitor several "critical" printers. Instead of accessing the printers' administrative console using ` curl ` (a kludge, yes), we opted for SNMP -- easier, but unfortunately less secure for the printers. SNMP OIDs for the printer are readily available so this looked easy enough. To get the printer console's display, for example, one just issues: /usr/bin/snmpwalk -v1 -On -c $community_string $printer_address \ 1.3.6.1.2.1.43.16.5.1.2 | awk -F: '{print $NF}' \ | sed 's/\"//g;/^$/d;s/^\s//' Fortunately, most of the steps (getting the OID from the printer MIB, rehashing the output into something usable by Nagios) are already done for use by a nifty little shell script, check_snmp_printer.sh .