Skip to content

Instantly share code, notes, and snippets.

View shahidhk's full-sized avatar

Shahidh K Muhammed shahidhk

View GitHub Profile
@shahidhk
shahidhk / introspection.json
Created February 12, 2024 15:43
GraphQL Introspection JSON
{"operationName":"IntrospectionQuery","query":"\n query IntrospectionQuery {\n __schema {\n \n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n \n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n \n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n
@shahidhk
shahidhk / chinook_postgres.sql
Created March 25, 2020 11:57
Chinook database as a PostgreSQL file
This file has been truncated, but you can view the full file.
-- -- /*******************************************************************************
-- -- Chinook Database - Version 1.4
-- -- Script: Chinook_PostgreSql.sql
-- -- Description: Creates and populates the Chinook database.
-- -- DB Server: PostgreSql
-- -- Author: Luis Rocha
-- -- License: http://www.codeplex.com/ChinookDatabase/license
-- -- Modified By: John Atten
@shahidhk
shahidhk / sheet_to_calendar.gs
Last active January 21, 2020 17:12
Google Apps Script to take information from Google Sheet and create events in Google Calendar
// Sheet structure:
// Columns:
// event_id, city, start, end, location, title, notes
// leave event_id empty, it will be updated when the script runs
var
COL_EVENT_ID = 0, COL_EVENT_ID_ADDRESS = 'A',
COL_CITY = 1,
COL_START = 2,
COL_END = 3,
COL_LOCATION = 4,
@shahidhk
shahidhk / diff.go
Created October 14, 2019 04:53
Utility function to print YAML diff
// usage:
// DiffYaml(d2, d1, os.Stdout)
package diff
import (
"fmt"
"io"
"strings"
"github.com/aryann/difflib"

Schema for Postgres postgres:11

create table test_table_1 (
time timestamptz default now(),
id int,
name text
);
create table test_table_2 (
time timestamptz default now(),
id int,
@shahidhk
shahidhk / process_pg_dump.sh
Last active March 26, 2019 10:47
Script to clean up pg_dump to keep just the SQL statements - for use with Hasura migrations
#! /usr/bin/env bash
#
# Usage: ./process_pg_dump.sh <file-name.sql>
#
if [ "$#" -ne 1 ]; then
echo "Invalid usage: ./process_pg_dump.sh <file-name.sql>"
fi
filename=$1
query getFirst10Pokemons {
pokemons(first: 10) {
name
}
}
Operator Postgres equivalent Description
_contains @> Does the column value contains these key-value pairs at top-level?
_contained_in <@ Is the column value contained in this JSON object at top-level?
_has_key ? Does the string exist as a top-level key within the JSON value?
_has_keys_any ?| Do any of these array strings exist as top-level keys?
_has_keys_all ?&amp; Do all of these array strings exist as top-level keys?
#!/usr/bin/env bash
# wait for a program to start listening on a PORT ($1)
wait_for_port() {
local PORT=$1
echo "waiting for $PORT"
for i in `seq 1 60`;
do
nc -z localhost $PORT && echo "port $PORT is ready" && return
echo -n .
CREATE VIEW online_users AS
SELECT count(*) AS count
FROM "user"
WHERE ("user".last_seen_at > (now() - '00:00:15'::interval));