Skip to content

Instantly share code, notes, and snippets.

@savayer
savayer / usage.ts
Created May 3, 2024 11:30
show notification modal about new version available
const currentVersion = Constants.expoConfig.version;
getAppInfoFromTheStore(country)
.then((appInfo) => {
if (isValidVersionFormat(appInfo?.version)) {
const [currentMajor, currentMinor, currentPatch] = currentVersion
.split('.')
.map(Number);
const [newMajor, newMinor, newPatch] = appInfo.version
.split('.')
/**
* It converts object {"id": "1,2", "type": "someType", "value": "abc"}
* to filter[id]=1%2C2&filter[type]=someType&filter[value]=abc
* */
export default function toJsonApiFilter(
obj: Record<string, any> | undefined,
): string {
const queryStringParts: string[] = [];
if (!obj) {
import Cookies from 'js-cookie';
import React, { useEffect, useState } from 'react';
import { Close } from './icons';
import { classNames, getOs } from './utils';
/**
* Lookup key for the Cookie value to hide the app banner for a period of time.
**/
const APP_BANNER_IS_HIDDEN = 'app_banner_is_hidden';
import React, { ReactNode } from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import {
Gesture,
GestureDetector,
gestureHandlerRootHOC,
} from 'react-native-gesture-handler';
import Reanimated, {
runOnJS,
useAnimatedStyle,
@savayer
savayer / tokens.md
Created June 28, 2023 06:14 — forked from staslysak/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

Например после аутентификации юзер sasha получает право обращатся и получать от ресурса "super.com/vip" некие данные. Во время обращения юзера sasha к ресурсу vip система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)

/**
* Please, improve this component and fix all problems.
*
* What is important:
* - design (extensibility, testability)
* - code cleanliness, following best practices
* - consistency
* - naming
* - formatting
*
@savayer
savayer / Lighbox.js
Last active September 20, 2022 08:42
set state bug. SOLVED. Lighbox shouldn't be inside the caller of the Lightbox :D
import React, { useEffect, useRef, useState } from 'react';
import { Modal } from './Modal';
import { Swiper, SwiperSlide } from 'swiper/react';
import { Lazy, Navigation, Keyboard, Mousewheel } from 'swiper';
import { Chevron, Close } from './icons';
import { classNames } from './utils';
export function Lightbox({ images, photoIndex, onClose, style }) {
const [loaded, setLoaded] = useState(false);
const [swiper, setSwiper] = useState(false);
@savayer
savayer / data.js
Last active December 21, 2021 06:59
medicine history
const grayColor = 'rgba(240, 244, 244, 0.96)'
export default [
{
title: 'Практическая медицина',
type: 'orange',
mainColor: '#EA8668',
blocks: [
{
name: 'Первая вакцинация',
@savayer
savayer / ConfirmAction.vue
Last active December 17, 2021 09:21
Confirm action vue plugin
<template>
<div class="d-modal_overlay active" v-if="isShowConfirmAction">
<div class="d-modal">
<div class="d-modal__title">
{{ title }}
</div>
<div class="d-modal__text">
{{ description }}
</div>
<slot />
@savayer
savayer / package.json
Last active December 9, 2021 05:16
base webpack config
{
"name": "name",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "webpack serve --config webpack.config.js --mode development",
"build": "webpack build --config webpack.config.js --mode production"
},
"keywords": [],
"author": "",