Skip to content

Instantly share code, notes, and snippets.

View r0xsh's full-sized avatar
:shipit:
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

Antoine Bagnaud r0xsh

:shipit:
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
View GitHub Profile
@r0xsh
r0xsh / dyn_arr.h
Created February 28, 2023 19:27 — forked from nicebyte/dyn_arr.h
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
Write health
5600E1A8C7EF - 44 08 8C 16 988E0A00 - or [rsi+rdx+000A8E98],r9l
5600E1A8C7F7 - 8B 14 87 - mov edx,[rdi+rax*4]
5600E1A8C7FA - 89 94 86 B88E0A00 - mov [rsi+rax*4+000A8EB8],edx <<
5600E1A8C801 - 48 83 C0 01 - add rax,01
5600E1A8C805 - 48 3D 00010000 - cmp rax,00000100
RAX=0000000000000000
RBX=00005600E948BE70
@r0xsh
r0xsh / gist:0031bbd09a1ee88a5b149e57dcebb035
Created November 24, 2020 01:18
Everything You Always Wanted To Know About GAMEBOY
============================================================================
Everything You Always Wanted To Know About GAMEBOY *
============================================================================
* but were afraid to ask
Pan of -ATX- Document Updated by contributions from:
Marat Fayzullin, Pascal Felber, Paul Robson, Martin Korth
#!/bin/bash
killall -q polybar
while pgrep -x polybar >/dev/null; do sleep 1; done
xrandr --listactivemonitors | tail -n +2 | while read -r line
do
master=$(echo $line | grep '+\*')
if [[ -z $master ]]
then
@r0xsh
r0xsh / sound_swap.sh
Created November 14, 2019 23:19
Switch between pulseaudio sinks
get_sinks()
{
pacmd list-sinks |\
grep -E 'index:|device.description' |\
sed -e 's/^ *//;s/ *$//' -e 's/^\t*//;s/ *$//' -e 's/^* //'|\
sed -r -e 's/index: ([0-9]+)/[\1] /g' -e 's/device.description = "(.*)"/\1/g' |\
sed -ze 's/] \n/] /g'
}
switch_sink_default()
xrandr --listactivemonitors | grep '+\*' | awk '{print $4}'
@r0xsh
r0xsh / read.java
Created April 12, 2019 07:46
Android: Read file contents from Uri
public static byte[] readUri(Context context, Uri uri) throws IOException {
ParcelFileDescriptor pdf = context.getContentResolver().openFileDescriptor(uri, "r");
assert pdf != null;
assert pdf.getStatSize() <= Integer.MAX_VALUE;
byte[] data = new byte[(int) pdf.getStatSize()];
FileDescriptor fd = pdf.getFileDescriptor();
FileInputStream fileStream = new FileInputStream(fd);
fileStream.read(data);
DEVICE="/dev/sda"
KEYMAP="fr-pc"
# Clean du disk et convert to GPT format
sgdisk -og $DEVICE > /dev/null
# Define les sizeblocks
ST_EFI=2048
EN_EFI=$(((512 * 2 * 1024) + $ST_EFI))
@r0xsh
r0xsh / websocket.rs
Created April 11, 2017 13:54
How a websocket in another thread can use parent's functions
extern crate ws;
use std::thread;
use ws::{listen, CloseCode, Sender, Handler, Message, Result};
fn is_odd(n: ws::Message) -> String {
match n.into_text() {
Ok(e) => {
match e.as_ref() {

Keybase proof

I hereby claim:

  • I am r0xsh on github.
  • I am r0xsh (https://keybase.io/r0xsh) on keybase.
  • I have a public key ASDOWveU0_7_BNwMo_E9fZs7zEBTYbSsPeyb33ThLx7pQAo

To claim this, I am signing this object: