Skip to content

Instantly share code, notes, and snippets.

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

ReSampled pointofpresence

🏠
Working from home
View GitHub Profile
@pointofpresence
pointofpresence / get_opt.py
Last active March 31, 2024 21:08
Python: Получение аргументов командной строки
import getopt
import sys
 
argv = sys.argv[1:]
opts, args = getopt.getopt(argv, 'x:y:')
 
# list of options tuple (opt, value)
print(f'Options Tuple is {opts}')
 
# list of remaining command-line arguments
export default class DeepDiffMapper {
static VALUE_CREATED = 'created'
static VALUE_UPDATED = 'updated'
static VALUE_DELETED = 'deleted'
static VALUE_UNCHANGED = 'unchanged'
static map(obj1, obj2, changedOnly = true) {
@pointofpresence
pointofpresence / simple http web server.py
Last active March 31, 2024 20:51
simple http web server
#! /usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
import sys
COLOR = "\033[1;32m"
RESET_COLOR = "\033[00m"
class S(BaseHTTPRequestHandler):
def _set_response(self):
@pointofpresence
pointofpresence / TS tuples.js
Last active March 31, 2024 20:44
TS: Кортежи
Basic tuples
let myTuple: [ string, number, boolean? ];
myTuple = [ 'test', 42 ];
@pointofpresence
pointofpresence / filter list.txt
Last active March 31, 2024 20:39
Python: Удалить словарь из списка по значению ключа
# Удалить словарь из списка:
thelist[:] = [d for d in thelist if d.get('id') != 2]
# Используя синтаксис thelist[:], мы можем сохранить ссылку на исходный список и избежать создания нового списка.
# Это может быть полезно, если переменная thelist уже используется в других частях кода, и вы хотите обновить ее содержимое.
@pointofpresence
pointofpresence / ffmpeg split .bat
Last active March 31, 2024 20:29
FFmpeg: Разбить видео на фрагменты по времени
https://stackoverflow.com/questions/5651654/ffmpeg-how-to-split-video-efficiently - VIDEO SPLIT
time ffmpeg -v quiet -y -i input.ts -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 -sn test1.mkv
time ffmpeg -v quiet -y -i input.ts -vcodec copy -acodec copy -ss 00:30:00 -t 01:00:00 -sn test2.mkv
@pointofpresence
pointofpresence / backdrop-filter blur.css
Last active March 31, 2024 20:20
CSS: Размытие заднего плана с backdrop-filter: blur()
/* чтобы размыть под layer CSS (например, для модалок) */
backdrop-filter: blur(7px);
@pointofpresence
pointofpresence / isfile_isdir.py
Last active March 31, 2024 20:14
Python: Определить, является ли путь файлом или директорией
os.path.isfile("bob.txt") # Does bob.txt exist? Is it a file, or a directory?
os.path.isdir("bob")
@pointofpresence
pointofpresence / python enum.py
Last active March 31, 2024 20:11
Python: Использование Enum
from enum import Enum, auto
class Color(Enum):
RED = auto()
BLUE = auto()
GREEN = auto()
list(Color) # [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
@pointofpresence
pointofpresence / Binary request and save.py
Last active March 31, 2024 20:08
Python: Скачать и сохранить бинарный файл
# Binary request and save
# Request the profile picture of the OP:
response = requests.get("https://i.stack.imgur.com/iysmF.jpg?s=32&g=1")
with open("response.jpg", "wb") as f:
f.write(response.content)