Skip to content

Instantly share code, notes, and snippets.

View ZSendokame's full-sized avatar
:shipit:
Programming

ZSendokame ZSendokame

:shipit:
Programming
  • 192.168.51.1
  • 06:28 (UTC -04:00)
View GitHub Profile
@ZSendokame
ZSendokame / snippets.ps1
Last active January 13, 2025 07:26
PowerShell oneliners
# Get all files in two depths with an m4v extension, pipe and rename.
Get-ChildItem */*.m4v | Rename-Item -NewName {$_.Name -Replace '\.m4v$', '.mp4'}
# Remove all mp4 / jpg files that has only integers in the name.
Get-ChildItem -File */* | Where {$_.Name -Match "^[0-9]+\.(jpg|mp4)"} | Remove-Item
# Count all files in two depths
(Get-ChildItem */* | Measure-Object).Count
@ZSendokame
ZSendokame / profile.ps1
Created January 10, 2025 23:37
My PowerShell Profile
# Defining useful variables and adding scripts into the PATH for later use
$desktop = [Environment]::GetFolderPath("Desktop")
$env:PATH += ";$desktop\scripts"
# SETUP
Clear-Host; wfetch
Set-Location $desktop
# The scripts folder must be created in your desktop for it to work, personally, it has the following scripts:
# wfetch: https://gist.github.com/ZSendokame/91c110ed2b4fc0bfebf57b1a4d5a4795
@ZSendokame
ZSendokame / hash.ps1
Last active August 30, 2025 00:17
Rename all files on two depths to their MD5 hash and remove the originals.
param (
[Parameter(Mandatory=$true)]
[string]$path
)
$files = (Get-ChildItem $path) | Get-ChildItem
foreach($file in $files){
$extension = $file.Extension
$newName = (Get-FileHash -LiteralPath $file.FullName -Algorithm MD5).Hash.toLower()
@ZSendokame
ZSendokame / flier.py
Last active January 2, 2025 21:40
Small script to do scraping from the terminal.
import fly
import arguing
args = arguing.Arguing()
selector = args.set('--selector', required=True)
work = args.set('--map')
html = fly.HTML(args.pipe())
selected = html.css(selector)
for match in selected:
@ZSendokame
ZSendokame / backup.ps1
Created December 26, 2024 21:36
The simplest backup script for personal uses, feel free to modify.
# WARNINGS AND WORKINGS:
# The script can be downloaded anywhere, but if there is no folder named as defined in $backupFolder, then it will create it.
# BEFORE running the script, add the folders to backup in the $folders array.
# To execute backup.ps1, calling it from a PowerShell session is enough (.\backup.ps1).
# Useful variables to modify and/or use.
$backupFolder = ".\backup"
$desktop = [Environment]::GetFolderPath("Desktop")
$folders = @()
@ZSendokame
ZSendokame / primes.txt
Created October 4, 2024 21:56
200k primes
This file has been truncated, but you can view the full file.
2
3
5
7
11
13
17
19
23
29
@ZSendokame
ZSendokame / relindex.py
Created June 22, 2024 00:50
Make dictionaries by list segments.
def relindex_value(iterable: list, column: list) -> list[dict]:
result = []
aux = {}
for index, item in enumerate(iterable):
aux[column[index % len(column)]] = item
if (index % len(column)) == (len(column) - 1):
result.append(aux)
@ZSendokame
ZSendokame / space.ps1
Created April 9, 2024 20:56
Get how many gigabytes there is in a directory.
function space(){
param($Directory)
$total = 0
foreach($file in Get-ChildItem $Directory){
$total += $file.length
}
return $total / 1Gb
}
@ZSendokame
ZSendokame / logs.json
Last active March 4, 2024 20:44
Team Fortress 2 game logs. logs.json contain data from multiple games. 5 Cheaters detected
{
"MrYiang": {
"tf_projectile_arrow": {
"kills": 2,
"crits": 2
},
"spy_cicle": {
"kills": 2,
"crits": 2
},
@ZSendokame
ZSendokame / flatten.py
Last active March 2, 2024 11:57
flattening of dictionaries.
def flatten(structure: dict, head = [], flattened = {}) -> list:
for key, value in structure.items():
if isinstance(value, dict):
head.append(key)
flatten(value, [*head, key], flattened)
else:
flattened['__'.join(head)] = value
return flattened