Skip to content

Instantly share code, notes, and snippets.

View rasulnavir's full-sized avatar
🕸️
Building things on the web

Rasul Navir rasulnavir

🕸️
Building things on the web
  • Baku, Azerbaijan
  • 20:24 (UTC +04:00)
View GitHub Profile
@rasulnavir
rasulnavir / setting-up-pusher-in-nextjs-app-router-project.md
Last active March 14, 2025 00:29
Setting up Pusher in a Next.js (app router) project

It's better of course to extract the environment variables, but for the sake of clarity, they're taken from process.env on-demand.

Setup pusher client (for client components):

// lib/pusher/client.ts

import Pusher from 'pusher-js'

const key = process.env.NEXT_PUBLIC_PUSHER_APP_KEY
const cluster = process.env.NEXT_PUBLIC_PUSHER_CLUSTER
@rasulnavir
rasulnavir / forwardref-generics-18.ts
Created October 18, 2024 15:44 — forked from IrvingArmenta/forwardref-generics-18.ts
Example of a forward ref generic component in React 18
import React, { ForwardedRef, forwardRef, MouseEvent } from 'react';
type ClickableListProps<T> = {
items: T[];
onSelect: (
item: T,
event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>,
) => void;
};
@rasulnavir
rasulnavir / nestjs-typeorm-abstract-validator.md
Last active July 10, 2022 09:00
NestJS TypeORM - Unique column validation

Abstract "unique field" validator for NestJS + TypeORM


Create a file that will hold the Validator Constraint and the Decorator:

// src/validators/is-unique.validator.ts

import {
    registerDecorator,
    ValidationArguments,
@rasulnavir
rasulnavir / .zshrc
Last active July 10, 2022 08:20
.zshrc with OhMyZsh configuration
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Lunarvim path
PATH=$PATH:~/.local/bin
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@rasulnavir
rasulnavir / laravel-project-permissions.md
Last active July 10, 2022 08:21
Laravel project folder permissions

Change project to your folder name

sudo chown -R www-data:www-data /var/www/project
sudo usermod -a -G www-data $USER
sudo find /var/www/project -type f -exec chmod 644 {} \;
sudo find /var/www/project -type d -exec chmod 755 {} \;
sudo chgrp -R www-data /var/www/project/storage /var/www/project/bootstrap/cache
sudo chmod -R ug+rwx /var/www/project/storage /var/www/project/bootstrap/cache
@rasulnavir
rasulnavir / MoneyInput.vue
Last active July 10, 2022 08:23
Vue.js money (currency) input (NOT PERFECT: better to use some UI Library number input component instead)
<template>
<input
type="text"
v-bind="$attrs"
:value="value"
@keydown="onKeydown"
@blur="onBlur"
/>
</template>
@rasulnavir
rasulnavir / sublime-text-4-setup-for-web-development.md
Last active July 10, 2022 08:28
SUBLIME TEXT 4 Setup for Web Development (Laravel, Vue, Tailwind)

Start with packages:

A File Icon,
All Autocomplete,
AutoFileName,
BracketHighlighter,
Close All Untouched Files,
Color Highlighter,
DocBlockr, // comments
DotENV, // .env syntax highlight
@rasulnavir
rasulnavir / easing-functions.js
Last active July 10, 2022 08:28
Easing Functions
const easings = {
linear(t) {
return t
},
easeInQuad(t) {
return t * t
},
easeOutQuad(t) {
return t * (2 - t)
},
@rasulnavir
rasulnavir / scroll-to-section.js
Last active July 10, 2022 08:29
Scroll to section Vanilla JS
function scrollIt(
destination,
duration = 200,
easing = 'linear',
callback
) {
const easings = {
linear(t) {
return t
},
@rasulnavir
rasulnavir / distortion-maps-collection
Last active June 20, 2021 16:35
Distortion maps collection
https://sun9-33.userapi.com/oyXE4fwIIVoSQarMRSvvT7xmx-XUUJXsET5lHw/HrxVsQfpFh8.jpg
https://sun9-50.userapi.com/Lp5ut8ndp6Il_vTqolQp_xgbcFYjhE_7YlbDDQ/ThSI5WGIsW0.jpg
https://sun9-64.userapi.com/LLEMh69j3IOX4EjAI5PZ4SA3JX1F03uz3JQ_Mw/Rv_c7as7JOM.jpg
https://sun9-76.userapi.com/xSRye6hJXryCKAb9-tBps-pYI9Fp93r1mDWKdQ/raGNt4xki0s.jpg
https://sun9-64.userapi.com/Tjj9yeQ6xWOEy-cOT5qMkOnRi7dpgfQivDTh2A/Pv93WMQzvvU.jpg
https://sun9-75.userapi.com/DoAhtS4rY5KB8Gw93rEWgUhDQMiEUFbFBkEmqg/hLdamrzPowY.jpg