Skip to content

Instantly share code, notes, and snippets.

View MaymoonaAlBoloshi's full-sized avatar
😞
The cookies aren't real -- I too have been decieved

Maymoona Al Balushi MaymoonaAlBoloshi

😞
The cookies aren't real -- I too have been decieved
  • Rihal
  • Oman / Batina . Barka
  • 21:49 (UTC +04:00)
View GitHub Profile
@MaymoonaAlBoloshi
MaymoonaAlBoloshi / counter-speed-test.md
Last active June 2, 2023 16:13
python, js in node, go, rust

JS

console.time("counter");
for (let i = 0; i < 1000000000; i++) {}
console.timeEnd("counter");

counter: 933.401ms

Python

// persisting Context of theme
import React from 'react';
import { useState, useEffect, useContext } from 'react';
import { usePersist } from '../hooks';
import { themeType } from '../types';
export interface IThemeProviderProps {
theme: themeType;
themeLoaded: boolean;
import { useState, useEffect } from 'react';
export const usePersist = (key: string, initialValue: any) => {
const [value, setValue] = useState(() => {
const storedValue = localStorage.getItem(key);
return storedValue ? JSON.parse(storedValue) : initialValue;
}
);
useEffect(() => {