Skip to content

Instantly share code, notes, and snippets.

View jondkelley's full-sized avatar
:octocat:

Jonathan D Kelley jondkelley

:octocat:
View GitHub Profile
@jondkelley
jondkelley / twitter_follow.py
Last active August 29, 2018 06:44
Fetch Tweets Using Python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A tool to fetch limit N number of twitter posts from twitter handle
Usage:
twitter_follow --handle HANDLE [--limit NUMBER]
twitter_follow -h
Options:
-h show help
@jondkelley
jondkelley / smtpserver-python37.py
Last active September 19, 2018 01:00
Example of how to overload custom SMTP commands in asyncio smtp server in python3 (no proxy or mailbox capability shown)
#!/usr/bin/env python3
# pip3 install aiosmtpd
import asyncio
from aiosmtpd.controller import Controller
from aiosmtpd.handlers import AsyncMessage
from aiosmtpd.smtp import SMTP, syntax
import logging
import uuid
import logging
@jondkelley
jondkelley / smtpserver-python37-2.py
Created September 19, 2018 02:04
Example of how to overload custom SMTP commands in asyncio smtp server in python3 (no proxy or mailbox capability shown)
#!/usr/bin/env python3
# pip3 install aiosmtpd
from aiosmtpd.controller import Controller
from aiosmtpd.handlers import AsyncMessage
from aiosmtpd.smtp import SMTP, syntax
from asyncio import coroutine
import asyncio
import logging
import uuid
import logging
@jondkelley
jondkelley / smtpserver-python37-2.py
Last active September 19, 2018 02:40
Example of how to overload custom SMTP commands in asyncio smtp server in python3 along with an AMQP client
#!/usr/bin/env python3
# pip3 install aiosmtpd
from aiosmtpd.controller import Controller
from aiosmtpd.handlers import AsyncMessage
from aiosmtpd.smtp import SMTP, syntax
from asyncio import coroutine
import asyncio
import logging
import uuid
import logging
@jondkelley
jondkelley / example.sh
Last active September 23, 2018 21:29
example
#!/bin/bash
ARC="x86_64"
install_driver () {
arg1=$1
arg2=$2
arg3=$3
arg4=$4
echo $arg1 ${arg2} $arg3 $arg4
@jondkelley
jondkelley / 1_playbook_best_practices.md
Last active October 20, 2022 16:56
Linux Awesome Gists: Ansible Best Practices

Ansible Playbook Design & Best Practices

The complexity you might consider dictates the style of your environments as you see the examples 'good' 'better' and 'best' below. The best is not always better if it's a waste of time after all.

General best-advice writing root playbooks

Tips

  • Do use hosts: limiters to the least destructive inclusion group for added safety whenever possible.
  • Do use extended block notation if you need additional levels of control around playbook / role execution.
@jondkelley
jondkelley / readme.md
Last active May 23, 2024 13:28
Linux Awesome Gists 1: Sending a file from command line one-liners

Send an attachment via email on bash using...

mailx

Install Debian/Ubuntu

  • apt-get install postfix

Alternatively, without the bloat of postfix

#!/bin/bash

BASEDIR=$(dirname "$0")
LOGGING_PREFIX="gen_cert.sh >> "

PASSKEY=somekey

rm -f ${BASEDIR}/server.crt
@jondkelley
jondkelley / gist:b2e693e07acfbc3dac97705464edc9bb
Created October 25, 2018 19:44
cat a file in Windows using ansible
---
- name: 'get newrelic-infra config'
win_shell: 'more newrelic-infra.yml'
args:
chdir: 'C:\Program Files\New Relic\newrelic-infra\'
executable: cmd
register: hello
- name: 'show newrelic-infra config'
@jondkelley
jondkelley / diagnose_dns.py
Last active March 13, 2019 14:14
diagnose dns with dynect
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pip3 install dnspython3
# pip3 install dnspython
import json
import dns.resolver
import requests
import os