This file contains hidden or 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
# add string every 100 lines | |
sed '0~100 i <string_to_add>' | |
sed '<(INT)start_from_line>~<(INT)add_every_n_lines> i <string_to_add>' |
This file contains hidden or 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 arg, value in sorted(vars(args).items()): | |
logging.info("Argument %s: %r", arg, value) |
This file contains hidden or 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
def check_float_or_int(value: [int, float], return_str=False) -> [str, float, int]: | |
""" | |
The function will take a a number and see if it can be int without changing its value. | |
for example for 1.0 the function will change the type from float to int and return 1. | |
If the number is a float of 1.2 the program will return float 1.2. | |
:param value: number, can be int float or str | |
:param return_str: if this flag set to True, the number will be returned as a string | |
:return: the number itself, if its a float whole number it will convert to int. | |
""" | |
int_ = int(value) |
This file contains hidden or 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
# show MultiQueue configuration from expert | |
mq_mng --show | |
mq_mng -o | |
# show MultiQueue configuration from clish | |
show interface <interface> multi-queue [verbose] | |
# configure MultiQueue from clish | |
set interface <interface> multi-queue {off|auto|manual core <id of CPU core>} |
This file contains hidden or 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
# run command | |
sshpass -p qwe123 ssh -n -o StrictHostKeyChecking=no "admin@$IP" 'fw stat' | |
# transfer a file | |
sshpass -p 'qwe123' scp cp.pnp admin@$IP:/opt/CPshrd-R80.30/conf/cp.pnp |
This file contains hidden or 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
return an array | |
const counters = <array>.filter(c => c.id !== counterId); |
This file contains hidden or 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
tr -s \ <<file_name> |
This file contains hidden or 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
const express = require('express'); | |
const https = require('https'); | |
const fs = require('fs'); | |
const port = 8000; | |
const path = require('path') | |
var key = fs.readFileSync(__dirname + '/key.pem'); | |
var cert = fs.readFileSync(__dirname + '/cert.pem'); | |
var options = { | |
key: key, |
This file contains hidden or 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
# creating udp connection under port 161 and then exiting (working for tcp) | |
cat <(echo "") - | nc <ip-address> 161 | |
# creating udp connection under port 161 and then exiting after one second (can also work for udp) | |
echo "" | nc -w 1 172.31.253.167 161 -u | |
# getting the result with success message | |
nc -uvz 172.31.253.167 161 |
This file contains hidden or 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
# keep track of the last executed command | |
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG | |
# echo an error message before exiting | |
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT | |
For example, if we run ls --fake-option then we’ll see an informative error message as follows. | |
ls: unrecognized option '--fake-option' | |
Try 'ls --help' for more information. | |
"ls --fake-option" command filed with exit code 2. |
NewerOlder