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

2020-11-22T15:13:45

After upgrading to Linux kernel 5.4.0-54-generic, I was unable to adjust my display brightness.

dmesg output shows i915 'Y' invalid for parameter 'enable_dpcd_backlight'

/etc/default/grub contains i915.enable_dpcd_backlight=Y for GRUB_CMDLINE_LINUX_DEFAULT.

Removing the i915.enable_dpcd_backlight=Y from GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub resolved the issue.

READ MORE

2020-06-27T08:08:39

A while back, I found that my iDRAC firmware was out of date. Being a good sysadmin, I downloaded the update and followed the instructions to perform the update via the iDRAC itself. Being a while back, I don't remember exactly what transpired but the update failed in one way …

READ MORE

2019-10-15T21:44:13

lirc mysteriously stopped working when I upgraded to kernel 4.19.66-v7+ on my Raspberry Pi a while back. After an initial battle that lead to no success, I let it collect dust until this fateful night when she returned to her full functionality.

tl;dr

The kernel module lirc_rpi has been replaced …

READ MORE

2019-09-16T20:53:45

Add the following to your ~/.bash_profile for simple merging of PDFs:

pdfmerge() { 
    gs -dPDFSETTINGS=/prepress -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@
}

Usage:

pdfmerge merged.pdf first.pdf second.pdf

Source:
https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf

READ MORE

2019-06-16T20:30:46

I recently ran into a situation where I needed to copy some CSV data residing on a Windows machine to a Linux machine. The remote desktop client software I was using (on my Linux machine) wasn't set up to nativiely allow copy and paste to and from the server. It …

READ MORE

2018-08-19T10:29:23

The following example looks for the "idle" time before backlight brightness is reduced.

Find what you're looking for:

gsettings list-recursively | grep idle

Get the value:

gsettings get org.gnome.settings-daemon.plugins.power idle-brightness

Set the value:

gsettings set org.gnome.settings-daemon.plugins.power idle-brightness 120

 

READ MORE

2018-01-06T17:16:21

Completely disable systemd power-saving modules:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Disable systemd lid switch (for laptops):

sed -i -e 's/HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf

The above became necessary as systemd-logind was detecting that the lid was closed and calling suspend.target. The calls were numerous and consumed large amounts of …

READ MORE

2017-12-30T20:13:20

Objective:

Enable the "Start up automatically after a power failure" feature found within OS X without OS X installed.

Solution:

  1. Find the LPC controller via lspci.
  2. Reference the LPC controller datasheet to find the register to update.
  3. Update the register with setpci.
  4. Test.
  5. Add the setpci …

READ MORE

2017-10-25T17:47:53

Before stumbling upon this module, whenever I connected to my audio receiver via Bluetooth, I had to change the Pulseaudio sink as well as set the default output. Thankfully there is an easy fix that will do both of these when a new sink is available.

Add the following to …

READ MORE

2017-07-12T19:50:17

Using IUS (Inline with Upstream Stable)--a nifty repository provided by EPEL--we can upgrade beyond PHP 5.4 by first removing our current version of PHP, installing our preferred version (5.6 in our case), and then restarting Apache:

$ sudo yum remove php-cli mod_php php-common

$ sudo yum …

READ MORE

2017-06-30T21:58:27

Renewing an SSL but can't recall exactly how it was filled out last time? Try the following:

openssl req -text -in request.csr

The above command will decode the CSR file and output its contents in human readable text. Enjoy!

More here: https://linux.die.net/man/1/req

READ MORE

2017-03-23T17:32:14

Sometimes it is necessary to resize partitions (e.g. updates to GitLab require additional space on /opt). Here's what we need to do. If you have an LVM parition, you're in luck! Things are pretty straightforward.

  1.   Run vgdisplay (Volume Group Display) to verify we have space to expand our partition. …

READ MORE

2017-03-23T17:22:08

Here's a simple way to count lines of code via the command line that I recently used for a Django project:

find . -name '*.py' -not -path "*/migrations/*" | xargs wc -l

or

wc -l **/*.py

Source: http://stackoverflow.com/questions/1358540/how-to-count-all-the-lines-of-code-in-a-directory-recursively#1358573

READ MORE

2017-03-15T07:38:50
dd if=<path to input file> | pv -s <size e.g. 1377M> | dd of=<path to target device>

Source: https://superuser.com/questions/351814/how-to-copy-an-iso-image-onto-usb-with-dd#351815

READ MORE

2017-02-04T16:02:28

To swap control and command, add the following to your ~/.Xmodmap file:

remove control = Control_L
remove mod4 = Super_L Super_R

keysym Control_L = Super_L
keysym Super_L = Control_L
keysym Super_R = Control_L

add control = Control_L Control_R
add mod4 = Super_L Super_R

The above current works for both an …

READ MORE

2016-11-21T23:35:33

The Old Way

import os

os.system('find /home/user/documents -type f -iname "*.doc"')

The New, Recommended Way

import subprocess

subprocess.check_call([
    'find',
    '/home/user/documents',
    '-type', 'f',
    '-iname', '*.doc'
])

Bonus Tidbit

At this point, we can incorporate some nice exception handling:

import subprocess

try:
    subprocess.check_call([
        'find',
        '/home/user/documents',
        '-type', 'f',
        '-iname', '*.doc'
    ])
except subprocess.CallProcessError …

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

2015-12-30T20:50:04
if [ "$TERM" = "linux" ]; then
    echo -en "\e]P0232323" #black
    echo -en "\e]P82B2B2B" #darkgrey
    echo -en "\e]P1D75F5F" #darkred
    echo -en "\e]P9E33636" #red
    echo -en "\e]P287AF5F" #darkgreen
    echo -en "\e]PA98E34D" #green
    echo -en "\e]P3D7AF87" #brown
    echo -en "\e]PBFFD75F" #yellow
    echo -en "\e]P48787AF" #darkblue
    echo -en "\e]PC7373C9" #blue
    echo -en "\e]P5BD53A5" …

READ MORE

2015-11-03T08:12:24

Not doing anything but your hard drive is screaming? iotop to the rescue.

iotop

In my case, updatedb.mlocate was the culprit.

READ MORE

2015-10-24T11:43:09

Redshift sometimes stays enabled, setting the color temperature too low during the day. A quick fix is to set the color temperature from command line:

redshift -O 6000

 

READ MORE

2015-10-21T22:49:47

Every once and a while, I lose network connectivity to the point where my NFS share is unmounted and, when remounted, the Desktop fills up with everything in ~/.

The problem lies in the file ~/.config/user-dirs.dirs. It should be as follows (for my setup):

XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public" …

READ MORE