Skip to content

Instantly share code, notes, and snippets.

@dgulino
dgulino / ash.bash
Created January 25, 2013 23:08
I've come up with a much better, simpler recipe to color my OSX Terminal session depending on the host I'm ssh-ing into. First, take a function with some cool BASH-only splitting and arrays and add that I found a way to address the current session in Applescript. Then add a one line way to enable bash ssh auto-complete when using the function. E…
ash() {
ARGS="$@"
IFS=" "
set -- $ARGS
ARGSARRAY=( $@ )
HOST=${ARGSARRAY[0]}
IFS="-"
set -- ${HOST}
MYARRAY=( $@ )
SERVERTYPE=${MYARRAY[0]}
@dgulino
dgulino / pyliner.py
Created February 10, 2013 16:19
Python script that runs one-liner python scripts similarly to how Perl runs them portions based on http://code.activestate.com/recipes/437932-pyline-a-grep-like-sed-like-command-line-tool/ (Graham Fawcett, Jacob Oscarson, Mark Eichin) interface inspired by Perl
#!/usr/bin/env python
"""
Python script that runs one-liner python scripts similarly to how Perl runs them
portions based on http://code.activestate.com/recipes/437932-pyline-a-grep-like-sed-like-command-line-tool/
(Graham Fawcett, Jacob Oscarson, Mark Eichin)
interface inspired by Perl
"""
@dgulino
dgulino / tgraph.py
Last active November 29, 2022 19:28
Console plotting in python. A single or multiple delimited numbers per newline.
#!/usr/bin/env python
from __future__ import division
from __future__ import print_function
#Copyright 2022 Drew Gulino
##This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
@dgulino
dgulino / timedcount.py
Last active August 24, 2021 14:13
Python console application that takes a stream of newline delimited characters (lines) and returns the count of these lines every N seconds.Nice way, in combination with grep, to keep track of certain activity in a log
#!/usr/bin/env python
#Copyright 2007 Drew Gulino
##This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@dgulino
dgulino / tgraph.erl
Last active December 12, 2015 09:18
Console plotting in erlang script (escript)
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp disable
%% Author: Drew Gulino
-module(tgraph).
-export([main/1]).
main(CmdLine) ->
OptSpecList = option_spec_list(),
@dgulino
dgulino / runavg.erl
Last active December 12, 2015 09:18
Output chunked average of numeric stream The main use case is when I'm looking into a problem, and tailing a log. Too much data. Awk/perl/pyline the interesting numbers and tail that. Numbers running too fast or changing too often to see a pattern. So I then pipe the number stream through a block average and then to tgraph. tail -f some.log | aw…
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp disable
%% Author: Drew Gulino
-module(runavg).
-export([main/1]).
main(CmdLine) ->
OptSpecList = option_spec_list(),
@dgulino
dgulino / runavg.py
Last active December 29, 2015 08:29
Outputs a simple average of all numbers, or given a size of numbers to group, will output a running average.
#!/usr/bin/env python
"""$ c=1;while true;do echo $c;let c=$c+1;sleep .5;done | ./avg.py -n 10
5.5
15.5
25.5
..."""
#Copyright 2005 Drew Gulino
##This program is free software; you can redistribute it and/or modify
require Logger
defmodule Tgraph do
def main(args) do
Logger.info inspect args
options = parse_args(args)
f = Dict.get(options,:file,:stdio)
case is_atom(f) do
true -> f
@dgulino
dgulino / ddiff
Last active January 16, 2018 16:17
Graphic diff of file across multiple remote machines via SSH
#!/usr/bin/env ruby
#osx: brew install diffuse
#linux rpm: rpm install diffuse
require 'optparse'
require 'pp'
options = {}
OptionParser.new do |parser|
parser.define_head "Distributed Diff"
parser.on('-h', '--hosts HOSTS') do |v|
{
"meta": {
"theme": "onepage"
},
"basics": {
"name": "Drew Gulino",
"label": "Senior Software Developer (SRE)",
"picture": "",
"email": "[email protected]",
"phone": "",