Skip to content

Instantly share code, notes, and snippets.

View shahidhk's full-sized avatar

Shahidh K Muhammed shahidhk

View GitHub Profile
# Query
mutation {
  update_product(
    where: {
      uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
    },
    _delete_key: {
      spec: "driver_units"
 }
# Query
mutation updateProductSpec ($data: jsonb) {
  update_product(
    where: {
      uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
    },
    _append: { spec: $data }
  ) {
 affected_rows
# Query
mutation updateProductSpec ($data: jsonb) {
  update_product(
    where: {
      uuid: {_eq: "09cf633b-a34c-45cc-ad59-3273e3ad65f3"}
    },
    _append: { spec: $data }
  ) {
 affected_rows
# Query
mutation insertProduct($spec: jsonb) {
  insert_product(objects:[{
    name: "Skullcandy Ink'd Headset with mic",
    category: "Earphones",
    description: "Invest in these Skullcandy Ink'd earphones and enjoy listening to music in a high-quality audio reproduction. It comes with Supreme Sound technology that ensures deep and powerful bass to take your music to a new level",
    price: 799,
    spec: $spec
 }]) {
@shahidhk
shahidhk / product_table_with_jsonb.sql
Last active August 3, 2021 22:48
An indicative product table with JSONB column for specs
CREATE TABLE product (
uuid UUID NOT NULL DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
category TEXT NOT NULL,
description TEXT NOT NULL,
price NUMERIC NOT NULL,
spec JSONB NOT NULL,
PRIMARY KEY (uuid)
);
# Delete all docker images from the machine
docker system prune --all
#!/usr/bin/python
import socket
import time
count = 0
holdSockets = []
from random import choice
from string import ascii_lowercase
@shahidhk
shahidhk / kube_prompt.zsh
Created March 1, 2018 18:26
ZSH function to show current Kuberentes context on the right prompt (just add this it your .zshrc)
kube_prompt()
{
kubectl_current_context=$(kubectl config current-context)
kubectl_prompt="( \u2388 $kubectl_current_context )"
echo $kubectl_prompt
}
RPROMPT='%F{81}$(kube_prompt)'
FROM golang:1.8.5-jessie as builder
# install xz
RUN apt-get update && apt-get install -y \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# install UPX
ADD https://github.com/upx/upx/releases/download/v3.94/upx-3.94-amd64_linux.tar.xz /usr/local
RUN xz -d -c /usr/local/upx-3.94-amd64_linux.tar.xz | \
tar -xOf - upx-3.94-amd64_linux/upx > /bin/upx && \
chmod a+x /bin/upx
FROM golang:1.8.5-jessie
# install dep
RUN go get github.com/golang/dep/cmd/dep
# create a working directory
WORKDIR /go/src/app
# add Gopkg.toml and Gopkg.lock
ADD Gopkg.toml Gopkg.toml
ADD Gopkg.lock Gopkg.lock
# install packages
# --vendor-only is used to restrict dep from scanning source code