Skip to content

Instantly share code, notes, and snippets.

View romanvm's full-sized avatar

Roman Miroshnychenko romanvm

View GitHub Profile
# (c) Roman Miroshnychenko <roman1972@gmail.com> 2023
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Copyright (c) 2021, Roman Miroshnychenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@romanvm
romanvm / applet.js
Last active February 17, 2023 10:29
VPN indicator fix for Cinnamon desktop Network applet
// The code is public domain and you can use it as you want.
// The following code should be added to _updateIcon function after else block and before catch block
// around line # 2345
// File path: /usr/share/cinnamon/applets/network@cinnamon.org/applet.js
// When VPN is connected the network icon is changed to "lock with WiFi" if connected via WiFi
// and to "lock with wire" if connected via other methods.
// *** Start of VPN icon fix ***
for (let i = 0; i < this._activeConnections.length; i++) {
const a = this._activeConnections[i];
if (a._section === NMConnectionCategory.VPN && a.state === NM.ActiveConnectionState.ACTIVATING) {
@romanvm
romanvm / sqlite_storage.py
Last active September 22, 2022 18:33
Simple key-value storage based on SQLite
# coding: utf-8
#
# Copyright (c) 2017 Roman Miroshnychenko <roman1972@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@romanvm
romanvm / example.service
Last active September 22, 2022 18:33
Example of a simple Linux systemd service
[Unit]
Description=Example systemd service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=on-sucess
RestartSec=1
User=nobody
# coding: utf-8
from __future__ import print_function
import random
import socket
def get_random_port():
random.seed()
while True:
port = random.randint(4000, 16000)
@romanvm
romanvm / generate.py
Last active February 15, 2022 18:32
Script that generates necessary data files to create a custom addon repository for Kodi mediacenter
#!/usr/bin/env python
# coding: utf-8
#
# Copyright (c) 2017, Roman Miroshnychenko <romanvm@yandex.ua>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@romanvm
romanvm / threadpoolss.py
Last active February 15, 2021 00:36 — forked from kgaughan/threadpoolss.py
All the thread pool mixins for SocketServer are, well, not that good, so I knocked together my own. This one can cleanly shut down the pool
"""
Thread pool extensions to SocketServer.
"""
import Queue
import SocketServer
import sys
import threading
@romanvm
romanvm / multi_select.py
Last active March 22, 2020 19:13
The example of a multi-select dialog in a Kodi addon created with PyXBMCt framework
# The example of a multi-select dialog in a Kodi addon created with PyXBMCt framework.
# You will need a checkmark image file.
import os
import xbmcgui
import xbmcaddon
import pyxbmct.addonwindow as pyxbmct
_addon = xbmcaddon.Addon()
_path = _addon.getAddonInfo("path")
_check_icon = os.path.join(_path, "check.png") # Don't decode _path to utf-8!!!
Package: /mysql/
Pin: release *
Pin-Priority: -1