Skip to content

Instantly share code, notes, and snippets.

@nkurapati
nkurapati / build-app-using-gulp-npm.js
Last active December 11, 2017 09:22
Minimum requirements to build JavaScript application for testing and production. It saves time to build & refresh new changes
var gulp = require("gulp");
var inject = require("gulp-inject");
var del = require("del");
var connect = require("gulp-connect");
var htmlclean = require('gulp-htmlclean');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var babel = require("gulp-babel");
@nkurapati
nkurapati / node-proxy-server.js
Last active November 9, 2017 13:45
Implement Node.js as proxy server. It can handle its own api and can get data from other servers.
/*
This proxy handles 2 types are api.
1. Local Api: which send data from local server ex: Routes will start with /api/*
2. Remote Api: Which takes request from user (frontend/mobile/etc) -> sends it to remote server -> sends response to user.
You can use routes starts with your own filter ex: /remote/*
*/
var express = require('express');
var httpProxy = require('http-proxy');
var bodyParser = require('body-parser');
@nkurapati
nkurapati / getImageAspectFit.js
Created September 27, 2016 05:38
Calculate Image Aspect Fit size according to available space width and Height
function getImageAspectFit(originalWidth, originalHeight, availableWidth, availableHeight) {
var newSize = [];
//Solution One:
if(originalWidth > originalHeight){
newSize["width"] = (availableWidth < originalWidth) ? availableWidth : originalWidth
newSize["height"] = (originalHeight / originalWidth) * newSize["width"]!