Skip to content

Instantly share code, notes, and snippets.

View junaidk's full-sized avatar

Junaid Khalid junaidk

  • Mirantis
  • Berlin
View GitHub Profile
@junaidk
junaidk / ReadMe
Last active October 2, 2023 06:31
Code to decipher Vigenere Cipher Using frequency analysis
First find the strings of characters that are repeated in the ciphertext.The distances between consecutive occurrences of the strings are likely to be multiples of the length of the keyword. Then factors each of these numbers. If any number is repeated in the majority of these factorings, it is likely to be the length of the keyword.
After finding keyword length ...
We find k0 (first letter of keyword) first. Each of the characters y0, yL, y2L,
y3L, y4L, ..., y(q–1)L (q ≈ n / L)have been encrypted by adding k0 . Essentially, if we restrict to these characters, we have a simple shift cipher with shift k0.) We count the frequency of each letter (A, B, ..., Z) in these q characters of the ciphertext, and divide these frequencies by q to obtain probabilities.
Let W = (w0, w1, ..., w25), where w0, w1, ..., w25 are the probabilities of A, B, ..., Z in
positions 0, L, 2L, ..., (q−1)L of the ciphertext.
w0, w1, ..., w25 are the probabilities of A− k0, B− k0, ..., Z− k0 in
the plaintext (same positions).
@junaidk
junaidk / ec2.sh
Last active July 7, 2023 04:55
Get List of EC2 instances from All regions
# install aws cli first and configure it with credentials and default region
# the script will iterate over all regions of AWS
for region in `aws ec2 describe-regions --output text | cut -f4`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region $region
done
@junaidk
junaidk / resources.md
Last active January 4, 2023 10:25
Google App Script Resources
@junaidk
junaidk / README.md
Created February 18, 2021 07:31
GlusterFS with virtual disk

step 0

sudo apt-get install -y xfsprogs

sudo apt install software-properties-common sudo add-apt-repository ppa:gluster/glusterfs-7 sudo apt update sudo apt install -y glusterfs-server

step 1

sudo mkdir /mnt/disks

@junaidk
junaidk / Dockerfile
Created January 29, 2021 07:20
Jenkins Image with Docker
FROM jenkins/jenkins:2.263.1
USER root
RUN apt-get update && apt-get install -y sudo
RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers
RUN apt-get install -y rsync && apt-get install -y curl
RUN curl -sSL https://get.docker.com/ | sh
RUN usermod -a -G staff jenkins
@junaidk
junaidk / reddit-download.go
Last active January 11, 2021 15:15
Download images and videos from reddit saved posts
package main
import (
"fmt"
"github.com/anaskhan96/soup"
"github.com/dustin/go-humanize"
"io"
"io/ioutil"
"net/http"
"os"
@junaidk
junaidk / overview.md
Last active March 2, 2020 07:51
Docker overview
  • Docker overview

    Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.

    The Docker platform

    Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight because they don’t need the extra load of a hypervisor, but run directly within the host machine’s kernel.

Docker provides tooling and a platform to manage the lifecycle of your containers:

@junaidk
junaidk / tunnel.md
Last active January 14, 2020 06:18
creat ssh tunnel
@junaidk
junaidk / deleteRole.sh
Created November 7, 2019 09:27
Delete Roles in AWS
for ROLEIN in $(cat remaining-roles-2 | jq -r ".Roles[] | .RoleName"); do
## filter role on pattern
ROLE=$(echo $ROLEIN | grep -E "\-SR|\-MR|M-CP-X|M-CP-Y")
if [ -z "$ROLE" ]
then
echo ""
else
echo role ${ROLE}
@junaidk
junaidk / deleteVPC.sh
Last active November 7, 2019 09:26
Delete vpc and its dependencies from AWS
#!/bin/bash
#name=${1:-docundotapvpc1}
#region=${2:-us-east-1}
#id=${1:-vpc-08343443447ef34b}
#aws ec2 describe-vpcs --region ${region} | jq -r ".Vpcs[] | select(.VpcId | contains(\"${id}\")) | .VpcId" 2>/dev/null |
name=testingnetwork
region=ap-southeast-1
aws ec2 describe-vpcs --region ${region} | jq -r ".Vpcs[] | select(.Tags[].Value | contains(\"${name}\")) | .VpcId" 2>/dev/null |