Skip to content

Instantly share code, notes, and snippets.

@aramkumar06
aramkumar06 / upload.js
Created June 11, 2022 07:43 — forked from richwednesday/upload.js
Image Upload to S3 From Node.js
const http = require("http");
const https = require("https");
const AWS = require('aws-sdk');
const formidable = require("formidable");
const uuid = require("uuid");
let server = http.createServer(launch);
let s3 = new AWS.S3({
// s3 credentials
});
@aramkumar06
aramkumar06 / offline
Last active February 24, 2020 12:31 — forked from LoveMeWithoutAll/vue-file-uploader-to-firestore.vue
vue-file-uploader-to-firestore
// Test this by running the code snippet below and then
// use the "Offline" checkbox in DevTools Network panel
window.addEventListener('online', handleConnection);
window.addEventListener('offline', handleConnection);
function handleConnection() {
if (navigator.onLine) {
isReachable(getServerUrl()).then(function(online) {
if (online) {
@aramkumar06
aramkumar06 / es6-json-to-csv
Last active February 14, 2020 05:47 — forked from dannypule/json_to_csv.js
Export JSON to CSV file using Javascript
const items = json3.items
const replacer = (key, value) => value === null ? '' : value // specify how you want to handle null values here
const header = Object.keys(items[0])
let csv = items.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','))
csv.unshift(header.join(','))
csv = csv.join('\r\n')
console.log(csv)
@aramkumar06
aramkumar06 / token.interceptor.ts
Created February 9, 2020 11:20 — forked from danielcrisp/token.interceptor.ts
TokenInterceptor - Async HTTP Interceptors with Angular 4
import { Injectable } from '@angular/core';
import { HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/mergeMap';
import { AuthService } from './auth.service';
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
/*This function serves as the core of our DB layer
This will generate a SQL query and execute it whilest returning the response prematurely
@param obj:{Object} this is the options object that contain all of the query options
@return Promise{Object}: returns a promise that will be reject or resolved based on the outcome of the query
The reasoning behind this kind of logic is that we want to abstract our layer as much as possible, if evne the slightest
sytnax change occurs in the near future, we can easily update all our code by updating this one
We are using knex as a query builder and are thus relying on Knex to communicate with our DB*/
/*Can also be used to build custom query functions from a data.service. This way our database service will remain
unpolluted from many different functions and logic will be contained in a BLL*/
/* All available options
@aramkumar06
aramkumar06 / Optimizing postgresql
Last active January 25, 2020 16:07 — forked from valyala/README.md
Optimizing postgresql table for more than 100K inserts per second
# Optimizing postgresql table for more than 100K inserts per second
* Create `UNLOGGED` table. This reduces the amount of data written to persistent storage by up to 2x.
* Set `WITH (autovacuum_enabled=false)` on the table. This saves CPU time and IO bandwidth
on useless vacuuming of the table (since we never `DELETE` or `UPDATE` the table).
* Insert rows with `COPY FROM STDIN`. This is the fastest possible approach to insert rows into table.
* Minimize the number of indexes in the table, since they slow down inserts. Usually an index
on `time timestamp with time zone` is enough.
* Add `synchronous_commit = off` to `postgresql.conf`.
* Use table inheritance for fast removal of old data:
@aramkumar06
aramkumar06 / installJdkTarGzUbuntu.sh
Created January 15, 2020 10:39 — forked from filipelenfers/installJdkTarGzUbuntu.sh
Install JDK from tar.gz Ubuntu
#Login as root
sudo su
#create jdk directory
mkdir /opt/jdk
#uncompress, change to your file name
tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk
#check if files are there
@aramkumar06
aramkumar06 / docker-compose-node-mongo.yml
Last active December 25, 2019 10:15 — forked from wesleybliss/docker-compose-node-mongo.yml
Docker Compose with example App & Mongo
version: '2'
services:
myapp:
build: .
container_name: "myapp"
image: debian/latest
environment:
- NODE_ENV=development
- FOO=bar
volumes:
@aramkumar06
aramkumar06 / cf
Last active February 21, 2020 05:36 — forked from heartonbit/gist:2575ce02ca730559d2f2c65eb8682231
GCC 7 on Ubuntu 14.04 & 16.04
https://github.com/cloudfoundry/uaa
http://docs.cloudfoundry.org/api/uaa/version/74.4.0/index.html#overview
https://docs.cloudfoundry.org/concepts/architecture/uaa.html
https://www.baeldung.com/cloud-foundry-uaa
React
https://medium.com/@thechrisbull/4-different-kinds-of-components-creating-a-react-ui-component-framework-saga-a-designer-9043c0cc597
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
## Ubuntu 18
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
## Ubuntu 16
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
## Ubuntu 14
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list