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 {
@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
@aramkumar06
aramkumar06 / api_backends.conf
Created November 17, 2019 08:16 — forked from nginx-gists/api_backends.conf
Deploying NGINX Plus as an API Gateway, Part 1
upstream warehouse_inventory {
zone inventory_service 64k;
server 10.0.0.1:80;
server 10.0.0.2:80;
server 10.0.0.3:80;
}
upstream warehouse_pricing {
zone pricing_service 64k;
server 10.0.0.7:80;
FROM ubuntu
MAINTAINER Kimbro Staken
RUN apt-get install -y python-software-properties python python-setuptools ruby rubygems
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10