Skip to content

Instantly share code, notes, and snippets.

import { Plugin } from "graphile-build";
import {
PgAttribute,
PgClass,
PgIntrospectionResultsByKind,
} from "graphile-build-pg";
import {
embed,
gql,
makeExtendSchemaPlugin,
@hos
hos / codes.json
Created April 23, 2021 08:48
Response codes of Ameria Bank REST API. Maybe also can be used for ARCA response codes.
{
"0-1": {
"description": "Processing center response timeout",
"message": "sv_unavailable"
},
"0-100": {
"description": "No payment attempts",
"message": "no_payments_yet"
},
"0-2000": {
const ReplaceFieldType: Plugin = (builder) => {
// Process the output fields
builder.hook("GraphQLObjectType:fields:field", (field, build, context) => {
const { getTypeByName, graphql } = build;
const { GraphQLList, GraphQLNonNull } = graphql;
const {
scope: { pgFieldIntrospection: attr },
} = context;
import Container from 'components/Container';
import Text from 'components/Text';
import Title from 'components/Title';
import { TERMS_PRIVACY } from 'localization/constants';
import { useI18n } from 'localization/helpers';
import { GetServerSideProps } from 'next';
import React, { FC } from 'react';
import FormRow from 'sections/FormRow';
import useStyles from '../screens/terms-privacy-policy/styles';
@hos
hos / copy-firestore-collection.mjs
Created December 20, 2022 15:35
Copy from one firestore collection to another
import admin from "firebase-admin";
import fs from "fs/promises";
const serviceAccount1 = JSON.parse(await fs.readFile("./service-account-1.json"));
const serviceAccount2 = JSON.parse(await fs.readFile("./service-account-2.json"));
const admin1 = admin.initializeApp({ credential: admin.credential.cert(serviceAccount1) }, "one");
const admin2 = admin.initializeApp({ credential: admin.credential.cert(serviceAccount2) }, "two");
const db1 = admin1.firestore();
@hos
hos / firestore-new-id.sql
Created February 11, 2023 05:48
Firestore's newId function implemented in PostgreSQL. Converted using ChatGPT.
create or replace function public.gen_id()
returns text as $$
declare
chars text := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
max_multiple integer := floor(256 / char_length(chars)) * char_length(chars);
i integer;
auto_id text := '';
target_length integer := 20;
bytes bytea;
begin
import { jsonParse } from "@dataplan/json";
import { access, context, lambda, listen } from "grafast";
import { gql, makeExtendSchemaPlugin } from "graphile-utils";
import { SCHEMA_NAME } from "../config.js";
/* The JSON object that `tg__graphql_subscription()` delivers via NOTIFY */
interface TgGraphQLSubscriptionPayload {
event: string;
subject: string | null;
import cors from "cors";
import express, { Express, NextFunction } from "express";
import { IncomingMessage, Server, ServerResponse } from "http";
import inspector from "inspector";
import { Duplex } from "stream";
import { isDev, isLocal } from "./config.js";
import * as middleware from "./middleware/index.js";
import { firebaseAuthMiddleware } from "./middleware/installFirebaseAuth.js";
import { makeShutdownActions, ShutdownAction } from "./shutdownActions.js";
import { jsonParse } from "@dataplan/json";
import { access, context, lambda, listen } from "grafast";
import { gql, makeExtendSchemaPlugin } from "graphile-utils";
const PackagePlugin = makeExtendSchemaPlugin((build) => {
const { sql } = build;
if (!sql) {
throw new Error("sql not found");
}
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, and understand