Skip to content

Instantly share code, notes, and snippets.

@kachar
kachar / xdLocalStorage.js
Created February 13, 2021 11:52
cross-domain-local-storage ES6
/**
* Created by dagan on 07/04/2014.
* https://github.com/ofirdagan/cross-domain-local-storage
*/
const MESSAGE_NAMESPACE = "cross-domain-local-message";
/* global console */
export const xdLocalStorage = () => {
const requests = {};

After the March update 1.55.0 of VSCode I've experienced a misconfiguration in golang extension

Failed to run '/snap/bin/go env. The config change may not be applied correctly.

Golang is installed locally via snap so I had to change the following paths in vscode settings.json

go env GOPATH
go env GOROOT
# https://taskfile.dev
# sudo snap install task --classic
version: "3"
tasks:
ps: docker-compose ps
up: docker-compose up -d {{- .SERVICE}}
@kachar
kachar / README.md
Last active February 19, 2021 08:59

Usage

<WizardProvider steps={4}>
  <Container maxWidth="sm">
    <Paper className={classes.paper}>
      <WizardSlotForm />
    </Paper>
 
@kachar
kachar / Dockerfile
Created February 16, 2021 15:13
Production ready multi-stage Next.js docker container based on node:14-alpine (avg size 250mb)
# Build target dependencies #
###########################
FROM node:14-alpine AS base
WORKDIR /app
ARG NODE_ENV=production
ENV PATH=/app/node_modules/.bin:$PATH \
NODE_ENV="$NODE_ENV"
COPY package.json yarn.lock /app/
EXPOSE 3040
@kachar
kachar / htmlentity.js
Last active January 6, 2021 12:59 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@kachar
kachar / psql_useful_stat_queries.sql
Created November 24, 2020 15:20 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@kachar
kachar / create_certificates.sh
Created October 31, 2020 20:15 — forked from OnnoGabriel/create_certificates.sh
Create self-signed CA certificates and certificates for local domains
#!/bin/bash
# Creates self-signed CA certificates and certificates for local domains.
#
# Prompts for a local domain name (e.g. my-app.localhost) and creates all
# necessary certificates.
#
# Next steps:
# Copy the certificates (e.g. my-app.localhost.crt and my-app.localhost.key) to
# your service (Nginx, Apache, ...) and configure it.
@kachar
kachar / RouteIndicator.tsx
Last active March 8, 2020 23:51 — forked from jaydenseric/RouteIndicator.js
A route change indicator for Next.js using React hooks.
import cn from 'classnames'
import Router from 'next/router'
import React, { useState } from 'react'
const DONE_DURATION = 250
export default function RouteIndicator() {
const [loading, setLoading] = useState(false)
const [timeoutId, setTimeoutId] = useState<ReturnType<typeof setTimeout>>()
@kachar
kachar / actions.js
Created July 1, 2019 21:30
actions.js
import React from 'react'
import _ from 'lodash'
import PropTypes from 'prop-types'
import lang from 'lang'
import Form from 'common/components/form'
import './actions.scss'
export default class EmotionWordActions extends Form {