For security, troubleshooting and client billing reasons went to turn on Varnish Cache logging today.
On Debian (should be the same in Ubuntu), with varnish 3.0.4 packages installed from repo.varnish-cache.org, it's all done in /etc/default/varnishncsa.
Uncommented VARNISHNCSA_ENABLED=1, added a custom LOG_FORMAT line with fields I wanted my logs to contain, using the varnishncsa manual page as my guide. Started up varnishncsa with sudo service varnishncsa start, only to find just the first field from my custom log format logged (remote host, or %h, in my case).
After all these years of managing crontab entries, I made an error the other day, causing a job to run on a wrong day. Oops.
I used to have a handy cheat sheet I'd insert at the top of /etc/crontab, but a while back stopped, thinking I've graduated past it. Clearly not, but my web searches for one didn't turn up any I liked. So made my own. Here it is in case anyone else needs handholding:
#+--------------- minute (0-59) #| +------------- hour (0-23) #| | +----------- day of month (1-31) #| | | +--------- month (1-12) #| | | | +------- day of week (0-7), 0=Sunday #| | | | | user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # your custom jobs here...
Needed a way to tile web browser windows for a system monitoring thing I'm working on. Came across this great tool called wmctrl that allows programmatic control of application windows. Wrote a script to automate launching a bunch of separate Chromium web browser windows, then resize them and arrange in a grid. See also this post on launching multiple Chromium browser windows from the command line.
Here's a video of the script in action:
Working with characters that have special meanings is sometimes a pain. A handy workaround is to work with their octal (or hexadecimal) representations instead. Let's say I want to manipulate input that contains single and double quotes with tools like grep, tr, sed and awk.
To check a local cert:
c="/path/to/cert" openssl x509 -noout -dates -subject -issuer -in $c
To check a remote cert, first get it with s_client, then feed to x509:
h="google.com" p="443" openssl s_client -host $h -port $p | openssl x509 -noout -dates -subject -issuer
depth=1 C = US, O = Google Inc, CN = Google Internet Authority verify error:num=20:unable to get local issuer certificate verify return:0 notBefore=Aug 14 21:46:27 2013 GMT notAfter=Oct 31 23:59:59 2013 GMT subject= /C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com issuer= /C=US/O=Google Inc/CN=Google Internet Authority read:errno=0
I like to use separate Firefox profiles with different add-ons for different roles like general web browsing, development, proxying, etc. In older versions of Ubuntu (Gnome 2), one could just right click the Firefox app launcher to modify startup options (see Multiple isolated instances of Firefox within a single login session on Linux), but in more recent versions (Gnome 3 and Unity), the process is a little more involved. Here's what's been working for me in Ubuntu 12.04.
Let's say I have a bunch of lines of text, some of which are related, and I'd like to convert related lines to columns.
In this example, each logical dataset is four lines long, so I'd like to grab four lines at a time and convert each newline character to a column separator. I could write a script to do that, but there's a handy utility called 'paste', that will do all the heavy lifting for me.
After switching to Linux as my default desktop/laptop OS years ago, the one unsolved issue for me was effectively managing my iPods. Due to Apple's closed nature and insistance on tightly controlling the user experience, managing iPods with anything other than iTunes is an ongoing pain. So in early 2013, I set out to find a replacement player.
I'd used the stock firmware for a while and had no feature issues with it. Then I noticed the device occasionally freezing, seemingly when coming across certain music files. Power button would not work, requiring a long select+power key press to restart. According to the release notes for the stock firmware update 01.02.18 (released in May 2013), it fixed an issue with the device hanging "after finished playing special mp3 files, which contain CRC error at the end of frames".
Nmap includes useful functionality of listing MAC Address Vendor name during scans, but my version listed many as "Unknown". The source of this information is a file called "nmap-mac-prefixes", as discussed in Chapter 14 of the NMAP book. The upstream source is IEEE. Since NMAP doesn't seem to provide a way to update the MAC prefix file outside of normal application updates (and my version of nmap was up to date), I wrote a quick and dirty script to handle this for me.