Skip to content

Instantly share code, notes, and snippets.

View dallasspohn's full-sized avatar
🏠
Working from home

Dallas Spohn dallasspohn

🏠
Working from home
View GitHub Profile
@dallasspohn
dallasspohn / GeneratePassword.py
Last active May 21, 2018 15:39
Generate a random password in Python
from os import urandom
from random import choice
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz',
'nums': '0123456789',
'big': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'special': '^!\$%&/()=?{[]}+~#-_.:,;<>|\\'
}
@dallasspohn
dallasspohn / find_string_in_directory.py
Created May 30, 2018 14:15
find duplicate strings
#! /bin/bash/python3
import os
import sys
s = raw_input("String to search? ")
os.system('grep -nr ' + s + ' ' + '.')
#print('grep -nr ' + s + ' ' + '.')
@dallasspohn
dallasspohn / flicker.py
Created June 12, 2018 21:34
for macOS flicker will keep your mac pc from sleeping. (pyautogui)
#!/usr/bin/python
import pyautogui
import time
import sys
import os
def Flicker():
"""Flicker moves the mouse around causing SKYPE for business to not turn yellow"""
#pyautogui in move coordinates. The first set is left to right the second is up and down.
try:
@dallasspohn
dallasspohn / itertoolsdic.py
Last active October 15, 2019 15:37
generic loop through file designating (x) rows for a key/value pair.
import itertools
import json
import toolz
keys = ['A', 'B', 'C', 'D']
with open('lines.txt') as infile:
for group in toolz.partition_all(
len(keys),
zip(itertools.cycle(keys), infile),
):
@dallasspohn
dallasspohn / BRSDevOpsTest.py
Last active October 9, 2018 04:09
Grabing and parsing IP and regions from AWS APIs.
#!/usr/bin/python
# This is a set of parameters I got for a coding test
# This was written to be run one function at a time to review code. At the bottom un comment each function you wish to run.
# Some are in two parts or two different ways of working. Question 4 was already saved so didn't include it.
# If you do not review prior to Mon the 8th I will find time to go back through and do some list comprehension and creating classes.
import sys
import re
import os
import requests
@dallasspohn
dallasspohn / jsonDump.py
Created November 23, 2018 18:18
taking lines in a file and sorting them in to json using keys. itertools, json. toolz
#!/bin/python3
#This file took lines of a file and sets them in a json format.
import itertools
import json
import toolz
appliance = []
keys = ['hostname','directory','java_ver','app_package']
with open('goodfile.txt') as infile:
@dallasspohn
dallasspohn / playlist_gathering.py
Created June 18, 2019 16:37
This takes many shows from many directories and orders them in a playlist.txt to be played. Used for my old time radio show collection.
#! /use/bin/python3
import os
#./ails_of_the_Texas_Rangers/Texas_Rangers_1950_08_05_05_Quick_Silver.mp3
#./theSixShooter/
os.system('rm playlist.txt')
george = "./letGeorgeDoIt/"
ranger = "./Tails_of_the_Texas_Rangers/"
six = "./theSixShooter/"
@dallasspohn
dallasspohn / .bash_profile
Created June 29, 2019 04:21
my bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/home/dallas/.rbenv/plugins/ruby-build/bin:/home/dallas/.rbenv/shims:/home/dallas/.rbenv/bin:/home/dallas/bin:/home/dallas/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/dallas/.rvm/bin:/home/dallas/.rvm/bin:/home/dallas/.vimpkg/bin
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
#source /Users/dallas/.git-prompt.sh
#source /Users/dallas/.bash_colors
@dallasspohn
dallasspohn / re_repofiles.py
Created July 30, 2019 15:34
Creates a list of artifacts from a manifest output. Looks at MISSING and EXISTS. Drops the EXIST artifact and sets the MISSING in a list so I can rsync from lacrosse.
import re
'''Good to run on all'''
with open('repofiles_raw.txt') as repofile:
x=repofile.readlines()
done=[]
newline=''.join([str(i) for i in x])
# Pythono3 code to rename multiple
# files in a directory or folder
import os
# Function to rename multiple files
def main():
i = 0
for filename in os.listdir("xyz"):