Skip to content

Instantly share code, notes, and snippets.

@forkloop
forkloop / vfio.md
Last active April 27, 2024 16:26 — forked from sameo/vfio.md

VFIO

Not KVM bound. The VFIO API deconstructs a device into regions, irqs, etc. The userspace application (QEMU, cloud-hypervisor, etc..) is responsible for reconstructing it into a device for e.g. a guest VM to consume.

Boot with intel_iommu=on.

IOMMU groups

Devices are bound together for isolation, IOMMU capabilities and platform topology reasons. It is not configurable.

@forkloop
forkloop / utilization_interceptor.py
Created May 18, 2019 15:46
grpc python server interceptor
# https://github.com/mehrdada/grpc/blob/aa477becd1a7c44f8150ad24539cf6d40af24b37/examples/python/interceptors/service-latency-interceptor/service_latency_interceptor.py
import logging
import threading
import grpc
def _wrap_rpc_behavior(handler, fn):
if handler is None:
return None
@forkloop
forkloop / set_bg.scpt
Last active December 3, 2024 11:20
Set desktop background to given a picture URL
#!/usr/bin/osascript
on run(argv)
if count of argv is equal to 0 then
set msg to "Usage\n\tset_bg URI"
return msg
end if
set uri to item 1 of argv
set dest to do shell script "echo /tmp/$(date +%Y%m%d%H%M%S).jpg"
@forkloop
forkloop / sync_dcim.rb
Created May 12, 2014 00:17
Backup Android photos
#!/usr/bin/ruby
require 'set'
require 'yaml'
# sync the Android DCIM foler periodically
PATH = '/mnt/sdcard/DCIM/Camera'
DEST = "#{ENV['HOME']}/Pictures/Android"
@forkloop
forkloop / gist:9148307
Created February 22, 2014 03:37
tmux.conf
set -g default-terminal "screen-256color"
set -g prefix C-b
set -g base-index 1
# Split window
bind | split-window -h
bind - split-window -v
# Reload config file
@forkloop
forkloop / particle_filter.py
Last active October 3, 2015 09:17
Particle Filter
#! /usr/bin/env python
"""
particle filter
http://people.csail.mit.edu/rplatt/hw5.html
using SIR
@forkloop
"""
from __future__ import division
import numpy as np