Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / README.md
Last active February 19, 2021 08:59

Usage

<WizardProvider steps={4}>
  <Container maxWidth="sm">
    <Paper className={classes.paper}>
      <WizardSlotForm />
    </Paper>
 
# https://taskfile.dev
# sudo snap install task --classic
version: "3"
tasks:
ps: docker-compose ps
up: docker-compose up -d {{- .SERVICE}}

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
@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 = {};
@kachar
kachar / git-crypt-rm-gpg-user.sh
Created April 25, 2022 18:08 — forked from etam/git-crypt-rm-gpg-user.sh
Git-crypt remove user.
#!/usr/bin/env bash
#
# Script to remove GPG user (recipient) with git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.