Skip to content

Instantly share code, notes, and snippets.

View RealPeha's full-sized avatar
🇺🇦
Comic Sans does not disappoint people. People disappoint people

Stas RealPeha

🇺🇦
Comic Sans does not disappoint people. People disappoint people
View GitHub Profile
const promiseCache = new Map();
const responseCache = new Map();
const buildCache = <TData>(cacheKey: string, cache: Map<string, TData>) => ({
forget: () => cache.delete(cacheKey),
get: () => cache.get(cacheKey),
set: (data: TData) => cache.set(cacheKey, data),
});
const getCache = <TData>(cacheKey: string) => {
const { session, Stage } = require('telegraf')
const sceneSessionKey = 'sceneSession'
const scene = /* new Scene() */;
const stage = new Stage([scene], { sessionName: sceneSessionKey })
const emptySessionScene = {
session: { __scenes: {} },
expires: null
}
@RealPeha
RealPeha / Multicall.sol
Created August 19, 2021 13:56
Multicall
pragma solidity ^0.8.0;
interface IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
}
pragma solidity ^0.8.0;
interface IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function balanceOf(address account) external view returns (uint256);
}
interface IPancakePair {
@RealPeha
RealPeha / React Native setup without Expo, Android Studio and Android Emulator.md
Last active January 26, 2021 11:01
React Native setup without Expo, Android Studio and Android Emulator
  1. Install Android SDK command line tools only: https://developer.android.com/studio/#command-tools
  2. Extract .zip to /opt/android/cmdline-tools/tools/
  3. sudo chown -R $(whoami) /opt/android/
  4. For API Level 26: /opt/android/cmdline-tools/tools/bin/sdkmanager "platforms;android-26" "build-tools;26.0.3" "add-ons;addon-google_apis-google-24"
  5. npm install -g react-native-cli
  6. react-native init ReactNativeProject
  7. cd ReactNativeProject
  8. Plug in your android phone
  9. yarn android / npm run android / react-native run-android
  10. yarn start / npm run start
@RealPeha
RealPeha / sceneBug.js
Last active February 7, 2020 14:50
Telegraf bug
const Telegraf = require('telegraf')
const session = require('telegraf/session')
const Stage = require('telegraf/stage')
const Scene = require('telegraf/scenes/base')
const mongoose = require('mongoose')
require('dotenv').config()
const scheme = new mongoose.Schema({
key: String,
session: {},