This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# IMPORTANT ASSUMPTION: | |
# YOU DO NOT HAVE ANY OTHER DISKS MOUNTED WITH AN `s1` PARTITION! | |
# A better way would be to use `diskutil list --plist` and parse the | |
# plist using ruby/python/javascript/your-language-of-choice | |
for disk in $(mount | egrep 'disk.+s1' | awk '{print $1}' | sed -e 's_^/dev/__' -e 's_s1$__') | |
do | |
diskutil eject ${disk} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [[ $(lsof -nP +L1 | wc -l) > 1 ]] | |
do | |
pair=$(lsof -nP +L1 | tail -n 1 | awk '{print $2" " $4}') | |
pid=$(echo $pair | awk '{print $1}') | |
fd=$(echo $pair | awk '{print $2}' | sed -e 's_[a-z]__g') | |
file=$(mktemp) | |
# Race condition check on first line of lsof output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SECURITY WARNING: the password will be visible in the process list on your local machine. | |
# Note: you need PuTTY's plink to get this to work, even on macOS | |
# macOS: `brew install putty` | |
# Windows: `choco install putty` | |
# Arguments: | |
# vpc_ip = Private IP Address of the Windows box. e.g. 172.16.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Math::IntegerDivision; | |
use Carp; | |
use Moose; | |
has 'numerator' => ( | |
is => 'rw', | |
isa => 'Int' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw/say/; | |
use WebService::IFConfig::Client; | |
my $client = WebService::IFConfig::Client->new(); | |
say $client->get_ip;' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_date () { | |
local date_cmd | |
local date | |
# Check if GNU date installed as gdate | |
: type gdate 2> /dev/null | |
[ $? == 0 ] && date_cmd=gdate || date_cmd=date | |
# Attempt GNU date - date will be unset if this fails | |
date=$(${date_cmd} --iso-8601=second 2> /dev/null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Contains a rounding error, but we didn't need the accuracy | |
# Check if $response is an empty string or not a number | |
if [ -z ${response} ] || [ $(( ${response} + 0 )) == 0 ] | |
then | |
mins=undef | |
secs=undef | |
then | |
else | |
mins=$(( ${response} / 1000 / 60 )) | |
secs=$(( ${response} / 1000 - 60 * ${mins} )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /hg/ { | |
uwsgi_pass unix:/run/uwsgi/hgweb.sock; | |
include uwsgi_params; | |
auth_basic "Mercurial repository"; | |
auth_basic_user_file /etc/nginx/htpasswd; | |
client_max_body_size 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
uid = uwsgi | |
gid = uwsgi | |
pidfile = /run/uwsgi/uwsgi.pid | |
emperor = /etc/uwsgi.d | |
stats = /run/uwsgi/stats.sock | |
chmod-socket = 660 | |
emperor-tyrant = true | |
cap = setgid,setuid | |
; https://www.mercurial-scm.org/wiki/PublishRepositoriesOnNginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[paths] | |
/hg/ = /srv/hg/repos/* | |
[web] | |
style = gitweb | |
staticurl = /hg/static | |
allow_push = * |