Skip to content

Instantly share code, notes, and snippets.

View koistya's full-sized avatar
🏠
Working from home

Konstantin Tarkus koistya

🏠
Working from home
View GitHub Profile
@koistya
koistya / main.yml
Last active July 8, 2023 16:46
GitHub Actions Workflows (example)
# GitHub Actions Workflow (example)
# .github/workflows/main.yml
name: CI/CD
on:
push:
branches: [main]
tags:
- "v*"
@koistya
koistya / twitter-auth.md
Last active July 8, 2023 14:57
Twitter auth flow using Firebase Auth (a.k.a. Google Identity Platform)
@koistya
koistya / closure-example.js
Created February 12, 2014 11:49
JavaScript Closure Example
var bind = function(x) {
return function(y) { return x + y; };
}
var plus5 = bind(5);
alert(plus5(3));
@koistya
koistya / modal.html
Last active September 18, 2022 05:36
Modal dialog with a YouTube player
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
@koistya
koistya / show-popup-on-selection.md
Last active July 15, 2022 04:13
Show Material UI menu on text selection
import React from 'react';
import Menu from '@material-ui/core/Menu';
import RootRef from '@material-ui/core/RootRef';
import Typography from '@material-ui/core/Typography';

class MyComponent extends React.Component {
  componentDidMount() {
    document.addEventListener('selectionchange', this.handleSelect);
  }
@koistya
koistya / Sample Docker Web Application.md
Last active July 15, 2022 01:00
Sample Docker-based web application setup

Docker-based Web Application Setup (example)

This is an example of hosting standalone web front-end (web) and data API (api) applications under the same domain via Nginx (acting as a reverse proxy) and Docker, where HTTP requests starting with example.com/graphql and example.com/login/* are being redirected to http://api:3000 and everything else under the same domain is going to be passed to http://web:3000.

Folder Structure

.
├── /nginx.sites/               # Server configuration for each of web apps
├── /nginx.snippets/            # Nginx code snippets
@koistya
koistya / facebook-customer-chat-demo.jsx
Last active July 13, 2022 10:20
Facebook Customer Chat with Next.js
import { useState, Fragment } from 'react'
import Script from 'next/script'
/**
* Facebook Customer Chat demo
*
* @see https://nextjs.org/docs/api-reference/next/script
* @see https://developers.facebook.com/docs/messenger-platform/discovery/customer-chat-plugin/sdk/
* @see https://developers.facebook.com/docs/javascript/reference/FB.init/
*/
@koistya
koistya / App.js
Last active June 8, 2022 09:55
How to add `onscroll` event in ReactJS component
import React from 'react';
let lastScrollY = 0;
let ticking = false;
class App extends React.Component {
componentDidMount() {
window.addEventListener('scroll', this.handleScroll, true);
}
interface PluginConfigTypes {
gtag: {
trackingID: string
}
otherPlugin: {
test: number
}
}
type Config<K extends keyof PluginConfigTypes> = {
/* SPDX-FileCopyrightText: 2021-present Konstantin Tarkus (hello@endtest.dev) */
/* SPDX-License-Identifier: MIT */
import * as React from "react";
import { TextField, Autocomplete } from "@mui/material";
import type { AutocompleteProps } from "@mui/material";
import { projects } from "./data";
type Option = { id: string; label: string };
type ComboboxProps = Omit<