Skip to content

Instantly share code, notes, and snippets.

@kaashyapan
kaashyapan / gist:cb99b6f40699519bfb009c86821d62b9
Created July 3, 2025 19:27 — forked from yuezhu/gist:47b15b4b8e944221861ccf7d7f5868f5
Generate self-signed certificate for HAProxy
# Generate a unique private key (KEY)
sudo openssl genrsa -out mydomain.key 2048
# Generating a Certificate Signing Request (CSR)
sudo openssl req -new -key mydomain.key -out mydomain.csr
# Creating a Self-Signed Certificate (CRT)
openssl x509 -req -days 365 -in mydomain.csr -signkey mydomain.key -out mydomain.crt
# Append KEY and CRT to mydomain.pem
@kaashyapan
kaashyapan / symbol_use.fsx
Created May 12, 2025 00:27 — forked from baronfel/symbol_use.fsx
example of using the F# compiler APIs to get usage of symbols
#r "FSharp.Compiler.Service.dll"
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Text
open FSharp.Compiler.Syntax
module Helpers =
type LetPrivateWalker() =
inherit SyntaxVisitorBase<range>()
@kaashyapan
kaashyapan / generate_ulid.sql
Created March 30, 2025 04:09 — forked from erikhoward/generate_ulid.sql
PostgreSQL function to generate an unique ID of type ULID
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE OR REPLACE FUNCTION generate_ulid() RETURNS uuid
AS $$
SELECT (lpad(to_hex(floor(extract(epoch FROM clock_timestamp()) * 1000)::bigint), 12, '0') || encode(gen_random_bytes(10), 'hex'))::uuid;
$$ LANGUAGE SQL;
@kaashyapan
kaashyapan / DragDropPage.fs
Created October 11, 2024 06:00 — forked from JordanMarr/DragDropPage.fs
Fable bindings for "react-dnd" using HTML5 provider
module DragDropPage
open Feliz
open Fable.React
open Fable.React.Props
open ReactDND
type Language = {
Name: string
}
@kaashyapan
kaashyapan / devguide.md
Last active September 16, 2024 19:07
HTI developer guide

HTI Developer guide

Ref : Key words for use in RFC https://datatracker.ietf.org/doc/html/rfc2119

General advice

  • Rethink best practises from scratch everyday. Rethink from first principles often. We like original thought and common sense.
  • The best code is no code. Next best is less code. Use tools that others have built and tested... if it suits the problem.
  • If you build it, you are responsible for it - forever.
  • Write code that less clever people (future you) can understand.
  • Code -> Test -> Sanity Check and then -> Deliver.
@kaashyapan
kaashyapan / ConstrainedTypesExamples.fsx
Created November 23, 2021 03:00 — forked from swlaschin/ConstrainedTypesExamples.fsx
Examples of creating constrained types in F#
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
// If you want to use the record and DU types, the whole type becomes
// private, which means that you also need to provide:
// * a constructor function ("create").
@kaashyapan
kaashyapan / Evaporate.fs
Created June 12, 2020 06:04
ts2fable file for TTlabs/Evaporate.js
module rec Evaporate
open System
open Fable.Core
open Fable.Core.JS
[<Import("*", "evaporate")>]
let evaporate: Evaporate.IExports = jsNative
[<AllowNullLiteral>]
@kaashyapan
kaashyapan / docker-compose-clean-log.sh
Last active August 9, 2019 17:35
docker compose clean logs for service
#!/bin/bash -e
# https://www.axllent.org/docs/view/clear-docker-log/
CONTAINER=$1
if [[ -z $CONTAINER ]]; then
echo "No container specified"
exit 1
fi
@kaashyapan
kaashyapan / README.md
Created April 11, 2018 13:02 — forked from alexvictoor/README.md
First steps with Flatbuffers in Javascript

This is a tiny sample to help you get up to speed with flatbuffers, javascript flavor. This gist contains a flatbuffers schema, tick.fbs, and the related generated javascript code, tick_generated.js . The git does not include flatbuffers.js itself, you can download it from flatbuffers github repository.
In index.html you will find a simple code fragment showing how to build a flatbuffer "Tick" buffer and how to read a Tick object out of an array of bytes.

If you want to change the model, hence the schema, you need the 'flatbuffers compiler', available for download on flatbuffers release page Then you can use the following command line:

flatc -s tick.fbs --gen-mutable

#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(