This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPalindrome(input){ | |
if(input.length == 0 || input.length ==1 ){ | |
return true | |
} | |
if(input.charAt(0) == input.charAt(input.length -1 )){ | |
return isPalindrome(input.substring(1, input.length -1) | |
} | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DecimalToBinary{ | |
public state void main(String[] args){ | |
String binary = findBinary(233, ""); | |
} | |
public state String findBinary(int decimal, String result){ | |
if(decimal == 0){ | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = []; | |
const error = null; | |
const load = async () => { | |
try{ | |
let response = await fetch('') | |
if(!data.ok){ | |
throw Error('error message') | |
} | |
data = await response.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="spin"></div> | |
</template> | |
<style> | |
.spin{ | |
display: block; | |
width: 40px; | |
height: 40px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [1, 2, 3, 4, 5, 6, 7]; | |
function inBetween(a,b){ | |
return function(num){ | |
return (num >=a && num <= b) | |
} | |
} | |
function inArray(arr){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react" | |
const defaultFormData = { | |
title: "", | |
body: "" | |
} | |
export default function Form() { | |
const [formData, setFormData] = useState(defaultFormData) | |
const { title, body } = formData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface childProps { | |
name: string; | |
} | |
export const Child = (props: childProps) => <></> | |
export const ChildWithFC: React.FC<childProps> = (props) => <></> | |
//Notes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as esbuild from 'esbuild-wasm' | |
import axios from 'axios' | |
export const unpkgPathPlugin = () => { | |
return { | |
name: 'unpkg-path-plugin', | |
setup(build: esbuild.PluginBuild) { | |
build.onResolve({ filter: /.*/ }, async (args) => { | |
console.log('onResolve', args) | |
if(args.path === 'index.js'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cons = (x, y) => (m) => m(x, y) | |
const car = (z) => z((p, q) => p) | |
const cdr = (z) => z((p, q) => q) | |
const someLinkedList = cons(1, cons(2, cons(3 , null))) | |
// iterating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react"; | |
const useLocalStorage = (key: string, initialValue: any) => { | |
const isServer = typeof window === "undefined"; | |
const [value, setValue] = useState(() => { | |
if (isServer) { | |
return initialValue; | |
} |