Skip to content

Instantly share code, notes, and snippets.

@skarfie123
skarfie123 / imageRename.py
Last active September 12, 2020 12:05
Quick script to add a suffix to all images in a folder:
# example: python "D:\Users\rahul\Documents\Python Scripts\image rename\imageRename.py" "D:\Users\rahul\Documents\Python Scripts\image rename\test_images" "blah"
# imageX.jpg --> imageX_blah.jpg
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("dir")
parser.add_argument("suffix")
args = parser.parse_args()
@skarfie123
skarfie123 / photoframeFiller.py
Created September 13, 2020 10:14
Photoframe Filler: take random images from each album folder to the SD card for a photoframe.
# example: python "D:\Users\rahul\Documents\Python Scripts\photoframeFiller.py" "D:\image_source" "E:\"
# copy from folders (albums) in image_source to sdcard E for photo frame
import os
import argparse
import random
import shutil
parser = argparse.ArgumentParser()
parser.add_argument("fromDir")
@skarfie123
skarfie123 / spotifyAdblock.hosts
Created April 6, 2021 18:35
To block ads, add these lines to your hosts file. See also spicetifyAdblock.css
127.0.0.1 doubleclick.net
127.0.0.1 adclick.g.doubleclick.net
127.0.0.1 googletagservices.com
127.0.0.1 appspot.com
127.0.0.1 securepubads.g.doubleclick.net
127.0.0.1 googleads.g.doubleclick.net
127.0.0.1 adservice.google.com
127.0.0.1 googlesyndication.com
127.0.0.1 tpc.googlesyndication.com
@skarfie123
skarfie123 / spicetifyAdblock.css
Last active May 22, 2021 10:52
To block ads, add these lines to your Spicetify Theme. See also spotifyAdblock.hosts
.Root__main-view > div:first-of-type {
display: none;
}
@skarfie123
skarfie123 / colours.cmd
Last active June 27, 2021 09:14 — forked from k-takata/256colors2.bat
All Windows 10 Terminal Colours 🌈
@echo off
setlocal EnableDelayedExpansion
set colour1=
set colour2=
echo %colour1%---%colour2% ESC[XXm %colour1%---
@REM dark background
set str=
for /l %%c in (30,1,37) do (
@skarfie123
skarfie123 / detectron2-pdm.ipynb
Created June 1, 2021 10:23
Detectron2 PDM.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@skarfie123
skarfie123 / pep8_naming_conventions.py
Created June 17, 2021 17:30
PEP8 Naming Conventions Examples
# https://www.python.org/dev/peps/pep-0008/#naming-conventions
# short lowercase module and package names
# underscores if needed, but discouraged for packages
# package.my_module ie package\my_module.py
from typing import TypeVar
# CapWords for Type Variable names, and preferably short
VT_co = TypeVar("VT_co", covariant=True)
@skarfie123
skarfie123 / edit_video.py
Created August 7, 2022 21:26
extract segments from video clips and concatenate
import os
import subprocess
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
clip_times = {
"clip1.mp4": [
((2, 12), (2, 20)),
((2, 25), (2, 35)),
],
@skarfie123
skarfie123 / suffix.ps1
Created August 5, 2023 11:43
add suffix to files in a folder
# Add suffix in place
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer } | ForEach-Object {
Rename-Item $_.FullName -NewName "$($_.BaseName)-$($_.Directory.Name)$($_.Extension)"
}
# Move to parent with suffix
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer } | ForEach-Object {
Move-Item $_.FullName -Destination "$($_.Directory.Parent.FullName)\$($_.BaseName)-$($_.Directory.Name)$($_.Extension)"
}