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
@matt212
matt212 / console2html.js
Last active May 12, 2018
console 2 html for jsfiddle
View console2html.js
!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 / code-snippet.js
Last active Apr 23, 2018
Code and Inline Documentation Sample
View code-snippet.js
/*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 / regenegrate-sequence.sql
Created Aug 8, 2017
regenerate sequences formatted
View regenegrate-sequence.sql
do
$$
DECLARE _sql text;
BEGIN
WITH all_sequences
AS
(
SELECT
pg_namespace.nspname AS schema_name,
pg_class.relname AS table_name,
@matt212
matt212 / sequence.sql
Last active Aug 9, 2017
after data migration, generate script for creating sequence and apply sequence on column in postgresql
View sequence.sql
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
@matt212
matt212 / pg-writable-stream.js
Last active Aug 1, 2017
promise based codeflow for unziping , reading, formating and bulk streaming into postgres
View pg-writable-stream.js
/*my normal promise function looks like this
normalfunc.then(function (data){
}).error(function (){
})
function normalfunc(data)
{
return new Promise(function(resolve, reject) {
resolve/reject
})
@matt212
matt212 / COPY postgres
Last active Jul 31, 2017
not working postgres
View COPY postgres
COPY srt (starttime, endtime) FROM STDIN delimiters E'\t'
1 4
6 12.074
13.138 16.183
17.226 21.605
22.606 24.733
24.816 27.027
31.657 33.617
34.66 37.204
View limits.conf
#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 / search.js
Last active Jul 12, 2017
index is required !
View search.js
var elasticsearch = require('elasticsearch');
var ElasticsearchWritableStream = require('elasticsearch-writable-stream');
var connections = require('./config/db');
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
client.ping({
requestTimeout: 30000,
View jdbc log file
[20:19:00,649][INFO ][importer.jdbc ][pool-2-thread-1] strategy standard: settings = {index_settings.elasticsearch.cluster=elasticsearch, index_settings.elasticsearch.host=localhost, index_settings.elasticsearch.port=9200, index_settings.index.number_of_shards=10, password=abc123, sql=select * from srt, url=jdbc:postgresql://localhost:5432/demodb?loglevel=0, user=postgres}, context = org.xbib.elasticsearch.jdbc.strategy.standard.StandardContext@b174f2c
[20:19:00,657][INFO ][importer.jdbc.context.standard][pool-2-thread-1] found sink class org.xbib.elasticsearch.jdbc.strategy.standard.StandardSink@15919ffa
[20:19:00,662][INFO ][importer.jdbc.context.standard][pool-2-thread-1] found source class org.xbib.elasticsearch.jdbc.strategy.standard.StandardSource@db207f0
[20:19:00,694][INFO ][org.xbib.elasticsearch.helper.client.BaseTransportClient][pool-2-thread-1] creating transport client on Windows 8.1 Java HotSpot(TM) 64-Bit Server VM Oracle Corporation 1.8.0_131-b11 25.131-b11 with effective settings {
View elastic.yml
bootstrap.memory_lock: false
cluster.name: elasticsearch
http.port: 9200
node.data: true
node.ingest: true
node.master: true
node.max_local_storage_nodes: 1
node.name: MEH
path.data: C:\ProgramData\Elastic\Elasticsearch\data
path.logs: C:\ProgramData\Elastic\Elasticsearch\logs