Skip to content

Instantly share code, notes, and snippets.

@Desttro
Desttro / models.py
Last active March 11, 2022 02:22
django + strawberry
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=128)
slug = models.SlugField(unique=True, editable=False)
content = models.TextField() # markdown
thumbnail = models.ImageField(upload_to='%Y/%m/%d/', width_field='width', height_field='height')
width = models.PositiveIntegerField(editable=False)
height = models.PositiveIntegerField(editable=False)
@miped
miped / tmux-cheatsheet.markdown
Created February 6, 2022 17:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

Both things have been introduced recently, and let you access even private ec2 instances

  1. Without VPN
  2. No open SSH port
  3. Authentication / Authorization is fully delegated to IAM
# Assumes valid AWS Credentials in ENV
@fizzyade
fizzyade / untangle_letsencrypt.md
Last active January 22, 2022 02:10
Set Untangle certificate to an auto renewing LetsEncrypt certificate

This uses acme.sh to generate a certificate which replaces the one shown in the certificate section in the Untangle UI.

It updates on each run and if the certificate is renewed it replaces the one used by untangle and restarts apache.

if the certificate isn’t renewed, it still checks if the certificate untangle is using is the one cached by acme.sh and it will replace it and restart apache if necessary.

The crontab entries allow it to do a certificate check at reboot and also at 4am every morning.

You’ll need to download acme.sh, but it requires no extra dependencies over what is supplied in untangle, you will need to edit the acme.sh configuration file to match how you update the cert.

@Darksonn
Darksonn / killswitch.rs
Last active November 10, 2022 20:50
Kill switch for hyper sockets
#[derive(Clone)]
pub struct KillSwitch {
kill: Arc<AtomicBool>,
}
impl KillSwitch {
pub fn new() -> Self {
KillSwitch {
kill: Arc::new(AtomicBool::new(false)),
}
}
@woowa-hsw0
woowa-hsw0 / assume_role.sh
Last active January 11, 2023 11:36
Start AWS CLI Session with MFA Enabled (+Yubikey)
#!/bin/bash
set -eu
umask 0022
if [[ $# -lt 1 ]]; then
echo "Usage: $0 role_name [AWS ACCOUNT NUMBER]" >&2
exit 1
fi
@hallettj
hallettj / Makefile
Last active December 10, 2023 13:32
Makefile for transpiling with Babel & Flow in a Node app, or in a client- or server-side shared library
# Makefile for transpiling with Babel in a Node app, or in a client- or
# server-side shared library.
.PHONY: all clean
# Install `babel-cli` in a project to get the transpiler.
babel := node_modules/.bin/babel
# Identify modules to be transpiled by recursively searching the `src/`
# directory.
Elastic Load Balancer, CloudFront and Let's Encrypt
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)