Working Ninja
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

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

2017-10-25T18:17:54

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

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 ...

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-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-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 ...

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 ...

READ MORE

2018-02-03T16:43:22

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 command to crontab.

I'll ...

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 ...

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 ...

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: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 Apple laptop and an Apple keyboard.

Also ...

READ MORE