Skip to content

Instantly share code, notes, and snippets.

View gyoza's full-sized avatar
💭
Kuuru the bestest doggo - RIP 2009-2018

Jon gyoza

💭
Kuuru the bestest doggo - RIP 2009-2018
  • Some Artificial Intelligence Company.
  • colorado, us
View GitHub Profile
@gyoza
gyoza / py
Created April 26, 2018 16:28
kill hung nginx workers
#!/usr/bin/env python2.7
#
# kills openresty nginx and possibly regular nginx '"hung"' worker processes
#
# version 0.1
#
import psutil
import os
import time
@gyoza
gyoza / py
Created April 26, 2018 16:28
kill hung nginx workers
#!/usr/bin/env python2.7
#
# kills openresty nginx and possibly regular nginx '"hung"' worker processes
#
# version 0.1
#
import psutil
import os
import time
@gyoza
gyoza / py
Created April 26, 2018 17:40
touch
def touch(path):
with open(path, 'a'):
os.utime(path, None)
@gyoza
gyoza / py
Created April 26, 2018 17:41
lockfiles
def touch(path):
with open(path, 'a'):
os.utime(path, None)
def lock_file(LOCK_FILE):
now = datetime.now()
restart_hours = [1]
if now.hour in restart_hours:
if VERBOSE: PrettyLogger(log_level="info", msg="H|Restart hour hgreen|Found.")
@gyoza
gyoza / ctmpl
Last active May 3, 2018 22:29
Get "oldest" system from service (go template, consul template) based on unix time in kv
{{/* get unix times for systems in service group */}}
{{range ls "mykv/myservice"}}
{{ $int := .Value | parseInt}}
{{ scratch.MapSetX "nodetimes" .Key $int}}{{ end }}
{{/* create map of names */}}
{{ range service "myservice|passing" }}
{{ $node := .Node }}
{{ scratch.MapSetX "names" $node $node }}{{ end }}
{{/* create map of time differences from "now" for each server */}}
{{ range $hkey, $hval := scratch.Get "nodetimes" }}
@gyoza
gyoza / build db and check it or build it again!!!
Last active November 17, 2018 18:07
python3.6 - sqlite3 build db and check it or build it again!!! (dicts are insert ordered now)
import sqlite3
db = sqlite3.connect('yomomma.db')
tables = {
"table1" : {
"stuff" : "INTEGER unique PRIMARY KEY",
"stuff2" : "INTEGER",
"stuff3" : "INTEGER",
},
@gyoza
gyoza / simplisafe.py
Last active March 20, 2019 14:20
set simplisafe to home
#!/usr/bin/env python3.6
import os
from selenium import webdriver
from selenium.webdriver.common.by import By as by
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as expect
CHROME_PATH = '/usr/bin/google-chrome'
@gyoza
gyoza / list2ssh.py
Last active April 20, 2019 06:17
iterm2 Build 3.3.0beta2 python-api - 'harvest ip out of screen selection, create new window, and sessions then ssh'
#!/usr/bin/env python3.7
import iterm2
import re
import os
import socket
import pprint
import asyncio
def sshToProccesTextRedux(lines):

Keybase proof

I hereby claim:

  • I am gyoza on github.
  • I am realdh (https://keybase.io/realdh) on keybase.
  • I have a public key ASA3c4oQ_Ej8YFCkHXB-ODUb59bF8gkbV53bUzODgymwTAo

To claim this, I am signing this object: