Skip to content

Instantly share code, notes, and snippets.

@ecthiender
ecthiender / example_reader.hs
Created July 21, 2021 07:40
Example of how to use Reader monad
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Control.Applicative (liftA2)
import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, ask,
runReaderT)
{- | Let's say we have a deeply nested call stack. There are many functions
calling other functions.
@ecthiender
ecthiender / doom_emacs_for_haskell.md
Last active October 25, 2023 05:33
Step by step instructions to setup doom emacs for Haskell + Haskell Language Server (LSP)

Install doom emacs

git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
cd ~/.emacs.d
bin/doom install

Optional

@ecthiender
ecthiender / screen_record_with_audio.sh
Last active November 9, 2020 07:36
Linux & ffmpeg: One-liner to record your screen along with audio
#!/bin/bash
set -e
resolution="$1"
if [[ -z "$resolution" ]]; then
resolution="1366x768"
echo "[WARN] No resolution passed. Defaulting to $resolution."
fi
outfile="$2"
/* The error handling library */
type ResultError<E> = {
errors: E,
trace?: any
}
type Success<T> = {
value: T
}
@ecthiender
ecthiender / health_check_harddisk.md
Created September 4, 2019 11:23
Perform health checks on your hard disk (Linux)

Perform health checks on your hard disk (Linux)

Check bad sectors

program: badblocks

sudo badblocks -v /dev/sdxy > badsectors.txt
@ecthiender
ecthiender / setup-gke-registry-hasura.md
Last active August 6, 2020 10:10
Setup an google cloud image registry with hasura kubernetes cluster on GKE

Setup Google cloud image registry with Hasura k8s platform on GKE

This guide helps you to setup the image registry configuration on a multi-node Hasura installation on GKE.

This is required in multi-node setups, because the sshd agent (which builds the docker images on git push) needs to push the image to an external image registry service, so that the image is available on all the nodes.

Pre-requisite

  1. gcloud CLI (https://cloud.google.com/sdk/install)
  2. kubectl (https://kubernetes.io/docs/tasks/tools/install-kubectl/)
@ecthiender
ecthiender / curl_introspection.sh
Created April 5, 2019 11:44
graphql introspection as curl
curl 'http://localhost:8080/v1alpha1/graphql' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://localhost:8080/console/api-explorer' -H 'content-type: application/json' -H 'x-hasura-role: admin' -H 'Origin: http://localhost:8080' -H 'DNT: 1' -H 'Connection: keep-alive' --data '{"query":"\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n
@ecthiender
ecthiender / setup-external-registry-hasura.md
Last active March 14, 2019 12:02
Setup an external private image registry with hasura kubernetes cluster

Setup an external private image registry, with Hasura k8s platform

If you are trying to install Hasura on a multi-node Kubernetes cluster and wondering how to setup the image registry, this is the guide for you.

Let us see how to setup a private image registry on a multi-node Hasura k8s platform cluster. This is required in multi-node setups, because the sshd agent (which builds the docker images on git push) needs to push the image to an external image registry service, so that the image is available on all the nodes.

NOTE: Do these steps before installing Hasura on the Kuberentes cluster.

Setup a private registry

  1. Setup an account in your private registry.
import random
from datetime import datetime
import time
import json
import requests
query = """
mutation {
insert_conditions (objects: [
{
version: '2'
services:
timescale:
image: timescale/timescaledb:latest-pg10
restart: always
environment:
POSTGRES_PASSWORD: postgrespassword
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine: