Skip to content

Instantly share code, notes, and snippets.

View hipertracker's full-sized avatar

Jaroslaw Zabiello hipertracker

View GitHub Profile
@hipertracker
hipertracker / docker-compose.yml
Created November 17, 2023 19:32
hasura on docker dev (fragment)
hasura:
restart: always
image: hasura/graphql-engine:v2.35.1
ports:
- "$HASURA_PORT:8080"
depends_on:
- postgres
environment:
HASURA_GRAPHQL_DATABASE_URL: $HASURA_GRAPHQL_DATABASE_URL
HASURA_GRAPHQL_ENABLE_CONSOLE: $HASURA_GRAPHQL_ENABLE_CONSOLE
@hipertracker
hipertracker / mpg2mp4.py
Last active December 5, 2023 11:03
Convert mpg4 into h264 file
#!/usr/bin/env python
"""
Convert mpg4 into h264 file.
src: https://gist.github.com/hipertracker/695ff1ebdd58a8ea463c67da65d292e2
"""
import os
import sys
from moviepy.editor import VideoFileClip
@hipertracker
hipertracker / python_hasura_subscr.py
Created July 24, 2023 13:01
How to connect from Python to hHasura subscriptions?
import websockets
import asyncio
import logging
import json
logger = logging.getLogger('websockets')
logger.setLevel(logging.DEBUG)
async def user_listener(*, uri: str, query: str, variables: dict = {}, extra_headers: dict = {}, debug: bool = False) -> None:
if debug:
@hipertracker
hipertracker / query.sql
Created June 7, 2023 09:22
Postgres query showing all pending queries
SELECT
usename,
pid,
client_addr,
STATE,
age( clock_timestamp(), query_start ),
query,
query_start,
wait_event_type,
wait_event,
@hipertracker
hipertracker / query.sql
Last active May 25, 2023 08:23
Postgres query to update all sequences to proper next value:
with sequences as (
select *
from (
select table_schema,
table_name,
column_name,
pg_get_serial_sequence(format('%I.%I', table_schema, table_name), column_name) as col_sequence
from information_schema.columns
where table_schema not in ('pg_catalog', 'information_schema')
) t
@hipertracker
hipertracker / App.vue
Created January 3, 2023 15:29
Villus for Vue >=2.7,<3.0 example
<script setup>
import { useClient } from "villus";
import {graphqlOptions} from "@/grapql/client"
//...
useClient(graphqlOptions);
</script>
@hipertracker
hipertracker / boot.ts
Last active December 31, 2022 13:41
Villus with Pinia integration (Vue 3, Quasar 2, TypeScript)
// src/boot.ts
import {createClient, defaultPlugins, handleSubscriptions} from "villus";
import {SubscriptionClient} from "subscriptions-transport-ws";
import {boot} from "quasar/wrappers";
import {OperationOptions} from "subscriptions-transport-ws/dist/client";
const subscriptionClient = new SubscriptionClient(import.meta.env.VITE_HASURA_WEBSOCKET, {});
const subscriptionForwarder = (operation: OperationOptions) => subscriptionClient.request(operation);
import os
def rename_folders(path, dirs, src, dst):
for name in os.listdir(path):
if re.match(dirs, name):
name2 = re.sub(src, dst, name)
filepath1 = path + os.sep + name
filepath2 = path + os.sep + name2
os.rename(filepath1, filepath2)
import itertools
import json
import re
from typing import List
def group(_input):
d = list(itertools.chain(*list(map(lambda x: list(x.items()), _input))))
_s = [[a, [c for _, c in b]] for a, b in itertools.groupby(sorted(d, key=lambda x: x[0]), key=lambda x: x[0])]
return {a: group(b) if all(isinstance(i, dict) for i in b) else list(itertools.chain(*b)) for a, b in _s}
@hipertracker
hipertracker / LocaleSwitcher.vue
Last active May 14, 2021 09:54
Quasar2 + Vue3 + TypeScript - locale switcher component
<template>
<q-btn-dropdown :label="locale" dense flat>
<q-list
v-for="(label, loc) in allowedLocales"
:key="loc"
:class="bgTheme"
dense
>
<q-item
v-close-popup