Skip to content

Instantly share code, notes, and snippets.

@nickpegg
nickpegg / 90-libvirt-usb.rules
Last active June 9, 2024 17:13
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 October 18, 2023 15:32
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 May 15, 2024 07:01
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 May 29, 2024 17:11
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) \
{ char *ss__sw = (x); bool ss__done = false; bool ss__cont = false; \
@jasonwhite
jasonwhite / joystick.c
Last active May 3, 2024 13:28
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 August 2, 2023 21:47
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
@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 {