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 / needlemanwunsh.js
Created April 11, 2021 13:18
Binary DNA modification to the Needleman Wunch algorithms
/**
* Modification to the Needleman Wunsch for Binary DNA
*/
class NeedlemanWunsch {
/**
* @param {string} seq1 - First
* @param {string} seq2
* @param {string} seq12
* @param {string} seq22
* @param {number} match_score
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
@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",
@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 / 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('')
function observable(v){
this.value = v;
this.valueChangedCallback = null;
this.setValue = function(v){
if(this.value != v){
this.value = v;
this.raiseChangedEvent(v);
}
// add this class to the div
.centerAnElement {
display: flex;
justify-content: center;
align-items: center;
}
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(
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';
@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() {