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
module Sequel
class Database
alias :old_synchronize synchronize
def synchronize(server=nil, &block)
ret = nil
old_synchronize(server) do |connection|
connection.exec("SET search_path = #{Coleoptera::SSP}")
ret = block.call(connection)
connection.exec("RESET ALL")
/*
* FUNCTION coleoptera.find_or_create_instructions(
* TEXT[] -- instruction labels
* )
* RETURNS coleoptera.instructions[]
*/
-- as plpgsql
CREATE OR REPLACE
FUNCTION coleoptera.find_or_create_instructions(IN TEXT[], OUT coleoptera.instructions[])
@sycobuny
sycobuny / FindMusic.pl
Created June 9, 2011 15:06
Pull files off my iPhone
#!/usr/bin/perl
####
# this script is not safe.
# don't expect it to sanitize your input; it doesn't.
# so don't use it on a web server or anywhere else someone untrusted can access
# it.
# it was designed to work on Linux Mint.
# it requires sqlite3 to be installed, and is invoked from the command line.
@sycobuny
sycobuny / capacity.php
Created June 19, 2011 15:09
Order Generator for Ria
<?php
require_once '.include/include.php';
class Capacity extends Selector
{
private $type;
private $capacity;
private $cost;
function Capacity($capacity, $type, $cost, $photo)
@sycobuny
sycobuny / channel.rb
Created August 2, 2011 03:04
Cool DB stuff
def add_user_access(user, *flags_to_add)
# normalize arguments into a form we'll recognize
flags_to_add.collect! { |flag| flag.to_sym }
id = user.to_i
# backup our arguments in case we need to restore to them later
flags = user_flags(id)
flags_backup = flags.dup
flag_lookup_backup = {}
flags_to_add.each do |flag|
@sycobuny
sycobuny / crash.c
Created August 3, 2011 02:29
Simple program designed to crash. For some reason.
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char crash[16];
char* plz = "this is probably longer than 16 characters";
strcpy(crash, plz);
return 0;
@sycobuny
sycobuny / chanserv_database.rb
Created September 3, 2011 05:31
Thoughts on Kythera ChanServ DB
module Database
class Account
one_to_many :chanserv_channel_founders,
:class_name => Database::ChanServ::Channel,
:foreign_key => :founder_id
one_to_many :chanserv_channel_successors,
:class_name => Database::ChanServ::Channel,
:foreign_key => :successor_id
one_to_many :chanserv_privileges,
:class_name => Database::ChanServ::Privilege
@sycobuny
sycobuny / block_with_eval.rb
Created September 24, 2011 20:44
We're asserting the hell out of some arguments
module Sequel
class Model
STRIP_UNSAFE_VAR_NAMES = /[^a-z_]/i
#########
protected
#########
#
# Asserts that arguments match a certain class, and raises errors if
@sycobuny
sycobuny / abstract.py
Created January 30, 2012 01:39
Get the selection of a wx.ComboBox in python
# line 37 in llm/view/dialog/library/abstract.py
self.type = wx.ComboBox(panel,
-1,
choices=["CD/DVD/Blu-Ray", "Book/Magazine"],
style=wx.CB_READONLY)
sbs.Add(self.build_line(wx.StaticText(panel, -1, "Type:"), self.type))
# new line 51 in llm/view/dialog/library/abstract.py
@sycobuny
sycobuny / test_script.pl
Created February 2, 2012 17:40
Demonstrating the "Scribe" Logger
#!/usr/bin/perl
use warnings;
use strict;
use Scribe;
my ($logger) = Scribe->new(
minlog => Scribe::DEBUG6,