Skip to content

Instantly share code, notes, and snippets.

View makarovas's full-sized avatar
:dependabot:

Makarov Aleks makarovas

:dependabot:
View GitHub Profile
@makarovas
makarovas / solidity
Created February 28, 2023 18:14
Solidity uniswap flashloan boat
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
contract FlashLoanBot {
address constant UNISWAP_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
address constant USDC_ADDRESS = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address constant USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
import {Response as TotalUsersResponse} from ''
import {Response as WeeklyNumberOfSignupsByCountryResponse} from ''
import {Response as WeeklySignupsResponse} from ''
import {BarElement, CategoryScale, Chart as ChartJS, ChartData, LinearScale, Tooltip} from 'chart.js'
import ChartDataLabels from 'chartjs-plugin-datalabels'
import cn from 'classnames'
import {useOutsideAlerter} from 'common/hooks/useClickOutside'
import {Icon} from 'common/Icon'
import dayjs from 'dayjs'
import getConfig from 'next/config'
@makarovas
makarovas / chartjs-plugin-datalabels, react-chartjs-2, Next.js, React, Typescript, react-simple-maps
Last active February 12, 2023 08:06
Map component (Typescript, React, Next.js, react-simple-maps )
import {AuthRequired} from 'common/AuthRequired'
import {memo, MouseEvent, useCallback, useState} from 'react'
import {ComposableMap, Geographies as RSMGeographies, Geography, Marker, ZoomableGroup} from 'react-simple-maps'
import {DoughnutChart} from './DoughnutChart'
import {useData} from './hooks'
import {StatsButton} from './StatsButton'
import {Tooltip} from './Tooltip'
import {A2CountriesUnion, Country, Geo, TooltipDirection} from './types'
const geoUrl = 'https://secret'
@makarovas
makarovas / form.js
Created February 21, 2019 14:30
Async form validation with react hooks
// https://codesandbox.io/s/x964kxp2vo?from-embed
import React, { Component, useState, useEffect, useRef } from "react";
export const useField = (
name,
form,
@makarovas
makarovas / simpleFormValidation.js
Created January 31, 2019 15:35
React form validation
import React from 'react';
import './style.css';
class RegisterForm extends React.Component {
constructor() {
super();
this.state = {
fields: {},
.container {
display: grid;
grid-gap: 2px;
height: 100vh;
grid-template-rows: 1fr 1fr;
padding-bottom: 20px;
grid-auto-rows: 1fr 2fr;
grid-template-columns: repeat(auto-fill, minmax(100px, auto));
}
@makarovas
makarovas / index-0-non-debounced.js
Created November 8, 2018 15:44 — forked from elijahmanor/index-0-non-debounced.js
React Debouncing Events
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {
Fetch
https://github.github.io/fetch/
This documents the polyfillable parts of the WHATWG fetch spec.
Usage synopsis (use the argument links to find out more):
fetch(url, options).then(function(response) {
var jsonData = require('../../file.json');
class blah extends React.Component {
render(){
var data;
function loadJSON(jsonfile, callback) {
var jsonObj = new XMLHttpRequest();

Принципы работы jsonp

Скопировать все файлы в одну папку.

Установить http-server, если ещё не установлен:

npm install -g http-server

Запустить сервер: