Skip to content

Instantly share code, notes, and snippets.

View space11's full-sized avatar
🐧

Borys space11

🐧
View GitHub Profile
@space11
space11 / frontend-framework-detector.js
Created April 30, 2024 15:43
Detect front end framework
// Credit to: https://stackoverflow.com/a/75537070/9336948
if(!!window.React ||
!!window.__REACT_DEVTOOLS_GLOBAL_HOOK__ ||
!!document.querySelector('[data-reactroot], [data-reactid]'))
console.log('React.js');
if(!!document.querySelector('script[id=__NEXT_DATA__]'))
console.log('Next.js');
if(!!document.querySelector('[id=___gatsby]'))
@space11
space11 / join_mp4_files.sh
Created April 17, 2024 18:18
Join mp4 files in linux
# Find files in directory
for f in *.m4a; do echo "file '$f'" >> mylist.txt; done
# Join found files using ffmpg
ffmpeg -f concat -i mylist.txt output.m4a
@space11
space11 / component.html
Created April 5, 2024 11:35
Allow only one ngx-bootstrap Popover at the time.
<button
type="button"
class="btn btn-default btn-secondary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on top"
placement="top"
>
Popover on top
</button>
import "regexp"
// Basic regular expressions for validating strings
const (
Email string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(([a-zA-Z]|[\\
@space11
space11 / mail.txt
Created November 22, 2023 18:50
Mail to Delete Any Account
Subject: Request for [Company Name] Account Deletion
Dear [Company Name] Team,
I am writing this email to request the deletion of my account as I have no further use for it. Kindly delete my account along with all my account information from your database.
Below are my account details:
Name: [Your Full Name]
Email: [Your Registered Email]
@space11
space11 / Sequential-Diagram-of-Electronic-Payment.uml
Last active October 24, 2023 15:58
Sequential Diagram of Electronic Payment
@startuml
title Sequential Diagram of Electronic Payment
actor CustomerA
actor BankA
actor BankB
participant "Seller/Service Provider" as Seller
CustomerA -> Seller: INITIATE PAYMENT
activate Seller
@space11
space11 / exception.filter.ts
Last active September 30, 2023 11:58
NestJs error filter example.
import { ArgumentsHost, Catch, ExceptionFilter, HttpException, HttpStatus, Logger } from '@nestjs/common';
@Catch()
export class HttpErrorFilter implements ExceptionFilter {
private readonly logger : Logger
constructor(){
this.logger = new Logger
}
catch(exception: Error, host: ArgumentsHost): any {
const ctx = host.switchToHttp();
@space11
space11 / install_nerd_font.sh
Created September 7, 2023 07:19
Install Nerd Font on Linux / Ubuntu
#Find the font
## Go to nerd fonts patched-fonts directory: https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts
# Go to user font directory
cd ~/.fonts
# Donwload a font file and save it.
curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/DroidSansMono/DroidSansMNerdFontMono-Regular.otf
# Rebuild the font cache
fc-cache -fv
@space11
space11 / sanitize.ts
Created September 4, 2023 21:47
Sanitizes input data to mitigate potential security risks by removing or escaping special characters, HTML entities, Unicode characters, and null bytes.
/**
* Sanitizes input data to mitigate potential security risks by removing or escaping
* special characters, HTML entities, Unicode characters, and null bytes.
*
* @param input The input data to be sanitized.
* @returns A sanitized version of the input data.
*/
function sanitizeData(input: string): string {
/**
* Removes carriage return characters (\r).
@space11
space11 / random.helpers.ts
Created August 15, 2023 18:02
Generates random number of digits of given length.
function generateRandomNumber(length: number): number {
return parseInt(
Math.ceil(Math.random() * Date.now())
.toPrecision(length)
.toString()
.replace('.', ''),
10
);
}