Skip to content

Instantly share code, notes, and snippets.

View relrod's full-sized avatar

Rick Elrod relrod

View GitHub Profile
#!/usr/bin/env python3
from typing import Any
class Foo:
def __init__(self, a: str):
self.a: str = a
def bark(self) -> str:
# can only call upper on str's
@relrod
relrod / .zshrc
Last active April 8, 2021 20:02
Restore some bash/readline-isms in ZSH
autoload -Uz compinit && compinit
setopt nonomatch
setopt interactivecomments
function unfuck-zsh-kb {
local WORDCHARS="${WORDCHARS//[\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\{\}\[\]\|\\\:\;\"\'\<\,\>\.\?\/]/}"
fn="$1"
shift
zle $fn "$@"
}
@relrod
relrod / proxy.md
Created September 22, 2020 17:41 — forked from yougg/proxy.md
complete ways to set http/socks/ssh proxy environment variables

set http or socks proxy environment variables

# set http proxy
export http_proxy=http://PROXYHOST:PROXYPORT

# set http proxy with user and password
export http_proxy=http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT

# set http proxy with user and password (with special characters)
@relrod
relrod / .gitignore
Last active July 16, 2020 06:05
ansible-acd-redirect-check
*-modules_removed
*.files
*.tar.gz
ansible*/
__pycache__
@relrod
relrod / morse.py
Created June 2, 2020 02:54
Silly morse code inventory plugin
# A super simple morse-code inventory plugin for demonstration and learning
# purposes.
#
# It takes files with lines like this:
# ! -- -.-- ..--.- --. .-. --- ..- .--. // the "my_group" group
# .- -.. -.-. ----- .---- ansible_user=nonroot // and some comment here
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
module Main where
import Data.Time.Clock.POSIX
import System.IO
avgNum :: Int
avgNum = 4
main :: IO ()
main = do
@relrod
relrod / gist:6aa4a37e75e5053ca7e5ced594c6a655
Created January 24, 2020 08:36
Ansible test failures
=================================== FAILURES ===================================
______________________ test_install_collections_from_tar _______________________
[gw3] linux -- Python 3.5.7 /tmp/python-9mti748p-ansible/python
src = b'/home/pytest/.ansible/tmp/ansible-local-21819apkw49_v/tmpq71fp8sn/tmp_idp207w'
dst = b'/tmp/pytest-of-pytest/pytest-2/popen-gw3/test-\xc3\x85\xc3\x91\xc5\x9a\xc3\x8c\xce\xb2\xc5\x81\xc3\x88 Collections Input0/ansible_namespace/collection/MANIFEST.json'
copy_function = <function copy2 at 0x7fb17ce8f488>
def move(src, dst, copy_function=copy2):
"""Recursively move a file or directory to another location. This is
similar to the Unix "mv" command. Return the file or directory's
@relrod
relrod / issue.md
Last active November 14, 2019 23:43

Ansible issue

Given fact_caching=jsonfile and ansible_python_interpreter: auto, when we delegate_to a host as the first task in a play, the python interpreter of the host we delegate to is what gets cached as the discovered_interpreter_python of the host the play is defined for.

Reproducer playbook

- name: first playbook
diff --git a/roles/koji_hub/templates/fedmsg-koji-plugin.py b/roles/koji_hub/templates/fedmsg-koji-plugin.py
index 6d7b3aa..3ff315d 100644
--- a/roles/koji_hub/templates/fedmsg-koji-plugin.py
+++ b/roles/koji_hub/templates/fedmsg-koji-plugin.py
@@ -183,6 +183,10 @@ def queue_message(cbtype, *args, **kws):
body.get('sigkey') == ''):
return
+ # Don't publish volume_id changes
+ if topic == 'build.state.change' and body.get('attribute') == 'volume_id':
@relrod
relrod / ysu.sh
Created September 17, 2018 16:19
#!/usr/bin/env bash
for ip in $(echo 150.134.{0..255}.{0..255}); do
echo $ip
ping -W 1 -c 1 $ip
if [[ $? -eq 0 ]]; then
echo $ip >> ips.used
else
echo $ip >> ips.error
fi
done