Skip to content

Instantly share code, notes, and snippets.

View alirezaarzehgar's full-sized avatar
😃
Focusing

Ali alirezaarzehgar

😃
Focusing
View GitHub Profile
@alirezaarzehgar
alirezaarzehgar / cheat.patch
Created May 4, 2023 09:43
Change mari0 source code to unlock mario abilities and place some cheats.
diff --git a/game.lua b/game.lua
index 11ca5fc..5134d77 100644
--- a/game.lua
+++ b/game.lua
@@ -14,11 +14,11 @@ function game_load(suspended)
--LINK STUFF
- mariocoincount = 0
- marioscore = 0
@alirezaarzehgar
alirezaarzehgar / report
Last active May 2, 2023 09:16
An small fun report system with bash
#!/usr/bin/env bash
tmp=$(mktemp)
vim ${tmp}
if [ ! -s ${tmp} ]; then
echo "Do not report empty text"
rm -rf ${tmp}
exit 1
fi
@alirezaarzehgar
alirezaarzehgar / hello_world.c
Created April 7, 2023 07:25
Hello world in c without stdlib using assembly
char msg[] = "Hello, World!\n";
void _start()
{
asm(
"movl $1, %eax\n"
"movl $1, %edi\n"
"movl $msg, %esi\n"
"movl $14, %edx\n"
"syscall\n"
@alirezaarzehgar
alirezaarzehgar / streverse.asm
Created March 24, 2023 20:15
Assembly exercises
section .bss
strp resb 10
buf resb 1
section .text
global _start
_start:
mov rax, 0
mov rdi, 0
#!/usr/bin/env bash
INF=enp2s0
ip tuntap add dev virttap mode tap user $USER
brctl addbr virtbr
brctl addif virtbr ${INF}
brctl addif virtbr virttap
ip link set virtbr up
@alirezaarzehgar
alirezaarzehgar / complex-install.sh
Last active February 7, 2023 08:21
Embed binary in bash
#!/usr/bin/env bash
add_command() {
echo "
lstart=\$(awk '/^__'${1}'_PAYLOAD_BEGIN__/ { print NR + 1; exit 0; }' \$0)
lend=\$(awk '/^__'${1}'_PAYLOAD_END__/ { print NR + 1; exit 0; }' \$0)
cat \$0 | head -n +\${lend} | tail -n +\${lstart} > \${dir}/${1}
chmod +x \${dir}/${1}"
}
@alirezaarzehgar
alirezaarzehgar / learn-new-tec.md
Last active April 7, 2023 07:06
My interest links

Don't start from details

If you have some topics or tools to learn, You should learn them step by step and little by little. TODO:

  • List every term and tool that you need to learn
  • Just search and learn this terms (in less that 5 minutes)
  • Start reading overview of their documentions (in less that 20 minutes)
  • Playing with "Quick start" or "Getting started"
  • Run examples and do exercise
@alirezaarzehgar
alirezaarzehgar / functions.fish
Last active January 25, 2023 12:08
My env utils
function big_lines
for arg in $argv
set i 1
for line in (cat $arg);
set cnt (echo $line | wc -c)
if test $cnt -gt 80;
printf "$i($cnt)\t$line\n"
end
set i (math $i + 1)
end
@alirezaarzehgar
alirezaarzehgar / short_files.sh
Last active February 28, 2023 09:25
Sort source files with its lines.
#!/usr/bin/env bash
if [ "$1" ]; then
cd "$1" || exit
fi
exts="*.[ch]"
dirs=$(ls -d -- */ 2>/dev/null)
if [ "${dirs}" ]; then
for d in ${dirs}; do
count=0
@alirezaarzehgar
alirezaarzehgar / capslock.cpp
Last active December 10, 2022 19:06
A very simple example for students ...
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
bool caps = false;
cin >> n;