Skip to content

Instantly share code, notes, and snippets.

View omer-biz's full-sized avatar

Omer Abdulaziz omer-biz

View GitHub Profile
@omer-biz
omer-biz / fill.py
Created January 6, 2024 20:58
Fill your disk with random files with random contents
#!/usr/bin/python
import sys
import getopt
def usage():
pass
# commandline arguments except the file name
argv = sys.argv[1:]
@omer-biz
omer-biz / Main.elm
Last active January 9, 2024 18:43
I implemented this after wathing this talk (https://www.youtube.com/watch?v=IcgmSRJHu_8), It's about making an impossible states impossible. Don't forget to do `elm install elm/time`
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, input, text)
import Html.Attributes exposing (value)
import Html.Events exposing (onClick, onInput)
import Time
type alias Question =
@omer-biz
omer-biz / deadlock.rs
Created February 6, 2023 11:02
Deadlock
let resource_one = Arc::new(Mutex::new(10));
let resource_two = Arc::new(Mutex::new(20));
let r1 = resource_one.clone();
let r2 = resource_two.clone();
let th1 = thread::spawn(move || {
let mut r2 = r2.lock().unwrap();
thread::sleep(Duration::from_secs(5));
let mut r1 = r1.lock().unwrap();
*r1 += 1;
@omer-biz
omer-biz / keyb.sh
Created February 3, 2023 05:38
Remap keyboard on x11
# make CapsLock behave like Ctrl:
setxkbmap -option ctrl:swapcaps
# make short-pressed Ctrl behave like Escape:
xcape -e 'Control_L=Escape'
@omer-biz
omer-biz / main.rs
Created January 29, 2023 13:32
A simple cacher implemented in Rust. Calculates and stores from a closure for future use. It uses HashMap to the store the data.
use std::collections::HashMap;
use std::hash::Hash;
use std::thread;
use std::time::Duration;
struct Cacher<K, V, F> {
calculator: F,
value: HashMap<K, V>,
}

ELF

ELF Header

The first portion of any ELF file is the ELF header. This generally provides offsets to other headers (program headers and section headers) within an ELF.

typedef struct {
  unsigned char e_ident[EI_NIDENT];
 uint16_t e_type;