Skip to content

Instantly share code, notes, and snippets.

View murtaza-u's full-sized avatar
⚒️
Building

Murtaza Udaipurwala murtaza-u

⚒️
Building
View GitHub Profile
@murtaza-u
murtaza-u / prompt
Created December 18, 2022 19:33
Custom bash prompt with Git information
#!/bin/bash
# Add everything below to your .bashrc
multiline_prompt=0
hostinfo=0
__ps1() {
# colors
local red='\[\e[1;31m\]'
@murtaza-u
murtaza-u / pre-commit
Last active December 18, 2023 06:27
Pre-commit Git hook to prevent accidentally committing `go.mod` with replace directive in it.
#!/bin/bash
root="$(git rev-parse --show-toplevel)"
cd "$root" || exit 1
if [[ ! -r go.mod ]]; then
exit 0
fi
mod="$(grep -E "^replace\s+.+\s{1}=>\s{1}.+$" go.mod 2>/dev/null)"
@murtaza-u
murtaza-u / main.c
Created March 10, 2022 19:18
using arrays in a special way
#include <stdio.h>
void add(int a, int b) {
printf("%d\n", a + b);
}
void sub(int a, int b) {
printf("%d\n", a - b);
}