Skip to content

Instantly share code, notes, and snippets.

Avatar
Go Phillies!

Tim Ski marshyski

Go Phillies!
View GitHub Profile
@marshyski
marshyski / jpg-convert.sh
Last active Aug 29, 2015
JPG conversion with ImageMagick
View jpg-convert.sh
#!/bin/bash
cd /usr/share/nginx/html/test/assets/img/dest
for i in *.jpg; do convert $i -resize 400x350! $(basename $i .jpg).jpg; done
for i in *.jpg; do convert $i -strip -quality 85% $(basename $i .jpg).jpg; done
@marshyski
marshyski / softlayer-image-build.sh
Last active Aug 29, 2015
Build a SoftLayer RHEL Image
View softlayer-image-build.sh
#!/bin/bash
BUILD_DATE=`date +"%d%b%Y"`
TIME=`date +"%H%M"`
BUILD_NAME="$1$BUILD_DATE"
KEY="ets-poc"
PEM_KEY="/home/timski/keyfile.pem"
APPDIR="/home/timski"
OS="REDHAT_LATEST_64"
@marshyski
marshyski / add-users-script.sh
Last active Aug 29, 2015
Adding Users Script
View add-users-script.sh
#!/bin/bash
PASS=`cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 32 | head -n 1`
while read line; do
PASS=`cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 32 | head -n 1`
useradd -d /home/$line $line
echo "$PASS" | passwd --stdin $line 1> /dev/null
echo "$line ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
@marshyski
marshyski / confluence-attach.py
Created Oct 6, 2014
Create page and attach file under a confluence wiki site with Python Suds
View confluence-attach.py
#!/usr/bin/python
# yum install python-suds
import suds
import base64
# Uncomment the logging if you want to see the XML input and output for debugging
import logging
import logging.handlers
@marshyski
marshyski / puppetclient-clean-cert.sh
Last active Aug 29, 2015
Shutdown script, remove clients cert by invoking Puppet Master API
View puppetclient-clean-cert.sh
#!/bin/bash
#Remove clients cert by invoking Puppet Master API
CERTNAME=`facter fqdn`
PUPMASTER='puppet'
SSLDIR=`puppet agent --configprint ssldir`
curl --noproxy '*' -X DELETE -H "Accept: pson" https://${PUPMASTER}:8140/production/certificate_status/${CERTNAME} --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem --key /etc/puppetlabs/puppet/ssl/private_keys/${CERTNAME} --cert /etc/puppetlabs/puppet/ssl/certs/${CERTNAME}
@marshyski
marshyski / requests-nohtml.py
Last active Aug 29, 2015
Example of Python requests & BeauitfulSoup with no HTML tags
View requests-nohtml.py
#!/usr/bin/python
import requests
from bs4 import BeautifulSoup
import json
q = requests.get('http://marshyski.com/man-behind-the-keyboard')
def cleanhtml():
return ''.join(BeautifulSoup(q.text).findAll(text=True)).replace('&nbsp;', ' ')
@marshyski
marshyski / yum-nginx-api-basic-auth.py
Created Oct 7, 2014
yum-nginx-api Basic Auth username & password
View yum-nginx-api-basic-auth.py
#!/usr/bin/python
import os
import magic
from flask import Flask, request, jsonify, make_response
from werkzeug.utils import secure_filename
from werkzeug.contrib.fixers import ProxyFix
from subprocess import call
from flask.ext.httpauth import HTTPBasicAuth
@marshyski
marshyski / multiple-requests-status.py
Last active Aug 29, 2015
Grab status from multiple URLs
View multiple-requests-status.py
#!/usr/bin/python
import requests
urls = [
'http://192.168.1.5/',
'http://192.168.1.15/',
'http://192.168.1.5:8080',
]
@marshyski
marshyski / puppet-health-requests.py
Last active Aug 29, 2015
Health Check Multiple Puppet Dashboard & PuppetDB with Python Requests
View puppet-health-requests.py
#!/usr/bin/python
import requests
from bs4 import BeautifulSoup
requests.packages.urllib3.disable_warnings()
urls = [
'https://192.168.1.100/nodes/failed?per_page=all',
'https://192.168.1.200/nodes/failed?per_page=all',
@marshyski
marshyski / flask-template-requests.py
Created Nov 3, 2014
Flask app to render template with basic status of web servers
View flask-template-requests.py
#!/usr/bin/python
import flask
import requests
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader
requests.packages.urllib3.disable_warnings()
app = flask.Flask(__name__)