Skip to content

Instantly share code, notes, and snippets.

View sycobuny's full-sized avatar

Stephen Belcher sycobuny

  • Kelly Services, NIH/NIA
  • Baltimore, MD
View GitHub Profile
@sycobuny
sycobuny / first.pp
Created August 14, 2012 18:39
Puppet Management of Git Repos - Testing Methods of Cleaning it Up
# commands that are too long to reasonably be represented
$_gwt = "git tag | grep -e '^release-[0-9]\\{1,\\}\$'"
$_gwl = "${_gwt} | cut -d\\- -f2 | sort -rn | head -n1"
# figure out how to deploy this project
case "$mode" {
# ...
# prod box, make sure the latest code is loaded
'production': {
@sycobuny
sycobuny / README.md
Created August 15, 2012 16:55
"Using Git" presentation - draft outline

Using Git

Part 1 (of ...?)

This is a presentation designed for the August 16, 2012 meeting of the Baltimore Perl Mongers. It is not quite an introduction to the idea of git (as many of the members are already aquainted with it to some degree), but a discussion of some of the more interesting features that can be folded into a workflow quickly and

@sycobuny
sycobuny / .bashrc
Last active October 9, 2015 02:57
My current rc files (and friends)
# do regular system bashrc stuff, if there's one set up
if [ -f /etc/bashrc ] ; then
. /etc/bashrc
fi
# use 256 colors if available, otherwise default to
if [ -f /usr/share/terminfo/x/xterm-256color ] ; then
export TERM=xterm-256color
else
export TERM=xterm
@sycobuny
sycobuny / lessthan80.pl
Created August 22, 2012 18:06
Demonstrating a method for breaking long lines
package POE::Component::dns::monitor::sniffer;
use POE;
use warnings;
use strict;
sub spawn {
my ($session) = POE::Session->create(
inline_states => {
_start => sub {
@sycobuny
sycobuny / perl5i.pl
Created August 22, 2012 20:35
A not-very-Perl-y way of looping
#!/usr/bin/env perl
use v5.14;
use warnings;
use perl5i::2;
[0 .. 5]->foreach(func($i) {
say "current value of i is $i"
});
@sycobuny
sycobuny / deunicode.rb
Created August 31, 2012 16:19
Convert my unicode diagrams to ASCII
#!/usr/bin/env ruby
# encoding: utf-8
# etc. etc. etc.........
unless request.user_agent =~ /AppleWebKit/
# sub out all diagram corners with ascii +
%w(┌ ┐ └ ┘).each do |corner|
data.gsub!(corner, '+')
end
@sycobuny
sycobuny / unique_with_null.sql
Created September 10, 2012 15:59
Possible Solution to Unique-With-NULL Problem
-- you may have to declare the function after the table exists.
CREATE FUNCTION check_unique_ex(TEXT, TEXT, TEXT)
RETURNS BOOLEAN
LANGUAGE SQL
AS $BODY$
SELECT EXISTS (
SELECT 1
FROM ex
WHERE a IS NOT DISTINCT FROM $1 AND
b IS NOT DISTINCT FROM $2 AND
@sycobuny
sycobuny / myavg.sql
Created September 14, 2012 14:55
Cheap non-aggregate MAX() and AVG() functions
CREATE OR REPLACE
FUNCTION MYAVG(VARIADIC NUMERIC[])
RETURNS NUMERIC
LANGUAGE SQL
AS 'SELECT AVG(unnest) FROM UNNEST($1)';
@sycobuny
sycobuny / prt.pl
Last active October 11, 2015 08:37
My Swiss-Army Script, Redux
#!/usr/bin/env perl
use warnings;
use strict;
my ($home, $psql, $pg_ctl, $pg_dump, $code_root, $mig_dir, $replication,
$localdb, $rvm, $rubyver, $gemset_name, $gemset, $ruby_bin, $padrino,
$rep_port, $local_port);
my ($SUPER, $OWNER, $PRODDB, $DEVDB, $TESTDB, $TESTTMPLDB);
@sycobuny
sycobuny / migrate.php
Last active October 12, 2015 20:08
Basic PHP database migration script
<?php
/**
* Set up the database connections and other libraries
*/
require(
join(DIRECTORY_SEPARATOR,
array(dirname(__FILE__), '..', '..', 'pg_connect.php'))
);