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 / stuff_and_things.md
Created May 11, 2012 17:55
Philosophical Ramblings about Dependencies, Wheels, NIH, etc.

So, there's a single distinctly good reason to use modules that have already been written: they're already written, which means you don't have to write them. That saves time off your schedule from blank file to completed product. However, in the Perl world at least, it feels that there's reason to assume this may not always be the best course of action.

I'm actively considering writing (and somewhat [working on][plmodel]) a database for library along the lines of [Sequel][sequel]. I've looked at [RoseDB][rosedb] and [DBIx][dbix] and neither really seemed to match the It Just Works simplicity of Sequel for basic ad-hoc querying/runtime object construction, nor the flexibility and power of building more complex queries without advanced SQL knowledge. Your mileage will vary on whether you feel building complex queries entirely in Perl should be necessary, some will say you should just write raw SQL if it's that necessary, and that's a valid point but not one I'll be discussing.

Database libraries are, ho

"""""""""""""""""""""
" SYNTAX HIGHLIGHTING
"""""""""""""""""""""
set t_Co=256
syntax enable
highlight comment ctermbg=blue
highlight comment ctermfg=gray
highlight constant ctermfg=red
highlight type ctermfg=green
highlight preproc ctermfg=blue
@sycobuny
sycobuny / query.php
Created May 25, 2012 15:29
Second pass at a PGModel Query object
<?php
foreach (array('literal', 'identifier', 'qualified_identifier',
'join_condition', 'conditional', 'grouping', 'limiting',
'ordering') as $__) {
$__ = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "$__.php"));
include_once($__);
}
unset($__);
@sycobuny
sycobuny / gist:2794978
Created May 26, 2012 19:04
PGModel Query class hierarchy
_QueryExpression (interface)
|
| - _QueryFunction (interface)
|
| - _QueryTableExpression (interface)
|
| - _QueryValueExpression (interface)
_QueryAliasableExpression (abstract, implements _QueryExpression)
@sycobuny
sycobuny / table.php
Created May 27, 2012 16:50
A good _QueryTable class?
<?php
class _QueryTable extends _QueryTableExpression {
private $identifier;
function __construct($identifier, $alias = null) {
$this->identifier = _QueryIdentifier::create($identifier, $alias);
}
public static function create($identifier, $alias = null) {
@sycobuny
sycobuny / 001_start.rb
Created May 31, 2012 02:50
Eric's Migrations for RSVPs yayyy
Sequel.migration do
change do
create_table :guests
primary_key :id
String :first_name, :null => false
String :last_name, :null => false
String :street
String :city
@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';
@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 / 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 / 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,