Skip to content

Instantly share code, notes, and snippets.

View issam-seghir's full-sized avatar
🏆
Always Learning - Always Improving ✨

Issam Seghir issam-seghir

🏆
Always Learning - Always Improving ✨
View GitHub Profile
@yinkakun
yinkakun / axios.ts
Last active February 6, 2025 09:26
next client auth with zustand, axios
import Axios from "axios";
import Router from "next/router";
const API_URL = process.env.NEXT_PUBLIC_API_URL;
export const axios = Axios.create({
baseURL: API_URL,
headers: {
"Content-Type": "application/json",
},
@TonyGravagno
TonyGravagno / zodDefaultInstance.ts
Last active November 22, 2024 11:39
Create a default object from a Zod schema
import { z } from 'zod'
/**
* @summary Function returns default object from Zod schema
* @version 23.05.15.2
* @link https://gist.github.com/TonyGravagno/2b744ceb99e415c4b53e8b35b309c29c
* @author Jacob Weisenburger, Josh Andromidas, Thomas Moiluiavon, Tony Gravagno
* @param schema z.object schema definition
* @param options Optional object, see Example for details
* @returns Object of type schema with defaults for all fields
@intergalacticspacehighway
intergalacticspacehighway / FlatListGapExample.jsx
Created February 28, 2023 01:14
Add gap in FlatList items with numColumns
import {Dimensions, FlatList, View} from 'react-native';
const screenWidth = Dimensions.get('window').width;
const numColumns = 2;
const gap = 5;
const availableSpace = screenWidth - (numColumns - 1) * gap;
const itemSize = availableSpace / numColumns;
const renderItem = ({item}) => {
@konstantin24121
konstantin24121 / verifyTelegramWebAppData.tsx
Last active February 24, 2025 04:05
Telegram Bot 6.0 Validating data received via the Web App node implementation
const TELEGRAM_BOT_TOKEN = '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw'; // https://core.telegram.org/bots#creating-a-new-bot
export const verifyTelegramWebAppData = async (telegramInitData: string): boolean => {
// The data is a query string, which is composed of a series of field-value pairs.
const encoded = decodeURIComponent(telegramInitData);
// HMAC-SHA-256 signature of the bot's token with the constant string WebAppData used as a key.
const secret = crypto
@mohokh67
mohokh67 / vscode-settings.md
Last active November 19, 2024 07:50
Install italic and customizable font for vscode

Link to Youtube video: https://youtu.be/QxcRmsGHcWY

Manual steps:

  • Download and install Victor Mono font
  • Update VSCode setting as bellow:
    • font size, line height and font weight are optional and you can update them as you prefer
{
  "editor.fontSize": 13,
  "editor.lineHeight": 24,
@astamicu
astamicu / Remove videos from Youtube Watch Later playlist.md
Last active February 25, 2025 12:38
Script to remove all videos from Youtube Watch Later playlist

UPDATED 22.11.2022

It's been two years since the last update, so here's the updated working script as per the comments below.

Thanks to BryanHaley for this.

setInterval(function () {
    video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

 video.querySelector('#primary button[aria-label="Action menu"]').click();
@AnsonT
AnsonT / basicjwt.js
Last active February 4, 2025 22:29
Simplest Passport/JWT implementation with cookie and bearer authentication support
import express from 'express'
import bodyParser from 'body-parser'
import cookieParser from 'cookie-parser'
import passport from 'passport'
import passportJWT, { ExtractJwt, Strategy as JwtStrategy } from 'passport-jwt'
import bcrypt from 'bcrypt'
import jwt from 'jsonwebtoken'
const { fromExtractors, fromAuthHeaderWithScheme, fromAuthHeaderAsBearerToken } = ExtractJwt
@darsain
darsain / svg_sprites.md
Last active February 19, 2025 07:08
How to use SVG sprites in img[src] and css backgrounds

To make this work in CSS:

background: url('images.svg#chart');

or img:

<img src="images.svg#chart">
@curran
curran / .block
Last active December 10, 2023 12:48
Download SVG from Data URL
license: mit