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
#!/bin/bash | |
openssl ecparam -genkey -name prime256v1 -conv_form uncompressed -outform PEM -out ec.pem | |
openssl req -newkey ec:ec.pem -passout pass:123456 -sha256 -subj "/C=IN/ST=Kar/L=En/O=ABC/OU=ABCDepart/CN=root/emailaddress=root@abc.com" -keyout rootkey.pem -out rootreq.pem -config openssl.cnf | |
openssl x509 -req -in rootreq.pem -passin pass:123456 -sha256 -extfile openssl.cnf -days 14600 -extensions v3_ca -signkey rootkey.pem -out rootcert.pem | |
openssl ecparam -genkey -name prime256v1 -conv_form uncompressed -outform PEM -out ec.pem | |
openssl req -newkey ec:ec.pem -passout pass:123456 -sha256 -subj "/C=IN/ST=Kar/L=En/O=ABC/OU=ABCDepart/CN=server/emailaddress=server@abc.com" -keyout serverkey.pem -out serverreq.pem -config openssl.cnf | |
openssl x509 -req -in serverreq.pem -passin pass:123456 -sha256 -extfile openssl.cnf -days 14600 -extensions usr_cert -CA rootcert.pem -CAkey rootkey.pem -CAcreateserial -out servercert.pem |
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
#!/usr/bin/env python | |
from itertools import groupby | |
myList = [1, 2, 1, 3, 1] | |
for x, y in groupby(sorted(myList)): | |
# groupby groups by consecutive elements which are similar | |
# x is the element, y is the list which contains the elements occurence | |
dup_list = list(y) | |
print 'x : ' + str(x) + ', y: ' + str(list(dup_list)) |
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
#!/usr/bin/env python | |
import subprocess | |
import os | |
# 1) Calling an external command in Python | |
# Simple way to call external command is using os.system(...). And this funciton returns the exit value of the command. | |
# But the drawback is we wont get stdout and stderr. | |
ret = os.system('some_cmd.sh') | |
if ret != 0 : |
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
tc qdisc add dev <interface_name> root netem delay 120ms | |
tc qdisc delete dev <interface_name> root netem | |
tc qdisc add dev <interface_name> root netem loss 2% |
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
#!/bin/bash | |
CSCOPE_DIR="$PWD/cscope" | |
echo_usage() | |
{ | |
echo "Usage: $0 gen|reset [folder]" | |
exit -1 | |
} |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
netns_name() { | |
str=`ip netns identify $$` | |
[[ "$str" != "" ]] && echo "\033[1;35m[$str]\033[0m " && return | |
} | |
export PS1="\u@\h\[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\n$ " | |
eval $(ssh-agent -s) |
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 loop | |
count=5 | |
for i in $(seq $count); do | |
echo $i | |
done |
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
1) Git SSH configuation | |
Generate RSA key pair | |
- ssh-keygen -t rsa -b 4096 -C "your_email@domain.com" | |
- This generates 2 file, id_rsa and id_rsa.pub in ~/.ssh directory. | |
- Copy the content of id_rsa.pub and configure in the git settings under the account details. | |
Then after opening terminal, always execute below 2 command to load the RSA private key (id_rsa). | |
After loading, all git commands can be executed without entering credentials every time. | |
- eval $(ssh-agent -s) | |
- ssh-add ~/.ssh/id_rsa |
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
grep -E "colou?r" * -R | |
- Matches both "colour" and "color" |
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
To Setup | |
sudo apt install hplip | |
sudo hp-setup -i | |
To scan and get soft copy | |
hp-scan |
OlderNewer