Skip to content

Instantly share code, notes, and snippets.

View fahimalizain's full-sized avatar
🍄
Hello!

Fahim Ali Zain fahimalizain

🍄
Hello!
View GitHub Profile
@fahimalizain
fahimalizain / .bashrc
Last active November 22, 2023 05:29
WSL Host IP
#!/bin/bash
# Obtains the Windows Host IP Address
# This can be used for accessing resources on the host device (eg. adb to WSA)
export WSL_HOST_IP="$(tail -1 /etc/resolv.conf | cut -d' ' -f2)"
@fahimalizain
fahimalizain / wsl-local-ports.ps1
Created January 31, 2023 01:31
Forward WSL Ports to your localhost
# Elevation!
# https://stackoverflow.com/a/31602095/2041598
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$remoteport = wsl hostname -I
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
@fahimalizain
fahimalizain / clean_git_branches.sh
Last active August 27, 2022 04:57
A simple script that deletes Git Branches older than specific days
#!/bin/bash
PWD=$(pwd)
DAYS_THRESHOLD=5
# Check if in Git Repository
if [ ! "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
echo "This is not a git repository!"
exit 1
fi
@fahimalizain
fahimalizain / .bashrc
Last active August 28, 2021 15:28
Beautiful bash-alias
# SSH-Agent
## SSH Agent and keys
# set SSH_AUTH_SOCK env var to a fixed value
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.sock
# test whether $SSH_AUTH_SOCK is valid
ssh-add -l 2>/dev/null >/dev/null
# if not valid, then start ssh-agent using $SSH_AUTH_SOCK
if [ $? -ge 2 ]; then
# if sock file exists, let's delete it
if [[ -e "$SSH_AUTH_SOCK" ]]; then
#!/bin/bash
mysqlPWD=frappe
if [ "$#" -ne 3 ]; then
echo "Please pass the v10 URL, sitename and the backup timestamp"
exit
fi
if [ ! -d "./v10-data" ]; then
@fahimalizain
fahimalizain / negate_bootstrap_container.scss
Created February 20, 2019 01:59
Negate bootstrap .container fixed widths. This helps to span any element across the screen, even though its inside a .container without using position absolute or fixed
.spread-screen {
width: 100vh;
// bootstrap 4
// the following are referenced from bootstrap.scss/_grid.scss
// mixins/_grid.scss @make-container @make-container-max-widths mixins
margin-left: -$spacer;
@each $breakpoint, $container-max-width in $container-max-widths {
@fahimalizain
fahimalizain / brute_force_excel.py
Created February 18, 2019 12:32
Brute force excel file with file level encryption
import pandas as pd
import win32com.client
import string, sys
xlApp = win32com.client.Dispatch("Excel.Application")
print("Excel library version:", xlApp.Version)
path = "Statement.xlsx"
tokens = [str(x) for x in list(range(0,4))]
# tokens.extend([x for x in string.ascii_lowercase])