Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / DirCmp.sh
Last active November 20, 2015 17:43
Oldies but Goodies
#!/bin/sh
#
# Copyright 1995, by Hewlett-Packard Company
#
# The code in this file is from the book "Shell Programming
# Examples" by Bruce Blinn, published by Prentice Hall.
# This file may be copied free of charge for personal,
# non-commercial use provided that this notice appears in
# all copies of the file. There is no warranty, either
# expressed or implied, supplied with this code.
###############################
# FAHD SHARIFF'S BASH PROFILE #
###############################
HISTCONTROL=ignoredups
EDITOR=emacs
set -o notify
set -o braceexpand
set -o emacs
@forestbaker
forestbaker / cat_does_more.sh
Last active December 5, 2015 08:02
useful use of cat
#!/bin/bash
clear
#set -xv
HOME="$(pwd -P)"
#
printf '\n%s\n' 'cat is a core binary utility that is used to "concatenate" files'
#man cat
#
printf '\n\n%s\n\n' 'create things filled with no thing'
[ -f ./file1 -a -f ./file2 ] && rm -f ./file[1,2] || touch ./file1 ./file2
@forestbaker
forestbaker / cookbook.txt
Last active January 27, 2016 22:55
Brevis pimentorum que in domo esse debeant
# 88
echo '======================================================================================='
# 80
echo '==============================================================================='
# 75
echo '=========================================================================='
@forestbaker
forestbaker / LimitFirefoxConnections
Last active November 17, 2015 07:45
limit Firefox connections
# limit Firefox connections/downloads to 8
# change values below in about:config
network.http.max-persistent-connections-per-server
network.http.max-persistent-connections-per-proxy
@forestbaker
forestbaker / find_flavorites
Last active December 6, 2015 02:21
find flavorites - oddly useful find commands
# finds all executable files in a sub-directory - casts a wide net
find /mydir/mysubdir -executable -type f
# find all duplicates in sub-directories - slooow
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w64 --all-repeated=separate
# find dupes while excluding .svn
find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w64 --all-repeated=separate
# faster dupe finder (removes 2nd find loop)
find -not -empty -type f -printf "%-30s'\t\"%h/%f\"\n" | sort -rn -t$'\t' | uniq -w30 -D | cut -f 2 -d $'\t' | xargs md5sum | sort | uniq -w32 --all-repeated=separate
@forestbaker
forestbaker / check_CertExpire.sh
Created December 5, 2015 02:21
6 week check ssl certificate expiration
#!/bin/bash
# rough function of http://blog.commandlinekungfu.com/2014/06/episode-179-check-is-in-mail.html
check_CertExpire() {
for d in "$@"; do
echo -ne $d\\t;
[[ $(( $(date +%s -d "$(echo | openssl s_client -connect www.$d:443 2>/dev/null |
openssl x509 -noout -dates | tail -1 | cut -f2 -d=)") - $(date +%s) ))
@forestbaker
forestbaker / websites.url
Last active December 21, 2015 20:42
websites
#################
# ENTERTAINMENT #
# free movies on youtube
https://www.openculture.com/freemoviesonline
http://www.openculture.com/freeaudiobooks
https://www.openculture.com/free_textbooks
##############
# ENCRYPTION #
@forestbaker
forestbaker / keyboard_shortcuts.txt
Last active January 18, 2016 08:15
command line keyboard shortcuts
#!/bin/bash
#
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
@forestbaker
forestbaker / test_64_bit.sh
Created December 8, 2015 22:58
Test if the kernel supports 64-bit
#!/bin/bash
# These commands test if the system is 64-bit. If not, a warning message in red is displayed, if it is 64-bit, x86_64 is displayed
[ 64 -eq $(arch | cut -c 5-) ] && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"
[ 64=="$(arch | cut -c 5-)" ] && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"
# Here is a new one, inspired by a post in this thread:
# http://unix.stackexchange.com/questions/12453/how-to-determine-linux-kernel-architecture
((1<<32)) && arch || echo -e "\e[0;41mTHIS IS NOT A 64-BIT OS\e[0m"