Skip to content

Instantly share code, notes, and snippets.

@maxclaus
maxclaus / README.md
Last active January 8, 2025 00:36
Forwarding TCP-traffic to a UNIX socket

Base Command

socat -d -d TCP4-LISTEN:15432,fork UNIX-CONNECT:/srv/mongodb-27017.sock

Final Script

./forward-port-to-socket.sh 15432 /srv/mongodb-27017.sock
@tanyuan
tanyuan / stow.md
Last active August 1, 2024 22:40
How to use GNU Stow.

GNU Stow: maintain dotfiles

Put all dotfiles in a specific folder so it is easy to use version control tool like git.

Steps

  1. Create directory ~/dotfiles/.
  2. Copy dotfiles into directories like:
@krishnasrinivas
krishnasrinivas / madmin-rest.md
Last active October 12, 2024 07:48 — forked from krisis/madmin-rest.md
Minio Management REST API spec

Minio Management REST API

Management APIs implement remote administrative operations over HTTP/REST. This guide is intended for SDK developers of package like madmin. If you are an enduser please take a look at mc admin CLI interface.

Authentication

  • All requests should be signed using AWS Signature Version V4

FEEDBACK: We can use simpler JSON webtoken for Auth just like how minio-browser does. Tokens are a standard way of auth for REST APIs.

  • us-east-1 should be used in signing
{
"title": "Languages",
"rules": [
{
"description": "Command + Shift to Command + e",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_shift",
SELECT
current_database(), schemaname, tablename, /*reltuples::bigint, relpages::bigint, otta,*/
round(avg((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::float/otta END)::numeric),1) AS tbloat,
round(avg(CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END), 0) AS wastedbytes
FROM (
SELECT
schemaname, tablename, cc.reltuples, cc.relpages, bs,
CEIL((cc.reltuples*((datahdr+ma-
(CASE WHEN datahdr%ma=0 THEN ma ELSE datahdr%ma END))+nullhdr2+4))/(bs-20::float)) AS otta,
COALESCE(c2.relname,'?') AS iname, COALESCE(c2.reltuples,0) AS ituples, COALESCE(c2.relpages,0) AS ipages,
@swinton
swinton / README.md
Last active May 4, 2025 12:04
Automatically sign your commits from GitHub Actions, using the REST API

Verified commits made easy with GitHub Actions

image

So you want to commit changes generated by a GitHub Actions workflow back to your repo, and have that commit signed automatically?

Here's one way this is possible, using the REST API, the auto-generated GITHUB_TOKEN, and the GitHub CLI, gh, which is pre-installed on GitHub's hosted Actions runners.

You don't have to configure the git client, just add a step like the one below... Be sure to edit FILE_TO_COMMIT and DESTINATION_BRANCH to suit your needs.

  • macOS Ventura (13.4, M1) 環境で確認済み。

Disable mDNS on macOS

  1. sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool YES
  2. Reboot

Enable mDNS on macOS

  1. sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool NO
[
{
"bindings": {
// Built-in
"ctrl-g": "menu::Cancel",
"ctrl-x 5 2": "workspace::NewWindow",
"ctrl-x ctrl-c": "zed::Quit",
"ctrl-x ctrl-f": "workspace::Open",
"ctrl-x k": "pane::CloseActiveItem",
"ctrl-x o": "workspace::ActivateNextPane",
@lcrilly
lcrilly / README.md
Last active August 8, 2025 12:32
Prometheus exporter for NGINX Unit metrics

Prometheus exporter for NGINX Unit metrics

The NGINX Unit control API includes a /status endpoint for usage statistics. This is a solution for exposing these metrics in Prometheus format.

The application (run by Unit) queries the /status URI on the control socket and converts the JSON response into Prometheus text format. PHP and Python implementations are available.

These instructions assume an existing Unit installation with a working configuration. We will add a new listener on the default prometheus port (9090) and route it directly to the Prometheus app.

Step 0. Install the preferred Unit language module (unit-php or unit-python)