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
@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 <pemente@northpark.edu> 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
@blackknight36
blackknight36 / beer.py
Created April 8, 2016 21:22
How many beers can you drink?
#!/usr/bin/python
def drink_beer():
global caps
global empties
global full
caps += 1
empties += 1
full -= 1
print "Drank full bottle.\n"
@blackknight36
blackknight36 / count_words.py
Created April 8, 2016 21:23
count words with $n letters
#!/usr/bin/python
f = open("input.txt", "ro")
words = f.readline().split(" ")
f.close()
limit = len(max(words, key=len)) + 1
for i in range(1, limit):
count = 0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.collectd.collectd</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/sbin/collectd</string>
<string>-f</string>