Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Konstantin Tarkus koistya

🏠
Working from home
Block or report user

Report or block koistya

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@koistya
koistya / example.js
Last active Jul 15, 2019
useScrollY() and useInnerWidth(nodeRef) React hooks
View example.js
import React from 'react';
import { useScrollY, useInnerWidth } from './hooks';
function Example(props) {
const nodeRef = React.useRef();
const scrollY = useScrollY();
const innerWidth = useInnerWidth(nodeRef);
return (
<pre ref={nodeRef} {...props}>
@koistya
koistya / CustomerChat.js
Created Mar 18, 2019
Facebook Customer Chat React.js component https://medium.com/p/5b7c21343048
View CustomerChat.js
import React from 'react';
import { fb } from '../utils';
import { ConfigContext } from '../hooks';
class CustomerChat extends React.PureComponent {
componentDidMount() {
this.timeout = setTimeout(() => {
fb(FB => this.timeout && FB.XFBML.parse());
}, 2000);
}
@koistya
koistya / fb.js
Created Mar 18, 2019
Lazy loader for Facebook JavaScript SDK / Customer Chat SDK https://medium.com/p/5b7c21343048/
View fb.js
import loadScript from 'load-script';
let initialized = false;
let queue = [];
export function fb(callback) {
if if (initialized) {
callback(window.FB);
} else {
queue.push(callback);
@koistya
koistya / docker-compose.yml
Last active Feb 28, 2019
Shadowsocks Proxy Server on DigitalOcean https://m.do.co/c/eef302dbae9f
View docker-compose.yml
version: "3"
services:
shadowsocks:
image: shadowsocks/shadowsocks-libev:edge
ports:
- "8388:8388"
environment:
- METHOD=aes-256-cfb
- PASSWORD=XXX
@koistya
koistya / show-popup-on-selection.md
Last active Aug 27, 2018
Show Material UI menu on text selection
View show-popup-on-selection.md
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 / 0x4AC7C6CF.asc
Last active Aug 16, 2018
My GPG Key (hello@tarkus.me)
View 0x4AC7C6CF.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFt1MBkBEADHMdrirvRavPbX74YwnYLDKBYF+TKG+2S2Yzrqe7reAXbwU4+l
Rf2CWWfaNuyNg5sInjWs9jdzgrwOx3faJZBl/2TnabY7xMutgKTkh3hXF6Oy2OEu
C+stYR4vzQHLrXGMH0iCjhxICh29On7Swk1OsY7R+4B1gmcSZ2FqyBBK4feM0Yb1
LJJ/K+xCJQ3KkoUnogA/n7utHDWRjTIdZsObeVxBln0D4fagPMPmDg0Jlup/THfk
SLKqG0FBCVS6dW8GS+GwIib3OzXeOpD3va99qvSg77gZTtf9LVtlwbYmgT0AUh3Z
a9ewxdup3yf/sIsBtg2K1FpKqp0gOtnafHy46zbQ8jkzNA58sVPyXsMIdPx3THV5
M4ttIv0ateoJ9NWedk68eM6Ysg5lPaJ9Oxs5A7s1ojN5Y15vNNEnu0biF/67w59x
97iSvuywQv1qoZWeN8KzsIOr5kCs48qUMauknuijMBph4nPIGbSapKs50B3HTaZZ
@koistya
koistya / deploy.sh
Last active Aug 16, 2018
Deploy a specific Git commit to Firebase using Cloud Build. Example: ./deploy.sh $COMMIT_SHA
View deploy.sh
#!/bin/bash
COMMIT_SHA=$1
PROJECT=bay6-next
REPO_NAME=github-<user/organisation>-<repo>
BUILD_BUCKET=gs://builds.example.com
TOKEN=$(gcloud auth application-default print-access-token)
curl https://cloudbuild.googleapis.com/v1/projects/${PROJECT}/builds \
--request POST \
View proxy.pac
function FindProxyForURL(url, host){
return "PROXY 127.0.0.1:1081; DIRECT";
}
@koistya
koistya / auth.js
Last active Dec 17, 2017
Doing common JavaScript tasks without Redux https://medium.com/p/f23ffbbb02ae
View auth.js
import '@firebase/auth';
import firebase from '@firebase/app';
const callbacks = new Set();
export default {
signIn() {
const provider = new firebase.auth.FacebookAuthProvider();
return firebase.auth().signInWithPopup(provider);
},
@koistya
koistya / LoginDialog.js
Last active Dec 17, 2017
Doing common JavaScript tasks without Redux https://medium.com/p/f23ffbbb02ae
View LoginDialog.js
import auth from '../auth';
const defaultState = { error: null, loading: false };
class LoginDialog extends React.Component {
state = { ...defaultState };
signIn = event => {
this.setState({ ...defaultState, loading: true });
auth
You can’t perform that action at this time.