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 / 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 / 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 / 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 / .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 / 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 / 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 / git_options.pp
Created August 14, 2012 18:00
All options I can think of for git deployment
node testnode {
git::repository { "repo":
# default values
server_user => "root",
owner_user => "root",
owner_group => "root",
target_dir => "repo",
githost => "githost",
gituser => $server_user,
target_dir => $name,
@sycobuny
sycobuny / ex.rb
Created August 9, 2012 13:03
Demonstrating various differences between class and instance methods in Ruby
#!/usr/bin/env ruby
class SomeClass
def self.add_two_numbers(one, two)
one + two
end
def add_two_numbers(one, two)
self.class.add_two_numbers(one, two)
end
@sycobuny
sycobuny / docview.rb
Created August 2, 2012 19:26
Simple Document Viewer
#!/usr/bin/env ruby
# discover OS information to see if we should use pygments to colorize code
if RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/
# no clue if this will work at all on windows, so whatever
USE_PYGMENTS = true
PYGMENTS_BLACKLIST = []
elsif RUBY_PLATFORM =~ /darwin/
version = `sw_vers -productVersion`
if version =~ /^10\.7/
@sycobuny
sycobuny / tap.php
Created June 19, 2012 18:26
Quick and dirty PHP TAP
<?php
$__TEST__COUNT__ = 0;
$__TEST__SUCCESS__ = 0;
$__TEST__FAILURE__ = 0;
$__EXPECTED__TESTS__ = null;
function no_plan() {
global $__EXPECTED__TESTS__;
$__EXPECTED__TESTS__ = 'none';