Skip to content

Instantly share code, notes, and snippets.

View jcook793's full-sized avatar
💾
Curently Alive

John Cook jcook793

💾
Curently Alive
View GitHub Profile
@jcook793
jcook793 / hello-world.html
Created July 25, 2019 12:59
Simple hello world HTML for testing purposes
<html>
<head>
<style>
body { background: #000000; }
h1 { margin-top: 10em; text-align: center; color: #ffffff; font-family: "Helvetica"; }
</style>
</head>
<body>
<h1>Hello, world!</h1>
</body>
@jcook793
jcook793 / sql-to-csv.py
Created February 28, 2017 20:50
Takes a SQL file, executes it and generates a CSV file with column names for the output
import getpass
import pymysql
import csv
def main():
host = raw_input("DB hostname: ")
db = raw_input("Schema name: ")
user = raw_input("Username: ")
password = getpass.getpass("Password: ")
query_file = raw_input("Input SQL filename: ")
@jcook793
jcook793 / fix-color-profile.sh
Created September 23, 2016 21:07
Color profile fix
#!/bin/bash
#
# This fixes an issue I had where the color profile of my external display wouldn't "stick". Had a corrupt cache file, this removes it.
#
sudo rm $(getconf DARWIN_USER_CACHE_DIR)com.apple.colorsync.profiles.`id -u`
@jcook793
jcook793 / mysql-table-sizes.sql
Created September 21, 2016 20:16
Get table sizes from MySQL
select table_schema as 'schema',
table_name as 'table',
round(((data_length + index_length) / 1024 / 1024 / 1024), 0) 'gigs',
round((data_length + index_length) /
(select sum(data_length + index_length)
from information_schema.tables) * 100, 0) 'percent'
from information_schema.tables
order by (data_length + index_length) desc;
@jcook793
jcook793 / generate-mysql-grants.sh
Created April 22, 2014 22:52
Generates MySQL GRANT statements for all users in a DB
#!/bin/bash
users_hosts=`mysql -B -N -e "select user, host from mysql.user;"`
echo "${users_hosts}" | while read user_host; do
user=`echo "${user_host}" | cut -f 1`
host=`echo "${user_host}" | cut -f 2`
if [ "${user}" != "root" ]; then
grants=`mysql -N -e "show grants for '${user}'@'${host}';"`
echo "${grants}" | while read grant; do
echo "${grant};"
@jcook793
jcook793 / process_monitor.sh
Created August 14, 2013 03:40
Checks the process list every 5 seconds for a new process. If it finds one, sends an email.
#!/bin/bash
MASTER_PROCESS_FILE=/tmp/master_process_list.out
OUT_FILE=/tmp/process_list.out
SLEEP_TIME=5s
RECIPIENTS=me@nobody.com
ps -wweo pid,euser,ruser,suser,fuser,comm,args | grep -v "ps -wweo pid,euser,ruser,suser,fuser,comm,args" | grep -v `basename $0` > ${MASTER_PROCESS_FILE}
while true; do
@jcook793
jcook793 / create_mysql_user.sh
Created August 2, 2013 20:05
Creates a MySQL user across several instances. Useful if you use replication but (for whatever reason) you don't replicate the "mysql" database.
#!/bin/bash
DEV_SERVERS="dev-db001 dev-db002"
QA_SERVERS="qa-db001 qa-db002"
STAGE_SERVERS="stage-db001 stage-db002"
PROD_SERVERS="prod-db001 prod-db002"
MYSQL=`which mysql`
read -p "Which environment (dev, qa, stage, prod): " ENVIRONMENT
@jcook793
jcook793 / bash_prompt.sh
Created April 15, 2012 17:57 — forked from insin/bash_prompt.sh
Set color bash prompt according to active virtualenv, mercurial branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current mercurial repository
# * the return value of the previous command
#
# USAGE: