Working Ninja

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 /etc/pulse/ Or better yet, if you haven't already, create a local config for Pulse audio at ~/.config/pulse/

.include /etc/pulse/
load-module module-switch-on-connect

Now if only I had stumbled upon this before attempting to write a custom udev rule!



Python 2.7 is not provided on CentOS 6 because Yum depends on Python 2.6. Simply installing 2.7 over 2.6 will break Yum. Thankfully, Red Hat provides us with an alternate installation method through their SCL project.

First, get Python 2.7 installed:

Next, add the project path to the top of the script:

import sys

Lastly, call the script via Cron:

cat /path/to/project/ | scl enable python27 python

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 install mod_php56u php56u-cli php56u-mysqlnd

$ sudo apachectl restart



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:


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.
    •     The line PE Free / Size should have space available.
  2.   Next, add space to the parition with lvresize (Logical Volume Resize):
    sudo lvresize --size +100M /dev/mapper/opt
  3.   Now that the volume has been expanded, let's commit those changes to the filesystem:
    sudo xfs_growfs /dev/mapper/opt



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


wc -l **/*.py


dd if=<path to input file> | pv -s <size e.g. 1377M> | dd of=<path to target device>



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, to use Command+Tab to cycle windows, make sure to update keyboard shortcuts to use Ctrl+Tab instead of Alt+Tab (for Xfce, Window Manager -> Keyboard). All other keyboard shortcuts should come through (from the Control to Command swap perspective).



The Old Way

import os

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

The New, Recommended Way

import subprocess

    '-type', 'f',
    '-iname', '*.doc'

Bonus Tidbit

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

import subprocess

        '-type', 'f',
        '-iname', '*.doc'
except subprocess.CallProcessError as e:
    print e.returncode
    print e.cmd
    print e.output

See the official Python Documentation for more usage and recommendations on the subprocess module.


Install NFS server components:

# apt-get install nfs-kernel-server portmap

Add the "root" of all shares (if this is your only share, this should be all you need):

# echo "/home,fsid=0)" >> /etc/exports

Add additional shares:

# echo "/home/joe,sync,no_subtree_check)" >> /etc/exports

Update NFS exports table:

# exportfs -avr

Restart NFS server:

# service nfs-kernel-server restart

Don't forget to allow NFS through iptables.


# apt-get install nfs-common
# mount server:/share /share



Slow initial directory listing is caused by aliases (specifically color output). Explanation here: Use \ls -la instead of ll as a workaround.