Skip to content

Instantly share code, notes, and snippets.

@jordansissel
jordansissel / README.md
Last active May 28, 2022 06:43
Reading nested tar files.

What?

Sometimes tar files have tar files, and it might be nice to read the contents of some files several layers deep. Here's how we can do it with Ruby and Python3 with no external dependencies.

Podman save

We can create a layered tar file (a tar file containing other tar files) using docker save or podman save

% podman save fpm-ubuntu-18.04 -o test.tar
@jordansissel
jordansissel / comparison.md
Created February 11, 2012 08:42
DynamoDB is silly expensive
@jordansissel
jordansissel / conf
Last active May 19, 2022 08:17
Parsing flags from a file in Clamp in Ruby
--version 1.2.3.4
@jordansissel
jordansissel / data.md
Created July 3, 2012 23:36
Compression on large JSON file

The Data

Compression

  • Original: 708MB
  • xz -3: 70MB, 5:41.02 (2.07 mb/sec - 10:1 ratio)
  • bzip2 -3: 74MB, 4:39.11 (2.53 mb/sec - 9.5:1 ratio)
  • gzip -3: 103MB: 0:15.15 (46.73 mb/sec - 6.87:1 ratio)
  • lzop -3: 146MB, 0:06.53 (108.42 mb/sec - 4.85:1 ratio)
@jordansissel
jordansissel / 1-output.txt
Last active November 10, 2021 14:28
Convert curl|bash to an rpm with Docker and FPM
% docker build -t rust .
...
# Export the image to tarball, which itself contains tarballs and a manifest.json
% docker save -o rust.tar rust
# Extract the last layer
# tar's -O flag extracts a single entry from the tarball.
# The file we want is the last "Layer" in the manifest.json
% tar -xf rust.tar -O $(tar -xf rust.tar -O manifest.json | jq -r '.[].Layers[-1]') > curlbash.tar
@jordansissel
jordansissel / OUTPUT
Created November 9, 2021 04:37
pleaserun systemd service extraction with jq
[Unit]
Description=no description given
[Service]
Type=simple
User=root
Group=root
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
Display *dpy;
// Below here, Copilot generated the rest.
dpy = XOpenDisplay(NULL);
if (dpy == NULL) {
@jordansissel
jordansissel / output.md
Last active October 18, 2021 05:46
Climate controllers with local network access, according to Home Assistant
% git clone --depth 1 https://github.com/home-assistant/core

Find "climate" support, then look for components with iot_class matching "local"

% grep -l climate */const.py | awk -F/ '{print $1}' | xargs -n1 sh -c 'jq .iot_class $1/manifest.json | grep -q local && echo "* https://www.home-assistant.io/integrations/$1"' -
@jordansissel
jordansissel / RESULTS.md
Created September 21, 2012 07:41
screenshot + code showing how to query logstash/elasticsearch with a graphite function.

logstash queries graphed with graphite.

Operation: Decouple whisper from graphite.

Method: Create a graphite function that does a date histogram facet query against elasticsearch for a given query string for the time period viewed in the current graph.

Reason: graphite has some awesome math functions. Wouldn't it be cool if we could use those on logstash results?

The screenshot below is using logstash to watch the twitter stream of keywords "iphone" "apple" and "samsung" - then I graph them each, so we get an idea of popularity. As a bonus, I also do a movingAverage() on the iphone curve to show you why this is awesome.

@jordansissel
jordansissel / logstash-mysql-query-parse.md
Last active June 7, 2021 21:10
parsing mysql's query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '