Working Ninja
2022-01-09T18:11:37

I have been setting up some RESTful sensors for Home Assistant and to verify/fine tune their functionality, it dawned on me that I could use watch to continuously poll my endpoint to watch for a value change:

watch curl --no-progress-meter http://domain.tld/path/to/sensor/

If you're familiar with watch, you'll know that the …

READ MORE

2018-11-27T07:37:07

Email contents of a file:

echo -e "Subject: subject\n\n" | cat - /file | sendmail address

Email stdout:

output=`cmd` 
echo -e "Subject: subject\n\n$output" | sendmail address

READ MORE

2018-10-31T20:14:58

Here's a simple shell wrapper that prints all sockets opened by Firefox.

1. Add the following function to your ~/.bashrc:

function ffsocks() {
    netstat -anp --inet | awk '/firefox/ { print $5 }'
}

2. Reload your shell (or run source ~/.bashrc) to make ffsocks callable from …

READ MORE

2016-11-01T16:55:19

Before adding a script to cron and finding that it doesn't work because of a PATH issue, here's a handy command to test:

env -i ./script

This will run your script in the same environment that cron will.

READ MORE

2016-05-01T11:09:13
2016-03-26T10:26:48

GitLab was throwing me a 500 server error this morning after an upgrade via yum. To troubleshoot, I ran the self diagnose command from terminal:

# gitlab-rake gitlab:check

Which gave me the following error to fix:

All migrations up? ... no
  Try fixing it:
  sudo -u git -H bundle exec …

READ MORE

2016-01-17T12:54:16

Error:

The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.

Solution:

# dd if=/dev/zero of=/dev/sdb bs=2048

Source: http://askubuntu.com/questions/675649/unable-to-delete-usb-drive-partitions-block-size-error

READ MORE

2016-01-17T12:08:12

Use dmesg after plugging in your USB thumb drive to find the device name (/dev/sdb).

# umount /media/username/devicename
# dd bs=4M if=/path/to/filename.iso of=/dev/sdb

Note, do not output to a partition (e.g. /dev/sdb1). In the past this has created a loop device instead of copying the input file to the USB …

READ MORE

2015-10-13T07:38:08

This script will find (including subdirectories) and convert all m4a files to mp3.

find -name "*.m4a" -exec ~/m4atomp3 {} \;

m4atomp3:

#!/bin/bash
m4afile=$@
avconv -i "$m4afile" -ab 320k "${m4afile/.m4a/.mp3}"

Remember to chmod +x m4atomp3.

READ MORE

2014-11-11T17:56:26

Get to vhost root:
alias www='cd /var/www/vhosts/'

From domain.name, get to WordPress theme directory:
alias t='cd httpdocs/wp-content/themes/'

Restart Apache gracefully:
alias apachegrace='/etc/init.d/httpd restart graceful'

Directory listing with timestamp, ownership, permissions, etc:
alias ls="ls -l"

READ MORE