Skip to content

Instantly share code, notes, and snippets.

View M1ke's full-sized avatar

Mike Lehan M1ke

View GitHub Profile
@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
@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 / 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 / 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 / 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 / disk-usage-alert.sh
Last active February 21, 2024 15:35
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" your@email.com
fi
done
@M1ke
M1ke / turn-off-retweets
Last active March 7, 2018 23:22
Want to turn off Retweets from all users you're following without clicking each time? This script sorts that, using a timer to avoid your requests being blocked and returning a 403. Scroll to the bottom of your Following list, paste it into Chrome's console (Firefox should work too) and hit enter. It turns off 3 per minute (you could reduce the …
var interval=setInterval(function(){
$('.user-actions.including .retweet-off-text').last().click();
if ($('.user-actions.including .retweet-off-text').length<1) {
clearInterval(interval);
}
},20000);
@M1ke
M1ke / vebra-field-names.md
Last active December 21, 2015 08:58
Bash script to write column headings for CSVs downloaded via FTP from the Vebra 5.2 property management platform.

For developers working to import properties from the GMG Property Services software platform Vebra 5.2. The files provided are missing field headers which can require extra work from existing CSV parsing libraries which will require a column name input by number, which at the very least is awkward to type out.

This shell script abstracts this task away from your application - simply run this after the FTP download completes and your application can process the files with native CSV libraries without any additional input for interpreting column numbers or input of column titles. The headings are taken from official documentation.

@M1ke
M1ke / dd-progress.md
Last active December 24, 2015 13:49
Bash script to track progress of `dd` command.
@M1ke
M1ke / img-backup.md
Created October 3, 2013 11:15
Bash scripts for copying images to and from drives. Made with the intention of replicating SD cards for Raspberry Pi