Skip to content

Instantly share code, notes, and snippets.

mysql> select html_decode('This & that!');
+---------------------------------+
| html_decode('This & that!') |
+---------------------------------+
| This & that! |
+---------------------------------+
1 row in set (0.00 sec)
#!/bin/bash
FAIL=0
LOG=log.txt
ERROR_LOG=messages.txt
GENERATORS=("FILE_1" "FILE_2")
echo "===> Truncating logs"
rm -f $LOG
rm -f *_$ERROR_LOG
@ejhayes
ejhayes / list_user_cronjobs.sh
Last active December 15, 2015 05:29
For each user listed grab a list of their cronjobs and display back to the screen.
#!/bin/bash
cat /etc/passwd | sed -e "s/\([^:]\+\).*/\1/" | xargs -I user bash -c "echo user && su user -c \"crontab -l\""
@ejhayes
ejhayes / trac.py
Last active December 14, 2015 14:49
Basic trac api usage
# Login and authenticate
from xmlrpclib import ServerProxy
p = ServerProxy('http://USERNAME:PASSWORD@trac/storm/login/rpc')
# Query tickets and print out the results
for i in p.ticket.query('owner=eric&status!=closed'):
p.ticket.get(i)
# What ticket attributes are available to pass to the attributes struct?
p.ticket.getTicketFields()
@ejhayes
ejhayes / qualify_fails.sh
Last active December 10, 2015 23:18
This is a pretty nasty way of finding schema.yaml files, renaming them based on directory structure, and moving them to a centralized schemas directory. The goal is to use this for future schema validation.
find beta -type f -name \*.yaml | xargs -I file echo file | sed "s/\(\([a-zA-Z\_]\+\)\/\([a-zA-Z\_]\+\).*\)/kwalify -lf \1 \3\/\2.yaml/" | sh && e=$(find beta -type f -name \*.yaml | xargs -I file echo file | sed "s/\(\([a-zA-Z\_]\+\)\/\([a-zA-Z\_]\+\).*\)/kwalify -lf \1 \3\/\2.yaml/" | sh ) && echo $e | grep -v INVALID
@ejhayes
ejhayes / run_changescript.sql
Created December 7, 2012 23:38
SQL Server catch compile time and runtime errors
/*
Our runner script
*/
CREATE PROCEDURE inner_sp AS
EXEC dbo.usp_RecordChangeScript '2007-01-2012 (ERIC TEST).sql', '0.1.11'
EXEC dbo.usp_RecordChangeScript '2004-01-2012 (ERIC TEST).sql', '0.1.11'
-- CODE GOES HERE
GO
@ejhayes
ejhayes / git-export-multiple-paths.sh
Created November 16, 2012 19:29
Git Export - functions just like a subversion export. Very nice!
git archive --format=zip --remote=git@git:project.git master some/path other/path -o whatever.zip
@ejhayes
ejhayes / build1.ps1
Created November 9, 2012 16:15
Calling build2 with arguments gathered from build1
param (
[string]$test,
$buildArgs
)
echo $buildArgs.test
./build2.ps1 @buildArgs
@ejhayes
ejhayes / node.rb
Created August 7, 2012 05:43
Rake API for Puppet Dashboard - includes functionality to search for nodes that contain a class
task :hasclass => :environment do
class_name = false
if ENV['class']
class_name = ENV['class']
end
NodeClassMembership.find(:all, :include => [:node_class],:conditions => {
:node_classes => { :name => class_name }
}).each do |node|
@ejhayes
ejhayes / bootstrap_puppet_win.cmd
Created July 26, 2012 00:53
Bootstrap puppet install for windows
# rename the computer (and reboot)
runas /user:Administrator "netdom renamecomputer \"%COMPUTERNAME%\" /Newname \"EricTest\" /force /reboot 0"
# restart computer NOW
shutdown /r /t 0