Skip to content

Instantly share code, notes, and snippets.

View jerryclinesmith's full-sized avatar

Jerry Clinesmith jerryclinesmith

View GitHub Profile
@jerryclinesmith
jerryclinesmith / aws_redshift_column_names.sql
Last active March 10, 2022 14:46
AWS Redshift: column names for table, column delimited
-- LISTAGG only works on user created tables, so need this hack
create table #cols (column_name varchar(255), ordinal_position int)
insert into #cols
select column_name, ordinal_position
from SVV_COLUMNS
where table_name = '<table name>' and table_schema = '<schema name>'
select LISTAGG(column_name, ', ') within group (order by ordinal_position) from #cols
@jerryclinesmith
jerryclinesmith / select.controller.js
Created January 6, 2015 15:27
angular-ui-select: Example using Single and Multiple choice with bootstrap theme
vm.person = undefined;
vm.friends = undefined;
vm.people = [
{ name: 'Jerry', id: 1 },
{ name: 'Andy', id: 2 },
{ name: 'Tom', id: 3 },
{ name: 'Brian', id: 4 }
];
@jerryclinesmith
jerryclinesmith / time_span.rb
Created November 22, 2013 16:50
Measure difference between 2 times
class TimeSpan
def initialize(seconds)
@seconds = (seconds || 0).abs
end
def in_seconds
@seconds
end
@jerryclinesmith
jerryclinesmith / comparable_range.rb
Created November 22, 2013 16:48
Comparable Range - union, intersect, and check for overlap/less than/greater than with 2 ranges
class ComparableRange < Range
include Comparable
def self.new(r_start, r_end = nil, exclusive = false)
r_end ||= r_start
r_start, r_end = r_end, r_start if r_end < r_start
super
end
def overlaps(other)
@jerryclinesmith
jerryclinesmith / chainer.rb
Created November 22, 2013 16:44
Chain a set of commands
module Chainer
STATUSES = [ STATUS_SUCCESS = :success, STATUS_FAIL = :fail ]
def self.execute(context, *steps)
steps.each do |step|
step.execute context
break if context.fail?
end
context