Skip to content

Instantly share code, notes, and snippets.

View kyl191's full-sized avatar

Kyle Lexmond kyl191

View GitHub Profile
def ary(p):
f = [0]
i = 1
j = 0
while i < len(p):
if p[i] == p[j]:
f.append(j+1)
i = i + 1
j = j + 1
elif j > 0:
import hashlib, os, sys, re
from os.path import join, getsize
def sha512file(file):
sha512 = hashlib.sha512()
try:
f = open(file,"rb")
except IOError:
print("IO Error, unable to open file", file)
while True:
@kyl191
kyl191 / inventory.py
Created January 18, 2015 06:36
Python Inventory file for Ansible
#!/usr/bin/python
from __future__ import print_function
import json
overarch = {}
overarch["us"] = [
"kc.example.com",
"la.example.net",
]
overarch["germany"] = ["de.test.net"]
@kyl191
kyl191 / gist:442455bfd47fa8603ba2
Created February 3, 2015 06:40
password hasher for ansible
# Securely generate a hash for ansible
# don't paste the password into code at any point in time
from __future__ import print_function
from passlib.hash import sha256_crypt
from getpass import getpass
pw = getpass()
print(sha256_crypt.encrypt(pw))
@kyl191
kyl191 / wp_compare.py
Created February 26, 2015 13:49
Wordpress post comparison
# Compares 2 WP post tables to find published posts with the same name but different content
# Used after merging an old WP install into an existing one
import csv, difflib, hashlib, sys
file = open(1, encoding='utf-8')
main = [row for row in csv.reader(file)]
file = open(2, encoding='utf-8')
xen = [row for row in csv.reader(file)]
# There is no doubt a better way to do this using difflib, but I did this before finding out about it
main_posts = {}
@kyl191
kyl191 / nginx.spec
Last active August 29, 2015 14:17
Nginx-mainline spec file for Fedora <=21 & CentOS 6
%global _hardened_build 1
%global nginx_user nginx
%global nginx_group %{nginx_user}
%global nginx_home %{_localstatedir}/lib/nginx
%global nginx_home_tmp %{nginx_home}/tmp
%global nginx_confdir %{_sysconfdir}/nginx
%global nginx_datadir %{_datadir}/nginx
%global nginx_logdir %{_localstatedir}/log/nginx
%global nginx_webroot %{nginx_datadir}/html
@kyl191
kyl191 / vhost.conf
Created April 25, 2015 12:49
nginx/php
server {
listen 80;
listen [::]:80;
server_name {{item.key}};
root /var/www/{{item.key}};
index index.html index.htm index.php;
- - include:
- domain: org.apache.cassandra.metrics
- type: ClientRequest
- attribute:
- Count:
- #metric_type: counter
- metric_type: gauge
- alias: cassandra.metrics.client_request.count
- 50thPercentile:
- metric_type: gauge
@kyl191
kyl191 / gist:f5d9177cfe4f0635eafcb4a6a3947dba
Created March 26, 2017 18:23
Minimal CF template which creates a lambda fn & associates with a bucket, but fails
---
AWSTemplateFormatVersion: 2010-09-09
Description: Calligre Lambda CF Stack
Resources:
ImagePendingResizeBucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: Private
NotificationConfiguration:
LambdaConfigurations:
@kyl191
kyl191 / do-not-run-me.txt
Created June 11, 2018 02:24
ZenGallery password reset
# connect to db using mysql
$ mysql
MariaDB [(none)]> use zen_gallery_db;
MariaDB [zen_gallery_db]> select value from zp_options where name = 'extra_auth_hash_text';
(keep this value!)
# separate python process
import hashlib
hashlib.sha1('{username}{password}{value_from_above}'.encode('utf-8')).hexdigest()