Skip to content

Instantly share code, notes, and snippets.

View M1ke's full-sized avatar

Mike Lehan M1ke

View GitHub Profile
@M1ke
M1ke / disk-usage-alert.sh
Last active June 11, 2024 09:18
A shell script to check your disk usage and alert you if it hits a limit. Change the value (percentage) in the "if" statement on line 7 to alter the threshold. Change the email address to your email address. See readme for mail.cf instructions and crontab.
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
used=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 80 ]; then
echo "The partition \"$partition\" on $(hostname) has used $used% at $(date)" | mail -s "Disk space alert: $used% used" [email protected]
fi
done
@M1ke
M1ke / Bookmarklet
Last active February 26, 2024 07:15
Script to add a timer to a page, along with a function to record it in a Trello comment.
javascript:(function(){
var jsCode=document.createElement('script');
jsCode.setAttribute('src','https://gist.github.com/M1ke/4944552/raw/17d5768dab89f3737104202b4fc7a56d286fc4c7/trello-timer.js');
document.body.appendChild(jsCode);
}());
@M1ke
M1ke / post-commit.ps1
Created October 29, 2012 16:17
Shell file for hooks on Windows with mysysgit installed (includes curl if in path) and powershell code for systems without curl.
$liveCommitClient = new-object System.Net.WebClient;
$liveCommitMessage = git show --format='%s' --name-only HEAD
$liveCommitClient.DownloadFile("http://dashboard.hackmanchester.com/commits?git&message="+ $liveCommitMessage + "&user=73&secret=4aYGnJ3gKotIeUztieyV&files=" , "c:\tmp\null");
echo 0
@M1ke
M1ke / PhingBuiltTask.php
Created October 6, 2012 00:54
Phing Last Build Time Saver
<?php
/*
* $Id: FileSizeTask.php 1084 2011-05-06 09:55:25Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@M1ke
M1ke / phpnw12_word-count.js
Created June 24, 2012 13:53
PHPNW12 Talk Submission Word Count
var count=0;
$('#cf_field_4').unbind('keyup').keyup(function(){
var words=($(this).val().split(" ").length);
if (words!=count)
{
$(this).next().html(words+' words');
}
count=words;
});
var count2=0;
@M1ke
M1ke / TstampTask.php
Created May 8, 2012 14:06
Phing Timestamp: The tstamp task returns a PHP warning if the default timezone isn't set in the install. Rather than suppressing warnings, this adds the timezone setting, and additionally checks that the function exists so Phing doesn't break
<?php
/*
* $Id: TstampTask.php 557 2009-08-29 13:54:38Z mrook $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT