Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / gist:0f787af108607a309c1c0858d87b34a2
Last active August 25, 2022 07:48 — forked from svilensabev/gist:713584cd30133969f395d1333563031e
PostgreSQL timeslots, rrulesets and booking timetables
-- First create schema/data data for tests
DROP TABLE api.slot CASCADE;
CREATE TABLE api.slot (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name TEXT,
latitude NUMERIC,
longitude NUMERIC,
geog geography(Point, 4326) DEFAULT NULL
@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>>()
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test case | Fancytree</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script>