Skip to content

Instantly share code, notes, and snippets.

View barrsan's full-sized avatar
🏡
Working from home

Alex Baretsky barrsan

🏡
Working from home
View GitHub Profile
@nicksonthc
nicksonthc / fastapi-redis.py
Created April 11, 2024 16:12
FastAPI with asyncio Redis and Lifespan Example
from contextlib import asynccontextmanager
from datetime import datetime
from fastapi import FastAPI, Request
import fastapi
from fastapi.datastructures import State
from fastapi.responses import JSONResponse
import redis.asyncio as redis
class Redis:
redis_client: redis.Redis = None
@royce002
royce002 / GSAP Full Screen Scrolliing
Last active April 27, 2023 14:04
Parallax GSAP Scroll Trigger
<body>
<nav>
<img src="https://bit.ly/2NKLFXr" alt="">
<div>
<ul id="ul-menu">
<li><a id="menu_link" href="#section_beaches">Beaches</a></li>
<li><a id="menu_link" href="#section_temples">Civlization</a></li>
<li><a id="menu_link" href="#section_places">Places</a></li>
</ul>
@beppek
beppek / category.js
Last active February 5, 2023 00:48
Example of how to query multi level nested documents in Sanity
import { FcTreeStructure } from 'react-icons/fc';
export default {
name: 'category',
title: 'Category',
type: 'document',
icon: FcTreeStructure,
fields: [
{
name: 'title',
@marcio0
marcio0 / FilteredReference.js
Last active September 26, 2022 10:29
filtered reference field on sanity
import React from "react";
import PropTypes from "prop-types";
import { has } from "lodash";
import PatchEvent, { set, unset } from "part:@sanity/form-builder/patch-event";
import ReferenceInput from "@sanity/form-builder/lib/inputs/ReferenceInput";
import { withDocument } from "part:@sanity/form-builder";
import { map } from "rxjs/operators";
import client from "part:@sanity/base/client";
import { createWeightedSearch } from "../../utils/search";
import { observeForPreview } from "part:@sanity/base/preview";
@kuhelbeher
kuhelbeher / readme.md
Last active December 6, 2022 16:20
Eslint airbnb config + prettier for create-react-app project

This is tutorial of onfiguring eslint, prettier for your project

Make your code great again

  1. Eslint

First of all we need to install eslint and configs as dev dependencies. You can use your own config, but I will use config from airbnb:

yarn add -D eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
@kmelve
kmelve / promote-drafts.js
Created February 12, 2019 21:38
Sanity: Promote drafts
/* eslint-disable no-console */
import client from 'part:@sanity/base/client'
// Run this script with: `sanity exec --with-user-token migrations/renameField.js`
//
// This example shows how you may write a migration script that sets all drafts to published version
// and deletes the draft version
// This will migrate documents in batches of 100 and continue patching until no more documents are
// returned from the query.
//
@INQTR
INQTR / axios-interceptors-refresh-token.js
Last active March 2, 2025 13:30
Axios interceptors token refresh for few async requests. ES6
import axios from "axios";
import { settings } from "../settings";
import { authAPI } from ".";
const request = axios.create({
baseURL: settings.apiV1,
});
request.interceptors.request.use(
(config) => {
@Godofbrowser
Godofbrowser / axios.refresh_token.1.js
Last active October 17, 2025 18:32 — forked from culttm/axios.refresh_token.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@deptno
deptno / fragment.ts
Created June 25, 2018 02:53
graphql-tag fragment example
import gql from 'graphql-tag'
const FRAGMENT_REPOSITORY = gql`
fragment repository on Repository {
name
url
createdAt
description
descriptionHTML
labels {
@hermanbanken
hermanbanken / Dockerfile
Last active September 1, 2025 21:47
Compiling NGINX module as dynamic module for use in docker
FROM nginx:alpine AS builder
# nginx:alpine contains NGINX_VERSION environment variable, like so:
# ENV NGINX_VERSION 1.15.0
# Our NCHAN version
ENV NCHAN_VERSION 1.1.15
# Download sources
RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \