- Initialize a project using 'Quick Start' section of Tauri docs
- Install these packages
sudo apt install pkg-config \
libdbus-1-dev \
libgtk-3-dev \
libsoup2.4-dev \
libjavascriptcoregtk-4.0-dev \
libwebkit2gtk-4.0-dev \
librsvg2-dev
use futures::StreamExt; | |
use std::error::Error; | |
use tokio; | |
use tokio::macros::support::Pin; | |
use tokio::prelude::*; | |
use tokio::time::{Duration, Instant}; | |
pub fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let mut multi_threaded_runtime = tokio::runtime::Builder::new() | |
.threaded_scheduler() |
const express = require("express"); | |
const cluster = require("cluster"); | |
const totalCPUs = require("os").cpus().length; | |
const port = 3000; | |
if (cluster.isMaster) { | |
console.log(`Number of CPUs is ${totalCPUs}`); | |
console.log(`Master ${process.pid} is running`); |
/** Continuous windows as in carousel */ | |
export const getWindows = <T>(data: T[], size = 5) => ({ | |
acc: 0, | |
*[Symbol.iterator]() { | |
const length = data.length; | |
const array: T[] = []; | |
for (let i = 0; i < size; ++i) { | |
array.push(data[this.acc + i >= length ? this.acc + i - length : this.acc + i]); | |
} | |
if (this.acc >= length) this.acc = 1; |
import type { Reducer } from 'react' | |
import { Fragment, useReducer } from 'react' | |
interface IReducerState { | |
name: string | |
age: number | |
} | |
type IReducerAction = | |
| { |
import { useEffect, useRef, useState } from 'react' | |
import { minPanelWidth } from '@/constants' | |
import style from './styles.module.less' | |
interface ISplitViewProps { | |
leftChild: React.ReactNode | |
rightChild: React.ReactNode | |
} | |
const SplitView: React.FC<ISplitViewProps> = ({ leftChild, rightChild }) => { |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | |
import "@openzeppelin/contracts/security/Pausable.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract MyToken is ERC20, ERC20Burnable, Pausable, Ownable { | |
constructor() ERC20("MyToken", "MTK") {} |
const INT_MAX = ~(1 << (32 - 1)) | |
const ITSAKINDOFMAGIC = [ | |
0x3, | |
0x6, | |
0x9, | |
0x1d, | |
0x36, | |
0x69, | |
0xa6, // 2 to 8 |
// https://docs.metamask.io/guide/ethereum-provider.html | |
interface Nothing {} | |
type Union<T, U> = T | (U & Nothing); | |
interface ConnectInfo { | |
chainId: string; | |
} | |
interface ProviderRpcError extends Error { |
sudo apt install pkg-config \
libdbus-1-dev \
libgtk-3-dev \
libsoup2.4-dev \
libjavascriptcoregtk-4.0-dev \
libwebkit2gtk-4.0-dev \
librsvg2-dev
import { EffectCallback, useCallback, useEffect, useMemo, useRef } from "react"; | |
export const usePrevious = <T = any>(value: T, initialValue: T) => { | |
const ref = useRef<T>(initialValue); | |
useEffect(() => ((ref.current = value), undefined)); | |
return ref.current; | |
}; | |
export const useEffectWithPrevious = <K extends string, V extends unknown>(effectHook: (changedDeps: Partial<Record<K, [current: V, previous?: V]>>) => EffectCallback, dependencies: Record<K, V>) => { | |
let initialValue: typeof dependencies | undefined; |