Skip to content

Instantly share code, notes, and snippets.

View markuman's full-sized avatar
🐧
Linux Only - fail fast, move on

Markus Bergholz markuman

🐧
Linux Only - fail fast, move on
  • Lekker Energie GmbH
  • Berlin
View GitHub Profile
@woowa-hsw0
woowa-hsw0 / assume_role.sh
Last active January 11, 2023 11:36
Start AWS CLI Session with MFA Enabled (+Yubikey)
#!/bin/bash
set -eu
umask 0022
if [[ $# -lt 1 ]]; then
echo "Usage: $0 role_name [AWS ACCOUNT NUMBER]" >&2
exit 1
fi
@darahayes
darahayes / ansible_kms_encrypt_decrypt.md
Last active February 18, 2024 18:57
KMS Encrypt and Decrypt filters in Ansible

KMS Encrypt and Decrypt Filters for Ansible

This Gist shows how you can encrypt/decrypt variables with KMS during your Ansible playbook execution. While google searching I couldn't find anything useful on the subject.

Let's say your project has a folder of playbooks called plays.

In that folder, create a folder called filter_plugins and insert kms_filters.py (included in this gist)

@fliphess
fliphess / sentry.py
Last active July 28, 2024 08:06
Ansible sentry callback plugin - Send all errors from ansible to Sentry
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import getpass
import logging
import logging.config
import os
import socket
try:
@KyleBanks
KyleBanks / docker-stats-json
Created February 10, 2017 01:27
Returns Docker stats as a JSON Object
docker stats --no-stream \
--format "{\"container\": \"{{ .Container }}\", \"memory\": { \"raw\": \"{{ .MemUsage }}\", \"percent\": \"{{ .MemPerc }}\"}, \"cpu\": \"{{ .CPUPerc }}\"}"
@Richard-Mathie
Richard-Mathie / Redis Cluster Setup with Docker Swarm.md
Last active May 11, 2022 12:58
Redis cluster setup with docker swarm

Redis Cluster Setup with Docker Swarm

Setup

./redis.sh

Test

test the redis cluster

-- A hastily-written Lua solution to the arithmetic puzzle
-- written about in http://composition.al/blog/2016/12/31/a-simple-but-difficult-arithmetic-puzzle-and-the-rabbit-hole-it-took-me-down/
-- Took me longer to write than I initially thought, but at least the first approach I thought of worked.
-- I deliberately kept the code as I wrote it (took me 69 minutes to get to this), no post-facto cleanups done.
local function copy_table(t)
local u = {}
for k,v in pairs(t) do
if type(v) == "table" then
u[k] = copy_table(v)
#!/bin/bash
# Prerequisites: http://wiki.openwrt.org/doc/howto/buildroot.exigence
# Additionally JDK is needed
generate_buildenv() {
# Prepare build enviroment
mkdir lede_build
cd lede_build
git clone https://github.com/lede-project/source.git
@naddeoa
naddeoa / xps-touchscreen-workaround.service
Last active February 14, 2024 22:03
I just got an XPS and I ran into the issue where the touch screen stops working after resume. After doing a little digging, I was able to find out that this is fixed in the Linux kernel by a developer named Mika Westerberg. I got in touch with him and he was able to set me off on the right track for developing a proper work around that I could u…
[Unit]
Description=Potentially dangerous fix touchscreen after resume on the XPS 13 9350
After=suspend.target
[Service]
Type=simple
ExecStart=/home/anthony/path/to/xps-touchscreen-workaround.sh
[Install]
WantedBy=suspend.target
@avimar
avimar / knex-functions.js
Created August 28, 2016 07:15
knex mysql update on duplicate and replace
function upsert(table, data, update){
if(!update) update=data;
var insert = knex(table).insert(data).toString();
var update = knex(table).update(update).toString().replace(/^update .* set /i, '');
return knex.raw(insert + ' on duplicate key update ' + update);
}
function replace(table, data){
var insert = knex(table).insert(data).toString().replace(/^INSERT/i, 'REPLACE');
return knex.raw(insert);

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.