Skip to content

Instantly share code, notes, and snippets.

View mamedinfo's full-sized avatar
:octocat:
Working from home

Mammad Gurbanov mamedinfo

:octocat:
Working from home
View GitHub Profile
@mamedinfo
mamedinfo / fff.md
Last active June 27, 2023 03:30
Ec2-nginx-mysql-nodejs.mdx

Nginx

  1. sudo dnf list | grep nginx //Search

  2. sudo dnf update //To Install Latest Update

  3. sudo dnf install -y nginx // Install Nginx

  4. sudo systemctl start nginx.service //Start Nginx Server

  5. sudo systemctl status nginx.service // Check Server Status

  6. sudo systemctl enable nginx.service // Enable Auto Server Start on

  7. sudo yum update

@mamedinfo
mamedinfo / socket_io_events.js
Last active November 25, 2021 01:11
socket events cheetsheet
socket.emit('message', "this is a test"); //sending to sender-client only
socket.broadcast.emit('message', "this is a test"); //sending to all clients except sender
socket.broadcast.to('game').emit('message', 'nice game'); //sending to all clients in 'game' room(channel) except sender
socket.to('game').emit('message', 'enjoy the game'); //sending to sender client, only if they are in 'game' room(channel)
socket.broadcast.to(socketid).emit('message', 'for your eyes only'); //sending to individual socketid
io.emit('message', "this is a test"); //sending to all clients, include sender
io.in('game').emit('message', 'cool game'); //sending to all clients in 'game' room(channel), include sender
io.of('myNamespace').emit('message', 'gg'); //sending to all clients in namespace 'myNamespace', include sender
socket.emit(); //send to all connected clients
socket.broadcast.emit(); //send to all connected clients except the one that sent the message
@mamedinfo
mamedinfo / gitcom.md
Created March 16, 2021 03:19 — forked from jednano/gitcom.md
Common git commands in a day-to-day workflow

Git Cheat Sheet

Initial Setup

Create an empty git repo or reinitialize an existing one

git init
@mamedinfo
mamedinfo / server.js
Created May 31, 2020 17:53 — forked from nirzaq/server.js
Cache API Call and Cache rendered pages in Next.js
const express = require("express");
const cors = require("cors")
const { join } = require("path");
const { parse } = require("url");
const next = require("next");
const fetch = require("isomorphic-unfetch")
const LRUCache = require('lru-cache')
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== "production";
@mamedinfo
mamedinfo / nginx-tuning.md
Created November 26, 2019 12:55 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@mamedinfo
mamedinfo / Javscript.md
Last active August 14, 2019 14:33
Javascript

Nested functions and closures

function outside(x) {
  function inside(y) {
    return x + y;
  }
  return inside;
}
fn_inside = outside(3); // Think of it like: give me a function that adds 3 to whatever you give
@mamedinfo
mamedinfo / ubuntu-server-setup-16.04.md
Created August 17, 2018 22:45 — forked from marcuslilja/ubuntu-server-setup-16.04.md
Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

  • Nginx
  • MySQL
  • PHP
  • Node
  • Composer