Skip to content

Instantly share code, notes, and snippets.

View blackknight36's full-sized avatar
💭
I may be slow to respond.

Michael blackknight36

💭
I may be slow to respond.
View GitHub Profile
#!/usr/bin/perl
use strict;
use List::Util qw(shuffle);
my $cmd = "find \"/home/music\" -type f";
my @files = `$cmd`;
my @songs = shuffle @files;
open(LIST, ">", "/var/tmp/rand_playlist.m3u");
@blackknight36
blackknight36 / gist:87fcaa788a1e7c82f023719d549df3c2
Created April 6, 2016 14:38
This command will give the date of when the password was last reset.
gawk -F: '{ print $1 ":" strftime("%Y%m%d",86400*$3) ":" strftime("%Y%m%d",86400*$4)}' /etc/shadow
Awk one liners
HANDY ONE-LINERS FOR AWK 22 July 2003
compiled by Eric Pement <[email protected]> version 0.22
Latest version of this file is usually at:
http://www.student.northpark.edu/pemente/awk/awk1line.txt
USAGE:
@blackknight36
blackknight36 / sed examples
Created April 6, 2016 14:42
Handy one-liners for sed
-------------------------------------------------------------------------
HANDY ONE-LINERS FOR SED (Unix stream editor) Apr. 26, 2004
compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.4
Latest version of this file is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.student.northpark.edu/pemente/sed/sed1line.txt
This file is also available in Portuguese at:
http://www.lrv.ufsc.br/wmaker/sed_ptBR.html
FILE SPACING:
@blackknight36
blackknight36 / grep examples
Created April 6, 2016 14:44
Useful grep examples
Remove blank lines and comments:
egrep -v "^#.*" <FILE> |grep "."
Grep OR statement:
grep 'pattern1\|pattern2' filename
Grep OR Using -E
grep -E 'pattern1|pattern2' filename
Inverse grep (show lines that do *not* match a pattern)
-----BEGIN CERTIFICATE-----
MIIFdDCCBFygAwIBAgIQJ2buVutJ846r13Ci/ITeIjANBgkqhkiG9w0BAQwFADBv
MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
eHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFow
gYUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMSswKQYD
VQQDEyJDT01PRE8gUlNBIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkq
hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAkehUktIKVrGsDSTdxc9EZ3SZKzejfSNw
AHG8U9/E+ioSj0t/EFa9n3Byt2F/yUsPF6c947AEYe7/EZfH9IY+Cvo+XPmT5jR6
@blackknight36
blackknight36 / environment.rdb
Created April 7, 2016 13:50
custom environment fact for facter
Facter.add("environment") do
setcode do
Facter::Util::Resolution.exec('/bin/cat /usr/local/etc/environment')
end
end
# System authorization information
install
# Use network installation
url --url="http://server.example.com/ftp/pub/fedora/23/Everything/x86_64/os"
auth --enableshadow --passalgo=sha512
# Disable setup agent
firstboot --disable
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
#!/usr/bin/python
from pypuppetdb import connect
import platform
hostname = platform.node()
cert = '/etc/puppetlabs/puppet/ssl/certs/%s.pem' %hostname
key = '/etc/puppetlabs/puppet/ssl/private_keys/%s.pem' %hostname
ca_cert = '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem'
@blackknight36
blackknight36 / htg.sh
Last active November 21, 2017 15:48
Happy Thanksgiving script
#!/bin/bash
#
# htg.sh - Happy Thanksgiving :)
#
# Requires the 'banner' package to work
# dnf install banner on Redhat based systems
echo -e "\n ,+*^^*+___+++_\n ,*^^^^ )\n _+* ^**+_\n +^ _ _++*+_+++_, )\n _+^^*+_ ( ,+*^ ^ \+_ )\n { ) ( ,( ,_+--+--, ^) ^\\n { (@) } f ,( ,+-^ __*_*_ ^^\_ ^\ )\n {:;-/ (_+*-+^^^^^+*+*<_ _++_)_ ) ) /\n ( / ( ( ,___ ^*+_+* ) < < \\n U _/ ) *--< ) ^\-----++__) ) ) )\n ( ) _(^)^^)) ) )\^^^^^))^*+/ / /\n ( / (_))_^)) ) ) ))^^^^^))^^^)__/ +^^\n ( ,/ (^))^)) ) ) ))^^^^^^^))^^) _)\n *+__+* (_))^) ) ) ))^^^^^^))^^^^^)____*^\n \ \_)^)_)) ))^^^^^^^^^^))^^^^)\n (_ ^\__^^^^^^^^^^^^))^^^^^^^)\n ^\___