Skip to content

Instantly share code, notes, and snippets.

View andyshinn's full-sized avatar
🖥️
don't put computers in your mouth

Andy Shinn andyshinn

🖥️
don't put computers in your mouth
View GitHub Profile
@panzi
panzi / rekey.py
Last active March 9, 2024 05:43
Re-key all the embedded vaults in an Ansible vars file.
#!/usr/bin/env python3
# derived from https://stackoverflow.com/a/67161907/277767
# Changes to the StackOverflow version:
# * delete temporary files that contain vaults!
# * prompt for passwords instead of passing them as program argument
# * more precise vault replacement
# * a bit nicer error messages that points at the line where re-keying failed
# * decryption if no password is provided
@ThYpHo0n
ThYpHo0n / .zshrc
Last active April 11, 2024 19:00
WSL(2) bash profile helpers
# WSL?
if [[ "$(< /proc/sys/kernel/osrelease)" == *microsoft* ]]; then
export $(dbus-launch)
export LIBGL_ALWAYS_INDIRECT=1
export WSL_VERSION=$(wsl.exe -l -v | grep -a '[*]' | sed 's/[^0-9]*//g')
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export DISPLAY=$WSL_HOST:0
# pip path if using --user
export PATH=$PATH:$HOME/.local/bin
# SSH
@rcoup
rcoup / conftest.py
Created June 27, 2019 15:02
Click CliRunner with PDB working better under pytest
import contextlib
import io
import warnings
import pytest
from click.testing import CliRunner
"""
In your tests:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 Avi Networks
# 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
__metaclass__ = type
DOCUMENTATION = '''
@Gems
Gems / docker-compose.sh
Last active October 20, 2023 07:38
A `docker-compose` wrapper for multiple configuration files with relative paths
#!/usr/bin/env bash
TMP_FILE=/tmp/docker-compose.$$.yaml
finish() {
rm ${TMP_FILE} ${TMP_FILE}.tmp 2>/dev/null
}
trap finish EXIT
@lennybacon
lennybacon / Update-VisualStudio2017.ps1
Last active January 19, 2021 17:51
Headless update for Visual Studio
Write-Host "Update Visual Studio Installer" -ForegroundColor Cyan
# [Microsoft Developer community](https://developercommunity.visualstudio.com/content/problem/307261/unattend-self-update-of-vs-installer.html)
$vsCommunityDownloadUrl = "https://download.visualstudio.microsoft.com/download/pr/8a973d5d-2ccb-428c-8204-290a15d30e2c/be8c694b12879a8f47f34369d55d453c/vs_community.exe";
$vsSetupDirectory = "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Setup"
$vsCommunitySetupPath = "$vsSetupDirectory\vs_community.exe";
if((Test-Path -Path $vsSetupDirectory) -eq $false){
$r = md $vsSetupDirectory
}
if((Test-Path -Path $vsCommunitySetupPath) -eq $false){
@robert8138
robert8138 / airflow_toy_example_dag.py
Last active October 26, 2020 05:49
A toy example DAG
"""
A DAG definition file in Airflow, written in Python.
"""
from datetime import datetime, timedelta
from airflow.models import DAG # Import the DAG class
from airflow.operators.bash_operator import BashOperator
from airflow.operators.sensors import TimeDeltaSensor
default_args = {
'owner': 'you',
@mattapperson
mattapperson / rancher-deploy.js
Last active October 14, 2015 19:13
rancher-deploy - A quick script I wrote to deploy services to rancher in one command... will finish it up and deploy via NPM soon...
#!/usr/bin/env node
process.env.RANCHER_URL = '<your project URL here>';
process.env.RANCHER_ACCESS_KEY = '<your access key here>';
process.env.RANCHER_SECRET_KEY = '<your secret key here>';
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var path = require('path');
var fs = require('fs')
@sheenobu
sheenobu / notes.md
Last active September 22, 2015 16:32
vulcand websocket diff
  • The WebsocketUpgrader has to be put so far up the chain within frontend.go, otherwise you have a non-hijackable ResponseWriter.
  • The RoundRobin class is used to determine which backend to net.Dial against.
  • I could not yet figure out how to shove the RoundRobin rebalencer into this. The API for it does not have a NextServer().
  • The whole Bidir stuff on the bottom of the upgrader is by someone else. (vulcand/vulcand#78 (comment))
  • The bidir code causes some errors to be logged when the connection is closed.
  • The code isn't using an http.Handler errorHandler like it should.
  • NO TLS???
@progrium
progrium / consul.py
Last active September 16, 2020 14:29
Consul health check integration with DataDog
import requests
from checks import AgentCheck
class ConsulCheck(AgentCheck):
def should_check(self):
r = requests.get(self.init_config["consul_url"] + "/v1/agent/self")
if r.status_code != 200:
return False
agent = r.json()