Skip to content

Instantly share code, notes, and snippets.

View nenkoru's full-sized avatar

Ruslan Chernenko nenkoru

View GitHub Profile
class FormatTelephone:
def __init__(self,
phone,
mask="+* (***) ***-**-**",
maskSymbol="*"):
self.phone = phone
self.maskSymbol = maskSymbol
self.mask = mask
@nenkoru
nenkoru / accept_languages.py
Created October 18, 2021 18:55
Function to convert language list to accept-languages headers
import re
from typing import List
import operator
import decimal
# computers can't do precise operations with floating point, which is causing us to use Decimal
def float_range(start, stop, step=0.1):
comparison_operator = operator.gt if step > 0 else operator.lt
start, step = decimal.Decimal(start), decimal.Decimal(str(step))
while not comparison_operator(start, stop):
@nenkoru
nenkoru / ventura-ntfs.md
Last active January 10, 2023 09:17
How to mount NTFS partition in MacOS Ventura | January 2023

How to mount NTFS usb or partition into the MacOS Ventura for free

  1. Install MacFuse

  2. Install ntfs-3g-mac from Brew

brew tap gromgit/homebrew-fuse
brew install ntfs-3g-mac
  1. Get identifier of the disk and partition you need to mount
@nenkoru
nenkoru / main.py
Last active September 19, 2023 16:50
Run LLAMA with a subprocess from a python and check the prompt
import os
import subprocess
def execute(cmd):
popen = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
encoding="utf-8",
)
with open("output.txt", "w") as f:
@nenkoru
nenkoru / parse.js
Created June 24, 2023 20:44
Parse games compatibility from yuzu
let xhr = new XMLHttpRequest();
xhr.open("GET", "https://yuzu-emu.org/game/", false)
xhr.send()
parser = new DOMParser();
yuzuDocument = parser.parseFromString(xhr.response, 'text/html');
function extractInnerTextFromNodes(nodes, childElement) {
var texts = []
for(var i = 0; i < nodes.length - 1; i++) {
@nenkoru
nenkoru / starcoder.py
Created July 16, 2023 12:02
Starcoder for lmi
from typing import Union, Iterable, List
from collections.abc import Iterable as abc_Iterable
import transformers
import ctranslate2
class CT2Generator:
"""Implements LMIProtocol."""
@nenkoru
nenkoru / main.py
Created August 1, 2023 19:36
A showcase of embedding of an external file into the prompt for hfcc.nvim
# Current path: test/main.py
#
# Included snippet from test/utils/timezone.py:
# from datetime import datetime, timezone, tzinfo
#
#
# def datetime_exists(dt):
# """Check if a datetime exists. Taken from: https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html"""
# # There are no non-existent times in UTC, and comparisons between
# # aware time zones always compare absolute times; if a datetime is
@nenkoru
nenkoru / hfcc_poc.py
Created August 7, 2023 20:46
An example of simple language server using pygls
#!/usr/bin/python3
from pygls.server import LanguageServer
from lsprotocol.types import (
TEXT_DOCUMENT_COMPLETION,
CompletionItemKind,
CompletionItem,
CompletionList,
CompletionParams,
)
@nenkoru
nenkoru / pbi.py
Last active April 2, 2024 12:11
Connect to PowerBI OLAP from Python cross-platform using dotnet
"""
My journey started after reading this topic. And I started to gather all the breadcrumbs and clues I have found around the Internet.
First of all. There is a difference between Mono and dotnet(aka .net core), as pointed by Darren Gosbell on a microsoft learn page [4].
As everyone stumbling upon this issue I tried using Mono and specific to Windows version of Adomd whic is located in this link [5]. It didn't work as there were API used specific to Windows. It was failing.
Then I learned that there is actualy a 'native' dotnet app that could run those DLLs.
I started by loading that native to Windows AdomdClient DLL version using Mono - Fail.
Then using dotnet - Fail.
And right after that I understood that a .net core DLL has to be used. So I found one on Nuget [3].
And boom, right after that the original problem has gone, but I had a malformed connection string, which I believe was leading to lib to try to run a interactive login(just imo) and then failing into an issue where it said that a function or a
@nenkoru
nenkoru / article.md
Created December 12, 2023 07:28
How to share a MacOS screen to any device with Retina quality and low-latency

How to share a screen in MacOS to any device with Retina quality and low-latency.

Embarking on a quest for seamless MacBook-to-Android tablet screen sharing, I quickly discovered that existing solutions, like the clunky Duet, left much to be desired. Undeterred, I delved into the realm of browser-based screen sharing, realizing that our ubiquitous browsers might just hold the key to a smoother experience.

My exploration led me to the fascinating world of WebRTC, a technology weaving its magic across the internet and, importantly, in screen-sharing solutions. What caught my attention was not just its capability to facilitate screen sharing but the added perk of peer-to-peer connectivity, bypassing the need for intermediary servers. Imagine sharing your screen without the fuss of servers – WebRTC promised just that.

As I scoured various projects enabling browser-based screen sharing, I stumbled upon Spreen, a nifty JS project. Spreen seamlessly integrates a server-side JS code that acts as a messenger, facil