This is a quick way to find a random free port on a system using PHP:
$port = find_free_port();
Benchmarked locally, where finding a port always took around 0.15ms.
# imports | |
import threading | |
import typing | |
import functools | |
# Constants | |
class LockConstants: | |
PRINTLOCK = threading.Lock() | |
SOMEOTHERLOCK = threading.Lock() |
>>> a=lambda: (n:=4) | |
>>> n | |
2 | |
>>> a() | |
4 | |
>>> n | |
2 |
from os import system | |
from time import sleep | |
string = [ | |
"| | | | | _ | | _ | | _ | | | | | | \\ | | | __ | \\ \\ / / | | | | | __ | | _ | | __ | ", | |
"| |_| | | |_| | | __| | __| \\ ` / | |\\ | | | ___| \\ \\ _ / / \\ ` / | ___| | |_| | | ___/ ", | |
"| _ | | _ | | | | | | | | | \\ | | |_ \\ \\/_\\/ / | | | |_ | _ | | |\\ \\ ", | |
"|_| |_| |_| |_| |_| |_| |_| |_| \\ | |___| \\_/ \\_/ |_| |___| |_| |_| |_| \\_\\ "] | |
#! /usr/bin/env python3 | |
""" | |
List all Firefox tabs with title and URL | |
Supported input: json or jsonlz4 recovery files | |
Default output: title (URL) | |
Output format can be specified as argument | |
""" |
def plural_days(n): | |
days = ['день', 'дня', 'дней'] | |
if n % 10 == 1 and n % 100 != 11: | |
p = 0 | |
elif 2 <= n % 10 <= 4 and (n % 100 < 10 or n % 100 >= 20): | |
p = 1 | |
else: | |
p = 2 |
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts, | |
that detects and handles AJAXed content. Forked for use without JQuery. | |
Usage example: | |
waitForKeyElements ( | |
"div.comments" | |
, commentCallbackFunction | |
); | |
//--- Page-specific function to do what we want when the node is found. | |
function commentCallbackFunction (element) { | |
element.text ("This comment changed by waitForKeyElements()."); |
import cv2 | |
import io | |
import socket | |
import struct | |
import time | |
import pickle | |
import zlib | |
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
client_socket.connect(('192.168.1.124', 8485)) |
# -*- coding: utf-8 -*- | |
morse_alphabet = { | |
"А" : ".-", | |
"Б" : "-...", | |
"В" : ".--", | |
"Г" : "--.", | |
"Д" : "-..", | |
"Е" : ".", | |
"Ж" : "...-", |
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python. | |
Usage:: | |
./dummy-web-server.py [<port>] | |
Send a GET request:: | |
curl http://localhost |