Skip to content

Instantly share code, notes, and snippets.

View archjeb's full-sized avatar

Jeremy Georges archjeb

View GitHub Profile
@archjeb
archjeb / askGemini.py
Created October 29, 2025 17:36
Simple Google AI API interaction
#!/usr/bin/Python3
import warnings
warnings.filterwarnings("ignore")
import google.generativeai as genai
google_api_key='<InsertYourAPIKey>'
genai.configure(api_key=google_api_key)
model = genai.GenerativeModel('gemini-2.0-flash')
@archjeb
archjeb / cotekShowStat.py
Created October 27, 2025 18:03
Simple Cotek Inverter/charger Status Output
#!/usr/bin/python3
'''
Script to display all the Status information on the Cotek Inverter
Tested with https://www.cotek.com.tw/sc-1200-1200w
4800Baud and 3 pin serial, so TXD, RXD and GND.
'''
#***********
# Version 1.0 - 10-27-25 -- J. Georges
#***********
@archjeb
archjeb / watchip.py
Last active January 14, 2021 18:59
Watch external IP and notify if there is a change
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# updated Jan 2021. Looks like noipy is requiring an IP on the command line now.
# added two methods to determine IP in case the first method fails.
#
'''
Script / Daemon to watch external IP and if it changes, send a slack message
'''
from requests import get
@archjeb
archjeb / getfwdhcp.py
Created January 11, 2021 22:40
Get a nice table of SRX DHCP bindings in sorted order
#!/usr/bin/env python3
'''
Get DHCP bindings sorted.
Make sure you use an account that has JUNOS CLI as the shell; not root.
'''
# Version 1.0 - 1-11-2021 - Jeremy Georges
#
# Reason for this script, is currently JUNOS on SRX platforms does NOT have
# very good logging for DHCP server address bindings. In ScreenOS, every DHCP
@archjeb
archjeb / rc.eos
Created December 24, 2020 19:20
Generate a serial number in vEOS-lab so it looks like a real switch in CVP and when using ZTP
#!/bin/bash
# Idea here is to run in /mnt/flash/rc.eos
# General Logic
# check to see if veos-config exists.
# if it does, then parse and see if a serial number is set correctly based on ma1 interface mac address.
# if not, then set serial number based on ma1 mac address since this is up at the time that rc.eos is executed.
# if file does not exist...this is easy, just create veos-config file with serial number set.
# We could create an allowance to not change the SERIALNUM variable even if it does not match. Just rem out the sed command
@archjeb
archjeb / del_networking.py
Created April 29, 2020 18:48
Delete ESXI Port Groups and vSwitches based on a prefix.
#!/usr/bin/env python
"""
Needed this to delete my lab PG and vSwitch stuff...
I create a lot of temporary Port Groups and vSwitches for lab testing and need a way to quickly delete them.
Idea here is to use a prefix naming convention for all PGs and vSwitches based on projects. We just use a regex based
on that prefix to determine whether or not we delete this PG and vSwitch.
"""
from __future__ import print_function
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim
@archjeb
archjeb / gist:5446b42da45fa7ec8ce80142a75143fb
Created December 13, 2019 21:30
Run a subprocess but timeout if the command hangs
from threading import Timer
# There are other ways to do this, such as use sudo with -n switch so it doesn't prompt for
# a user name. But the frame work for timer and Popen is useful for other use cases.
def RebootSystem():
'''
reboot system
user needs rights for this though.
Just to be safe, we'll have a timeout.
'''
proc=sp.Popen(["sudo","reboot", "now"], shell=False)
@archjeb
archjeb / CheckProcess.py
Created December 3, 2019 20:44
Check for a process by name and use return code to do something using subprocess.check_output
#!/usr/bin/env python
'''
Example of how to check for a process that is running and return something.
In this example, just checking to see if ffmpeg is running
'''
import subprocess as sp
try:
@archjeb
archjeb / CvpGetConfigs.py
Last active October 29, 2019 14:04
Basic script to authenticate to Arista Cloudvision (CVP) and get all device configs and save them as hostname.conf files locally
#!/usr/bin/env python
# Basic Script to authenticate to Arista Cloudvision (CVP) and get all device
# running configs.
import json
import requests
import urllib3
@archjeb
archjeb / getcvpdevices.py
Created October 28, 2019 18:57
Simple script to demonstrate how to execute CloudVision (CVP) API
#!/usr/bin/env python
#Basic Script to authenticate to Arista Cloudvision (CVP) and list all device
#data.
import json
import requests
import urllib3