Skip to content

Instantly share code, notes, and snippets.

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
View gist:a92fb309293d7843a82d9e8b47b1f88c
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:']
},
View app.js
//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"));
View 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
View 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"
View gist:4094152be78ed2604313badff5ab115c
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 Nov 19, 2020
Nodejs+postgres+redis Env Setup for App
View primarySetup.sh
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 Mar 22, 2019
convert json array to js object
View meh.js
var newObj = internObj.reduce((a, b) => Object.assign(a, b), {})
View meh.json
{
"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 Jan 31, 2019
multiple keys issues with different payload
View sample.yaml
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"
@matt212
matt212 / base.html
Last active May 15, 2018
Custom Modular Multiselect plugin and its implementation
View base.html
<!--
reason for creating this plugin
https://select2.org/programmatic-control/add-select-clear-items#preselecting-options-in-an-remotely-sourced-ajax-select2
which states that We need to modify our server api for client side plugin feature which is reallllly BAD !
also if you guys find any multiselect + autopopulate with ajax and edit mechanism please comment below on gist !
1. include modular-multiselect-plugin.js in base.html
2. include data-utils.js & plugin-enduser-implementation.js in base.html
3. include modular-multiselector.css in base.html