Skip to content

Instantly share code, notes, and snippets.

View sochix's full-sized avatar
🎯
Focusing

Ilia Pirozhenko sochix

🎯
Focusing
View GitHub Profile
<#
#
# Publish Project with msdeploy
# -----------------------------
#
# Parameters:
# * publishProfilePath - path to pubxml profile, downloaded from Azure
# * profileName - profile name from VS deploy dialog
# * projectName
#>
@sochix
sochix / API.md
Created February 1, 2017 09:01 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@sochix
sochix / app.js
Last active August 9, 2024 07:01
Counting requests in your Node.js+Express application
const app = require('express')()
const getRoute = (req) => {
const route = req.route ? req.route.path : '' // check if the handler exist
const baseUrl = req.baseUrl ? req.baseUrl : '' // adding the base url if the handler is child of other handler
return route ? `${baseUrl === '/' ? '' : baseUrl}${route}` : 'unknown route'
}
const fs = require('fs')
@sochix
sochix / app.js
Created April 16, 2019 15:48
Proper way to measure request duration in a Node.js + Express application
const app = require('express')()
const getDurationInMilliseconds = (start) => {
const NS_PER_SEC = 1e9
const NS_TO_MS = 1e6
const diff = process.hrtime(start)
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS
}