Skip to content

Instantly share code, notes, and snippets.

View pepoluan's full-sized avatar
🏡

Pandu E POLUAN pepoluan

🏡
View GitHub Profile
@pepoluan
pepoluan / fp_not_exist.py
Created March 24, 2025 05:15
Create a filename that does not exist
import random
import string
fromt pathlib import Path
def file_that_does_not_exist() -> Path:
def _randname() -> str:
return "".join(
@pepoluan
pepoluan / colored_bash_prompt_one_liners.sh
Last active March 5, 2025 04:05
Simple Colorized Bash Prompt One-Liners
# NO NEED to make a script
# Just choose any one variant, and copy that one line
# Then paste in a new session
#1 Green hostname, bold white command
export PS1="\n"'\[\033[0m\][\u@\[\033[1;32m\]\h\[\033[0m\] \W]\$ \[\033[1m\]'; export PS0='\[\033[0m\]'
#2 Green hostname, bold cyan command
export PS1="\n"'\[\033[0m\][\u@\[\033[1;32m\]\h\[\033[0m\] \W]\$ \[\033[1;96m\]'; export PS0='\[\033[0m\]'
@pepoluan
pepoluan / RegexLookup.vb
Last active September 13, 2024 08:11
RegexLookup function for Excel
' This is supposed to be a VBA (VB for applications) module, but GitHub does not have a syntax-highlighter for .vba files
'
' SPDX-License-Identifier: MPL-2.0
'
' This Source Code Form is subject to the terms of the Mozilla Public
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at https://mozilla.org/MPL/2.0/.
' REQUIREMENTS:
' - You MUST add a reference to "Microsoft VBScript Regular Expressions 5.5" (or any compatible versions)
@pepoluan
pepoluan / pwgen.py
Last active October 9, 2024 10:35
pwgen utility -- in Python
#!/usr/bin/env python3
# SPDX-License-Identifier: MPL-2.0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations
import argparse
import random
import secrets
@pepoluan
pepoluan / sponge.py
Last active October 9, 2024 10:35
sponge utility -- in Python
#!/usr/bin/env python3
# SPDX-License-Identifier: MPL-2.0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations
import argparse
import sys
import tempfile
@pepoluan
pepoluan / self-create-venv.py
Created May 16, 2024 10:37
Self-creating a virtualenv with required modules
import subprocess
import sys
import tempfile
from pathlib import Path
try:
### PERFORM IMPORTS OF NEEDED MODULE IN THIS try: BLOCK
from rich.traceback import install as rtb_install
rtb_install(show_locals=True)
@pepoluan
pepoluan / check-group.sh
Last active April 2, 2024 10:51
Check for User Nonsense
#!/bin/bash
for i in $(cut -s -d: -f4 /etc/passwd | sort -u ); do
if ! grep -q -P "^.*?:x:$i:" /etc/group; then
echo "Group $i is referenced by /etc/passwd but does not exist in /etc/group"
fi
done
@pepoluan
pepoluan / kernel_config_sort.py
Created March 15, 2024 11:59
Linux kernel config sorter
#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# Copyright (C) 2024, Pandu POLUAN
import fileinput
import re
@pepoluan
pepoluan / json_cleaner.py
Last active April 13, 2024 14:48
Python-based JSON Cleanup Preprocessor
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Context: https://stackoverflow.com/a/56701174/149900
from io import StringIO
WHITESPACE = " \t\r\n"
@pepoluan
pepoluan / perftest.py
Created October 7, 2021 05:17
Sort By .items() vs Sort By .keys()
import pprint
import random
import timeit
MEMBS_COUNT = 100
indexes = list(range(MEMBS_COUNT))
random.shuffle(indexes)
orig_dict = {}