Skip to content

Instantly share code, notes, and snippets.

View izabera's full-sized avatar

Isabella Bosia izabera

  • DDN
  • Flitwick, UK
View GitHub Profile
@ormaaj
ormaaj / roflparser.md
Created March 10, 2025 19:35
Silly bash typeset builtin wrapper

This script exploits bash's weird interpretation of POSIX's requirement that declaration builtins overloaded by functions must not modify the parsing of the arguments. Bash even extends this requirement to nonstandard extensions such as arrays. This typeset wrapper parses options by stealing the (approximately correct) optstring from ksh. It modifies each assignment then prints the effect of the command as a side-effect.

Code:

@jart
jart / trace.cpp
Last active November 13, 2024 16:18
Easy high performance chrome://tracing output for C++
// -*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;coding:utf-8 -*-
// vi: set et ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
#define _GNU_SOURCE
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
#include <threads.h>
#include <unistd.h>
@x0nu11byt3
x0nu11byt3 / elf_format_cheatsheet.md
Created February 27, 2021 05:26
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

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

ELF

Compilation

@deepcube
deepcube / bsolve
Last active August 29, 2015 14:20
#!/usr/bin/env bash
# solve Rubik's cube using the Tperm blindfold method. input: http://tomas.rokicki.com/cubecontest/
# idea from Stefan Pochmann's second entry: http://tomas.rokicki.com/cubecontest/winners.html
n=0 tperm="R2 U' R2 D B2 L2 U L2 D' B2 U "
cube=("$@") solved=(UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR)
declare -A inverse=([\']=\ [2]=2 [\ ]=\') setups=(
[UF]="R2 U R2 " [UR]="" [UB]="R2 U' R2 " [UL]=""
[DF]="D' L2 " [DR]="D2 L2 " [DB]="D L2 " [DL]="L2 "
[FR]="U2 R U2 " [FL]="L' " [BR]="U2 R' U2 " [BL]="L "
[FU]="R F' L' R' " [RU]="" [BU]="R' B L R " [LU]="L F' D' F L2 "
#!/bin/bash
save=$(bind -p; bind -X)
function clean-up {
bind -r '\C-i'
bind -f /dev/stdin <<< "$save"
}
trap 'clean-up' RETURN
function write-options {
@vivithemage
vivithemage / libmagic_example.c
Last active August 20, 2025 16:57
libmagic.h example
#include <stdio.h>
#include <magic.h>
int main(void)
{
char *actual_file = "/file/you/want.yay";
const char *magic_full;
magic_t magic_cookie;
/* MAGIC_MIME tells magic to return a mime of the file,
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active March 22, 2023 03:06
Discussion of korn.c, 1987 IOCCC entry, mentioned in http://stackoverflow.com/a/19214007/827263

korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).

korn.hint, as the name implies, offers some hints.

A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.

=====

Here's the code: