Skip to content

Instantly share code, notes, and snippets.

View jchv's full-sized avatar

jchv

  • United States
View GitHub Profile
@jchv
jchv / input-settings-fixes.diff
Created November 7, 2020 20:25
Fix for some bsnes input settings bugs (being tested.)
diff --git a/bsnes/target-bsnes/settings/input.cpp b/bsnes/target-bsnes/settings/input.cpp
index 13b04b7a..fd76ac78 100644
--- a/bsnes/target-bsnes/settings/input.cpp
+++ b/bsnes/target-bsnes/settings/input.cpp
@@ -68,12 +68,11 @@ auto InputSettings::updateControls() -> void {
assignMouse3.setVisible(false);
if(activeMapping) {
- auto& input = activeDevice().mappings[batched.left().offset()];
- if(input.isDigital()) {
@jchv
jchv / nix-code-wine.sh
Last active September 18, 2020 07:08
Script for getting a good IDE experience for programming Wine under NixOS. Assumes you are in the Wine folder, and have a ../wine-build.
#!/bin/sh
set -e
if [ "$1" = "inside-nix-shell" ]; then
echo "Clearing clangd cache."
rm -f "compile_commands.json"
rm -rf ".clangd"
LIBEAR32="$(nix-build "<nixpkgs>" -A bear --argstr system i686-linux)/lib/bear/libear.so"
LIBEAR64="$(nix-build "<nixpkgs>" -A bear --argstr system x86_64-linux)/lib/bear/libear.so"
@jchv
jchv / recover-sway-socket.md
Last active September 25, 2022 01:50
How to recover your SwayWM socket in an SSH session.

How to recover your SwayWM socket in an SSH session.

I've run into a strange problem where sometimes, my monitors are forced to DPMS off and moving the cursor or pressing keys does not free it. I suspect this is a bug in my SwayWM configuration or a bug in Swaylock, but it resolves itself if I wait until the device again locks, which causes a second Swaylock instance to appear.

In any case, if you get yourself stuck and need to recover, you might want to be able to run swaymsg remotely. If you do, you might run into strange issues. swaymsg calls sway --get-socketpath to get the IPC socket, which... just returns the value of the SWAYSOCK environment variable. In my case, this also has the funny side-effect of starting a dbus session and SSH agent each time its invoked, because it is calling the NixOS-wrapped SwayWM binary. Probably should patch the NixOS version to explicitly call the unwrapped binary!

In order to recover the SWAYSOCK, one approach that should be relatively easy and does not requ

@jchv
jchv / backtrace.txt
Last active November 25, 2019 05:59
SwayWM crash on spamming tablet events
#0 0x00007faa9909d563 in wl_list_insert () from /nix/store/641prxh0dppg0d0cd1hkhcs83sq75g7b-wayland-1.17.0/lib/libwayland-server.so.0
No symbol table info available.
#1 0x00007faa9970b5cd in wl_signal_add (signal=0x11e7d10, listener=0x15b4ff0) at /nix/store/641prxh0dppg0d0cd1hkhcs83sq75g7b-wayland-1.17.0/include/wayland-server-core.h:435
No locals.
#2 xwm_set_seat (xwm=0x15b4c50, seat=0x11e7a10) at ../subprojects/wlroots/xwayland/selection/selection.c:309
No locals.
#3 0x00007faa9970c95a in wlr_xwayland_set_seat (xwayland=0x1235690, seat=0x11e7a10) at ../subprojects/wlroots/xwayland/xwayland.c:473
No locals.
#4 0x000000000044fd26 in unmanaged_handle_map (listener=<optimized out>, data=<optimized out>) at ../sway/desktop/xwayland.c:81
seat = 0x11e78c0
diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c
index fe3d4a8ff4..68c35e68e4 100644
--- a/dlls/winex11.drv/wintab.c
+++ b/dlls/winex11.drv/wintab.c
@@ -304,6 +304,8 @@ static WTPACKET last_packet;
* FIXME: we don't support more than 4 regular tablets or 2 multimode tablets */
#define CURSORMAX 12
static INT button_state[CURSORMAX];
+static INT gCursorX[CURSORMAX];
+static INT gCursorY[CURSORMAX];
@jchv
jchv / configuration.nix
Last active February 14, 2023 05:22
Nix configuration for VGA passthrough
{ config, pkgs, lib, ... }:
{
# IOMMU configuration
boot.kernelParams = [ "amd_iommu=on" "pcie_aspm=off" ];
boot.kernelModules = [ "kvm-amd" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ];
boot.extraModprobeConfig = ''
options vfio-pci ids=10de:13c2,10de:0fbb
options kvm ignore_msrs=1
'';
@jchv
jchv / README.md
Created May 24, 2018 13:31
Installing evdevremapkeys

Open a terminal. (Ctrl+Alt+T)

Become root:

sudo -i

Install the Python package:

@jchv
jchv / NchanSubscriber.js
Created December 7, 2016 19:01
NchanSubscriber CommonJS module
/*
* NchanSubscriber
*/
// https://github.com/yanatan16/nanoajax
!function(t,e){function n(t){return t&&e.XDomainRequest&&!/MSIE 1/.test(navigator.userAgent)?new XDomainRequest:e.XMLHttpRequest?new XMLHttpRequest:void 0}function o(t,e,n){t[e]=t[e]||n}var r=["responseType","withCredentials","timeout","onprogress"];t.ajax=function(t,a){function s(t,e){return function(){c||(a(void 0===f.status?t:f.status,0===f.status?"Error":f.response||f.responseText||e,f),c=!0)}}var u=t.headers||{},i=t.body,d=t.method||(i?"POST":"GET"),c=!1,f=n(t.cors);f.open(d,t.url,!0);var l=f.onload=s(200);f.onreadystatechange=function(){4===f.readyState&&l()},f.onerror=s(null,"Error"),f.ontimeout=s(null,"Timeout"),f.onabort=s(null,"Abort"),i&&(o(u,"X-Requested-With","XMLHttpRequest"),e.FormData&&i instanceof e.FormData||o(u,"Content-Type","application/x-www-form-urlencoded"));for(var p,m=0,v=r.length;v>m;m++)p=r[m],void 0!==t[p]&&(f[p]=t[p]);for(var p in u)f.setRequestHeader(p,u[p]);return f.send(i),f},e.nanoajax=t}({},function(){return
@jchv
jchv / mysql-backup.py
Last active February 22, 2016 04:49
Simple script for backing up MySQL databases to Amazon S3. Designed to be used in a periodic task.
#!/usr/bin/python
# Simple MySQL + S3 backup script
# By John <johnwchadwick@gmail.com>
from __future__ import print_function
import sys
import boto3
import argparse
from boto3.s3.transfer import S3Transfer
from tempfile import NamedTemporaryFile
// Page represents a cursor for a page of calendar entries.
type Page struct {
Calendar string `json:"calendar"`
EarliestDate time.Time `json:"earliestDate"`
LatestDate time.Time `json:"latestDate"`
Sort string `json:"sort"`
Skip int `json:"skip"`
Limit int `json:"limit"`
}