Skip to content

Instantly share code, notes, and snippets.

@hmm01i
hmm01i / intake.py
Created February 4, 2019 04:49
A snippet demonstrating working with data from a csv
#!/usr/bin/env python
###
# This script loads a csv named intake.csv
# For the purposes of the demo that file looked like this:
#
# name,weight,height,breakfast_foods,lunch_foods,diner_foods
# jacob,155,6'2","beef,chicken",salad,beef
#
###
@hmm01i
hmm01i / .gitlab-ci.yml
Created June 7, 2018 01:17
Example gitlab-ci script for ansible automation deployment
---
image: 'williamyeh/ansible:centos7'
variables:
ANSIBLE_ROLES_PATH: './roles/'
ANSIBLE_VAULT_PASSWORD_FILE: '/root/.ssh/vault.sh'
ANSIBLE_TIMEOUT: 60 # some systems are very slow to establish ssh connection
before_script:
- "ansible --version" # for verbosity
@hmm01i
hmm01i / mysite.ini
Last active June 7, 2018 01:12
i believe this is for nginx
[uwsgi]
module = wsgi
master = true
processes = 5
socket = mysite.sock
chmod-socket = 660
vacuum = true
@hmm01i
hmm01i / Dockerfile
Last active June 7, 2018 01:12
put this in the root of a flask app to docker'ize it
FROM tiangolo/uwsgi-nginx-flask:python3.6
COPY . /app
RUN pip install -r requirements.txt
@hmm01i
hmm01i / ldaps.yml
Created August 12, 2017 01:13
setup ldaps for 389 DS
---
# ansible code documenting steps to setup ssl certs for 389DS / RHDS
- set_fact:
dirsrv_root: "/etc/dirsrv/slapd-{{ dirsrv_server_id }}"
tags:
- dirsrv
- dirsrv-ssl
- name: certdb password file (temporary)
copy:
@hmm01i
hmm01i / snip_optparse.py
Created May 19, 2017 17:45
snippet example of using optparse
# just a short example of using optparse
import getpass
import optparse
# def parseCmdArgs():
cmdOpts = optparse.OptionParser(usage = '%prog [options]')
cmdOpts.add_option('-i', dest = 'ipaddr', help = 'IP address of CIMC')
cmdOpts.add_option('-u', dest = 'user', help = 'Username')
cmdOpts.add_option('-p', dest = 'passwd', help = 'Password (Optional. If not provided you will be prompted.)')
cmdOpts.add_option('-l', action = 'store_true', dest = 'list', help = 'Just query running firmware.')
@hmm01i
hmm01i / subproc.py
Created May 16, 2017 19:56
example of subprocess
import shlex, subprocess
cmd = 'ls -la'
shcmd = shlex.split(cmd)
p = subprocess.Popen(cmd)
@hmm01i
hmm01i / urllib2basicauth.py
Created May 16, 2017 19:48
Example of urllib with basic auth
# just an example for me to remember
import urllib2, base64
username = "testuser"
password = "changeme"
url = "https://example.com/"
request = urllib2.Request(url)
b64auth = base64.standard_b64encode("%s:%s" % (username,password))
request.add_header("Authorization", "Basic %s" % b64auth)