Skip to content

Instantly share code, notes, and snippets.

@glacjay
glacjay / tun-ping-win.py
Created September 19, 2010 16:24
Reading/Writing OpenVPN's TUN/TAP Device under Windows using Python.
import _winreg as reg
import win32file
adapter_key = r'SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}'
def get_device_guid():
with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters:
try:
@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
@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
@gmolveau
gmolveau / uuid_user.py
Last active May 6, 2024 17:55
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):
@s3rj1k
s3rj1k / HowTo
Last active July 22, 2024 14:19
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:
@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.
@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
@CharlesGodwin
CharlesGodwin / How to use ssh-copy-id.md
Last active July 7, 2024 13:00
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

@seefalert
seefalert / script_input_data.py
Last active September 12, 2023 06:51
Этот код - тестовый скрипт для проверки вашего кода. Убедитесь, что у вас есть папка "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:
@seefalert
seefalert / script_code_exec
Last active September 12, 2023 06:51
Тестовый скрипт для проверки вашего кода. Поместите тестовые файлы в папку "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()