Skip to content

Instantly share code, notes, and snippets.

@seefalert
seefalert / script_code_exec
Last active September 30, 2024 08:28
Тестовый скрипт для проверки вашего кода. Поместите тестовые файлы в папку "tests", а ваш код в файл "my_code.py". Запустите скрипт для выполнения тестов и проверки результатов.
import os
import pathlib
import subprocess
import sys
import time
def load_test_file(file_path):
with open(file_path, encoding='utf-8') as file:
return file.read().strip().splitlines()
@seefalert
seefalert / script_input_data.py
Last active September 30, 2024 08:28
Этот код - тестовый скрипт для проверки вашего кода. Убедитесь, что у вас есть папка "tests" с тестовыми файлами и ответами. Также у вас должен быть файл "my_code.py" с кодом, который нужно протестировать. Запустите скрипт, и он выполнит тесты, выведет результаты и сообщит, успешно ли пройдены все тесты.
import os
import pathlib
import time
import psutil
import subprocess
import sys
def load_test_file(file_path):
with open(file_path, encoding='utf-8') as file:
@CharlesGodwin
CharlesGodwin / How to use ssh-copy-id.md
Last active August 16, 2024 03:17
Windows 10/11 scripts to support ssh-copy-id which is missing in Windows OpenSSH

The Windows version of OpenSSH client doesn't include a ssh-copy-id command. I don't know why. If it does one day, then this can be ignored.

NOTE If you have Windows Subsystem for Linux (WSL) installed, you can use the linux version of ssh-copy-id instead. Go to the description at the end of this document.

  • Download the file ssh-copy-id.cmd to your Windows PC, or copy and paste its contents.
  • Run the script passing your linux ssh information (for example ssh-copy-id.cmd pi@raspberrypi.local). This should work with any Linux platform. Alternatively, if you have experience, you can use the powershell version. ssh-copy-id.ps1. Run the script as powershell .\ssh-copy-id.ps1 pi@raspberrypi.local.
  • Run the command for each linux account you connect with. You will be prompted for your Linux host password. If you have more than 1 account on any machine, you must do this for each account.

The file name and location of the script is not important but the filename extension must be .cmd

@arrowinaknee
arrowinaknee / office_unlocker.pyw
Last active November 8, 2023 12:18
Снимает защиту от редактирования с файлов MS Word (.docx) и MS Excel (.xlsx)
import os
import shutil
import tempfile
import re
import sys
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
@doitian
doitian / registries.conf
Last active June 29, 2024 14:20
[Configure Docker Hub mirror in /etc/containers/registries.conf] #docker #podman #proxy
unqualified-search-registries = ['docker.io']
[[registry]]
prefix = "docker.io"
location = "docker.io"
[[registry.mirror]]
prefix = "docker.io"
# This will set the docker registry mirror of a chinese university.
# DON'T use it unless you have a network connection issue and you trust the mirror provider.
@s3rj1k
s3rj1k / HowTo
Last active September 5, 2024 13:53
Ubuntu 20.04.3 AutoInstall
# For recent versions of Ubuntu:
- https://www.pugetsystems.com/labs/hpc/ubuntu-22-04-server-autoinstall-iso/
# Docs:
- https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls
- https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/ConfigReference
- https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
- https://discourse.ubuntu.com/t/please-test-autoinstalls-for-20-04/15250/53
# Download ISO Installer:
@rpunt
rpunt / mktemp.ps1
Created February 15, 2020 16:52
I've wanted mktemp in powershell forever, so... fine.
function mktemp {
param (
[Parameter(mandatory=$false)]$Extension
)
$randomfile = [System.IO.Path]::GetRandomFileName()
if ($Extension) {
$randomfile = [System.IO.Path]::ChangeExtension($randomfile, $Extension)
}
return Microsoft.PowerShell.Management\Join-Path ([System.IO.Path]::GetTempPath()) "$randomfile"
}
@gmolveau
gmolveau / uuid_user.py
Last active October 8, 2024 18:21
sqlalchemy uuid for sqlite
########################
# UUID for SQLite hack #
########################
from sqlalchemy.types import TypeDecorator, CHAR
from sqlalchemy.dialects.postgresql import UUID
import uuid
class GUID(TypeDecorator):
@b4tman
b4tman / time_calc.py
Last active April 10, 2020 12:59
Калькулятор для вычисления выражений со значениями указанными в форме времени. Например "(12:05 - 11:30) / 2".
# -*- coding: utf-8 -*-
"""
simple calculator for time
based on fourFn.py (pyparsing module examlple)
"""
from pyparsing import Literal,CaselessLiteral,Word,Combine,Optional,\
ZeroOrMore,Forward,nums,alphas
import sys, operator
@valorin
valorin / mosh-allow-ufw.sh
Created December 6, 2014 20:49
Script to open and close Mosh ports in UFW
#!/bin/bash
# Load active ports
PORTS=`lsof -i | grep mosh-serv | cut -f2 -d":"`
STATUS=`sudo ufw status`
# Add Rules for new ports
for PORT in $PORTS; do
echo $STATUS | grep "$PORT/udp" > /dev/null