Skip to content

Instantly share code, notes, and snippets.

View Rigil-Kent's full-sized avatar
👾

Bryan Bailey Rigil-Kent

👾
  • 111
  • Baltimore, MD
View GitHub Profile
def camel_to_snake(data: str) -> str:
data = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', data)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', data).lower()
def snake_to_pascal(data: str) -> str:
return ''.join[word.title() for word in data.split('_')]
@Rigil-Kent
Rigil-Kent / random_ssh.sh
Created February 3, 2022 19:08
Change SSH Port to a random number in a specified range
# range is inclusive
# replaces the entire line of the match (uncommenting in the case of newly provisioned servers)
NEW_PORT=$(shuf -i 3101-7999 -n 1)
sudo sed -i "/Port 22/c Port $NEW_PORT" /etc/ssh/sshd_config && sudo systemctl restart sshd && echo "SSH Port has been changed to $NEW_PORT"
@Rigil-Kent
Rigil-Kent / prometheus.yml
Created January 10, 2022 19:54
Prometheus docker
global:
scrape_interval: 5s
external_labels:
monitor: 'node'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: [':9090'] ## IP Address of the localhost. Match the port to your container port
- job_name: 'node-exporter'
static_configs:
@Rigil-Kent
Rigil-Kent / routes.py
Last active May 31, 2020 03:47
flask-sitemapxml
from datetime import datetime, timedelta
from flask import current_app, make_response, render_template
from app.models import Post
@app.route('/sitemap.xml', methods=['GET'])
def sitemap():
'''Generate sitemap.xml iterating over static and dynamic routes to make a list of urls and date modified'''
pages = []
ten_days_ago = datetime.now - timedelta(days=10)
@Rigil-Kent
Rigil-Kent / datetime.html
Created May 9, 2019 18:26
Datetime Flask-TempusDominus
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input type="text" name="date" id="datetimepicker1" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>