Skip to content

Instantly share code, notes, and snippets.

View tofusoup429's full-sized avatar

bongkow tofusoup429

View GitHub Profile
let Apple:Organization = {
id:"AAPL",
name:"Apple",
address:"1 Apple Park Way Cupertino, California",
type:"Corporation",
nationality:"US"
}
interface Organization{
id:number,
name:string,
address:string,
type:string,
nationality:string
}
import {useState, useEffect} from 'react';
type DragAndDropStatus = "none"|"dragover"|"drop"|'dbclick';
interface Returns {
fileName:string,
dndStatus:DragAndDropStatus,
fileContent:ArrayBuffer|string|null,
fileSize:number,
dropzoneId:string,
initializeStates:()=>void;
import {useDropzone} from '@tofusoup429/dropzone';
import { useEffect } from 'react';
const FolderImage = () => {
return(
<svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" enableBackground="new 0 0 48 48">
<path fill="#FFA000" d="M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z"/>
<path fill="#FFCA28" d="M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z"/>
</svg>
)
let animal = ['dog','cat','wolf','tom'];
animal.splice(3,1,"you"); //replacing the 3-indexed element with "you"
console.log(animal);
//let animal = ['dog','cat','wolf','you'];
//ver 1.0.7
export const excelDateToJSDate = (date:number):Date => {
//takes a number and return javascript Date object
return new Date(Math.round((date - 25569)*86400*1000));
}
export const jsDateToExcelDate = (date:Date):number => {
//takes javascript a Date object to an excel number
let returnDateTime = 25569.0 + ((date.getTime()-(date.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24));
return Math.floor(returnDateTime)
{
"compilerOptions": {
"outDir": "lib/esm",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom", "es2016", "es2017"],
"jsx": "react",
"declaration": true,
"moduleResolution": "node",
"noUnusedLocals": true,
{
"name": "@tofusoup429/react-component-module-frame",
"version": "0.0.10",
"description": "React module frame",
"homepage": "https://github.com/tofusoup429/react-component-module-frame",
"main": "index.ts",
"license": "MIT",
"scripts": {
"build": "tsc"
},
@tofusoup429
tofusoup429 / erc20.sol
Last active April 17, 2021 23:12
erc20 token smart contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.0;
library SafeMath { // Only relevant functions
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
export const validateDateYYYYMMDD = (_date:string)=>{
try{
_date = _date.replace(/-/,"").replace(/\D/,"");
if(_date.length === 8){
let jsdate = new Date(_date.slice(0,4)+'-'+(("0"+_date.slice(4,6)).toString()).slice(-2)+'-'+(("0"+_date.slice(6,8)).toString()).slice(-2)).toISOString();
console.log('validateDateYYYYMMDD', jsdate.slice(0,10));
let month:string = jsdate.slice(0,10).match(/\d{4}-(\d{2})-\d{2}/)![1];
return parseInt(month) === parseInt((("0" + _date.slice(4, 6)).toString()).slice(-2));
}else{
return false