Skip to content

Instantly share code, notes, and snippets.

View n3r0bi0m4n's full-sized avatar
🙂

Alexey Ermakov n3r0bi0m4n

🙂
View GitHub Profile
@n3r0bi0m4n
n3r0bi0m4n / wl-r.c
Created January 13, 2026 13:45
wayland refresh rate for each screen
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wayland-client.h>
static void nop() {}
typedef struct Output
{
uint32_t id;

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@n3r0bi0m4n
n3r0bi0m4n / cout.rs
Created August 29, 2023 21:28
dumb rust cout
#![allow(non_camel_case_types)]
#![allow(unused_must_use)]
use std::fmt;
use std::ops::Shl;
struct cout;
struct endl;
impl fmt::Display for endl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "\n")
@n3r0bi0m4n
n3r0bi0m4n / array_macro.rs
Last active August 8, 2023 21:24
Rust Array macro
macro_rules! Array {
($n:expr, $t:ty) => (std::array::from_fn::<$t, $n, _>(|_| <$t>::default()));
($n:expr, $f:expr) => (std::array::from_fn::<_, $n, _>($f));
}
@n3r0bi0m4n
n3r0bi0m4n / takelastnbits.js
Created December 16, 2022 07:42
take last N bits
function takeLastNBits(n, bits) {
console.log(n.toString(2))
console.log((n&((1<<bits)-1)).toString(2).padStart(bits, 0))
}
@n3r0bi0m4n
n3r0bi0m4n / timestamp.js
Created March 3, 2021 17:52
js timestamp
function timestamp() {
const pad = (t) => String(t).padStart(2, '0');
const nowRaw = new Date();
return `${pad(nowRaw.getUTCHours())}:${pad(nowRaw.getUTCMinutes())}:${pad(nowRaw.getUTCSeconds())}.${String(nowRaw.getUTCMilliseconds()).padStart(3, '0')}`;
}
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//