Skip to content

Instantly share code, notes, and snippets.

View sd031's full-sized avatar
🧠
Youtube @learnTechWithSandip

Sandip Das sd031

🧠
Youtube @learnTechWithSandip
View GitHub Profile
@sd031
sd031 / cassandra.yaml
Created March 12, 2025 23:36
cassandra-kubernetes-example
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cassandra
spec:
serviceName: cassandra
replicas: 3
selector:
matchLabels:
app: cassandra
@sd031
sd031 / gist:ffd4e83ef2901d003e20a416c8794251
Created February 16, 2025 16:49
load balancer algoritm script
import random
import hashlib
class LoadBalancer:
def __init__(self, servers):
self.servers = servers
self.index = 0
self.connections = {server: 0 for server in servers}
self.weights = {server: 1 for server in servers} # Default weight is 1
self.server_response_times = {server: random.uniform(0.1, 1.0) for server in servers}
FROM golang:1.23.0-bookworm AS build
ARG upx_version=4.2.4
RUN apt-get update && apt-get install -y --no-install-recommends xz-utils && \
curl -Ls https://github.com/upx/upx/releases/download/v${upx_version}/upx-${upx_version}-amd64_linux.tar.xz -o - | tar xvJf - -C /tmp && \
cp /tmp/upx-${upx_version}-amd64_linux/upx /usr/local/bin/ && \
chmod +x /usr/local/bin/upx && \
apt-get remove -y xz-utils && \
rm -rf /var/lib/apt/lists/*
@sd031
sd031 / gist:bbeff9f940a26ecc10ed1c6aedd23184
Created November 23, 2023 14:02
go installation in ubuntu
update outdated software packages:
apt update
Setting up Go on Ubuntu:
apt install golang-go -y
Test the Setup:
go version
@sd031
sd031 / automate-deployment-using-python.py
Created November 15, 2023 02:11
Python script to automate the deployment of a web application to a server.
#pip install gitpython paramiko
import paramiko
from git import Repo
# Configuration
git_repo_url = 'https://github.com/yourusername/your-repo.git'
local_repo_dir = '/path/to/local/repo'
remote_server_ip = 'your.server.ip'
ssh_user = 'your_ssh_username'
Open Terminal.
List the current configured remote repository for your fork.
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
Specify a new remote upstream repository that will be synced with the fork.
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Verify the new upstream repository you've specified for your fork.
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
$ aws configure --profile project_name_1
$ aws configure --profile project_name_2
or can edit the : ~/.aws/credentials file directly
and when doing any service call, mention profile name at the end like this:
aws s3 ls --profile project_name_1
If you are going to work on a particular project for long and will not make any switches, it's better to set the profile as default:
e.g. export AWS_DEFAULT_PROFILE=project_name_2
@sd031
sd031 / nodefix
Created May 29, 2020 12:45
Legecy Node.js project dependency installation
Try
CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" npm i
https://stackoverflow.com/questions/52545166/node-6-node-gyp-rebuild-for-hiredis-fails-on-macos
It works for me, Mac OS 10.14.1 (18B75), node version 6.11.3 (legacy project)
@sd031
sd031 / AWS + DevOps Free courses on Udemy
Last active February 20, 2021 11:49
AWS and DevOps related courses available for 🆓 FREE 🆓 on udemy.
AWS and DevOps related courses available for 🆓 FREE 🆓 on udemy.
--> https://docs.google.com/document/d/1BEdrhZrTd-iY61HJ_JS5Y3ExTWtytUnHFR9EYf1ODdU/edit?usp=sharing
@sd031
sd031 / install_sam_cli.sh
Created September 24, 2019 02:22 — forked from wongcyrus/install_sam_cli.sh
Install AWS SAM CLI in Cloud9
sudo yum update -y
pip3 install awscli --upgrade --user
sudo ln -s /bin/touch /usr/bin/touch
yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
brew upgrade
brew update