Skip to content

Instantly share code, notes, and snippets.

View mjtiempo's full-sized avatar

Mark John Tiempo mjtiempo

View GitHub Profile
@mjtiempo
mjtiempo / lazyg.sh
Created June 9, 2024 09:38
Lazy git add, commit, push
#!/bin/bash
# Check if the script is run inside a git repository
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
echo "Not inside a git repository. Exiting."
exit 1
fi
# Check if there are modified files
if [ -z "$(git ls-files -m)" ]; then
@mjtiempo
mjtiempo / x0vncserver.service
Created June 7, 2024 19:56
TigertVNC service settings on Debian 12 (gdm)
[Unit]
Description=Remote desktop service (VNC) for :0 display
Requires=display-manager.service
After=network-online.target
After=display-manager.service
[Service]
Type=simple
Environment=XAUTHORITY=/run/user/1000/gdm/Xauthority
Environment=HOME=/root
@mjtiempo
mjtiempo / ssh-forwarding-a-b.md
Last active May 31, 2023 13:47
SSH from A through B to C, using private key on A
@mjtiempo
mjtiempo / fast_api_crud_orm.py
Created December 8, 2022 15:55
FastAPI with CRUD using ORM SQLAchemy
'''
Generated by ChatGPT using the prompt
fastapi crud using orm sqlalchemy
'''
from fastapi import FastAPI
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import sessionmaker
app = FastAPI()
engine = create_engine("<database_url>")
@mjtiempo
mjtiempo / fastapi_mongodb_with_logging.py
Created December 8, 2022 01:53
fastapi and mongodb crud with file logging
'''
Generated by ChatGPT using the prompt
fastapi crud mongo with logging to file
'''
from fastapi import FastAPI
from pymongo import MongoClient
import logging
app = FastAPI()
@mjtiempo
mjtiempo / openvpn3-cmd.sh
Created November 25, 2022 02:41
openvpn3 commands
#import config
openvpn3 config-import --config myvpnfile.ovpn
#show list of reusable configs
openvpn3 configs-list
#list active connection
openvpn3 sessions-list
#connect using config already imported
@mjtiempo
mjtiempo / x0vncserver.service
Created November 24, 2022 02:42
TigerVNC systemd service using sddm on kde plasma
[Unit]
Description=Remote desktop service (VNC) for :0 display
Requires=display-manager.service
After=network-online.target
After=display-manager.service
[Service]
Type=simple
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment XAUTHORITY=$(find /var/run/sddm/ -type f)"
Environment=HOME=/root
@mjtiempo
mjtiempo / python-dynv6-update.py
Created November 11, 2022 23:10
script to update your IPV6 address in DynV6.com
import requests
import socket
URL='http://dynv6.com/api/update'
HOSTNAME='your_dynv6_hostname'
TOKEN='your_dyn_v6_token'
'''
You can use Task scheduler to run this on windows and cron on linux
'''
@mjtiempo
mjtiempo / testrail.sh
Last active October 17, 2022 01:57
Install Testrail on Ubuntu >= 20.04
#!/usr/bin/env bash
PHP_VERSION=7.4
IONCUBE_VERSION=12.0.2
TESTRAIL_DB_NAME=testrail
TESTRAIL_DB_USER=testrail
TESTRAIL_DB_PASSWORD=testrail
DEBIAN_FRONTEND=noninteractive
echo "Updating Software"
@mjtiempo
mjtiempo / python-logging
Last active October 2, 2022 02:01
Logging to stdout and file in python
'''
src: https://stackoverflow.com/a/46098711/2433866
'''
import sys
import logging
import logging.handlers
logging.basicConfig(
level=logging.INFO,
format="[%(asctime)s] %(levelname)s in %(module)s: %(message)s",