Skip to content

Instantly share code, notes, and snippets.

View entrity's full-sized avatar

Markham Anderson entrity

View GitHub Profile
@entrity
entrity / Brighten.md
Last active January 12, 2016 04:42
Read/write the brightness on my Ubuntu 14.04 LTS installation on my ThinkPad 440s.

Convenient CLI and GUI for adjusting the brightness on my Ubuntu installation in my Thinkpad T440

These are convenience scripts for encrypting/decrypting files with a password, salt, and an algorithm of your choice.

After performing the encryption/decryption, the script will ask whether you want to move the source files to the trash (using trash-cli). This option defaults to No.

These scripts will not overwrite any existing files but rather will exit with an error code if an existing file blocks their operation.

Algorithm

The algorithm defaults to aes-256-cbc, but you can set an environment variable ALGORITHM to override it.

@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;
@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 / 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 / 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 / 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';
#!/bin/bash
pattern=$1
mtime=$2
grep_args="-q -i"
[[ ! -z "$3" ]] && grep_args=$3
export pattern
count=0
export count
@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
(
@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.