Skip to content

Instantly share code, notes, and snippets.

View ayushgp's full-sized avatar
😁

Ayush Gupta ayushgp

😁
View GitHub Profile
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
# set to the root of your Java installation
export JAVA_HOME=/usr/lib/jvm/<your-java-version>
export PATH=${JAVA_HOME}/bin:${PATH}
export HADOOP_CLASSPATH=$JAVA_HOME/lib/tools.jar
function logHeaders(req, res, next){
console.log(req.headers);
next();
}
function logURL(req, res, next){
console.log(req.url);
next();
}
function logFirst(req, res, next){
console.log("First!");
next();
}
function logSecond(req, res, next){
console.log("Second!");
next();
}
// First middleware
app.use(function(req, res, next){
console.log("Started");
next();
});
// Route handler
app.get('/', function(req, res, next){
res.send("Sent to client");
next();
function NewLogger(req, res, next){
console.log("A request was received at /new");
next();
}
app.use('/new', NewLogger);
var app = require('express')();
function logger(req, res, next){
console.log("A %s request was received at %s", req.method, req.url);
next();
}
// Use the middleware function
app.use(logger);
function LogRequsts(req, res, next){
console.log("A request was received!");
next();
}
@ayushgp
ayushgp / index.js
Last active May 27, 2016 07:06
A cron job that invalidates links and creates new ones.
var express = require("express");
var app = express();
function randomString(length) {
var result = '';
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
for (var i = length; i > 0; --i)
result += chars[Math.floor(Math.random() * chars.length)];
return result;
/**
* Using Rails-like standard naming convention for endpoints.
* GET /api/things -> index
* POST /api/things -> create
* GET /api/things/:id -> show
* PUT /api/things/:id -> update
* DELETE /api/things/:id -> destroy
*/
'use strict';