Skip to content

Instantly share code, notes, and snippets.

@jeromer
jeromer / compassbearing.py
Last active February 21, 2024 13:31
compass bearing between two points in Python
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
@shamil
shamil / mount_qcow2.md
Last active March 26, 2024 14:47
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
/*
d8888 .d8888b. 888b 888
d88888 d88P Y88b 8888b 888
d88P888 888 888 88888b 888
.d8888b d88P 888 888 888Y88b 888
88K d88P 888 888 888 Y88b888
"Y8888b. d88P 888 888 888 888 Y88888
X88 d8888888888 Y88b d88P 888 Y8888
88888P' d88P 888 "Y8888P" 888 Y888
#!/usr/bin/env bash
# Installs/Configures:
# - Docker
# - Docker Registy Container with self-signed cert
#
# Tested on Ubuntu 14.04.1
# Must be executed with elevated privilages
if [ "$(id -u)" != "0" ]; then
#!/bin/bash
##################################################################################
# Author: Gagandeep Arora
# Date: 01-Oct-2014
# Purpose: To sync the rbds using incremenatl snapshots from production ceph cluster
# to backup ceph cluster
##################################################################################
mirrorPool() {
#list all images in the pool
IMAGES=`$SOURCERBDCMD ls $SOURCEPOOL`
@RafPe
RafPe / vyos-optimisations
Last active August 5, 2023 03:38
vyos throughput optimizations
Server 2 sockets,6 cores each, 2.4ghz
# Set ixgbe options
# Limit RSS queues to the number of physical cores per cpu
# Disable offload
# When you change this, you need to run the command and reboot for it to take.
echo "options ixgbe LRO=0,0 MQ=1,1 RSS=6,6 VMDQ=0,0 vxlan_rx=0,0" > /etc/modprobe.d/ixgbe.conf
# Shut down HT cores
for i in $(seq 1 2 23); do
@tamurray
tamurray / tmurray_16VM_unix_Only_no_heat_scalTest-01.py
Created July 26, 2016 16:54
simple test script to spin up 16 vms in Openstack using python API clients
#!/usr/bin/python
import os
import sys
import time
from pprint import pprint
from concurrent import futures
from keystoneclient.v2_0 import client as ks_client
from novaclient import client as nova_client
from neutronclient.neutron import client as neutron_client
@claudiok
claudiok / OpenStack_consumer_GPU_passthrough.md
Last active March 26, 2023 08:20
Consumer-grade GPU passthrough in an OpenStack system (NVIDIA GPUs)

Consumer-grade GPUs in an OpenStack system (NVIDIA GPUs)

Assumptions

This assumes you have GTX980 cards in your system (PCI id 10de:13c0 & 10de:0fbb per card). Just add more IDs for other cards in order to make this more generic. This also assumes nova uses qemu-kvm as the virtualization hypervisor (qemu-system-x86_64). This seems to be the default on OpenStack Newton when installed using openstack-ansible.

We assume OpenStack Newton is pre-installed and that we are working on a Nova compute node. This has been tested on an Ubuntu 16.04 system where I installed OpenStack AIO version 14.0.0 (different from the git tag used in the instructions!): http://docs.openstack.org/developer/openstack-ansible/developer-docs/quickstart-aio.html

Prepare the system for GPU passthrough (set up IOMMU/vfio/...)

Note: This is heavily based on information from https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Enabling_IOMMU adapted for Ubuntu 16.04

@mdonkers
mdonkers / server.py
Last active March 17, 2024 04:06
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer