Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Foadsf / README.md
Last active November 20, 2024 08:54
🔄 Cross-platform PowerShell script for intelligent Git file move detection and history preservation (experimental - use at your own risk)

git-smart-move.ps1

A cross-platform PowerShell script that intelligently detects moved/renamed files in Git repositories and preserves their history using git-filter-repo.

⚠️ WARNING: This script is experimental and has not been thoroughly tested in production environments. Use at your own risk. Make sure to have backups before running it on your repository.

Requirements

  • PowerShell Core (Windows/Linux/macOS)
  • Git
  • git-filter-repo (pip install git-filter-repo)
@Foadsf
Foadsf / git_move_files.bat
Created November 19, 2024 13:35
A Windows batch script that recovers Git history for files moved without git mv by detecting deleted files and their new locations, then properly tracking the moves.
@echo off
setlocal enabledelayedexpansion
if "%1"=="" (
echo Usage: git_move_files.bat [RepositoryPath]
exit /b 1
)
set "repo_path=%1"
cd /d "%repo_path%" || (
@Foadsf
Foadsf / svn_move_files.bat
Created November 13, 2024 12:16
A cmd batch script that helps SVN track files moved outside of version control by temporarily moving them back to their original location and then using 'svn move' to relocate them properly.
@echo off
setlocal enabledelayedexpansion
:: Check if the SVN directory path is provided
if "%1"=="" (
echo Please provide the path to the SVN repository.
echo Usage: %~nx0 path\to\svn\repository
exit /b 1
)
:: Initialize variables
set repo_path=%1
@Foadsf
Foadsf / touch.bat
Created October 30, 2024 06:19
Windows batch implementation of Unix touch with recursive directory support
@echo off
setlocal enabledelayedexpansion
:: touch.bat - Windows implementation of Unix touch command
:: Usage: touch filename [filename2 filename3 ...]
:: Creates empty files if they don't exist or updates their timestamps if they do
:: Supports full paths and can create directories if needed
if "%~1"=="" (
echo Usage: touch filepath [filepath2 filepath3 ...]
@Foadsf
Foadsf / quarto-vscode-python-setup-windows.md
Last active September 27, 2024 09:10
A step-by-step guide to set up Quarto with Visual Studio Code and Python for literate programming on Windows.

Quarto, VS Code, and Python for Literate Programming on Windows

This guide will help you set up Quarto, Visual Studio Code, and Python for literate programming (also known as entangling) on Windows.

Prerequisites

  • Windows operating system
  • Python installed
  • Visual Studio Code installed
@Foadsf
Foadsf / DownloadYouTubePlaylistSubtitles.ps1
Created May 18, 2024 20:51
PowerShell script to download and extract plain text from autogenerated subtitles of a YouTube playlist
param (
[string]$playlistID
)
if (-not $playlistID) {
Write-Host "Please provide a playlist ID as a command-line argument."
exit 1
}
# Define the playlist URL and output file
from pylatexenc.latex2text import LatexNodes2Text
from nltk.probability import FreqDist
from nltk.corpus import stopwords
import argparse
import nltk
def analyze_word_frequency(filename, words_to_check):
"""Analyzes word frequency in a LaTeX document.
@Foadsf
Foadsf / find_binary.py
Created April 28, 2024 20:22
A Python script and Windows batch command to recursively find and delete binary files in a directory
import os
import sys
def is_binary(filename):
"""
Check if the file is binary. A file is considered binary if it contains a null byte
within the first 1024 bytes of its content.
you may run
FOR /F "tokens=*" %G IN ('python find_binary.py .') DO del "%G"
@Foadsf
Foadsf / .gitignore
Created February 25, 2024 10:00
Efficiently manage and display your Telegram groups with our Python script. Designed for Telegram users and group administrators, this script leverages the Telethon library to fetch and print a list of groups you own directly to your console. Perfect for organization and quick access, this tool simplifies group management on Telegram—ideal for d…
config.ini
@Foadsf
Foadsf / TelegramGroupUnbanUsers.py
Created November 14, 2023 14:10
Python script using Telethon to unban removed users in a Telegram group. This script fetches the list of users who have been kicked from a Telegram group and unbans them, enabling them to rejoin. It handles rate limits and provides an efficient way to manage group memberships.
import asyncio
from telethon.tl.types import ChannelParticipantsKicked
from telethon.sync import TelegramClient
from telethon.errors import FloodWaitError
# Replace these with your own Telegram API ID and Hash
api_id = 'YOUR_API_ID'
api_hash = 'YOUR_API_HASH'
# Replace with the positive integer ID of your group (omit the '-' sign)