Skip to content

Instantly share code, notes, and snippets.

Cole Tierney putnamhill

Block or report user

Report or block putnamhill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@putnamhill
putnamhill / bash-snippets.sh
Last active Jun 1, 2019
bash snippets - these are mostly just notes for myself; some I've found and some I've made
View bash-snippets.sh
# add a remote url to an existing remote
git remote set-url origin --push --add another:repo.git
# check locally for internet access
netstat -nrf inet | grep -q ^default && \
echo internet is up || \
echo internet is down
# search LDAP for login name with wildcards
ldapsearch -x -LLL uid='cTiern*' uid | sed -n 's/^uid:[[:blank:]]//p' | uniq
View bgrep.sh
#!/bin/bash
usage() {
cat <<EOT
Usage: ${0##*/} [-l] [-h] pattern [arg2] ...
Prints lines containing a BRE pattern, after stripping binary data.
Sort of like strings command followed by grep, only better.
If no file paths are specified after the pattern, paths are
read from stdin (tip: feed with find).
Options:
View lingo-shell-xtra-snippets.ls
on listReadOnlyVolumes
return shell_cmd_list("mount | sed -n 's/^\/dev\/.* on \(\/.*\) (.*read-only.*/\1/p'")
end
on nonEmptyFolderExists atPosixPath
rslt = shell_cmd_list("ls " &qq(atPosixPath) &" 2>/dev/null")
return count(rslt) > 0
end
on directoryExists atPosixPath
@putnamhill
putnamhill / dir-vers.pl
Created Jun 13, 2012
This script prints the version of adobe director used to create a file. Now detects director file versions 6, 7, 8, 8.5 (or 9.0), 10.1, 11.5.0r593, 11.5.8.612, and 12.
View dir-vers.pl
#!/usr/bin/perl -w
use constant IFFTYPES => qw( RIFX XFIR );
use constant DIRTYPES => qw( MV93 39VM MC95 );
use constant {
INT_SIZE => 4,
VERSION_OFFSET => 40
};
use Getopt::Long;
#use diagnostics;
@putnamhill
putnamhill / genUID.sh
Last active Oct 8, 2015
A bash version of the genUID.app CLSID generator for Adobe Director MOA classes.
View genUID.sh
#!/bin/bash
# genUID.sh - A bash version of the genUID.app CLSID generator for Adobe Director MOA classes.
openssl rand -hex 16 | awk '{
printf "DEFINE_GUID(CLSID(CRegister), 0x%sL, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s);\n",
substr($0, 1, 8), substr($0, 9, 4), substr($0, 13, 4), substr($0, 17, 2),
substr($0, 19, 2), substr($0, 21, 2), substr($0, 23, 2), substr($0, 25, 2),
substr($0, 27, 2), substr($0, 29, 2), substr($0, 31, 2)
}' | \
@putnamhill
putnamhill / notifymail.sh
Created Nov 1, 2012
an email notifier that listens for finger connections from the mail server
View notifymail.sh
#/bin/bash
# usage:
# sudo nohup notifymail 2>&1 >/dev/null
# to see if it is already running
# ps ax | egrep ' (sh /Users/colet/bin/[n]otifymail)|([n]c -l 79)$'
[ $(whoami) != 'root' ] && echo must be root && exit
# first clean up any old related processes
@putnamhill
putnamhill / win2003-ntp.txt
Last active Dec 16, 2015
Configuring ntp on Windows 2003 using the command prompt. Use stratum two servers if possible: https://support.ntp.org/bin/view/Servers/StratumTwoTimeServers?redirectedfrom=Servers.StratumTwo
View win2003-ntp.txt
net stop w32time
w32tm /unregister
w32tm /register
net time /setsntp:"tick.example.com,0x1 tock.example.com,0x1"
net start w32time
@putnamhill
putnamhill / smtp-test
Last active Dec 18, 2015
smtp commands to test email between two servers via telnet
View smtp-test
telnet smtp.example.com 25
Trying 203.0.113.1...
Connected to smtp.example.com.
Escape character is '^]'.
220 example.com running My Bitchin Mail Server 1.0.0
HELO example.org
250 example.com hello example.org (198.51.100.1)
MAIL FROM:<postmaster@example.org>
250 2.1.5 sender OK
RCPT TO:<someone@example.com>
@putnamhill
putnamhill / mysql-notes
Last active Sep 29, 2016
Creating a new user with the mysql client and set some privileges for all the tables of a database.
View mysql-notes
CREATE USER 'someuser'@'localhost' IDENTIFIED BY 'cleartext-password';
GRANT SELECT,INSERT,UPDATE,DELETE ON `database`.* TO 'someuser'@'localhost';
@putnamhill
putnamhill / stop-watch.sh
Created Jul 31, 2013
A simple bash stop watch.
View stop-watch.sh
#!/bin/bash
START=$(date +%s)
read -s -n1 -p $'Press a key when done.\n'
ELAPSED_SECONDS=$(bc <<< "scale=10; ($(date +%s) - $START)")
if [ $ELAPSED_SECONDS -gt 60 ]; then
ELAPSED_MINUTES=$((ELAPSED_SECONDS / 60))
ELAPSED_SECONDS=$((ELAPSED_SECONDS - ELAPSED_MINUTES * 60))
echo -n "$ELAPSED_MINUTES minutes "
fi
You can’t perform that action at this time.