Friday, December 28, 2018

Mapping capslock to an extra control key in Xorg

Edit /etc/default/keyboard and add the following:

XKBOPTIONS="ctrl:nocaps"

Then run:

sudo dpkg-reconfigure keyboard-configuration

Friday, November 23, 2018

Convert epoch to human readable datetime

  • Linux: date -d @1316645223
  • BSD and MacOS: date -r 1316645223
Both return -> Wed Sep 21 15:47:03 PDT 2011

Friday, August 31, 2018

Pretty print JSON from command line

echo '{ "element0" : "hi", "element1" : "there" }' | python -m json.tool
prints:
{
    "element0": "hi",
    "element1": "there"
}
You can also cat a JSON file and pipe to the same command

Ansible become_user for a block of commands

use a block to apply a become_user to a block of commands
- block:
    - name: checkout repo
      git:
        repo: https://github.com/some/repo.git
        version: master
        dest: "{{ dst }}"
    - name: change perms
      file:
      dest: "{{ dst }}"
      state: directory
      mode: 0755
      owner: some_user
  become: yes
  become_user: some user