Skip to content

Instantly share code, notes, and snippets.

View rot26's full-sized avatar
💬
is typing...

Chris Coleman rot26

💬
is typing...
  • Denver, Colorado, United States
  • 01:25 (UTC -06:00)
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active July 23, 2024 10:30
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@mneil
mneil / __init__.py
Last active February 3, 2023 16:06
AWS Lambda Python Log Factory w/ Filter Secrets
'''
Place this file in your lambda package next to the handler file.
Setting the log formatter on lambda loses the request id out of the context.
But, you often want to use a logger across a few files and name them
or change the log format.
This factory will ensure that the lambda context id is available to any
log format you choose. It also has the ability to filter out strings
from the logs using a regular expression.
@mneil
mneil / conftest.py
Created November 24, 2020 21:28
Patch boto3 to avoid credentials errors and real API calls during unit tests.
'''
Unit test setup automatically called
'''
from unittest import mock
import pytest
# Fixture, autouse
@pytest.fixture(scope='session', autouse=True)
def patch_boto3(request):
@janeczku
janeczku / 01-multus-k3s.md
Last active June 19, 2024 12:46
Multus CNI with k3s and RKE

Using Multus CNI in K3S

By default, K3S will run with flannel as the CNI and use custom directories to store CNI plugin binaries and config files(You can inspect the kubelet args K3S uses via journalctl -u k3s|grep cni-conf-dir). So you need to configure that properly When deploying Multus CNI.

For example given the official Multus manifests in https://github.com/intel/multus-cni/blob/36f2fd64e0965e639a0f1d17ab754f0130951aba/images/multus-daemonset.yml, the following changes are needed:

volumes:
 - name: cni
@laggardkernel
laggardkernel / startup-time-of-zsh.md
Last active July 12, 2024 22:28
Comparison of ZSH frameworks and plugin managers

Comparison of ZSH frameworks and plugin managers

Changelog

  • update 1: add a FAQ section
  • update 2: benchmark chart and feature comparison table
  • update 3:
    • improve the table with missing features for antigen
    • new zplg times result

TLDR

@rot26
rot26 / .npmrc
Last active July 17, 2018 04:09
default npmrc
# Default npm flag settings
# Put this `.npmrc` file in your npm project root next to `package.json`
# Always save packages that get installed to avoid "missing dependencies"
save = true
# Always save the EXACT version that you ran and installed.
# upgrade to latest version on each new version (put `npm outdated` in your CI)
# `npm outdated && yarn upgrade --latest && npm outdated`
save-exact = true
@modille
modille / grep_xlsx_files.sh
Created March 6, 2017 17:00
Recursively find and grep through multiple Excel spreadsheets
# convert *.xlsx to *.xlsx.csv using https://github.com/dilshod/xlsx2csv
pip install xlsx2csv
# (shell-fu from http://stackoverflow.com/a/12965604)
find . -iname "*.xlsx" -exec sh -c 'xlsx2csv "$1" > "$1.csv"' x {} \;
# grep .csv files
brew install ripgrep
rg -i -g "*.csv" "waldo"
# ...or plain ole grep
@indiesquidge
indiesquidge / objects-over-classes.md
Last active January 17, 2024 09:30
We are better off avoiding ES6 classes in JavaScript when possible

Plain JavaScript objects are better than classes when they can be used, and many popular modern frameworks have adopted their use.

Consider that in React a component can be created as either a class or as an object.

// using a class
class Welcome extends React.Component {
  render() {
 Hello, {this.props.name}
@lilongen
lilongen / run-ansible-with-any-host-without-inventory
Last active May 5, 2023 23:16
How to run Ansible without specifying the inventory but the host directly?
Question:
. How to run Ansible without specifying the inventory but the host directly?
. Run a playbook or command with arbitrary host not in the inventory hosts list?
. run ansible with arbitrary host/ip without inventory?
Answer:
Surprisingly, the trick is to append a ,
The host parameter preceding the , can be either a hostname or an IPv4/v6 address.
ansible all -i example.com,
#!/bin/bash
# Description: This script spins up a multi node Docker Swarm w/ Docker
# Networking and Consul discovery w/ Registrator
# Author: Ryan C Koch
# ryanckoch@gmail.com
# Usage: bash docker-playground.sh usage
PLAYGROUND_NAME="docker-playground"
CONSUL_IMAGE="progrium/consul"