Skip to content

Instantly share code, notes, and snippets.

View JPvRiel's full-sized avatar

Jean-Pierre van Riel JPvRiel

  • South Africa, Johannesburg
View GitHub Profile
@JPvRiel
JPvRiel / 0_reuse_code.js
Created August 19, 2016 20:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@JPvRiel
JPvRiel / bash_string_substitution.md
Last active October 10, 2016 23:10
Bash String Substitution

Syntax

${varName/Pattern/Replacement}

Given a variable

$ val="test"
@JPvRiel
JPvRiel / ssllabs_cert_test_web_scrape.py
Created November 27, 2016 21:11
A web scraping example using python. It used ssllabs.com to test a list of web sites and scraped the results. This was only useful back in 2015 before they published an API
# Python script to test ssl via ssllabs service
# - input: space or newline delimited set of hostnames to test
# - process: sends request, polls till results are complete
# - output: saves html page
# - output: prints summary results per site in csv
# - output format: <fqdn/hostname>,<http status code>,<overall rating>,<certficate score %>,<protocol support score %>,<key exchange score %>,<cipher strength score %>
# python libs to use
import csv
from lxml import html
@JPvRiel
JPvRiel / docker-compose
Last active December 23, 2016 15:11
sudo_docker_compose_workaround
#!/usr/bin/env bash
if [ -z "$VIRTUAL_ENV" ] || [ "$VIRTUAL_ENV" -ne "/home/a211278l/bin/python-venvs/docker" ]; then
source ~/bin/python-venvs/docker/bin/activate
fi
sudo -E "$(which docker-compose)" $@
deactivate
@JPvRiel
JPvRiel / Find out which process has created an X window.md
Created March 24, 2017 09:22
Find out which process has created an X window

Overview

W window has a _NET_WM_PID property set by the applicaiton. To really validate if the application has set this correctly is more work (see reference).

Simple Example

Run command and click the window

$ xprop _NET_WM_PID
@JPvRiel
JPvRiel / decrypt_directory_of_pdfs_bash_qpdf.md
Created November 12, 2017 19:56
Decrypt a directory of PDFs using bash, basename and qpdf

Given a working directory and a folder c with encrypted PDFs, use qpdf, basename and a bash loop:

for f in c/*.pdf; do qpdf --password=<password> --decrypt $f "$(basename -s .pdf $f).pdf"; done
@JPvRiel
JPvRiel / spice-guest-tools Windows 10 BSOD.md
Last active September 4, 2018 17:59
Fixing "page fault in nonpaged area" Windows 10 BSOD caused by installing spice-guest-tools

Synopsis

Boot failure was caused by installing spice-guest-tools which, if you read details about it, also includes the QXL driver and the install broke my Windows 10 build 17134 guest somehow. This occured on Ubuntu 16.04 LTS with QEMU emulator version 2.5.0.

Error

BSOD with "page fault in nonpaged area" occurs after installing spice-guest-tools-latest.exe. It possibly clobbers other stable/good versions of drivers.

Automatic boot repair fails. After going through advanced options and getting to a command prompt, inspect the boot repair logs:

@JPvRiel
JPvRiel / ps_command_examples.md
Created September 4, 2018 18:00
`ps` command examples

Show top 10 processes by resident memory set size

ps -eo pid,user,rsz,vsz,comm,args --sort -rss --cols 160 | head -n11
@JPvRiel
JPvRiel / inspect_raid.md
Last active January 7, 2019 09:28
Linux MD software raid inspection

inspect_raid.sh

A bash script that collects some useful commands to check Linux MD software arrays and component devices for some issues, e.g.

  • RAID component device has a SMART warnings or errors.
  • A RAID with HDD and SSD mixed doesn't have the HDD components set to write-mostly or the SSD is set to write-mostly.

It can also display info. Set env var SHOW_INFO='y' or anything else, e.g. 'n' (default) to just report issues.

Usage

@JPvRiel
JPvRiel / git_workflow.md
Last active June 22, 2019 08:00
git workflow

Merging

Merge master into branch

A good idea if upstream has had commits and, to catch up, you need to test your feature branch with changes from upstream included

git checkout feature
git pull origin master