Skip to content

Instantly share code, notes, and snippets.

@ppdouble
ppdouble / couting-source-code
Created February 7, 2024 03:08
counting line of the source codes
find . -name '*.java' | xargs wc -l
@ppdouble
ppdouble / create-hotspot-wep.sh
Last active September 11, 2023 04:36
Create Hotspot with WEP
[user@fdr-lnx ~]$ nmcli connection down MyFedoraHotspot
Connection 'MyFedoraHotspot' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)
[user@fdr-lnx ~]$ nmcli connection delete MyFedoraHotspot
Connection 'MyFedoraHotspot' (076c78bf-9e91-4779-832e-7306adb7b277) successfully deleted.
[user@fdr-lnx ~]$ ls -lh /etc/NetworkManager/system-connections/ | grep MyFedoraHotspot
[user@fdr-lnx ~]$ nmcli con add type wifi ifname wlp0s30f4 con-name MyFedoraHotspot autoconnect yes ssid MyFedoraHotspot
Connection 'MyFedoraHotspot' (9ec71f65-881b-43b3-b666-710a21d5c6a9) successfully added.
[user@fdr-lnx ~]$ nmcli con modify MyFedoraHotspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
[user@fdr-lnx ~]$ nmcli con modify MyFedoraHotspot wifi-sec.key-mgmt none
Warning: WEP encryption is known to be insecure.
@ppdouble
ppdouble / change_pushed_commit_comment.sh
Created August 18, 2023 09:04
git change pushed commit comment
git commit --amend -m "New commit message."
git push --force <remoteName> <branchName>
# https://linuxize.com/post/change-git-commit-message/
@ppdouble
ppdouble / generate-time-sequence.sh
Created July 20, 2023 06:28
Generate time sequence in bash
for i in $(seq -w 1 02);
do
for j in $(seq -w 10);
do
for k in $(seq -w 16);
do
printf '%s:%s:%s,\t' "$i" "$j" "$k";
done
done
done
@ppdouble
ppdouble / copy-files-from-remote.sh
Last active July 21, 2023 10:11
Copy files from remote host to local machine with specific port using rsync. Alternative of scp. To copy a large number of files from remote.
# https://stackoverflow.com/questions/9090817/copying-files-using-rsync-from-remote-server-to-local-machine
# https://explainshell.com/explain?cmd=rsync+-havzP+-e+%22ssh+-p+%24portNumber%22+user%40remote.host%3A%2Fpath%2Fto%2Fcopy+%2Flocal%2Fpath
# copy files from remote host with specific ssh port
rsync -havzP -e "ssh -p portNumber" user@remote.host:/path/to/copy /local/path
# copy abc into local def
rsync -avzP user@remote-host:/source/folder/abc /destinate/folder/def/
# copy the files in abc into local abc
@ppdouble
ppdouble / aes_ecb_pkcs5_encrypt.py
Last active July 13, 2023 00:40
Encrypt Util for AES ECB PKC5 in python3
import base64
import subprocess
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
# Python 3.11.3
# pycryptodome-3.18.0-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
def pad_pkcs5(byte_array: bytearray, block_size: int):
"""
@ppdouble
ppdouble / randomStr.sh
Created June 27, 2023 16:22
Create 32 length random String in bash
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c 32 | xargs
@ppdouble
ppdouble / gen-2048-rsa-key-pair.sh
Last active June 9, 2023 00:04
generate 2048 bits rsa public private key pair for jwt token
jwtkey=/home/jwt/sign/keys
mkdir -p $jwtkey
openssl genrsa -out $jwtkey/rsa-prv.pem 2048
openssl rsa -in $jwtkey/rsa-prv.pem -pubout > $jwtkey/rsa-pub.pem
# OpenSSL `1.0.2k-fips on 26 Jan 2017` on `CentOS Linux release 7.9.2009 (Core)` gives pkcs#1 with -----BEGIN RSA PRIVATE KEY-----
# OpenSSL `3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)` on `Fedora release 38 (Thirty Eight)` gives pkcs#8 with -----BEGIN PRIVATE KEY-----
@ppdouble
ppdouble / loop-curl-request.sh
Created June 1, 2023 11:18
loop curl request
for ((i=1; i<=50; i++)); do curl -X POST http://127.0.0.1:8090/myapi/demo; echo ""; done;
@ppdouble
ppdouble / run.py
Created May 24, 2023 15:44
Download service using web.py
#!/usr/bin/env python
import web
urls = (
'/', 'index'
)
class index: