Skip to content

Instantly share code, notes, and snippets.

import unittest
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
class TestTemplate(unittest.TestCase):
"""Include test cases on a given url"""
@xandout
xandout / copy_secret_between_namespaces.yaml
Created September 10, 2019 21:15
Copy Kubernetes Secret to new namespace using k8s job. RBAC Enabled
# SOURCE: Replace "infrastructure-namespace-with-secret" with the name of the namespace with yor source secret
# DEST: Replace "your-new-namespace" with the name of the namespace you want to copy to.
---
# First role is created in the namespace with your master secret. This role allows you to "get" a "secret" named "letsencrypt-prod" in that namespace
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: infrastructure-namespace-with-secret
name: role-read-secret
rules:
@xandout
xandout / host_vars-slash-prod-vpn-server.yml
Last active August 13, 2019 17:17
OpenVPN Server Deployment via Ansible
ansible_host: prod-vpn.yourfqdn.com # How Ansible will reach the Linux server for configuration
ansible_user: ubuntu # Which Linux user will Ansible use?
server_fqdn: "{{ ansible_host }}" # How your clients connect to the VPN server
@xandout
xandout / docker-compose.yml
Last active June 30, 2019 16:33
Docker, ELK, Syslog, Magic
version: '2.4'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1
volumes:
- es-data:/usr/share/elasticsearch/data
environment:
- discovery.type=single-node
- cluster.name=docker-cluster
- "ES_JAVA_OPTS=-Xms2G -Xmx2G"
1561572401,horse-uat,Ubuntu,16,16.04,xenial
1561572405,moose-uat,Ubuntu,16,16.04,xenial
1561572408,duck-uat,Ubuntu,16,16.04,xenial
1561572413,goat-uat,Ubuntu,16,16.04,xenial
1561572415,horse-dev,Ubuntu,16,16.04,xenial
1561571759,moose-dev,Amazon,2016,NA,NA
1561572422,duck-dev,Ubuntu,16,16.04,xenial
1561572426,goat-dev,Ubuntu,14,14.04,trusty
@xandout
xandout / describeImages.go
Created August 22, 2017 21:15
AWS SDK Golang Client
svc := ec2.New(getSessionForRegion(region))
input := &ec2.DescribeImagesInput{
Filters: []*ec2.Filter{
{
Name: aws.String("image-id"),
Values: []*string{aws.String(ami)},
},
},
}
func getSessionForRegion(region string) *session.Session {
return session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{Region: aws.String(region)},
}))
}
// defer rows.Close()
// colNames, err := rows.Columns()
// if err != nil {
// log.Fatal(err)
// }
// cols := make([]interface{}, len(colNames))
// colPtrs := make([]interface{}, len(colNames))
// for i := 0; i < len(colNames); i++ {
// colPtrs[i] = &cols[i]
@xandout
xandout / README.md
Last active November 22, 2023 21:12
Terraform Stateless

Create new resources each time terraform runs

This configuration will allow you to deploy resources many times in a row with no "stateful" behavior.

terraform apply
#!/bin/python
"""
python report.py | sendmail user@domain.com
"""
import yum, platform
import os
from collections import namedtuple
DiskUsage = namedtuple('DiskUsage', 'total used free')