Skip to content

Instantly share code, notes, and snippets.

@xlfe
xlfe / telemere-gcp-structured-logs.clj
Last active November 4, 2024 21:36
How to get Structured Logging on GCP with Telemere
(def gcp-json-handler
(tele/handler:console
{:output-fn (tele/pr-signal-fn
{:pr-fn jsonista.core/write-value-as-string
:clean-fn (tele/clean-signal-fn {:incl-kvs? true})})}))
(def encore-levels->gcp-severity
{:trace :DEFAULT ; (0) The log entry has no assigned severity level.
:debug :DEBUG ; (100) Debug or trace information.
:info :INFO ; (200) Routine information, such as ongoing status or performance.
{ config, pkgs, lib, ... }:
let
# bash script to let dbus know about important env variables and
# propagate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile {
@xlfe
xlfe / find-var.clj
Last active January 20, 2023 09:15 — forked from borkdude/find-var.clj
Babashka script to find var usages in current project (using installed clj-kondo instead of clj-kondo pod)
#!/usr/bin/env bb
;; usage:
;; $ find-var.clj babashka.main/main src:test
;; example output:
;; src/babashka/main.clj:672:32
;; src/babashka/main.clj:673:22
;; src/babashka/main.clj:676:28
;; test/babashka/test_utils.clj:31:59

openpgp4fpr:535FFD2607AFCB2C97831159CD1D679C615C17C8

@xlfe
xlfe / ipmitemp.py
Created March 2, 2020 10:19
manage fans
from pySMART import Device, DeviceList
import subprocess, datetime, time, logging, sys
#below this triggers an alert and fans spin up
MIN_FAN = 10
MAX_FAN = 64
IPMI_SLEEP_DELAY = 2
SYS_FAN_THRESH = [55, 50, 45, 00]
SYS_FAN_SPEEDS = [64, 48, 30, MIN_FAN]
@xlfe
xlfe / keybase.md
Last active November 24, 2019 21:06

Keybase proof

I hereby claim:

  • I am xlfe on github.
  • I am xlfe (https://keybase.io/xlfe) on keybase.
  • I have a public key whose fingerprint is 535F FD26 07AF CB2C 9783 1159 CD1D 679C 615C 17C8

To claim this, I am signing this object:

@xlfe
xlfe / export.py
Created June 30, 2019 05:56
Export from Google App Engine Datastore Backup LevelDB format to JSON flat file
import sys, os, json
import datetime
sys.path.append(os.path.expanduser('~/google-cloud-sdk/platform/google_appengine/'))
from google.appengine.api.files import records
from google.appengine.datastore import entity_pb
from google.appengine.api import datastore
def myconverter(o):
if isinstance(o, datetime.datetime):
@xlfe
xlfe / CVE-download.py
Last active March 10, 2018 23:26
CVE and CWEs to CSV files
# coding: utf-8
# #CVE and CWE formatting to TSV
# In[217]:
from jsonpath_ng import jsonpath, parse
import csv
@xlfe
xlfe / make_docset.sh
Created October 26, 2017 00:46
Bash script that generates a Kapeli Dash docset for the google-cloud-java API Docs
#!/bin/bash
wget http://kapeli.com/javadocset.zip
unzip javadocset.zip
wget https://github.com/GoogleCloudPlatform/google-cloud-java/archive/gh-pages.zip
unzip gh-pages.zip google-cloud-java-gh-pages/latest/apidocs/*
./javadocset google-cloud-java google-cloud-java-gh-pages/latest/apidocs/
@xlfe
xlfe / generate_ioc_chart.py
Last active September 14, 2017 22:26
convert an xml openIOC (Stuxnet) to a graphical form
from graphviz import Digraph
from lxml import etree, objectify
import random
#https://stackoverflow.com/questions/30232031/how-can-i-strip-namespaces-out-of-an-lxml-tree
def strip_ns_prefix(tree):
query = "descendant-or-self::*[namespace-uri()!='']"
for element in tree.xpath(query):
element.tag = etree.QName(element).localname
return tree