Skip to content

Instantly share code, notes, and snippets.

@jlinoff
jlinoff / README.md
Last active January 24, 2023 18:41
social security plot showing cumulative benefits for different starts crossover point using matplotlib

simple line plot example using matplotlib

This example shows the cumulative payout of social security using a normalized base value. It can be used to determine the best time to start collecting social security.

Here are some things the graph tells us.

If you believe that social security will remain viable for your entire life and you expect to live past age 79, then it is better to start

@jlinoff
jlinoff / inventory.py
Created February 2, 2022 00:31
Report all of the AWS service or resource types present in your accounts and regions from the command line (CLI).
#!/usr/bin/env python3
'''
Report all of the service or resource types present in accounts and
regions.
It generates six different reports:
1. diff the services between two accounts.
2. diff the resources between two accounts.
3. summary of services present in one or more accounts.
@jlinoff
jlinoff / ls.py
Created December 17, 2021 23:49
genric tools for local github repository analysis
#!/usr/bin/env python3
'''
list all repos.
'''
import datetime
import argparse
import getpass
import inspect
import os
import re
@jlinoff
jlinoff / README.md
Last active February 3, 2022 01:17
How I Setup a Latop Prototyping Environment for Grafana and Postgres
@jlinoff
jlinoff / instructions.txt
Last active November 15, 2021 22:40
How i setup macports for monterey (MacOSX SDK 12)
# How i fixed the SDK 12 warning from macports.
# Set me up as a sudo user.
# add this to /etc/sudoers (visudo)
# jlinoff ALL=(ALL) NOPASSWD: ALL
sudo dseditgroup -o edit -a jlinoff -t user admin
sudo dseditgroup -o edit -a jlinoff -t user wheel
# make sure xcode is installed and the license is accepted
xcode-select --install
@jlinoff
jlinoff / example.sql
Last active August 24, 2021 20:50
Convert row data to columns in postgresql for display in grafana stats panel
-- ========================================================================
-- Convert rows to columns for grafana stats display for enum like columns.
-- ========================================================================
--
-- Create a dummy table.
--
DROP TABLE IF EXISTS xdata CASCADE;
CREATE TABLE IF NOT EXISTS xdata (id SERIAL PRIMARY KEY, state TEXT NOT NULL);
COMMENT ON TABLE xdata IS 'Example data to show how the convert_rows_to_columns() function works';
@jlinoff
jlinoff / collect.py
Last active August 7, 2021 19:33
jenkins tools
#!/usr/bin/env python3
# pylint: disable=line-too-long
r'''
Extract the Jenkins build data into a JSON file for insertion into a
database where it can be used for graphing in grafana.
The following environment variables control the behavior of this program.
JFN Name of the text file to write all of the job names to.
This is mainly used for debugging.
@jlinoff
jlinoff / check_parquet_schema.py
Last active April 22, 2020 14:33
Pyarrow based python script that checks a parquet file to see if it can be read
#!/usr/bin/env python3
'''
This script accepts a list of parquetfiles and then runs through them
to see which column entries in the schema can be read. It is useful
for determining where pyarrow does not yet support a particular
schema type.
'''
import os
import sys
import pyarrow.parquet as pq
@jlinoff
jlinoff / Dockerfile.parquet-tools
Last active April 18, 2020 21:09
Docker image that builds parquet-tools and allows you to run parquet-tools
# Docker image that will allow one to run parquet-tools on any platform that supports docker.
#
# Build like this:
# $ docker build -f Dockerfile -t jlinoff/parquet:latest .
#
# Run it like this in the directory that contains your parquet file.
# $ docker run -it --rm --init -h jpt --name jpt -v $(pwd):/mnt jlinoff/parquet bash -i
# $ docker run -it --rm --init -h jpt --name jpt -v $(pwd):/mnt jlinoff/parquet jpt --help
# $ docker run -it --rm --init -h jpt --name jpt -v $(pwd):/mnt jlinoff/parquet jpt column-sizes test.parquet
#
@jlinoff
jlinoff / lambda.py
Created June 28, 2019 23:28
List all python3 packages and versions present in the AWS lambda environment
#!/usr/bin/env python3.7
'''
List all of the installed packages in the environment and write them
to the S3 bucket.
'''
import http
import json
import importlib
import os
import pkgutil