Skip to content

Instantly share code, notes, and snippets.

@bootandy
bootandy / .Xmodmap
Created June 27, 2024 20:51
xmodmap for tweaking keyboard. Swap CapsLock Escape. Swap CTRL ALT.
! See keys with:
! xev
! Clear memory:
! setxkbmap -option
!
! Use this file:
! xmodmap ~/.Xmodmap
!
!setxkbmap -layout gb -option ctrl:nocaps
@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 / 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 / display_plugin
Last active June 27, 2024 20:50
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 / 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 / rust_fail.rs
Last active October 29, 2019 09:21
Figure out why this won't work in rust
use rayon::prelude::*;
use std::rc::Rc;
use std::sync::Arc;
use std::cell::RefCell;
use std::cell::RefCell;
#[macro_use]
extern crate rayon;
struct ResultOfCalc {
@bootandy
bootandy / errors.py
Last active November 7, 2024 09:45
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 / ftl.py
Last active July 18, 2018 22:50
A tiny text based game based on FTL
import random
import math
from os import system, name
ship_types = [
"Cobra", "Krait", "Viper", "Anaconda", "Sidewinder", "Vulture", "Asp",
]
ship_grading = [
"Rookie",
@bootandy
bootandy / samples.rs
Last active April 3, 2018 13:44
sample rust code
pub fn how_to_loop_round_a_vec(tokens : &[reader::Token]) {
let ti = tokens[1..].iter();
let mut new_list = vec![to_add];
// If you do not specify an iter() in a loop then into_iter() is used which consumes the vec
for nxt_token in ti {
new_list.push(
match nxt_token {
&reader::Token::List(ref list) => apply_sym(None, None, &list, func_map),
&_ => nxt_token.clone()
}