Skip to content

Instantly share code, notes, and snippets.

View tinmarino's full-sized avatar

NobleRat tinmarino

View GitHub Profile
@ppacher
ppacher / pretty.sh
Last active January 5, 2023 23:47
Bash: Async capture stdout and stderr and colorize/prefix output
#!/bin/bash
pretty() {
prefix=$1
# a named pipe can be unlinked as soon as it has been attached to some file descriptor
# this allows to create anonymous pipes
# create a temporary named pipe
PIPE=$(mktemp -u)
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active June 5, 2024 18:14
Hyperlinks in Terminal Emulators
@masudcsesust04
masudcsesust04 / change-apache-default-document-root-directory.md
Created July 28, 2017 05:57
4 steps to change your apache default document root directory

Step - 1: Create a directory

$ mkdir /home/masud/www/

Step - 2: Open apache2 configuration file

$ sudo nano /etc/apache2/apache2.conf 
@jdarpinian
jdarpinian / executable.c
Last active May 30, 2024 19:42
Add one line to your C/C++ source to make it executable.
///$(which true);FLAGS="-g -Wall -Wextra --std=c17 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $FLAGS "$THIS_FILE" -o "$OUT_FILE" || exit $?;exec bash -c "exec -a \"$0\" \"$OUT_FILE\" $([ $# -eq 0 ] || printf ' "%s"' "$@")"
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
@yellowbyte
yellowbyte / compiling_asm.md
Last active June 4, 2024 20:17
how to assemble assembly with NASM assembler to 32-bit or 64-bit ELF binary with or without libc

32-bit ELF binary

how to assemble and link:

nasm -f elf32 -o <filename>.o <filename>.asm
ld -m elf_i386 -o <filename> <filename>.o

template code (hello world):

section .text
global _start
@fnky
fnky / ANSI.md
Last active June 8, 2024 08:50
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@wuct
wuct / deadlock.rs
Created June 29, 2020 11:49
A deadlock example in Rust with threads and `Mutex`
use std::sync::{Arc, Mutex};
use std::thread;
fn main() {
let a = Arc::new(Mutex::new(0));
let b = Arc::new(Mutex::new(0));
let mut handles = vec![];
{
let a = Arc::clone(&a);