Skip to content

Instantly share code, notes, and snippets.

View gatopeich's full-sized avatar
🧟‍♂️
hacking since 1987

gatopeich

🧟‍♂️
hacking since 1987
View GitHub Profile
@gatopeich
gatopeich / 50-gamepad.conf
Created February 5, 2023 16:33
Sample gamepad configuration Xorg with hints to use as Mouse+Keyboard for Minecraft
# Gamepad configuration for general use, and emulating mouse+keys for Minecraft
Section "InputClass"
Identifier "Gamepads"
Driver "joystick"
MatchIsJoystick "on"
#MatchDevicePath "/dev/input/js*"
#MatchProduct "GAME"
# Map arrow pad (axis 5 & 6) to cursor keys left right up down
Option "MapAxis5" "keylow=113 keyhigh=114"
@gatopeich
gatopeich / Mapping keys and mouse to gamepad
Created February 5, 2023 10:26
Mapping keys and mouse to gamepad with Linux UDEV system
This is something I never had the time to put together.
Today I asked openai.org and it provided a nice walk-through...
QUESTION> How can I map gamepad buttons to keys and mouse with UDEV?
To map gamepad buttons to keyboard and mouse inputs with UDEV, you will need to create a udev rule file to specify the mapping. Here are the steps:
Identify the gamepad device name: Run ls /dev/input/by-id to see a list of all input devices connected to your system. Look for the one that corresponds to your gamepad and note its name, e.g. /dev/input/by-id/usb-<VENDOR_ID>-<PRODUCT_ID>.
Create a udev rule file: Create a new file in /etc/udev/rules.d/ with a descriptive name, e.g. 99-gamepad-mapping.rules.
@gatopeich
gatopeich / merge_bash_history.sh
Last active February 2, 2023 09:25
Merge and keep bash history from different folders and processes
#!/bin/bash
# BASH history merger by Agustín F. Pozuelo (c) 2023
# Merge history files from multiple sessions, removing duplicate commands
# TODO: Maintain order of commands in the most recent appearances
# BASH history merger.
# I use this to maintain history of my many BASH sessions
# Each session writes history to a separate file
# Running this from inside .bashrc, the 10 most recent sessions are merged together
@gatopeich
gatopeich / Wii from SD card in 2020.md
Created July 12, 2020 12:34
Run Wii games from SD card in quick, safe and easy steps (2020 mini guide)

After spending days following some obsolete or incomplete or just too long and specific guides, here is my take on setting up a Wii in the year 2020

  1. Format SD card with 1 partition of 32kb clusters: sudo mkdosfs /dev/sdXX -s 128 -F 32. Up to 32GB SD-HC should work fine, despite what was said in old forums
  2. Install BootMii + HBC with LetterBomb: https://wiibrew.org/wiki/LetterBomb
  3. BACKUP your NAND with BootMii to be safe from bricking: https://sites.google.com/site/completesg/how-to-use/bootmii This is mostly for peace of mind though
  4. Install cIOS 249 base 56 v10 beta52 on slot 249 and base 57 on slot 250. This is the most complex step, be careful to follow the instructions here: https://sites.google.com/site/completesg/backup-launchers/installation
@gatopeich
gatopeich / InPlaceJSON.cpp
Created May 24, 2020 01:02
C++17 in-place JSON parser
// In-place JSON parsing concept by gatopeich 2020
// Taking advantage of C++17 features like std::string_view
// No rights reserved, use at your own risk!
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string_view>
namespace inplacejson
@gatopeich
gatopeich / RawFlood.cpp
Last active April 1, 2020 08:38
Using TPACKET_V3 to measure interface capacity. Proof of concept by gatopeich
// Using TPACKET_V3 to measure interface capacity. Proof of concept by gatopeich
// Based on the folloging information sources:
// [1] Kernel documentation: https://www.kernel.org/doc/Documentation/networking/packet_mmap.txt
// [2] Kernel "selftest" tools: https://github.com/torvalds/linux/blob/master/tools/testing/selftests/net/psock_tpacket.c
// [3] Answer to "Sending data with PACKET_MMAP..." in https://stackoverflow.com/a/43427533/501336
// [4] packet.7 man page http://man7.org/linux/man-pages/man7/packet.7.html
// [5] Kernel sources https://github.com/torvalds/linux/blob/master/net/packet/af_packet.c
#include <linux/if_packet.h>
#include <linux/if_ether.h>
@gatopeich
gatopeich / minecraft@.service
Created April 8, 2019 22:08
Systemd service for Minecraft Bedrock server (MCMrARM's mcpelauncher-server)
# /etc/systemd/system/minecraft@.service by gatopeich
#########
# HowTo #
#########
#
# - Copy this file to /etc/systemd/system/minecraft@.service
#
# - adduser --system --shell /bin/bash --home /opt/mcpe --group minecraft
#
@gatopeich
gatopeich / service_script.sh
Created March 29, 2019 12:29
Generic Linux service script, systemd and LSB compatible but also working on older systems
#!/bin/bash
# Generic Linux service script, systemd and LSB compatible but also working on older systems
# To install:
# 1. Place under /etc/init.d/ with the name of the service
# 2. sudo chmod +x /etc/init.d/my_service
# 3. sudo systemctl enable my_service || sudo chkconfig --add my_service
# 4. sudo service my_service start
@gatopeich
gatopeich / dataclass_from_dict.py
Created February 19, 2019 15:08
Python 3.7 dataclass to/from dict/json
from dataclasses import dataclass, fields as datafields
from ujson import dumps, loads
# Note: ujson seamlessly serializes dataclasses, unlike stdlib's json
@dataclass
class Point:
x: float
y: float
# Shallow dataclass can be rebuilt from dict/json:
@gatopeich
gatopeich / Extract Minecraft from Genymotion into MCPE-Launcher
Last active May 2, 2020 22:57
Get minecraft from Genymotion into MCPE-Launcher
$ ~/genymotion/tools/adb devices -l
List of devices attached
192.168.57.101:5555 device product:vbox86p model:Google_Nexus_7___4_4_4___API_19___800x1280 device:vbox86p
$ ~/genymotion/tools/adb shell ls /data/app/com.mojang.minecraft*
/data/app/com.mojang.minecraftpe-1.apk
$ ~/genymotion/tools/adb pull /data/app/com.mojang.minecraftpe-1.apk
/data/app/com.mojang.minecraftpe-1.apk: 1 file pulled. 50.6 MB/s (79278178 bytes in 1.494s)