Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stampycode's full-sized avatar

Tim Stamp stampycode

View GitHub Profile
@stampycode
stampycode / .vimrc
Last active February 23, 2016 16:09
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
@stampycode
stampycode / httpd_autoinclude.conf
Last active February 23, 2016 16:23
A httpd config file for auto-including other httpd config files from a wildcard directory path.
<IfModule mod_perl>
<Perl>
foreach $file (glob '/data/*/httpd.conf') {
push @Include, $file;
}
</Perl>
</IfModule>
@stampycode
stampycode / .screenrc
Last active February 23, 2016 16:27
Custom screenrc file for maintaining a flexible and stable multi-terminal interface through one primary connection
# ~/.screenrc
termcapinfo xterm* ti@:te@
startup_message off
vbell off
autodetach on
altscreen on
shelltitle "$ |"
defscrollback 100000
defutf8 on
nonblock on
@stampycode
stampycode / writeCheck.php
Created March 4, 2016 14:04
check which files/dirs are writeable, recursively
<?php
$out = [];
function readall($dir, &$out) {
$try = explode("\n", `ls -1 $dir/`);
$try = array_flip($try);
foreach($try as $k => $v) {
if(!$k || $k === '.' || $k === '..') {
continue;
}
$k = "$dir/$k";
@stampycode
stampycode / .bashrc
Last active May 20, 2016 16:05
The .bashrc file I use every day. Customise the prompt, add colours and feedback for usability.
# Prevent terminal specfic alterations being made or output if the session is running in TTY mode
[[ -t 1 ]] || return
# ~/.bashrc
PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "
HISTSIZE=1000000
alias rs="screen -dR"
alias sshauth="eval \"\$(ssh-agent)\" && ssh-add -t 600 ~/.ssh/id_rsa"
@stampycode
stampycode / yumupdate.sh
Last active June 15, 2016 22:12
emails a summary of a regular yum update to your inbox, designed to be run by cron
#!/bin/bash
/usr/bin/yum update -y &> /tmp/yu
EMAIL=<enter your email here>
DOMAIN=<enter your domain here>
SUBJ=`cat /tmp/yu |grep "Total download size:" |cut -c 22-30`
if [[ $SUBJ ]] ; then
SUBJ="Subject: yum: $SUBJ of updates"
@stampycode
stampycode / memlog.sh
Last active June 15, 2016 22:14
utility script for recording the memory in use on a server and emailing and clearing the log intermittently
#!/bin/bash
EMAIL=<insert your email here>
cd /home/ec2-user
if [[ $1 == "send" ]] ; then
sleep 5
cat memlog | /usr/bin/sendmail -F"MemLog <$EMAIL>" $EMAIL

Keybase proof

I hereby claim:

  • I am StampyCode on github.
  • I am stampycode (https://keybase.io/stampycode) on keybase.
  • I have a public key whose fingerprint is FC06 B490 56F2 50BB D96F 9696 40FD 6A8C 5BC0 7954

To claim this, I am signing this object:

@stampycode
stampycode / fsync.sh
Last active August 22, 2016 08:36
Mac fswatch file change propagation daemon
#!/bin/bash
code=0
if [[ ! "$1" ]] || [[ "$1" && ! -d "$1" && "-h" != "$1" && "--help" != "$1" ]] || [[ "$2" && ! -d "$2" ]] ; then
code=1
fi
if [[ ! "$2" || $code -gt 0 || "-h" = "$1" || "--help" = "$1" ]] ; then
echo Propagates file changes from one directory into another
echo usage:
@stampycode
stampycode / How Strong Is Your Generated Key.php
Last active February 20, 2017 15:40
How Strong Is Your PRNG Generated Key
| Example Key | Key Alphabet | Number of Possible Combinations
-------------------------------------------------------------------------------------------------------------------------
10**3 | 976 | Numerical | 1000
16**3 | 6d2 | Hexadecimal | 4096
10**4 | 9766 | Numerical | 10000 // eg. Bank Card Pin number
26**3 | bsa | Alphabetical | 17576
16**4 | 6d20 | Hexadecimal | 65536
10**5 | 97667 | Numerical | 100000
62**3 | bSA | a-zA-Z0-9 | 238328
64**3 | bSA | Base64 | 262144