Skip to content

Instantly share code, notes, and snippets.

View Ehekatl's full-sized avatar

Dylan Wang Ehekatl

View GitHub Profile
@mattymo
mattymo / yaml_ordered.py
Last active September 29, 2019 11:02 — forked from willmerae/yaml_ordered.py
Ansible inventory plugin that preserves the order of hosts in a host group
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
import os
from collections import MutableMapping
from yaml.nodes import MappingNode
@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active April 22, 2024 13:01
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@magicdude4eva
magicdude4eva / zsh-syntax-highlighting paste performance improvement
Last active April 19, 2024 14:03
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
#!/bin/bash
# Inspired by https://github.com/oogali/ebs-automatic-nvme-mapping
# Thanks Oogali!
# Tested on Ubuntu 16.04
# To be used with the below udev rule (/etc/udev/rules.d/99-ebs-nvme.rules)
# SUBSYSTEM=="block", KERNEL=="nvme[0-9]*n[0-9]*", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM+="/usr/local/sbin/nvme-mapping.sh /dev/%k" SYMLINK+="%c"
if [[ -x /usr/sbin/nvme ]] && [[ -b ${1} ]]; then
# capture 32 bytes at an offset of 3072 bytes from the raw-binary data
# not all block devices are extracted with /dev/ prefix
@TimJDFletcher
TimJDFletcher / GNUPG_agent_forwarding.md
Last active April 10, 2024 20:09 — forked from surhudm/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For headless systemd based hosts

@steven2358
steven2358 / ffmpeg.md
Last active April 21, 2024 02:08
FFmpeg cheat sheet
@mpontillo
mpontillo / test-maas-enlistment.sh
Last active February 2, 2022 08:47
Script to fetch the default TFTP configuration from MAAS and fetch the cloud-config URL.
#!/bin/bash -e
TMPDIR="$(mktemp -d)"
function cleanup() {
rm -rf "$TMPDIR"
}
trap cleanup EXIT
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active November 5, 2023 12:14
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@JPvRiel
JPvRiel / linux_memory_control_to_avoid_swap_thrashing.md
Created November 7, 2016 22:29
Notes on linux memory management options to prioritize and control memory access using older ulimits, newer cgroups and overcommit policy settings. Mostly as an attempt to keep a desktop environment responsive and avoid swap thrashing under high memory pressure.

Overview

Some notes about:

  • Explaining why current day Linux memory swap thrashing still happens (as of 2016).
  • Mitigating "stop the world" type thrashing issues on a Linux workstation when it's under high memory pressure and where responsiveness is more important than process completion.
  • Prioritizing and limiting memory use.
  • Older ulimit versus newer CGroup options.

These notes assume some basic background knowledge about memory management, ulimits and cgroups.

@DaniSancas
DaniSancas / neo4j_cypher_cheatsheet.md
Created June 14, 2016 23:52
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)