Shell Script

Including GitHub Source Code into Markdown with a Preprocessor

I'm doing some writing in Pandoc, and the Markdown implementation doesn't have an "include" feature to pull in source code. After looking around, there are some tools that implement #include or !include, but there weren't quite what I wanted, so I wrote this in awk.

Log Everything: Send Shell Commands to Syslog

This is an article on security, but I started to record all my commands to syslog so I can track what I'm doing, when, and for how long, more or less. Then I record this on my calendar to see if I'm staying focused on work, or getting distracted. It's a nice blog post.

Bash History to Syslog

Edit: so I implemented it on my computer, but changed it slightly:

# log all my commands
function log2syslog
     declare command
     command=$(fc -ln -0)

Serve a Stream from a Webcam by Bypassing a Password with a Proxy

This is a one-line trick to serve images from a password-protected webcam to the world.

curl -i http://admin:@ | nc -lCt localhost 10203

My webcam doesn't have a password, but it could. What this does is use curl to get the stream, and then use nc to serve it to a client.

How to Backup MySQL on a Website

Usually, a web host will give you FTP access to a directory and a web interface. A button in the web interface will produce a .ZIP file with the database contents, and you can download it via FTP.

Kindle Tricks (Linux)

An Amazon press release said that they sold more Kindle books than paper books. That might be true, but, they probably included the thousands of books being sold for free, or a few dollars. There are numerous public domain books "for sale" on Kindle. I downloaded several dozen.

Here are a few Amazon Kindle tricks.

Watchdog: Restarting WiFi on OpenWRT if the Link Goes Away

I put my WRT54G into a noisy electrical environment, and it seems to cause the wifi to fade out a couple times a week, sometimes permanently. (I did this after using a USB adapter on Windows proved too unstable.)

After some experimentation, this script below seems to do a reasonable job of keeping it up. Save it, and put it into the crontab. (You have to install the crond package.) The gateway is at

#! /bin/sh

# Checks if the wifi conn is up.  If not, it tries to restart
# the wifi.  If that fails, then reboot.

if ping -c 1 > /dev/null

Novice's Notebook

This is a repository of "novice" articles, written with the intent of driving more traffic to the site, and getting more ad clicks. It's pretty crass, I know, but the information may be very useful.

OpenWRT Router IP Exposure Script

If you have an OpenWRT router (any router that can run the software can be converted), you can do a little quasi-dynamic-DNS trick. This is useful if you don't really care enough to set up Dyn DNS, and you have a web server setup.

The main disadvantage is that you don't have a DNS record. The main advantage is that the updates don't need to propagate through DNS, so if you have an app that relies on talking to your LAN, you can quickly detect any changes.

First, save this as /usr/bin/checkmyip


[ -f /tmp/myip ] &
Syndicate content