Skip to content

Instantly share code, notes, and snippets.

View bazuka5801's full-sized avatar
💻
Working from Yandex

Maxim Bazuev bazuka5801

💻
Working from Yandex
View GitHub Profile
// progress in 0..1 range, time is epoch seconda
function estimateProgressRemainTime(progressLast, timeLast, progressCurrent, timeCurrent) {
// Calculate the time taken for the progress made
const timeTaken = timeCurrent - timeLast; // time in seconds
const progressMade = progressCurrent - progressLast;
// Avoid division by zero or negative progress
if (progressMade <= 0) {
return "No progress made or invalid input.";
}
// Usage
/*
Here, the redisificationResult function is being used to cache the result of the getPaidSeatsOfServices
function call for a specific eventId.
The cacheSeconds is set to 60, which means the result will be cached in Redis for 1 minute.
The key is dynamically generated based on the eventId, which allows for caching different results for different events.
By using redisificationResult, the code is ensuring that if the same eventId is passed again within the 1-minute cache window,
// draft_info.json
const mark_items = [
{
"color": "#00c1cd",
"id": "F1F76016-94CB-4229-BA6F-C13574EF5594",
"time_range": {
"duration": 443100000,
"start": 443100000
},
@bazuka5801
bazuka5801 / q-input.scss
Created January 22, 2023 13:31
QInput customization
.myinput {
border-radius: 8px;
background: #f00;
// border
:deep(.q-field__inner) {
border-radius: inherit;
.q-field__control {
border-radius: inherit;
export class Vector2 {
protected _x: number
protected _y: number
constructor(x: number, y: number) {
this._x = x || 0
this._y = y || 0
}
We couldn’t find that file to show.
@bazuka5801
bazuka5801 / fix-capacitor-keyboard-show.js
Last active November 11, 2021 14:45
When we use capacitor in quasar, and select any input, keyboard showing, but selected input field scrolling down and we can't see what we input. We get keyboard show bug. This code snipper - fixing that bug.
// Bug example video: https://youtu.be/3tQJakYez1Q
// Expected result: https://youtu.be/HEXWEVXjen8
import { Keyboard } from '@capacitor/keyboard';
// Define outside of view
let activeElement = null;
data: () => ({
/*
@bazuka5801
bazuka5801 / icongenie-profile.sh
Created June 1, 2021 02:02
Quasar - Icon Genie
# [Optiona] Installing icongenie
yarn global add @quasar/icongenie
# Generate profile
icongenie p \
-o prod \
-i ./src/assets/logo.png \
-b ./src/assets/splash.png \
--splashscreen-icon-ratio 0 \
--skip-trim \
@bazuka5801
bazuka5801 / [WEB] [CSS] Line after
Created October 21, 2018 16:09
[WEB] [CSS] Line after
&:after {
position:absolute;
top: 50%;
transform: translateY(-50%);
width: 100vw;
height: 5px;
z-index:-1;
content: " ";