Skip to content

Instantly share code, notes, and snippets.

version: '2'
services:
graphql-engine:
image: hasura/graphql-engine:latest
ports:
- '80:8080'
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://<rds-user>:<rds-password>@<rds-instance>:5432/<rds-dbname>
HASURA_GRAPHQL_ACCESS_KEY: mylongsecretaccesskey
-- Create the function
CREATE FUNCTION insert_deposit()
RETURNS trigger AS $BODY$
DECLARE active_account BOOLEAN;
BEGIN
IF NEW."deposit_amount" <= 0 THEN
RAISE EXCEPTION 'Deposit amount must be greater than 0';
END IF;
SELECT a.is_active INTO active_account FROM "account_savings" a WHERE a.account_no = NEW."account_no";
IF active_account != TRUE THEN
-- the function to call when the trigger is invoked
CREATE FUNCTION trigger_on_note_revision()
RETURNS TRIGGER
LANGUAGE PLPGSQL AS $BODY$
BEGIN
-- Create revision only if node's subject or body columns have changed
IF OLD.title <> NEW.title OR OLD."data" <> NEW."data" THEN
INSERT INTO note_revision (note_id, created_at, title, "data")
VALUES (OLD.id, OLD.updated_at, OLD.title, OLD."data");
NEW.updated_at = now();
version: '2'
services:
timescale:
image: timescale/timescaledb:latest-pg10
restart: always
environment:
POSTGRES_PASSWORD: postgrespassword
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine:
import random
from datetime import datetime
import time
import json
import requests
query = """
mutation {
insert_conditions (objects: [
{
@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.
@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-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 / 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
/* The error handling library */
type ResultError<E> = {
errors: E,
trace?: any
}
type Success<T> = {
value: T
}