Skip to content

Instantly share code, notes, and snippets.

View petdance's full-sized avatar

Andy Lester petdance

View GitHub Profile
@petdance
petdance / vim9.yaml
Created May 8, 2024 15:51
Ansible task to donwnload, build and install vim 9
---
- name: Vim 9
hosts: vim9
become: true
gather_facts: false
vars:
tarball: vim-9.1.tar.bz2
builddir: /usr/src/vim91
vimdir: /usr/local/vim91
vimexe: "{{ vimdir }}/bin/vim"
@petdance
petdance / gist:1c8ea0570dca5f60fcd860b69a2b4fc6
Last active January 10, 2023 21:15
Benchmarking /literal/ vs /$foo/ vs /$foo/o
$ cat slash-o.pl
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use Benchmark ':all';
my $COUNT = 10_000_000;
@petdance
petdance / gist:a696a4da79b9f42c30e840228245e31d
Created December 15, 2022 14:55
Optimizing sub recompilation
use 5.010;
use strict;
use warnings;
use Benchmark ':all';
my $COUNT = 10_000_000;
say "$COUNT iterations under $^V";
@petdance
petdance / solr-exporter.sh
Created February 19, 2020 17:23
Solr stats exporter
#!/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 December 3, 2019 19:31
cmp_bag() is slow with large arrays
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
use Test::More 'no_plan';
use Test::Deep qw( cmp_bag );
@petdance
petdance / trunkdiff-files
Created November 14, 2019 17:12
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 September 10, 2019 20:06
Put this in ~/.bash/prompt.sh, and add "source ~/.bash/prompt.sh" in your .bashrc
#!/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 August 20, 2019 21:38
My ~/.vim/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
@petdance
petdance / Functional.pm
Created July 18, 2019 16:39
TW::Functional
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.
// 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;