Skip to content

Instantly share code, notes, and snippets.

View entrity's full-sized avatar

Markham Anderson entrity

View GitHub Profile
#!/bin/bash
# check for -f flag as first argument; if present, bypass all restrictions
if [[ "$1" == "-f" ]]; then
shift
git-commit "$@"
exit 0
fi
fail()
@entrity
entrity / compulife_update_notifier.sh
Created April 30, 2014 14:25
Poll the Compulife server to check whether a new (data) update is available. Should be run daily as a cronjob. If a new update is available, emails notification to developers.
#!/bin/bash
LATEST_UPDATE=`curl http://www.compulife.com/US_update/UPDATE.DAT`
LATEST_UPDATE_FILE=$HOME/compulife-last-update.dat
echo Running compulife update test | wall
# Compose email
read -r -d '' BODY <<EOM
Compulife update available
$LATEST_UPDATE
@entrity
entrity / db-safety.sh
Last active August 29, 2015 14:04
Rails migration rollback for bad deploy
#!/bin/bash
# Run this script before deploying to make a text file containing all
# schema_migrations.
#
# After deploying, if a rollback is required, run this script again
# with an argument of 'back' to cherry-pick new migrations out of
# schema migrations (ones that weren't in the pre-deploy log of
# schema_migrations) and reverse them with rake db:migrate:down VERSION=X.
@ECHO OFF
REM Set vars
SET projdir=%ProgramFiles%\DataRaptorDialer
SET batfile=%projdir%\DataRaptorDialer.BAT
SET regfile=%projdir%\DataRaptorDialer.REG
IF NOT EXIST "%projdir%" ( MKDIR "%projdir%" )
REM Make .BAT file
(
#!/bin/bash
pattern=$1
mtime=$2
grep_args="-q -i"
[[ ! -z "$3" ]] && grep_args=$3
export pattern
count=0
export count
@entrity
entrity / paychex_bookmarklet.js
Last active August 29, 2015 14:13
Paychex TimeandLabor Clockout Calculator
javascript:
TIME_REGEX = /^(\d+):(\d+) (\w+)/;
function show (targetHours) {
var clockoutMatch = /(\d{2}):(\d{2}):(\d{2}){0,1}/.exec(getClockoutTime(targetHours).toString());
var outputHours = parseInt(clockoutMatch[1]);
var outputMeridian = (outputHours >= 12) ? 'pm' : 'am';
if (outputHours > 12) outputHours = outputHours % 12;
var clockoutString = "Clock out: "+outputHours+':'+clockoutMatch[2]+' '+outputMeridian;
if (clockoutMatch[3]) clockoutString += ' & '+clockoutMatch[3]+' sec';
@entrity
entrity / id3-mover.sh
Last active August 29, 2015 14:15
Rename media files using data in ID3 tags
#!/bin/bash
# Examines id3 tages of files in given directory and moves them
# to $TOPDIR, renaming path and file to match "artist/album/track - title.ext"
# - if album is absent: "artist/track - title.ext"
# - if track is absent: "artist/album/title.ext"
# - if title is absent: "artist/album/filename"
TOPDIR="$HOME/Music"
@entrity
entrity / mysql_from_rails_config.sh
Last active August 29, 2015 14:16
Connect to MySQL by parsing Rails database.yml
#!/bin/bash
usage () {
echo "Usage:"
echo -e "\t$0 [options] [dir] [rails env]"
echo "Options:"
echo -e "\t-e rails_env"
echo -e "\t-f yaml_file"
echo "Inclusion of 'file' option overrides 'dir' arg"
echo "@arg dir defaults to pwd"
@entrity
entrity / my-timer.py
Created March 9, 2015 17:37
Python timer app. When timer expires, it jiggles the icon in the unity launcher until a 'KILL' signal is sent to its pipe.
#!/usr/bin/env python
from gi.repository import Unity, GObject, Dbusmenu
import time, sys, re, os, pipes, StringIO
DESKTOP_FILE_NAME = 'my-timer.desktop'
PIPEFILE_NAME = '/tmp/my-timer-pipefile'
# Assumes your desktop file is 'my-timer.desktop'
launcher = Unity.LauncherEntry.get_for_desktop_id(DESKTOP_FILE_NAME)
launcher.set_property('progress_visible', True)
@entrity
entrity / my-timer-2.desktop
Last active September 23, 2017 07:13
Python timer app with a GUI for time input and display of time remaining. When timer expires, it jiggles the icon in the unity launcher until the GUI window receives a focus-in event.
[Desktop Entry]
Name=My Timer
Exec=/home/markham/scripts/timer.py
Icon=/usr/share/icons/cute.jpg
Type=Application
Terminal=false
StartupNotify=true
Categories=GTK;GNOME;Utility;