Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Lester petdance

View GitHub Profile
@petdance
petdance / solr-exporter.sh
Created Feb 19, 2020
Solr stats exporter
View solr-exporter.sh
#!/bin/bash
SOLRJOB=$1
SOLRHOST=$2
if [[ $SOLRJOB == "" || $SOLRHOST == "" ]] ; then
echo 'Usage: solr-exporter.sh SOLRJOB SOLRHOST'
echo ' Ex: solr-exporter.sh solrdev volley.flr.follett.com'
exit 1
fi
@petdance
petdance / gist:bb4482751f477b64c3d11ff6d143c89d
Created Dec 3, 2019
cmp_bag() is slow with large arrays
View gist:bb4482751f477b64c3d11ff6d143c89d
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
use Test::More 'no_plan';
use Test::Deep qw( cmp_bag );
View trunkdiff-files
#!/usr/bin/env python3
import os
import re
status = re.compile('^(\\+\\+\\+|---) \\s+ ([^\t]+) \t .+ \t \\((.+?)\\)$', re.X)
deletes = []
adds = []
diffs = []
@petdance
petdance / prompt.sh
Created Sep 10, 2019
Put this in ~/.bash/prompt.sh, and add "source ~/.bash/prompt.sh" in your .bashrc
View prompt.sh
#!/bin/bash
# Adapted from from https://github.com/hoelzro/bashrc/blob/master/colors.sh
function __prompt
{
local EXIT="$?" # Stash the exit status for later.
# List of color variables that bash can use
local BLACK="\[\033[0;30m\]" # Black
@petdance
petdance / .vimrc
Created Aug 20, 2019
My ~/.vim/vimrc
View .vimrc
"============================================================================
" General settings
"----------------------------------------------------------------------------
set nocompatible " nocp: turn off vi compatibility
set undolevels=1000 " ul: lots and lots of undo
set history=50 " hi: size of :command history
set modelines=20
set modeline " ml: Turn on modelines
set backup " keep a backup file
View Functional.pm
package TW::Functional;
=head1 NAME
TW::Functional -- functions for helping write more functional code
=head1 WARNING
This module must contain no TW-specific code. These are purely abstract functions.
View service.js
// service.js -- Reports back the ISBNs in a the given ISBN's family.
'use strict';
const oracledb = require('oracledb');
const http = require('http');
const url = require('url');
const hostname = 'hostname.com';
const port = 42000;
View splitdump.py
#!/usr/bin/env python
# Python version of https://gist.github.com/petdance/a147f8da9d2afde593382321c07dd2d1
import csv
import string
def create_sql():
return '''
DROP TABLE IF EXISTS response;
DROP TABLE IF EXISTS reasons;
View splitdump.pl
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new;
@petdance
petdance / counts.sql
Last active May 3, 2019
Gender counts per reason
View counts.sql
/* The MariaDB I installed doesn't support CTEs, so use a subquery */
SELECT * FROM (
select
reason,
SUM( CASE WHEN gender = 'Male' THEN 1 END) as M,
SUM( CASE WHEN gender = 'Female' THEN 1 END) as F,
SUM( CASE WHEN gender NOT IN ('Male','Female') THEN 1 END) AS X,
COUNT(gender) AS T
from response
inner join reasons on reasons.responseid = response.responseid