Skip to content

Instantly share code, notes, and snippets.

@nickpegg
nickpegg / 90-libvirt-usb.rules
Last active November 25, 2025 13:02
KVM USB auto-passthrough using udev
# File location: /etc/udev/rules.d/90-libvirt-usb.rules
ACTION=="bind", \
SUBSYSTEM=="usb", \
ENV{ID_VENDOR_ID}=="6b62", \
ENV{ID_MODEL_ID}=="6869", \
RUN+="/usr/local/bin/kvm-udev attach <domain>"
ACTION=="remove", \
SUBSYSTEM=="usb", \
ENV{ID_VENDOR_ID}=="6b62", \
ENV{ID_MODEL_ID}=="6869", \
@johnstcn
johnstcn / ethminer_ubuntu_nvidia.md
Last active October 1, 2022 16:34
NVIDIA/CUDA ethminer setup under Ubuntu Server 16.04

Headless Ethminer (nVidia) Setup Guide

Cian Johnston, July 2017

WARNING: THESE WORDS ARE OLD AND MAY NOT WORK FOR YOU IN THESE NEW AND INTERESTING TIMES.

A couple of weeks ago, I decided I should put my gaming rig to work crypto mining. I did not expect to make any significant profit on this, it was more of a fun project to set up. However, there were a large number of tutorials and guides already out there, and many were more than a year out of date.

This guide assumes the reader already has a crypto wallet set up, is comfortable with Linux and the command line, and knows how to use Google if they run into problems.

The end result is an Ubuntu 16.04 LTS headless server running CUDA ethminer via systemd.

@Joe4evr
Joe4evr / AudioModule.cs
Last active February 27, 2025 23:17
D.Net 1.0 audio example
using System.Threading.Tasks;
using Discord.Commands;
public class AudioModule : ModuleBase<ICommandContext>
{
// Scroll down further for the AudioService.
// Like, way down
private readonly AudioService _service;
// Remember to add an instance of the AudioService
@drazisil
drazisil / pretty-json.php
Last active October 12, 2021 16:15
Pretty-print a JSON string in PHP.
<?php
/**
* Formats a JSON string for pretty printing
*
* @param string $json The JSON to make pretty
* @param bool $html Insert nonbreaking spaces and <br />s for tabs and linebreaks
* @return string The prettified output
* @author Jay Roberts
*/
@0
0 / bluetooth_serial.md
Last active March 16, 2025 19:32
Connecting a Bluetooth device for serial communication on Arch Linux.

The following are instructions for connecting a Bluetooth device for serial communication on Arch Linux using BlueZ 5.31.

Prerequisites

The following packages are required:

  • bluez: bluetoothd
  • bluez-utils: bluetoothctl, rfcomm
@develhox
develhox / switchs.h
Last active August 9, 2025 22:09
Switch operand implementation for the strings
#ifndef __SWITCHS_H__
#define __SWITCHS_H__
#include <string.h>
#include <regex.h>
#include <stdbool.h>
/** Begin a switch for the string x */
#define switchs(x) \
{ const char *ss__sw = (x); bool ss__done = false; bool ss__cont = false; \
@jasonwhite
jasonwhite / joystick.c
Last active November 15, 2025 14:16
Reads joystick/gamepad events on Linux and displays them.
/**
* Author: Jason White
*
* Description:
* Reads joystick/gamepad events and displays them.
*
* Compile:
* gcc joystick.c -o joystick
*
* Run:
@mvidner
mvidner / sendkeys
Last active March 26, 2025 14:27
Translate a string to "sendkey" commands for QEMU.
#!/usr/bin/env ruby
# Translate a string to "sendkey" commands for QEMU.
# Martin Vidner, MIT License
# https://en.wikibooks.org/wiki/QEMU/Monitor#sendkey_keys
# sendkey keys
#
# You can emulate keyboard events through sendkey command. The syntax is: sendkey keys. To get a list of keys, type sendkey [tab]. Examples:
#
# sendkey a
anonymous
anonymous / keypad2.cpp
Created January 19, 2014 06:56
Modified version of Arduino's Keypad.h to work with Adafruit's MCP23017 GPIO port expander library
/*
||
|| @file Keypad.cpp
|| @version 3.1
|| @author Mark Stanley, Alexander Brevig
|| @contact [email protected], [email protected]
||
|| @description
|| | This library provides a simple interface for using matrix
|| | keypads. It supports multiple keypresses while maintaining
@jamesu
jamesu / dtmf_generate.c
Created August 8, 2012 17:17
Generate DTMF tones
//
// Generate DTMF tones
//
#include <stdio.h>
#include <math.h>
float OutData[44100];
typedef struct ToneInfo {