Skip to content

Instantly share code, notes, and snippets.

View BiggerNoise's full-sized avatar

Andy Davis BiggerNoise

View GitHub Profile
@BiggerNoise
BiggerNoise / SelectList.groovy
Created July 3, 2019 16:17
This will allow DataGrip results to be copied to the clipboard so they can be easily used in a select query
SEP = ", "
QUOTE = "\'"
NEWLINE = System.getProperty("line.separator")
KEYWORDS_LOWERCASE = com.intellij.database.util.DbSqlUtil.areKeywordsLowerCase(PROJECT)
def record(column, dataRow) {
def value = dataRow.value(column)
if( value == null)
return
@BiggerNoise
BiggerNoise / Slack-Paste.groovy
Created April 26, 2019 16:18
This will allow DataGrip results to be copied to the clipboard in a slack friendly markdown format.
SLACK_CODE = "```"
SEP = "|"
NEWLINE = System.getProperty("line.separator")
def scan(ROWS, COLUMNS) {
result = []
result.add(COLUMNS.collect { col -> col.name() })
ROWS.each { row -> result.add(COLUMNS.collect { col -> row.value(col).toString() }) }
@BiggerNoise
BiggerNoise / Dockerfile
Created February 8, 2016 17:41
Simple Dockerfile and bash scripts for playing around with signals & docker
FROM debian:jessie
MAINTAINER Koan Health <development@koanhealth.com>
ADD ./run.sh /usr/bin/
CMD ["run.sh"]
@BiggerNoise
BiggerNoise / .bash_profile
Created April 8, 2015 16:40
Some useful shell commands and aliases when working with godep
# simple commands to alter the GOPATH for longer than a single command
alias guse='GOPATH=$(godep path):$HOME/dev/go'
alias greset='GOPATH=$HOME/dev/go'
@BiggerNoise
BiggerNoise / command.rb
Created April 1, 2014 02:13
Little add in module to make parameter parsing a little easier in Virtus classes.
class Command
include ActiveModel::Validations
include ActiveRecord::Serialization
include Virtus
include VirtusParameters
def initialize(params = {})
super
parse_params params
end
[
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["ctrl+shift+k"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+shift+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+j"], "command": "join_lines" },
{ "keys": ["ctrl+shift+j"], "command": "join_lines" },
{ "keys": ["super+\\"], "command": "reveal_in_side_bar" },
{ "keys": ["super+alt+l"], "command": "reindent" },
// Select text between brackets
{
@BiggerNoise
BiggerNoise / assign_case_command.rb
Created March 3, 2014 21:10
Command Pattern at work
class AssignCaseCommand < Command
attribute :case, Case
attribute :owner, User
attribute :created_by, User
attribute :comments, String
attribute :distribute_at, DateTime
attribute :distribute_rule_name, String
attribute :require_initial, Boolean
@BiggerNoise
BiggerNoise / task_poller.rb
Created September 4, 2013 20:04
Proposed way to rework the execute() method in ActivityTaskPoller so that it does not mark an activity as failed when only the completion notification fails
def execute(task)
activity_type = task.activity_type
begin
context = ActivityExecutionContext.new(@service, @domain, task)
activity_implementation = @activity_definition_map[activity_type]
raise "This activity worker was told to work on activity type #{activity_type.name}, but this activity worker only knows how to work on #{@activity_definition_map.keys.map(&:name).join ' '}" unless activity_implementation
output = activity_implementation.execute(task.input, context)
@logger.debug "Responding on task_token #{task.task_token} for task #{task}"
rescue ActivityFailureException => e
respond_activity_task_failed_with_retry(task.task_token, e.message, e.details)
@BiggerNoise
BiggerNoise / document_read_test.rb
Created July 1, 2013 01:15
Trying to demonstrate an issue that I am having when running capybara with a page that has an on document ready callback
require "capybara"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:selenium, app)
sess.visit("/")
puts 'You Lose' unless sess.has_content? 'Here it Is'
@BiggerNoise
BiggerNoise / read_flawed_spreadsheet.rb
Created January 25, 2013 18:38
Shows using the spreadsheet gem to read a file that is flawed. Worksheets and dimensions are correct, but cell data cannot be read. File that causes the issue can be found at: http://dl.dropbox.com/u/83477489/sample.xls
#!/usr/bin/env ruby
wb = Spreadsheet.open('sample.xls')
puts "Opened Spreadsheet, #{wb.sheet_count} sheets encountered"
(0..wb.sheet_count-1).each do |sheet_number|
ws = wb.worksheet(sheet_number)
puts "\tWorksheet #{ws.name} has #{ws.row_count} rows and #{ws.column_count} columns}; and Dimensions: #{ws.dimensions}"
end