Skip to content

Instantly share code, notes, and snippets.

@bootandy
bootandy / display_plugin
Last active March 6, 2023 21:30
display_plugin
# To be run when plugged into display:
# Reset to normal laptop:
# xrandr --output eDP-1 --scale .5x.5
xrandr --auto
xrandr --output eDP-1-1 --mode 1920x1080 --pos 2560x400 --scale 1x1
xrandr --output DVI-I-2-1 --scale 1x1 --mode 2560x1440 --left-of eDP-1-1
# curve screen:
@bootandy
bootandy / .psqlrc
Last active October 6, 2022 16:18
PSQLRC file with colors
-- prompts:
-- From: select inet_server_addr()
select case
when inet_server_addr()='10.0.0.61' then '%[%033[1;35m%]' -- red
when inet_server_addr()='10.0.0.24' then '%[%033[1;31m%]' -- purp
else '[%037[1m%]' -- cyan
end as col \gset
\set PROMPT2 '[more] %R > '
@bootandy
bootandy / new_linode.txt
Last active October 5, 2022 22:25
Todo on new linode
<install nginx, postgresql postgresql-contrib>
adduser andy
usermod -aG sudo username
<copy bash_profile>
<copy: /etc/nginx/sites-enabled/>
<copy: /etc/systemd/system/>
<copy: letsencrypt files, install certbot https://community.letsencrypt.org/t/move-to-another-server/77985/4 >
<update crontab>
<sudo vim /etc/postgresql/14/main/pg_hba.conf https://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge >
sudo usermod -a -G andy www-data
@bootandy
bootandy / errors.py
Last active July 4, 2022 16:27
code errors
########## Handle every case on dictionary gets and type casts.
# No:
winner_odds = schedule_json.get("sp", {}).get("main", [])
away_odds = float(winner_odds[0].get("odds", 0))
# Count the ways the above can go wrong
# len(winner_odds) == 0
# winner_odds[0] == {"odds": "a string"}
# winner_odds[0] == might not be a dictionary
# schedule_json.get("sp") might not contain a dictionary
# schedule_json.get("sp", {}).get("main") might not contain a list
@bootandy
bootandy / kubelogs.sh
Created February 15, 2022 23:39
# Script to tail logs of given kube service
#!/bin/bash
# Script to tail logs of given kube service
if [ $# -eq 0 ]
then
printf "Give me a service to look for"
exit 1
fi
@bootandy
bootandy / python_logging.yaml
Last active August 26, 2021 07:14
Sample logging config file for python logging module
# use with: logging.config.dictConfig(yaml.load(open('logging.yaml', 'r')))
# Formatters detailed here: http://docs.python.org/2/library/logging.html#logrecord-attributes
version: 1
formatters:
simple:
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
detail:
format: '%(asctime)s - %(levelname)s - File: %(filename)s - %(funcName)s() - Line: %(lineno)d - %(message)s'
@bootandy
bootandy / .Xmodmap
Last active June 28, 2021 15:07
Xmodmap: Swap Alt Ctrl keys, capslock AS control, shift-capslock as capslock.
! See keys with:
! xev
! Clear memory:
! setxkbmap -option
!
! Use this file:
! xmodmap ~/.Xmodmap
!
!setxkbmap -layout gb -option ctrl:nocaps
@bootandy
bootandy / flask_logging.py
Created June 30, 2020 14:51
flask with logging
# https://rz0r.net/post/2019-05-27-flask-logging/
import os
import logging
import socket
from flask import Flask
from logging.config import dictConfig
class ContextFilter(logging.Filter):
hostname = socket.gethostname()
@bootandy
bootandy / divs.html
Created September 18, 2012 13:21
HTML - make div align to bottom of page / div
<!-- How 2 make a HTML div float at the bottom of the page: -->
<div id="container" style='position:relative;'>
<!-- Other elements here -->
<div id="copyright" style='position:absolute; bottom:0;'>
Copyright Foo web designs
</div>
</div>
@bootandy
bootandy / mongo_admin.txt
Last active November 6, 2019 23:10
Mongodb admin notes
Start mongodb replica servers:
mongod --replSet abc --dbpath /db/1 --port 27001 --oplogSize 50 --logpath log.1 --logappend --fork --rest
mongod --replSet abc --dbpath /db/2 --port 27002 --oplogSize 50 --logpath log.2 --logappend --fork --rest
mongod --replSet abc --dbpath /db/3 --port 27003 --oplogSize 50 --logpath log.3 --logappend --fork --rest
Basic config for a replica set:
cfg=
{
"_id" : "abc",