Skip to content

Instantly share code, notes, and snippets.

View sergeyt's full-sized avatar
:electron:
There is a time for everything, a time to search and, a time to give up...

Sergey Todyshev sergeyt

:electron:
There is a time for everything, a time to search and, a time to give up...
View GitHub Profile
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y install docker-ce
sudo service docker restart
sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
@sergeyt
sergeyt / mapObject.ts
Created February 27, 2019 07:39
generic map object
function mapObject<K extends keyof any, T, TResult>(obj: Record<K, T>, makeResult: (val: T, key?: K) => TResult): Record<K, TResult> {
return (Object.keys(eventMap) as K[]).reduce(
(acc, key) => ({
...acc,
[key]: makeResult(obj[key]),
}),
{} as Record<K, TResult>
);
}
@sergeyt
sergeyt / tcp2http.go
Created February 6, 2020 01:36
Quick HTTP to TCP workaround
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"net/http"
@sergeyt
sergeyt / resume.json
Created January 10, 2021 05:57
SergeyT's JSON resume
{
"basics": {
"name": "Sergey Todyshev",
"label": "Programmer, simplifier, optimizer",
"summary": "I'm a software engineer with 18 years of professional experience. I have expert knowledge in C#, TypeScript and many other languages I use to develop amazing products. I am proactive doer, simplifier and optimizer. Efficiency, readability and simplicity matters for me.",
"picture": "https://avatars3.githubusercontent.com/u/190322?s=460&u=b87d4e8a9c8b452b1b96f1a6dc615865909e901f&v=4",
"email": "[email protected]",
"phone": "+79132017700",
"website": "https://tsvbits.com",
"profiles": [
@sergeyt
sergeyt / multidisk-drive.ts
Created August 5, 2021 18:08
Drive abstraction
export type ItemType = "file" | "folder";
export interface Item {
type: ItemType;
id: string;
name: string;
path: string;
driveId: string;
}
@sergeyt
sergeyt / UploadcareDrive.ts
Created August 5, 2021 18:12
UploadcareDrive implementation
import axios from "axios";
import { Drive, File, Item } from "../types";
import { checkResponseOK } from "./utils";
type Options = {
type: string;
id: string;
name: string;
publicKey: string;
secretKey: string;
@sergeyt
sergeyt / DropboxDrive.ts
Created August 5, 2021 18:14
DropboxDrive implementation
import axios from "axios";
import trimStart from "lodash/trimStart";
import { Drive, Item, File } from "../types";
import { checkResponseOK, downloadBlob, trimPrefix } from "./utils";
type Options = {
type: string;
id: string;
name: string;
accessToken: string;
@sergeyt
sergeyt / MultidiskHomePage.ts
Created August 5, 2021 18:16
multidisk home page
import isEmpty from "lodash/isEmpty";
import useSWR from "swr";
import { getDrives } from "../core/store";
import Loader from "../components/Loader";
import Placeholder from "../components/Placeholder";
import DriveList from "../components/DriveList";
export default function Home() {
const { data: drives } = useSWR("/drives", getDrives);
if (!drives) {
@sergeyt
sergeyt / MultidiskDriveList.ts
Created August 5, 2021 18:18
multidisk drive list
import Link from "next/link";
import ListItem from "@material-ui/core/ListItem";
import ListItemAvatar from "@material-ui/core/ListItemAvatar";
import Avatar from "@material-ui/core/Avatar";
import { SiDropbox as DropboxIcon } from "react-icons/si";
import { FiHardDrive as DriveIcon } from "react-icons/fi";
import ListItemText from "@material-ui/core/ListItemText";
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
import List from "@material-ui/core/List";
import { Drive } from "../types";
@sergeyt
sergeyt / MultidiskDriveViewPage.ts
Created August 5, 2021 18:23
multidisk drive view page
import { useRouter } from "next/router";
import useSWR from "swr";
import { Box } from "@material-ui/core";
import { getDrive } from "../../core/store";
import Loader from "../../components/Loader";
import ItemList from "../../components/ItemList";
import Uploader from "../../components/Uploader";
export default function DriveView() {
const router = useRouter();