Skip to content

Instantly share code, notes, and snippets.

View marc-hanheide's full-sized avatar
💭
coding?

Marc Hanheide marc-hanheide

💭
coding?
View GitHub Profile
@marc-hanheide
marc-hanheide / myip.sh
Created March 10, 2024 17:44
Use Python to get your external apparent IP address
#!/bin/sh
python -c "import requests; print(str(requests.get('https://icanhazip.com').text))"
@marc-hanheide
marc-hanheide / patching-commands.md
Created November 3, 2023 14:28
Create a patch for submodules

How to create a patch for a repository with submodules

You checkout whatever repository you want.

Then you make all the changes that are required to make it all work in any submodule as needed. You don't commit in the submodules.

Make sure you have committed everything in your own repository and git diff shows that there are only changes in your submodules and you "parent" repository is still clean.

git --no-pager diff --no-color --submodule=diff > patch.diff
@marc-hanheide
marc-hanheide / cloudsend.sh
Created March 18, 2022 18:34 — forked from tavinus/cloudsend.sh
Send files to Nextcloud/Owncloud shared folder using curl
#!/usr/bin/env bash
############################################################
# MIGRATED TO REPOSITORY
# https://github.com/tavinus/cloudsend.sh
#
# This gist will NOT be updated anymore
############################################################
############################################################
@marc-hanheide
marc-hanheide / docker-compose.yaml
Last active February 23, 2022 16:40
Docker novnc-desktop-standalone compose solution
version: '3'
services:
novnc_desktop_bionic:
image: lcas.lincoln.ac.uk/lcas/novnc-desktop-standalone:bionic
ports:
- 6080:6080
restart: always
volumes:
- userhome:/home/lcas
cap_add:
@marc-hanheide
marc-hanheide / mount_qcow2.md
Created January 26, 2022 20:37 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@marc-hanheide
marc-hanheide / tricks.ps1
Last active April 12, 2021 19:04
Tricks for interacting with MS Teams using PowerShell
# First get powershell (also available for Mac) ;-)
# Install Teams module in powershell (once)
Install-Module -Name MicrosoftTeams
# Connect to Teams
Connect-MicrosoftTeams
# Find the Team (can take a while):
Get-Team -DisplayName "UoL-SAGA Code camp 2021"
@marc-hanheide
marc-hanheide / upload.sh
Created October 16, 2020 14:47
CURL upload to NextCloud shared folder
#!/bin/bash
FILEPATH="$1"
SHARED_TOKEN="Xp749RSG2K4NknT"
URL="https://lcas.lincoln.ac.uk/nextcloud/public.php/webdav"
FILENAME="`basename $FILEPATH`"
curl -X PUT -T "$FILEPATH" -u "$SHARED_TOKEN:" $URL/$FILENAME
@marc-hanheide
marc-hanheide / ssh_scan.sh
Created October 14, 2020 14:47
Find all ssh host keys on a network segment
#!/bin/bash
SUBNET="10.5.42.0/24
# compare the output to your ~/.ssh/known_hosts list
for ip in `nmap -p 22 --open -oG - $SUBNET | grep '22/open' | cut -f2 -d" " `; do key="`ssh-keyscan -H -t rsa $ip 2>&1| grep -v '^# '`"; if [ "$key" ]; then echo "$ip $key"; fi ; done
@marc-hanheide
marc-hanheide / README.md
Last active September 7, 2020 10:38
Guacamole VNC setup

Using virtual VNC Xserver over guacamole

Installation

  1. Install sudo apt-get install xfce4-session xfce4-goodies xrdp tigervnc-standalone-server
  2. The files /etc/xrdp/sesman.ini and /etc/xrdp/xrdp.ini may have to edited as in this gist, but it may work also with default configs
  3. For reconnections (in guacamole) to existing session to work, the resolution in guacamole for the connection should be fixed (e.g. to 1280x900 in the connection settings)
  4. Each user who wants to use it, should have the files ~/.xsession and ~/.vnc/xstartup with the defaults in this gist in their home directory

Without Guacamole

@marc-hanheide
marc-hanheide / 01_generate_certificate_authority.sh
Last active May 20, 2020 09:54
Generate certificates for mongodb
# set all variables
KEY_BITS=4096
CA_PRIVATE_KEY_NAME="certificate_authority_private_key.key"
CA_CERT_NAME="certificate_authority_root_certificate.cert"
DAYS_VALID=365
# these are subject variables to be added into the certificate
CA_COUNTRY_CODE="GB"
CA_PROVINCE="Lincolnshire"
CA_LOCATION="Lincoln"
CA_ORGANISATION="University of lincoln"