Skip to content

Instantly share code, notes, and snippets.

@eugrus
eugrus / jsonfmt.py
Last active July 29, 2023 23:46
Форматирование JSON
#!/usr/bin/python3
import json
import sys
def format_json(input_file):
try:
with open(input_file, 'r', encoding='utf-8') as file:
# Загружаем содержимое файла как JSON
data = json.load(file)
@eugrus
eugrus / workflowy-json2txt.py
Created July 29, 2023 22:49
Конвертер JSON-бэкапов Workflowy.com в табулированный текст
#!/usr/bin/python3
import sys
import json
import csv
# Функция для рекурсивного обхода JSON-структуры и извлечения значений тега "nm"
def extract_nm_values(data, level=0):
nm_values = [] # Создаем список для хранения значений тега "nm"
@eugrus
eugrus / class.cpp
Last active August 23, 2023 21:57
simple class
#include <iostream>
#include <string>
class Fruit {
private:
std::string name;
std::string colour;
public:
Fruit(std::string name, std::string clr) : name(name), colour(clr) {}
@eugrus
eugrus / args-between-whitespaces.sh
Created August 23, 2023 22:58
Bash/CGI parsing of URI args separated by whitespaces
#!/bin/bash
echo "Content-Type: text/plain; charset=utf-8" && echo
IFS='?' read -ra url_parts <<< "$REQUEST_URI"
# Extract the query string from the URL
query_string="${url_parts[1]}"
# URL-decode the query string
@eugrus
eugrus / tab press event.bas
Last active May 22, 2025 00:49
VBA for Word
Option Explicit
Dim myKey
' https://learn.microsoft.com/en-us/office/vba/api/word.keybindings.add
Private Sub Document_New()
KeyBindings_AddKey
End Sub
Private Sub Document_Open()
KeyBindings_AddKey
# Получение доступа к запущенному экземпляру Word
$word = [System.Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application")
# Вставка текста "Hello, world!" в текущую позицию курсора
$word.Selection.TypeText("Hello, world!")
@eugrus
eugrus / killword.ps1
Last active September 23, 2023 14:58
Get-Process | Where-Object { $_.ProcessName -eq "WINWORD.EXE" } | ForEach-Object { Stop-Process -Id $_.Id -Force }
# Set error reporting
Set-StrictMode -Version latest
# Check if the required arguments are provided
if ($args.Count -ne 2) {
Write-Host "Usage: searchindocs.ps1 <SearchedString> <SearchPath>"
param(
[string]$path = "."
)
function Get-FolderStructure {
param(
[string]$folderPath
)
$folders = Get-ChildItem -Path $folderPath -Directory
@eugrus
eugrus / rsync.sh
Last active December 26, 2023 00:46
while ! rsync --partial --progress -av -e ssh user@server:"/remotepath" '/localpath'; do sleep 5; done