Skip to content

Instantly share code, notes, and snippets.

View VadimChorrny's full-sized avatar
🇺🇦

Vadym VadimChorrny

🇺🇦
View GitHub Profile
@VadimChorrny
VadimChorrny / location.app-controller.ts
Created February 19, 2024 20:31
Simple way to get IP-address from request in Express.
async getMyIp(req: Request, res: Response) {
const ip =
req.headers["cf-connecting-ip"] ||
req.headers["x-real-ip"] ||
req.headers["x-forwarded-for"] ||
req.socket.remoteAddress || "";
return res.status(200).send({ip});
}
@VadimChorrny
VadimChorrny / iso-3166-countries.ts
Created October 25, 2023 14:09
This repository provides a comprehensive list of countries and their corresponding ISO 3166 codes, making it easy to work with countries in your software projects.
export interface ICountry {
name: string;
code: string;
}
export const Countries: ICountry[] = [
{name: "Afghanistan", code: "AF"},
{name: "Åland Islands", code: "AX"},
{name: "Albania", code: "AL"},
{name: "Algeria", code: "DZ"},
{name: "American Samoa", code: "AS"},
@VadimChorrny
VadimChorrny / clean_code.md
Created April 15, 2021 12:35 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules