Skip to content

Instantly share code, notes, and snippets.

Ry Biesemeyer yaauie

Block or report user

Report or block yaauie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yaauie
yaauie / dpkg-cat
Created Apr 26, 2018
I had a need the other day to read files out of RPM and DEB packages, but wanted to avoid extracting them to my local filesystem; the following scripts cobble together the various tools I found to simply read a single file from either to stdout.
View dpkg-cat
#!/usr/bin/env bash -x
# prereq: tar
package="${1:?package}"
file="${2:?file}"
tar -xOf $package data.tar.gz | tar -zxO $file
View gzip-decode-filter.rb
# Copyright 2018 Ry Biesemeyer (@yaauie)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@yaauie
yaauie / ensure-trailing-newline.bash
Created Apr 12, 2018
Ensure Trailing Newline: ensures that the given plaintext file ends with a newline character, appending in-place only if it is missing.
View ensure-trailing-newline.bash
#!/usr/bin/env bash -e
#
# Ensure Trailing Newline: ensures that the given plaintext file ends with a
# newline character, appending in-place only if it is missing.
#
# Portable on POSIX-based or POSIX-compatible systems, as it uses POSIX-standard
# invocations of `wc`, `tail`, and `echo`.
#
# Copyright 2018 Ry Biesemeyer
#
@yaauie
yaauie / logstash-filters-cache-common.rb
Created Jan 12, 2018
logstash-filters-cache-common
View logstash-filters-cache-common.rb
class Logstash::Filters::CacheCommon < LogStash::Filters::Base
config :get, validate: :hash, required: false
config :set, validate: :hash, required: false
def register
@get ||= {}
@set ||= {}
if (@get.empty? && @set.empty?)
@yaauie
yaauie / json2csv
Created Aug 1, 2017
Script that takes an JSON-blob on stdin containg an array of objects, and outputs a CSV.
View json2csv
#!/usr/bin/env sh
if which jq ; then
cat | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv'
else
>&2 echo "\033[31mERROR: $(basename $0) requires jq\033[0m"
exit 127
fi
@yaauie
yaauie / README.md
Last active Feb 9, 2017
A simple command-line tool for creating randomised pairings, written in Ruby.
View README.md

Rando-Pair

It creates randomised pairings from the given inputs.

Examples:

Simple:

╭─{ yaauie@durin:~ }
╰─● rando-pair Alice Bob Charlie Donald Evelyn Frank Gertrude
View immutable-collectors.java
package com.yaauie.guava-utils;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet;
@yaauie
yaauie / jsonpp
Last active Aug 12, 2016
order-preserving jsonpp
View jsonpp
#!/usr/bin/env ruby
# encoding: utf-8
require 'json'
begin
$stdout.puts(JSON.pretty_generate(JSON.load($stdin.read)))
rescue JSON::ParserError => e
$stderr.puts(e.message)
exit 1
@yaauie
yaauie / Iso8601.g4
Created May 29, 2016
ISO-8601 Grammar
View Iso8601.g4
grammar Iso8601;
temporal : year (HYPHEN subyear)? offset? EOF
;
subyear : month (HYPHEN submonth)?
| W_LITERAL week (HYPHEN subweek)?
| Q_LITERAL quarter (HYPHEN subquarter)?
| oday (T_LITERAL subday)?
;
@yaauie
yaauie / kafka-lag-top.rb
Created Feb 8, 2016
a top-like version of https://gist.github.com/yaauie/40a9176f354f0100db47 put this in the bin of the kafka tarball you downloaded from https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz and invoke it with the path to the zookeeper node as its only argument.
View kafka-lag-top.rb
#!/usr/bin/env ruby
require 'shellwords'
require 'time'
END {
zookeeper = ARGV.shift || fail("Usage #{$0} <zookeeper>")
$stderr.puts("Getting stats via #{zookeeper}")
one_five_fifteen = []
You can’t perform that action at this time.