Skip to content

Instantly share code, notes, and snippets.

View douglascodes's full-sized avatar

Douglas King douglascodes

View GitHub Profile
@douglascodes
douglascodes / FormLetterPasswords
Created December 4, 2015 16:43
A form letter to send to my accounts where they have terrible 1990s limits on passwords.
The current password policy is insufficient for properly securing my account.
While trying to reset my password I noticed a limit of {pw_limit}.
1. This artificially imposed limit locks my account password to only {pw_limit} characters and not all symbols.
2. The above suggests the passwords are stored in plain text. Which is never a good thing.
3. The current input limit is {pw_limit} characters. Google recommends a 60 character limit and 8 character minimum.
4. I typically use passwords of at least 20 characters and use any symbol available in the regular US key set.
Please upgrade the service to be able to handle passwords of greater length, symbols, and enable proper hashing and salting. For reference please see the following.
@douglascodes
douglascodes / i3-wm_4.10.2_install
Created May 7, 2015 02:26
Installation instructions for getting i3-wm to compile on CentOS 7
yum update
#Install for compiling and configuring needs
yum install nano bzip2 gcc git pkgconfig autoconf automake libtool gperf byacc libxslt bison flex
#If in a VM you will need to install files for kernel dev to load Guest additions (VirtualBox)
yum install kernel-devel
#Mount the guest additions CD and install
sudo mount /dev/sr0 /media
@douglascodes
douglascodes / diff directory listings
Last active August 29, 2015 14:05
Reads two sorted files as STDIN, one strips forward slashes if they exist
diff --suppress-common-lines -yw <(sort -u restore_log) <(sed -r 's/^\///g' <(sort -u original_log) )
@douglascodes
douglascodes / xml_parse
Created June 22, 2014 14:52
Download, parse and strip tags from two XML attributes in single Linux command line. Great for testing RSS feeds.
wget -q -O- {http://www.example.com/foo.xml} | xpath -q -e '{path/to/xml_element/attr1} | {path/to/xml_element/attr2}' | sed -re 's/(<\w+?>|<\/\w+?>)//g'
@douglascodes
douglascodes / percent_different_bash.sh
Last active December 16, 2015 06:48
Bash script for finding the percentage of Byte difference between two files. Uses wc, cmp, grep and bc.
#! /bin/bash
echo Reports the percentage of matching bytes between two files.
LENGTH_OF_A=$( wc -c $1 | grep -Eo [0-9]+)
LENGTH_OF_B=$( wc -c $2 | grep -Eo [0-9]+)
SAME_SIZE="false"
if [ "$LENGTH_OF_B" -gt "$LENGTH_OF_A" ]
then
LONGER=$2
@douglascodes
douglascodes / controlled_perm.rb
Last active December 15, 2015 12:39
A controlled permutation. Cycles an array of arrays calling the proc with each possible set of the sub arrays whilst preserving the positions of the original array. Basically gets every combination of "One from column A, one from column B, ..." and so on.
a_of_a = [["Jazz", "Soul", "Rock"],["Cheeseburgers", "Hot dogs", "Milkshakes"], ["cable", "radio", "internet"]]
result = Array.new(a_of_a.length)
procky = Proc.new { |arg|
print arg.join(" and "), " are my favorite things. \n"
}
def controlled_perm(x, a_of_a, result, procky)
x += 1
if a_of_a.length == x
procky.call(result)
return