Skip to content

Instantly share code, notes, and snippets.

@Grynn
Grynn / docker-fs
Created December 13, 2014 18:45
Show filesystem for a running docker container. Call with source ./docker-fs <id of container>
#!/bin/bash
set -e
if [ -z $1 ]; then
echo Usage: docker-fs [short-id \| name]
exit 1;
fi
ID=$(docker inspect -f '{{.Id}}' $1)
@Grynn
Grynn / run-speedtest.sh
Last active August 29, 2015 14:11
Run grynn/speedtest (via Docker) on a random port: curl -sS https://gist.githubusercontent.com/Grynn/638b998df8c6af1b6b66/raw/run-speedtest.sh | bash
#!/bin/bash
set -e
DEBUG=1
while getopts p:h:v? flag; do
case $flag in
p)
opt_p=$OPTARG
;;
php -r "getmxrr('abc.com', $m, $w); $mx = array_combine($w,$m); ksort($mx); echo json_encode(['abc.com'=>$mx],JSON_PRETTY_PRINT);"
#!/bin/bash
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
@Grynn
Grynn / ssh_ping
Created February 5, 2015 09:15
Ping SSH Client
#!/bin/bash
ping $(perl -e '$ENV{"SSH_CLIENT"} =~ m/^(\S+)/; print "$1\n";')
@Grynn
Grynn / keybase.md
Created March 20, 2015 00:12
Keybase proof of id

Keybase proof

I hereby claim:

  • I am grynn on github.
  • I am grynn (https://keybase.io/grynn) on keybase.
  • I have a public key whose fingerprint is 7C92 03B8 2B01 361C C8F6 9D86 4143 B7D7 716C 6CFB

To claim this, I am signing this object:

<?php
//GetPass for a website
//getpass(sitename.com) returns a XORed version of the sitename + salt
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$homeDir = realpath(getenv("USERPROFILE"));
} else {
$homeDir = realpath("~");
}
$salt = file_get_contents("$homeDir/.salt");
@Grynn
Grynn / lsrecent
Last active November 18, 2015 18:23
List 10 most recently modified files (in a directory tree)
#!/bin/bash
# May not work if filename have spaces
# Inspired by this answer on StackOverflow
# http://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s
find . -type f -printf '%T@ %P\n' | sort -nr | cut -d ' ' -f2- | head
## Windows Version ##
# gfind . -type f -name "clean*.php" -printf "%T@ \"%P\"\n" | gsort -nr | cut -d ' ' -f2-
# Assumes gfind = Gnu find and gsort Gnu sort
cat /etc/apache2/sites-available/* /etc/nginx/sites-available/* | perl -ne 'print if (!m/^\s*#/ && m/ServerName|ServerAlias/i);'
#!/bin/bash
while read p; do
(svn list -R "$p" | xargs -I{} echo $p{} | tee -a allfiles.txt) &
done < repos.txt
wait #for above jobs to finish...