Skip to content

Instantly share code, notes, and snippets.

View grisu48's full-sized avatar
🏠
Working from home

Felix Niederwanger grisu48

🏠
Working from home
View GitHub Profile
@grisu48
grisu48 / makecert.sh
Created May 4, 2021 06:52 — forked from jim3ma/makecert.sh
Golang TLS server and client
#!/bin/bash
# call this script with an email address (valid or not).
# like:
# ./makecert.sh joe@random.com
mkdir certs
rm certs/*
echo "make server cert"
openssl req -new -nodes -x509 -out certs/server.pem -keyout certs/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
echo "make client cert"
openssl req -new -nodes -x509 -out certs/client.pem -keyout certs/client.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
@grisu48
grisu48 / obs.md
Last active July 16, 2020 12:46
OBS Cheat sheet

OSC Cheat sheet

This small cheat sheet has been created by me after duing the OBS training with mpluskal. Hope it is of help to anybody that is starting with obs :-)

Configure OBS

First, let's set some aliases for the shell

$ vim ~/.bashrc
@grisu48
grisu48 / hosts
Created January 29, 2020 09:06
Windows hosts file for privacy
# WTFPL, phoenix - http://www.wtfpl.net/
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
#!/bin/bash
## 2019, phoenix
## Start Raspberry Pi in QEMU instance
##
#
# 1. Get the Raspian image: https://www.raspberrypi.org/downloads/raspbian/
# 2. Get Raspberry Kernel and dtb: https://github.com/dhruvvyas90/qemu-rpi-kernel
# 3. Extract Raspbian and put the Kernel and the dtb into a directory
# 4. Convert the IMG to a QCOW2: qemu-img convert -f raw -O qcow22019-09-26-raspbian-buster-lite.img 2019-09-26-raspbian-buster-lite.qcow
# 5. Make some more space: qemu-img resize 2019-09-26-raspbian-buster-lite.qcow2 +5G
@grisu48
grisu48 / sockaddr_tostr
Created November 5, 2019 11:02 — forked from jkomyno/sockaddr_tostr.h
Convert a struct sockaddr address to a string, IPv4 and IPv6
// Convert a struct sockaddr address to a string, IPv4 and IPv6:
char *get_ip_str(const struct sockaddr *sa, char *s, size_t maxlen)
{
switch(sa->sa_family) {
case AF_INET:
inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
s, maxlen);
break;
@grisu48
grisu48 / Gaussian2d.py
Last active September 4, 2019 08:41
Gaussian2d implementation and test
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import random
import numpy as np
from math import *
import time
import sys
class Gauss2d :
@grisu48
grisu48 / ansible-shutdown.yml
Created July 16, 2019 11:04
Ansible playbook to shutdown nodes
---
- hosts: ap-nodes
gather_facts: no
tasks:
- name: shutdown
command: /sbin/shutdown -h now
sudo: yes
- name: wait go down
local_action: wait_for host={{ ansible_ssh_host }} port=22 state=stopped
@grisu48
grisu48 / create_vm_snapshot.sh
Last active September 23, 2020 07:56
Shell script to stop KVM, create BTRFS snapshot and restart KVM machines again
#!/bin/bash
# Shell script to stop all KVM instances, create a BTRFS snapshot (read-only) and restart the stopped KVM instances
# https://gist.github.com/grisu48/535c27cd25c096248ce234ad81abf1b9
## Configuration ##############################################################
IMGDIR="/mnt/RAID/libvirt/images"
SNAPDIR="/mnt/RAID/libvirt/snapshots"
# timeout in seconds
TIMEOUT=300
@grisu48
grisu48 / .bash_aliases
Created May 29, 2019 06:51
Template for my bash aliases
#!/bin/bash
alias killall="killall -u `whoami` -i"
alias weather="curl 'http://wttr.in/'"
ctrim() {
if [ $# -lt 1 ]; then
echo "ctrim - trim the given pictures (using convert --trim)"
else
for i in $@; do
@grisu48
grisu48 / ctrim.sh
Last active May 28, 2019 09:06
Bash function to trim pictures using imagemagick
#!/bin/bash
# Bash function to trim pictures using imagemagick
# This snippet is meant to be inserted as function in ~/.bashrc
ctrim() {
if [ $# -lt 1 ]; then
echo "ctrim - trim the given pictures (using convert --trim)"
else
# TODO: Parallel runs
for i in $@; do