This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var relativeDate = function(date){ | |
var month = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; | |
var now = new Date(); | |
if(date === now){ | |
return "Just now"; | |
} | |
var yearDiff = date.getYear()-now.getYear(); | |
var monDiff = date.getMonth()-now.getMonth(); | |
var dateDiff = date.getDate()-now.getDate(); | |
if(date.toDateString() === now.toDateString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
template<class T> struct Node{ | |
T data; | |
Node<T>* next; | |
Node(T t){ | |
this->data = t; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Roll No: 101403051 | |
Name: Ayush Gupta | |
Group: COE3 | |
Question: 1 | |
*/ | |
#include<bits/stdc++.h> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Added this at line 886: | |
CMD_contains, | |
//Added the function description at line 1012 | |
T(contains, 2, 2, N, 0), //return position of substring, if not found return empty string | |
//Implemented contains function at line | |
case CMD_contains: { | |
size_t pos = args[1].find(args[0]); | |
if(pos!=string::npos){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LogRequsts(req, res, next){ | |
console.log("A request was received!"); | |
next(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function NewLogger(req, res, next){ | |
console.log("A request was received at /new"); | |
next(); | |
} | |
app.use('/new', NewLogger); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
OlderNewer