Skip to content

Instantly share code, notes, and snippets.

View Hammer2900's full-sized avatar
🚚
Working from home

Yevhen Ts. Hammer2900

🚚
Working from home
View GitHub Profile
@Hammer2900
Hammer2900 / monitors_x11.py
Created October 15, 2022 09:36
Get all monitors with x11 lib
from Xlib import display
from Xlib.ext import randr
def find_mode(id, modes):
for mode in modes:
if id == mode.id:
return f'{mode.width}x{mode.height}'
@Hammer2900
Hammer2900 / nm_l2tp_ipsec_vpn.md
Last active September 1, 2022 05:45 — forked from pastleo/nm_l2tp_ipsec_vpn.md
setup L2TP IPSEC VPN in archlinux using NetworkManager
@Hammer2900
Hammer2900 / i3-smarttitles.py
Created May 26, 2022 14:24 — forked from ericbrandwein/i3-smarttitles.py
Hide or show titles in i3wm windows depending on if the Workspace has more than one window. Requires [i3ipc-python](https://github.com/acrisci/i3ipc-python) to be installed.
#!/usr/bin/env python
import i3ipc
# Create the Connection object that can be used to send commands and subscribe
# to events.
i3 = i3ipc.Connection()
def change_titles(windows):
if len(windows) > 1:
@Hammer2900
Hammer2900 / rztk_bot.py
Created October 8, 2021 09:42
Bot for evaluating products in a store rztk
import os
import re
import requests
import telebot
from box import Box
from meiga import Result, Error, Failure
from rich.console import Console
from rich.progress import track
from rich.table import Table
#Принудительно меняем раскладу для Konsole и kitty
#Для телеграм меняем на Русский
#Для всего остального меняю на английский
from i3ipc import Connection, Event
import subprocess,os
@Hammer2900
Hammer2900 / template.py
Created August 25, 2021 09:52 — forked from JohnRipper/template.py
template for i3ipc extensions
#!/usr/bin/env python3
import i3ipc
from i3ipc import Event
from i3ipc.events import IpcBaseEvent, Event
i3 = i3ipc.Connection()
# callback for when workspace focus changes
def on_workspace(i3, e:IpcBaseEvent):
print(e.__dict__)
import macros, strutils
type
TokenKind = enum
FInt, FString, Text
Token = object
case kind: TokenKind
of FInt, FString: nil
of Text: c: String
@Hammer2900
Hammer2900 / square_window.py
Created July 24, 2019 05:09
i3 control window position
import i3ipc
i3 = i3ipc.Connection()
def center_window():
"""
Float and center window, i3wm.
:return:
"""
@Hammer2900
Hammer2900 / main.py
Created June 18, 2019 21:29
json to class string
class GenerateTextFromRules:
class_header = 'class {name}:\n'
method = ' def __init__(self, {vars}):\n'
var = ' self.{name} = {value}\n'
def __init__(self, name, *args, **kwargs):
print(''.join([
self.make_class_header(name),
self.make_method(self.combine_var(args)),
self.make_var(args)
@Hammer2900
Hammer2900 / bson_to_python_file.py
Created March 3, 2019 19:05 — forked from pomack/bson_to_python_file.py
Convert a MongoDB BSON file to a python file that can be imported.
#!/usr/bin/env python
import argparse
import bson
import datetime
import struct
import sys
INDENT_SPACES = ' '
def read_bson_file(file, as_class=dict, tz_aware=True, uuid_subtype=bson.OLD_UUID_SUBTYPE):