Skip to content

Instantly share code, notes, and snippets.

View gelin's full-sized avatar

Denis Nelubin gelin

View GitHub Profile
@gelin
gelin / dolphin-animation.py
Last active April 5, 2024 09:45
Converts Flipper Animation assets to video files
#!/usr/bin/env python3
# Converts Flipper Animation assets to video files.
# Typical usage: ./dolphin-animation.py ${FLIPPERZERO_FIRMWARE}/assets/dolphin/external/L2_Wake_up_128x64
# Dependencies: python3-pil, ffmpeg
# Font: https://www.fontsaddict.com/font/download/haxrcorp-4089-cyrillic-altgr-regular.ttf
import argparse
import enum
import os
@gelin
gelin / chatgpt.md
Last active March 18, 2023 20:13
LRU set created by ChatGPT

Could you suggest a collection implementation for Java/Kotlin? it must be a set of strings. But a set with a limited size. If a new element is added to the set which did not exists in it, the last recently accessed element is removed from the set keeping the size of the set constant.

A suitable collection for this use case would be a LinkedHashSet. This collection maintains the order of elements as they are added and provides constant time access to the most recently added or accessed element.

To implement the limited size constraint, you can create a subclass of LinkedHashSet and override the add method to remove the least recently accessed element when the size limit is reached.

Here is an example implementation in Kotlin:

class LimitedSizeSet(private val maxSize: Int) : LinkedHashSet<String>() {
@gelin
gelin / readme.md
Created September 19, 2021 07:11
Как установить свежий LineageOS на планшет Sony Xperia Z3 Tablet Compact

Устройство

Sony Xperia Z3 Tablet Compact SGP611

Инструменты и принадлежности

  • Приложение fastboot. Оно поставляется вместе с Android SDK.
  • USB кабель
  • Компьютер под управлением Linux, с установленным Android SDK, USB и доступом в Интернет
@gelin
gelin / blueprint.json
Last active June 7, 2020 10:34
Integromat scenario blueprint to send daily digest with Google Calendar events and today weather to Telegram
{
"name": "Daily Digest",
"flow": [
{
"id": 12,
"module": "builtin:BasicRouter",
"version": 1,
"mapper": null,
"metadata": {
"designer": {
@gelin
gelin / wacom-config
Created May 30, 2020 12:21
Small GUI script to configure some parameters of Wacom pen tablet
#!/usr/bin/env python3
from sh import xsetwacom
from easygui import buttonbox
# define for your device
PREFIX = 'Wacom One by Wacom S Pen '
INPUTS = [
'stylus',
'eraser',
@gelin
gelin / jsonb_set.md
Created February 20, 2020 15:51
jsonb_set example

What is the result of this?

SELECT jsonb_set('{}', '{test}', to_jsonb((SELECT 'test' LIMIT 0)::text));

SELECT to_jsonb((SELECT 'test' LIMIT 0)::text);
@gelin
gelin / add-chrome-app
Created February 20, 2020 15:50
Adds any URL as the Chrome application to the main menu
#!/usr/bin/env python3
import argparse
import tempfile
import os.path
import subprocess
import urllib.request
import urllib.parse
from PIL import Image
@gelin
gelin / install.sh
Created February 20, 2020 15:49
Installs Redmine Time Tracker to main menu
#!/bin/sh
# Adds Redmine Time Tracker to the main menu.
# https://www.redmine.org/plugins/redmine-time-tracking-software
set -e
jar=$(find $PWD/ -name "*.jar")
echo "Found '$jar'"
@gelin
gelin / invite_to_slack.py
Created February 20, 2020 15:48
Invite users to Slack
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import csv
import requests
import time
# Create and register your app in Slack.
# You need the Legacy Token here: https://api.slack.com/custom-integrations/legacy-tokens
@gelin
gelin / DynamoDBNestedIncrement.kt
Created February 20, 2020 15:47
Increment nested number in DynamoDB
import com.amazonaws.services.dynamodbv2.document.PrimaryKey
import com.amazonaws.services.dynamodbv2.document.api.UpdateItemApi
import com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException
fun UpdateItemApi.nestedIncrement(key: PrimaryKey, attribute: String, path: List<String>, increment: Int) {
tryToIncrement(key, listOf(attribute) + path, increment)
}
private fun List<String>.toPathExpression(): String =
mapIndexed { index, _ -> "#p$index" }.joinToString(".")