Skip to content

Instantly share code, notes, and snippets.

View matt212's full-sized avatar
🚀
Open for consultation , Freelance and excited to collaborate and contribute

matt212

🚀
Open for consultation , Freelance and excited to collaborate and contribute
View GitHub Profile
@matt212
matt212 / gist:4e208a3f28b154f270ad0e05e4b0f37d
Created September 5, 2024 08:48
JSONCanvas to Mermaid config
/**
* Validates the structure and content of JSON Canvas data.
* @param {Object} data - The JSON Canvas data to validate.
* @throws {Error} If the data or structure is invalid.
*/
function validateJsonCanvasData(data) {
if (typeof data !== 'object' || data === null) {
throw new Error('Invalid data: must be a non-null object');
}
config
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'","https://cdnjs.cloudflare.com/","https://code.highcharts.com/","'unsafe-inline'"],
styleSrc: ["'self'", 'https://fonts.googleapis.com', "'unsafe-inline'"],
imgSrc: ["'self'", 'https://*.com'],
fontSrc: ["'self'", 'https://*.com', 'data:']
},
//const pinoInspector = require("pino-inspector");
const path = require("path");
const fastify = require("fastify")({
//logger: { prettyPrint: true, level: "debug", prettifier: pinoInspector },
ajv: {
plugins: [[require("ajv-keywords"), ["transform"]]],
},
});
fastify.register(require("@fastify/multipart"));
@matt212
matt212 / API Response
Created July 29, 2022 20:27
API Response
{"rows":[{"employeesid":20667909,"first_name":"joi","last_name":"baker","gender":"M","birth_date":"2020-01-02T00:00:00.000Z","recordstate":true,"created_date":"2020-12-06T09:17:39.413Z","updated_date":"2020-12-06T09:17:39.413Z"},{"employeesid":20667908,"first_name":"nick","last_name":"holden","gender":"F","birth_date":"2020-01-02T00:00:00.000Z","recordstate":true,"created_date":"2020-12-06T09:16:56.425Z","updated_date":"2020-12-06T09:16:56.425Z"},{"employeesid":20667907,"first_name":"Xinglin","last_name":"Morrin","gender":"F","birth_date":"2018-01-11T18:30:00.000Z","recordstate":true,"created_date":"2019-02-28T16:38:09.849Z","updated_date":"2019-02-28T16:38:09.849Z"},{"employeesid":20667906,"first_name":"Xinglin","last_name":"Morrin","gender":"M","birth_date":"2018-01-11T18:30:00.000Z","recordstate":true,"created_date":"2019-02-28T16:38:09.849Z","updated_date":"2019-02-28T16:38:09.849Z"},{"employeesid":20667905,"first_name":"Ortrud","last_name":"Binding","gender":"M","birth_date":"2018-01-11T18:30:00.000Z","r
@matt212
matt212 / customResponse
Created July 29, 2022 20:23
customResponse
{
"rows": [{
"employeesid": 20667909,
"first_name": "joi",
"last_name": "baker",
"gender": "M",
"birth_date": "2020-01-02T00:00:00.000Z",
"recordstate": true,
"created_date": "2020-12-06T09:17:39.413Z",
"updated_date": "2020-12-06T09:17:39.413Z"
@matt212
matt212 / gist:4094152be78ed2604313badff5ab115c
Created July 22, 2022 18:54
Sample search and group clause
File Refer https://drive.google.com/file/d/1fgEqB4LrSYhhgyeoKZl32ab-yO__bDht/view?usp=sharing
I would to optimized below query
select a.gender from "employees" as a
where lower( gender ) LIKE 'f%' group by gender
limit 20
@matt212
matt212 / primarySetup.sh
Last active November 19, 2020 18:52
Nodejs+postgres+redis Env Setup for App
sudo apt update
#Nodejs
sudo apt install nodejs
sudo apt install npm
#Postgres
sudo apt-get update
sudo apt install postgresql postgresql-contrib
#Redis-server
sudo apt install redis-server
sudo service redis-server start
@matt212
matt212 / meh.js
Created March 22, 2019 15:02
convert json array to js object
var newObj = internObj.reduce((a, b) => Object.assign(a, b), {})
{
"openapi": "3.0.0",
"info": {
"description": "This is a sample server Petstore server.",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
@matt212
matt212 / sample.yaml
Created January 31, 2019 20:20
multiple keys issues with different payload
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"