This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove containers | |
docker rm -f $(docker ps -a -q) | |
# Remove images | |
docker rmi -f $(docker images -a -q) | |
# Remove volumes | |
docker volume rm $(docker volume ls -q) | |
docker volume prune | |
docker system prune --volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: exclude (separate) 'notifyUser' property from 'request' object | |
const request = { | |
id: 1, | |
title: 'ID 1 title', | |
notifyUser: true | |
}; | |
const { notifyUser, ...updateSet } = request; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getEnumKeyByValue = (enumerated, value: string) => { | |
return Object.keys(enumerated)[ | |
Object.values(enumerated).indexOf(value as typeof enumerated) | |
]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** For key/value enum: */ | |
export enum CountryEnum { | |
fra = 'FRANCE', | |
ukr = 'UKRAINE', | |
} | |
// ['FRANCE', 'UKRAINE'] | |
export const CountryList = Object.entries(CountryEnum).map( | |
([, value]) => value, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Send bombard requests to russian propaganda and infrastructure sites. | |
# | |
# Requirements: Docker, Python 2.7+, requests | |
# | |
# Check which pip version do you have: pip --version | |
# Then you need to install | |
# pip install requests | |
# OR | |
# sudo python3 -m pip install requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Convert long integer number into abbreviated string. | |
* Fast approach without math functions usage. | |
* Integers up to 999 Uncentillions (1 Un = 1e306) are supported. | |
* | |
* getAbbreviatedNumber('1024'); // '1.02K' | |
* getAbbreviatedNumber('-123456', 3); // '-123.456K' | |
* getAbbreviatedNumber('1000000'); // '1M' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Removes any whitespace character. | |
* This includes tabs and newline characters, as well as | |
* multibyte whitespace such as the thin space and ideographic space, | |
* unprintable characters and invalid unicode characters. | |
* | |
* @param string $string | |
* @return string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$num = getRandNumber(5); | |
var_dump($num); // 5-digits number like 48149 | |
/** | |
* Returns fixed-length random integer. | |
*/ | |
function getRandNumber(int $length): int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// From old versions of Laravel | |
// Don't use in cryptography | |
function str_random($length = 16) | |
{ | |
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
return substr(str_shuffle(str_repeat($pool, $length)), 0, $length); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param mixed $value Value of any PHP type. | |
* @return string Value as readable string. | |
*/ | |
function toString($value, $compactArray = true): string | |
{ | |
$data_type = ''; | |
if (is_array($value)) { |
NewerOlder