Skip to content

Instantly share code, notes, and snippets.

@kocisov
kocisov / urql.ts
Created August 20, 2021 15:04
Urql client with @n1ru4l/live-query + json patch (over WS or SSE)
import { applyLiveQueryJSONPatch } from "@n1ru4l/graphql-live-query-patch-json-patch";
import {
applyAsyncIterableIteratorToSink,
makeAsyncIterableIteratorFromSink,
} from "@n1ru4l/push-pull-async-iterable-iterator";
import { createClient as createWSClient } from "graphql-ws";
import {
cacheExchange,
createClient,
dedupExchange,
@kocisov
kocisov / dependencies.json
Created February 28, 2020 23:25
ESLint config /> Next
{
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-config-react-app": "^5.2.0",
"eslint-plugin-flowtype": "^4.6.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
@kocisov
kocisov / keybase.md
Created September 13, 2019 11:47
keybase

Keybase proof

I hereby claim:

  • I am kocisov on github.
  • I am koci (https://keybase.io/koci) on keybase.
  • I have a public key ASCgJvc2MoA-J-xC2mRdkQMM2sOvndgLZNXMgitl-fFFgAo

To claim this, I am signing this object:

// main process then
const { app } = require('electron')
const fs = require('fs')
const directory = app.getPath('home') // /home folder on OS X
const cacheDirectory = `${directory}/twitch-bot-cache` // /home/twitch-bot-cache/
const cacheDataFile = `${cacheDirectory}/data.json` // /home/twitch-bot-cache/data.json
// "cached now" object
let caches = {}
@kocisov
kocisov / index.js
Created August 29, 2018 12:05
Hidden message of this gist is: Alec where is my green sword?
import React, { PureComponent } from 'react'
export default class extends PureComponent {
state = {
killCount: 0,
ytLink: ''
}
handleChange = (event) => {
this.setState({
@kocisov
kocisov / Atom-Like.md
Created August 4, 2018 19:29
Atom like VSCode
@kocisov
kocisov / index.js
Created July 17, 2018 20:19
Sup #2
class App extends Component {
// return false = COMPONENT_SHOULD_NOT_UPDATE!
// return true = COMPONENT_SHOULD_UPDATE!
shouldComponentUpdate(nextProps, nextState) {
// PureComponent do this for you, not for everything tho
return this.props.value != nextProps.value;
}
render() {
return (
import * as React from 'react'
class Button extends React.PureComponent {
render() {
return (
<button onClick={this.props.onClick}>{this.props.text}</button>
}
}
}
@kocisov
kocisov / keybase.md
Created July 16, 2018 14:47
keybase.md

Keybase proof

I hereby claim:

  • I am kocisov on github.
  • I am koci (https://keybase.io/koci) on keybase.
  • I have a public key ASBXHD4BBI1gweZOkEPh2gPUVO0fvd9JkFJGrVmeYCcWlgo

To claim this, I am signing this object:

@kocisov
kocisov / download.js
Created June 9, 2018 16:00
Download in JavaScript
function download(filename, text) {
// create link element
const element = document.createElement('a')
// set link href to our text
element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`)
// set attribute download
element.setAttribute('download', filename)