Skip to content

Instantly share code, notes, and snippets.

View LRagji's full-sized avatar

Laukik LRagji

View GitHub Profile
@LRagji
LRagji / Shell.sh
Last active September 27, 2020 09:16
Docker commands
docker ps # get info on all containers
docker stats <containerid> #get cpu memory info for a container
docker exec -it <containerid> /bin/bash #get into container shell
docker cp <containerid>:/containerpath/1000000.txt /hostpath #copies a file from active container.
scp -i <security pem file path> <remotemachine>:/home/ec2-user/1000000.txt <localmachinepath>
ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name
@LRagji
LRagji / Braindump.sql
Last active December 11, 2020 10:57
PG Commands
---To find database size, works with PG 12---------------------
SELECT pg_size_pretty( pg_database_size('QA') );
--------------------------------------------------------------------
------------- To find out top X size of tables, works with PG12 ----------------------
SELECT
nspname, relname AS "relation",
pg_size_pretty (
pg_total_relation_size (C .oid)
@LRagji
LRagji / DBInserts.txt
Created July 31, 2020 07:28
This script is used to run a stress test on timescaleDB by inserting huge rows to find the write speed
24 * * * * PGPASSWORD=postgres psql -h localhost -U postgres -d Test -f /home/ubuntu/inserts.sql >> /home/ubuntu/1.txt
@LRagji
LRagji / parseInt.js
Created February 21, 2019 11:24
[JS]Pro-Tips:Always specify "radix" in parseInt
let i=parseInt(0700,10)//GOOD Implementation radix is passed.
let i=parseInt(0700)//BAD Implementation choosing the radix is now upto the runtime.
//Check this article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
//If the input string begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when using parseInt.
@LRagji
LRagji / enviroment.js
Created February 21, 2019 11:16
[Node]Pro-Tips:Set environment to production when not declared
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production'
}
@LRagji
LRagji / Http-Errors.js
Created February 21, 2019 11:14
[Node]Pro-Tips: Use "http-errors" package to create HTTP errors
var createError = require('http-errors');
var express = require('express');
var app = express();
app.use(function (req, res, next) {
next(createError(404));
});
@LRagji
LRagji / expressPattern.js
Created February 21, 2019 11:09
Pro-Tips: Pattern for Express(Node) with error handling
var app = express();
//All routes to hook it up to
app.use('/', rootModule);
app.use('/module1', module1);
app.use('/module2', module2);
//Handle other requests that doesnot fall through above routes
app.use(function (req, res, next) {
next(createError(404));
@LRagji
LRagji / Pi 0 Node Install
Last active March 31, 2018 12:22
NVM Install
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash ##Replace the verion with latest
nvm ls-remote ## select version
nvm install xx.xx.x #install the specified version