Skip to content

Instantly share code, notes, and snippets.

View haydar-can's full-sized avatar
💭
I may be slow to respond.

Haydar haydar-can

💭
I may be slow to respond.
View GitHub Profile
@haydar-can
haydar-can / parse-float.js
Created December 22, 2022 22:35 — forked from ronaldronson/parse-float.js
Own parseFloat function
var parseFloat = function (val){
"use strict";
var res = NaN, i = 0, len, neg = false;
if ("number" == typeof val) {
return val;
}
if (null == val
|| "object" typeof val
@haydar-can
haydar-can / nginxproxy.md
Created September 5, 2018 10:52 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@haydar-can
haydar-can / restart_nginx.bat
Created September 5, 2018 10:50 — forked from keberwein/restart_nginx.bat
Restart Nginx Windows
@ECHO OFF
cd /nginx
taskkill /f /IM nginx.exe
start nginx
EXIT
@haydar-can
haydar-can / simple-nodejs-iv-encrypt-decrypt.js
Created May 11, 2018 19:10 — forked from yoavniran/simple-nodejs-iv-encrypt-decrypt.js
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@haydar-can
haydar-can / basic_auth_nodejs_test.js
Created April 16, 2018 07:00 — forked from charlesdaniel/basic_auth_nodejs_test.js
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@haydar-can
haydar-can / logging-middleware.js
Created March 8, 2018 21:09 — forked from cgmartin/logging-middleware.js
Morgan JSON log format example
'use strict';
var morgan = require('morgan');
var os = require('os');
morgan.token('conversation-id', function getConversationId(req) {
return req.conversationId;
});
morgan.token('session-id', function getSessionId(req) {
return req.sessionId;