Skip to content

Instantly share code, notes, and snippets.

View SanSan-'s full-sized avatar
🏠
Working from home

Alex Franz SanSan-

🏠
Working from home
  • Kaschenka
  • Leningrad, RU
View GitHub Profile
@SanSan-
SanSan- / reverse_dir.py
Created April 15, 2024 11:30
Reverse and rename files start with "001, 002, ... N-1, N" to "N, N-1, N-2, ..., 002, 001"
import os
def reverse_dir(dirname):
reverse_d = {v[0]: f'{i + 1:03d}. {v[0][5:]}' for i, v in enumerate(
sorted({filename: int(filename[:3]) for filename in os.listdir(dirname)}.items(), key=lambda x: x[1],
reverse=True))}
for old_filename, new_filename in reverse_d.items():
print(f'{old_filename} -> {new_filename}')
os.rename(os.path.join(dirname, old_filename), os.path.join(dirname, new_filename))
@SanSan-
SanSan- / process.js
Created March 10, 2024 14:46
collect all tags without repeat from current dir wd14 files in output file
var fs = require('fs');
const path = require('path');
const UTF8 = 'utf8';
const EXTENSION = '.wd14';
const OUTPUT_FILE = 'words.txt';
const EMPTY_STRING = '';
const NEW_LINE_SEPARATOR = '\n';
const COMA_SEPARATOR = ',';
const COMA_SPACE_SEPARATOR = ', ';
@SanSan-
SanSan- / rename.ps1
Last active February 27, 2024 11:46
In current dir rename all img with selected extension to they hash-code
$Algo = "MACTripleDES"
$current = Get-Location
if ($args[0] -ne $null) {
$Ext = $args[0]
} else {
$Ext = ".png"
}
$files = Get-ChildItem -Path $current.Path -Recurse | Where-Object {$_.Extension -eq $Ext}
Write-Output $files
@SanSan-
SanSan- / copress-cbz.ps1
Created February 27, 2024 11:40
Walk in current dir and convert all chapters to cbz
$current = Get-Location
$vols = Get-ChildItem -Path $current.Path -Directory
foreach ($vol in $vols)
{
$chapters = Get-ChildItem -Path $vol.Name -Directory
foreach ($chapter in $chapters)
{
$name = $chapter.Name
@SanSan-
SanSan- / action.ps1
Created February 27, 2024 11:31
Copy-Paste batch of captions for photos to wd14
$SelectPath = $args[0] # "D:\Photos\+stable-diffusion\lora\TriggerWord\IMG\N_TriggerWord\"
$TriggerWord = $args[1] # "TriggerWord"
if ($args[2] -ne $null) {
$FromExt = $args[2]
} else {
$FromExt = ".txt"
}
if ($args[3] -ne $null) {
$ToExt = $args[3]
@SanSan-
SanSan- / notes_to_tabs.js
Last active November 5, 2021 23:06
Fast mass replace in text by JavaScript when sed processor don't understand Unicode
var fs = require('fs');
const notesToTabs = [
{ key: '𝄢[до]', val: 'Z' },
{ key: '𝄢[ре]', val: 'X' },
{ key: '𝄢[ми]', val: 'C' },
{ key: '𝄢[фа]', val: 'V' },
{ key: '𝄢[соль]', val: 'B' },
{ key: '𝄢[ля]', val: 'N' },
{ key: '𝄢[си]', val: 'M' },
@SanSan-
SanSan- / console.log
Last active June 20, 2021 19:49
crc start debug + crc console-ring log
$ crc start -p ~/Downloads/pull-secret.txt --log-level debug
DEBU CodeReady Containers version: 1.28.0+08de64bd
DEBU OpenShift version: 4.7.13 (not embedded in executable)
DEBU Running 'crc start'
DEBU Total memory of system is 17179869184 bytes
DEBU No new version available. The latest version is 1.28.0
INFO Checking if running as non-root
INFO Checking if crc-admin-helper executable is cached
INFO Checking for obsolete admin-helper executable
DEBU Checking if an older admin-helper executable is installed
@SanSan-
SanSan- / log
Created June 18, 2021 17:27
crc issue debug log
$ crc delete -f
WARN open /Users/b/.kube/config: no such file or directory
Deleted the OpenShift cluster
$ crc cleanup
INFO Unload CodeReady Containers tray
INFO Removing launchd configuration for tray
INFO Removing /etc/resolver/testing file
INFO Unload CodeReady Containers daemon
INFO Stopping CRC Hyperkit process
INFO Removing hosts file records added by CRC
@SanSan-
SanSan- / upload2nexus.sh
Last active October 11, 2023 09:32
How to mass upload maven artifacts to nexus
#!/bin/bash
files="./files.out"
releasefiles="./release.out"
snapshotfiles="./snapshot.out"
username="admin"
password="admin123"
nexusurl="http://nexus/content/repositories/thirdparty/"
snapshoturl="http://nexus/content/repositories/Snapshots/"
function solution(A) {
function rightSum(A, N, i, res) {
i = typeof i !== 'undefined' ? i : 0;
res = typeof res!== 'undefined' ? res : 0;
if (i>=N) {
return res;
} else {
return rightSum (A, N, i+1, res+A[i]);
}