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 / sequence.sql
Last active August 9, 2017 08:22
after data migration, generate script for creating sequence and apply sequence on column in postgresql
select 'create sequence ' ||v.sequencename || ' owned by ' || v.table_name::text || '.' ||v.column_name::text || ';' AS createsequence,
'alter table ' || v.table_name::text || ' alter column ' || v.column_name::text
|| ' set default ' || v.column_default::text || ';' as altercolumnscript
from
(select
v.table_name, v.column_name, v.column_default,
replace(replace(replace(REPLACE(v.column_default,'nextval',''),'::regclass',''),'(''',''),''')','')
as sequencename
from
information_schema.columns v
#elasticsearch - nofile 65535
#elasticsearch - memlock unlimited
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
@matt212
matt212 / code-snippet.js
Last active April 23, 2018 11:31
Code and Inline Documentation Sample
/*Api Endpoint for file Upload ,Read,Transform , Bulkinsert with Async Promise based condensed codeflow approach equipped with Queue structure
and progress status provided by Socket.io integration */
router.post('/api/uploadcontent', function(req, res) {
/*New object and npm module(Busboy) initialized with cryptography conventions */
let resp = new Object();
let cryptoname = crypto.randomBytes(16).toString("hex");
let fil;
let busboy = new Busboy({
headers: req.headers
@matt212
matt212 / console2html.js
Last active May 12, 2018 09:00
console 2 html for jsfiddle
!function(o){console.old=console.log,console.log=function(){var n,e,t="";for(e=0;e<arguments.length;e++)t+='<span class="log-'+typeof(n=arguments[e])+'">',"object"==typeof n&&"object"==typeof JSON&&"function"==typeof JSON.stringify?t+=JSON.stringify(n):t+=n,t+="</span>&nbsp;";o.innerHTML+=t+"<br>",console.old.apply(void 0,arguments)}}
(document.body);
@matt212
matt212 / base.html
Last active May 15, 2018 15:08
Custom Modular Multiselect plugin and its implementation
<!--
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
@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"
{
"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 / meh.js
Created March 22, 2019 15:02
convert json array to js object
var newObj = internObj.reduce((a, b) => Object.assign(a, b), {})
@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 / 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