Skip to content

Instantly share code, notes, and snippets.

View biomathcode's full-sized avatar
🎯
Focusing

Pratik sharma biomathcode

🎯
Focusing
View GitHub Profile
@biomathcode
biomathcode / app.jsx
Created July 3, 2024 01:27
Video Encoding in React
import "./styles.css";
import { parseGIF, decompressFrames } from "gifuct-js";
import WebMWriter from "webm-writer";
export default function App() {
const handleChange = (e) => {
const file = e.target.files[0];
const filereader = new FileReader();
filereader.onload = (res) => {
@biomathcode
biomathcode / andhrapradesh.json
Last active March 10, 2024 21:04
Indian map - geojson or topojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@biomathcode
biomathcode / sonner-state.tsx
Created January 9, 2024 19:15
Sonner State Objserver
import React from 'react';
import type { ExternalToast, ToastT, PromiseData, PromiseT, ToastToDismiss, ToastTypes } from './types';
let toastsCounter = 1;
class Observer {
subscribers: Array<(toast: ExternalToast | ToastToDismiss) => void>;
toasts: Array<ToastT | ToastToDismiss>;
constructor() {
import React, { useEffect, useState, useRef, useMemo, useCallback } from 'react';
import { Text, Editor, createEditor, Node, Range, Point, Transforms } from 'slate';
import {
Slate,
Editable,
withReact,
useSelected,
useFocused,
useSlate } from 'slate-react';
import { withHistory } from 'slate-history';
import { useEffect, useRef } from "react";
export default function App() {
// create a ref
const divElement = useRef();
// trigger on the first render of the component
useEffect(() => {
// get the height of the div element
console.log(
// add this class to the div
.centerAnElement {
display: flex;
justify-content: center;
align-items: center;
}
function observable(v){
this.value = v;
this.valueChangedCallback = null;
this.setValue = function(v){
if(this.value != v){
this.value = v;
this.raiseChangedEvent(v);
}
@biomathcode
biomathcode / localstorage.js
Created March 16, 2022 15:32
localstorage
import React, {useState, useEffect} from 'react';
import useLocalStorage from 'use-local-storage';
const AdressBook = () => {
const [book , setBook] = useLocalStorage('addressbook', [{}])
const [name, setName] = useState('')
const [address, setAddres] = useState('')
@biomathcode
biomathcode / infinitescrollwithrecoil.js
Created February 24, 2022 10:30
infinite scroll with recoil example
const itemQuery = selectorFamily({
key: 'ItemQuery',
get: cursor => () => ApiCall(cursor),
});
const currentCursorInternal = atom<number>({
key: 'currentCursorInternal',
default: 0,
});
@biomathcode
biomathcode / notionToDev.js
Last active December 23, 2021 14:43
Publishing articles from notion to dev community
const { Client } = require("@notionhq/client");
const axios = require('axios')
const notion2md = require("notion-to-md");
const databaseId = 'YOUR_DATABASE_ID';
const notion = new Client({
auth: "YOUR_NOTION_TOKEN",