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 / alerts.sql
Created April 16, 2013 17:24
Find OSSEC alerts before a given date for a given IP
WITH params AS (SELECT '192.168.1.1' AS ip,
'2012-12-31' AS min_date)
SELECT a.id,
a.server_id,
a.rule_id,
('1970-01-01'::timestamp + (a.timestamp::text || ' seconds')::interval) AS timestamp,
a.location_id,
integer_to_inet(a.src_ip) AS src_ip,
integer_to_inet(a.dst_ip) AS dst_ip,
CASE WHEN a.src_port = 0 THEN NULL ELSE a.src_port END AS src_port,
@sycobuny
sycobuny / ugly_delete.sql
Created April 16, 2013 15:20
Cleaning out old OSSEC alerts
WITH
del_data AS (
DELETE
FROM data
WHERE EXISTS (
SELECT id
FROM alert
WHERE timestamp <= EXTRACT(EPOCH FROM (NOW() - '1 year'::interval))::integer AND
data.id = alert.id
)
@sycobuny
sycobuny / wedding_march.ly
Created April 14, 2013 22:47
I seem to be progressing with Lilypond. Here's Felix Mendelssohn's Wedding March from "A Midsummer Night's Dream" - the output's viewable at https://dl.dropboxusercontent.com/u/425499/wedding_march.pdf
\version "2.16.2"
\header {
title = "Wedding March"
composer = "Felix Mendelssohn"
}
dfnat = \markup \concat \vcenter { F \natural D \natural }
dfshp = \markup \concat \vcenter { F \sharp D \sharp }
cshp = \markup \concat \vcenter { C \sharp }
cfswp = \markup \concat \vcenter { C \natural F \sharp }
@sycobuny
sycobuny / exec_example.pp
Last active December 16, 2015 01:59
Debating formats for a custom type for RVM in puppet. I'm aware of an existing RVM type and provider, but it appears to install a global copy of RVM, and a group of which users must become a member to access. I'm looking to manage single-user installations of RVM.
# execute a command using an installed ruby/gemset
rvm::exec { 'start-myapp':
local => 'apache',
ruby_version => '1.9.3-p394',
gemset_name => 'myapp',
user => 'apache',
group => 'apache',
binary => 'thin',
arguments => ['start', '-p', '9292', '-P', '/var/run/myapp.pid'],
creates => '/var/run/myapp.pid',
module MyApp
class APIError < Exception; end
class Web < Sinatra::Base
def self.api(&block)
# some crazy stuff to wrap any get/put/delete/post/patch
# requests into a block with automatic error handling, and
# pass on all other requests to the sinatra base class.
end
@sycobuny
sycobuny / transactions.rb
Created March 18, 2013 15:22
Trying to get transactions to misbehave similar to https://gist.github.com/rintaun/5186914
require 'sequel'
require 'logger'
DB = Sequel.postgres('steve', :host => 'localhost')
DB.loggers << Logger.new($stdout)
# DB.run 'CREATE TABLE cars (id SERIAL PRIMARY KEY, asdf TEXT NOT NULL) WITHOUT OIDS;'
class Car < Sequel::Model
end
@sycobuny
sycobuny / namespaces.rb
Created March 13, 2013 21:19
Demonstrating some namespacing layouts in ruby
module Sequel
class Model
end
end
module Models
class User < Sequel::Model; end
class Post < Sequel::Model; end
end
\version "2.16.2"
\header {
title = "Ombra Mai Fu"
composer = "Georg Friederich Handel"
}
upper = \relative c' {
\clef treble
\key f \major
\time 3/4
var responses = {
leader: function() {
bot.say(to, leaderboard_data.Passings[leaderboard_running[0].index].Driver.DriverName + ' is leading the race. ' + lapticker + '')
console.log(to, leaderboard_data.Passings[leaderboard_running[0].index].Driver.DriverName + ' is leading the race. ' + lapticker + '')
},
luckydog: function() {
bot.say(to, leaderboard_data.Passings[leaderboard_luckydog].Driver.DriverName + ' is sitting in lucky dog position. ' + lapticker + '')
console.log(to, leaderboard_data.Passings[leaderboard_luckydog].Driver.DriverName + ' is sitting in lucky dog position. ' + lapticker + '')
},
@sycobuny
sycobuny / redirect.php
Last active December 11, 2015 08:29
Obsessive amounts of redirection
<?php
function redirect($url, $exit_status = 1) {
header('HTTP/1.0 303 See Other', true, 303);
header("Location: $url");
echo "<html><head><meta http-equiv='refresh' content='0;$url'></head>";
echo "<body><script>window.location='$url'</script></body></html>";
exit($exit_status);
}