Skip to content

Instantly share code, notes, and snippets.

ACTION=="add", SUBSYSTEM=="input", ENV{ID_VENDOR_ENC}=="Logitech", ENV{ID_INPUT_KEYBOARD}=="1", RUN+="/bin/sh -c 'sudo -u user DISPLAY=:0 XAUTHORITY=/home/user/.Xauthority DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /usr/bin/notify-send -u critical \"foo\"'"
#include <stdio.h>
#include <functional>
#include <unordered_map>
template<template<typename> typename F>
struct fix { F<fix<F>> f; };
enum kind {
Int, Var, Add, Div, Mul, Sub
};
@th0rex
th0rex / Usage.md
Last active April 29, 2024 07:39
Build qemu as a library

Place file into qemu root directory Do cd path/to/qemu && ./name_of_file name_of_target (i.e. x86_64-softmmu) Library is at /path/to/qemu/x86_64-softmmu/libqemu.so You might need to compile vl.c and link with it in your final binary, just do something like this:

#define main __definetly_not_main
#include "/path/to/qemu/vl.c"
#undef main
> PS: You want to hook into font-lock rather than into
> `window-scroll-functions`. More about this is my next email.
Here's one way to do it.
[ Note: like the previous, this is guarantee 100% untested. ]
Stefan
@th0rex
th0rex / Cargo.toml
Created December 7, 2019 10:08
zydis rs bench
[package]
name = "zydis-rs-bench"
version = "0.1.0"
authors = ["th0rex "]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
goblin = "*"
@th0rex
th0rex / vm.sh
Last active October 11, 2018 12:35
#!/usr/bin/bash
# Start:
# sudo ./vm.sh
# Connect:
# sudo spicy --uri="spice+unix:///tmp/vm_spice.socket"
NET_OPTIONS="-net none" && [[ $1 == "--enable-net" ]] && NET_OPTIONS="-netdev user,id=default,net=10.0.2.0/24,dhcpstart=10.0.2.9 -device virtio-net-pci,netdev=default,mac=00:16:3e:00:01:01 -net nic -net user,smb=/vm/"
qemu-system-x86_64 \
# [y][x]
rot_table = [
[0, 1, 62, 28, 27],
[36, 44, 6, 55, 20],
[3, 10, 43, 25, 39],
[41, 45, 15, 21, 8],
[18, 2, 61, 56, 14],
]
fn parity(xs: &[u8]) -> u64 {
let mut ret = 0u64;
for (i, _) in xs.iter().enumerate() {
let mut acc = 0;
for j in i..i + 8 {
let x = xs[j % xs.len()];
acc ^= (x >> (7 - ((i + 1) % 8))) & 0b1;
}
ret |= (acc as u64) << (xs.len() - (i+1));
#[async(boxed, send)]
fn program_main(state: State) -> Result<(), Never> {
// Hack to make sure sessions is only created on the polling thread.
await!(futures::future::ok::<(), Never>(()))?;
let mut sessions: Vec<Session> = vec![];
#[async]
for cmd in state.command_rx {
use UICommand::*;
@th0rex
th0rex / mindiff.hs
Last active May 27, 2018 16:14
some haskell exercises
#! /usr/bin/runhaskell
import Control.Monad
import Data.List
mapSucc :: (a -> a -> b) -> [a] -> [b]
mapSucc _ [] = []
mapSucc f [x] = error "can't call mapSucc with a list of only one element"
mapSucc f [x, y] = [f x y]
mapSucc f (x:y:xs) = f x y : mapSucc f (y:xs)