Skip to content

Instantly share code, notes, and snippets.

@yann2192
yann2192 / raid.sh
Last active September 5, 2020 18:04
#!/usr/bin/env bash
DEVICE1=UUID="6319642d-a495-4505-8346-510a17ce587a"
DEVICE2=UUID="4908f36f-453d-4253-98c7-584200b0c17e"
RDEVICE=UUID="68493f2f-a2b4-4771-9193-487b0a221f23"
MOUNT_POINT="/mnt"
_mount() {
echo -n "LUKS key: "; read -s key; echo ""
cryptsetup luksOpen "$DEVICE1" ext1 < <(echo $key)
@yann2192
yann2192 / devault.py
Last active July 20, 2022 10:58
Parse YAML to decrypt ansible-vault encrypted string or encrypt standard string using ansible-vault
import subprocess
import sys
import yaml
class VaultTag(yaml.YAMLObject):
yaml_tag = "!vault"
def __init__(self, env_var):
@yann2192
yann2192 / swag.py
Created September 16, 2019 08:47
Launch swagger-ui with given filepath (use docker)
#!/usr/bin/env python
import os
import subprocess
import sys
if subprocess.check_call('docker pull swaggerapi/swagger-ui', shell=True) != 0:
print("Error pulling swagger-ui")
path = os.path.abspath(sys.argv[1])
@yann2192
yann2192 / xssh.py
Created January 18, 2019 20:45
ssh + tmux
import sys
import os
from cmd import Cmd
import libtmux
class Shell(Cmd):
def __init__(self, *args):
self.args = args
@yann2192
yann2192 / pg_change_db_owner.sh
Created September 1, 2016 12:36 — forked from jirutka/pg_change_db_owner.sh
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/bash
#
# The MIT License
#
# Copyright 2014 Jakub Jirutka <[email protected]>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@yann2192
yann2192 / hardening_usbarmory.md
Last active November 22, 2023 11:36
Hardening USB Armory

Hardening the USB Armory

As a good crypto nerd, I usually use an entirely encrypted linux FS: / but also /boot using grub LUKS support. It's a good setup but it's not perfect, the BIOS and the bootloader are not protected.

I recently got a USBArmory and I wanted to apply the same (or a better) setup.

I found some useful links but no clear howto. So this is my setup.

@yann2192
yann2192 / backup.sh
Last active April 12, 2020 09:29
Incremental backup using btrfs snapshot
#!/usr/bin/env bash
DEVICE=UUID="2b387045-9c35-4da0-8ed2-79014eb85040"
BACKUP_DEVICE="dde"
BACKUP_MOUNT="/mnt"
DEST="$BACKUP_MOUNT/backup"
MAX_BACKUPS=20
SOURCE="/home/yann"
SNAP_DIR="/home/backup"
@yann2192
yann2192 / reminder.py
Created August 6, 2014 13:11
Python reminder script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import imp
import subprocess
import time
import datetime
"""
-- Copyright (c) 2013 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
--- Path manipulation utility functions.
local path = {}
function path.dirname(filename)
while true do
@yann2192
yann2192 / gist:6103258
Created July 29, 2013 09:41
(django) Resync all table sequences in postgres
DO $$
DECLARE
tables CURSOR FOR SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg_%' ORDER BY tablename;
BEGIN
FOR table_record IN tables LOOP
BEGIN
EXECUTE 'SELECT setval('''|| table_record.tablename ||'_id_seq'', (SELECT MAX(id) FROM '||table_record.tablename||')+1)';
EXCEPTION
WHEN OTHERS THEN
END;