Skip to content

Instantly share code, notes, and snippets.

View qti3e's full-sized avatar
πŸ³οΈβ€πŸŒˆ

Parsa qti3e

πŸ³οΈβ€πŸŒˆ
View GitHub Profile
@qti3e
qti3e / detect.rs
Last active June 18, 2026 22:37
JOE's strlen
// Β© 2025 Parsa Ghadimi. MIT OR Apache-2.0 License.
//! Runtime CPU feature detection. The `setup` function from this code must be called at the very
//! start of the process initialization.
use core::fmt::Debug;
use core::fmt::Formatter;
use core::sync::atomic::AtomicU64;
use core::sync::atomic::Ordering;
@qti3e
qti3e / main.rs
Created February 28, 2025 22:52
attempt to use rseq in rust
use core::arch::asm;
use core::ptr::null_mut;
// https://github.com/torvalds/linux/blob/276f98efb64a2c31c099465ace78d3054c662a0f/arch/x86/entry/syscalls/syscall_64.tbl
const SYS_RSEQ: u64 = 334;
// https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno-base.h
const EINVAL: i64 = 22;
// https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h
const ENOSYS: i64 = 38;
@qti3e
qti3e / init.lua
Last active August 27, 2023 18:35
My neovim configuration
local o = vim.opt
local map = vim.keymap.set
local api = vim.api
local nvim_create_autocmd = api.nvim_create_autocmd
local nvim_create_augroup = api.nvim_create_augroup
-- =============================================================================
-- Global Options
-- =============================================================================
@qti3e
qti3e / chan_demo.ts
Created May 20, 2021 17:49
Go concurrency in JavaScript
import { Go, Chan, Lock } from "./go";
const chan = Chan<number>();
const sumPromise = Go(async ($: WaitFn) => {
let sum = 0;
for await (const msg of chan.receive()) {
console.log('Received', msg);
sum += msg;
}
@qti3e
qti3e / bernoulli.js
Created May 22, 2019 12:26
Generate first n Bernoulli numbers
function b(max) {
const B = Array(max + 1).fill(0);
B[0] = 1;
B[1] = 1/2;
for (let n = 2; n <= max; n += 2) {
let sum = 0;
let c = 1;
for (let j = 0, j2 = n; j <= n / 2; j += 2, j2 -= 2) {
|/|
0> vim
2> cd client && yarn start
3> cd server && yarn start
0
@qti3e
qti3e / main.c
Last active June 12, 2020 11:07
#include <stdlib.h> // for NULL
#include <sys/mman.h> // for mmap
#include <stdio.h>
#include <string.h>
#include <stdint.h>
unsigned char data[] = {
// "Hello\n"
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xA
};
This file has been truncated, but you can view the full file.
[
{
"names": [
"ΨͺΩˆΨ±Ω‡Ψ§Ω„"
],
"country": "TR",
"lng": 36.09,
"lat": 40.39
},
/**
* ____ _ _ _____
* /___ \ |_(_)___ / ___
* // / / __| | |_ \ / _ \
* / \_/ /| |_| |___) | __/
* \___,_\ \__|_|____/ \___|
*/
import { Request, Response } from "express";
async function bottom(props, resolve, parentDom) {
const btn = document.createElement("bottom");
parentDom.appendChild(btn);
btn.onclick = (e) => {
props.onClick(e, resolve);
}
return btn;
}
function html(elementName) {