Skip to content

Instantly share code, notes, and snippets.

View tofusoup429's full-sized avatar

bongkow tofusoup429

View GitHub Profile
const months = ["Jan", "Mar", "Mar", "April"];
months.splice(1, 2, "Feb", "Feb2");
console.log(months)
//output: [Jan,Feb,Feb2,April]
const months = ["Jan", "Mar", "Mar", "April"];
months.splice(1, 1, "Feb");
console.log(months)
//output: [Jan,Feb,Mar,April]
const months = ["Jan", "Mar", "Mar", "April"];
let febs = ["Feb", "Feb2", "Feb4"];
let returnedValue = months.splice(1, 3, ...febs);
console.log(returnedValue)
//output: ["Mar","Mar","April"]
const months = ["Jan", "Mar", "Mar", "April"];
months.splice(1, 3, "Feb", "Feb2", "Feb3");
//output: [Jan,Feb,Feb2,Feb3]
import { useEffect } from "react";
import { useDropzone } from "@tofusoup429/dropzone";
const SimpleDropzone = () => {
let {fileName, dndStatus, fileContent, fileSize, initializeStates} = useDropzone("DNDTargetElement");
useEffect(()=>{
if(dndStatus === 'drop'){
console.log(fileContent);
console.log(fileSize); // fileSize may be useful when you want to put restriction on the max size of acceptable file
//do whatever you want with the fileContent
initializeStates()
import {useState, useEffect} from 'react';
type DragAndDropStatus = "none"|"dragover"|"drop"|'dbclick';
interface Returns {
fileName:string,
dndStatus:DragAndDropStatus,
fileContent:ArrayBuffer|string|null,
fileSize:number,
initializeStates:()=>void;
const url:string = "https://...some-server-url.com";
const params:OrganizationUpdate = {
address:"...new address"
}
const updateRequest = await axios.post(url, params)
interface OrganizationUpdate{
address:"...new address"
}
const url:string = "https://...some-server-url.com";
const params:Pick<Organization, "address"|"nationality"> = {
address:"...new address",
nationality:"China"
}
const updateRequest = await axios.post(url, params)
const url:string = "https://...some-server-url.com";
const params:Partial<Organization> = {
address:"...new address"
}
const updateRequest = await axios.post(url, params)