Posts

How to create simple documentation server

Untitled To share /expose document content as a simple webserver using python and asciidoctor. Follow below steps: Create directory asciidoc Create Dockerfile as shown below Dockerfile FROM alpine RUN apk add --no-cache python3 bash sudo RUN apk add asciidoctor COPY ["*.adoc", "/"] RUN asciidoctor *.adoc ENTRYPOINT ["python3", "-m" ,"http.server", "9000"] Copy this docker file and required asciidoctor(.adoc) files to be exposed on web server Make sure to have index.adoc as default page RUN below command to create docker image build.sh docker build . -t asciidoctor RUN below command to start the server filename.sh docker run -d -p 8084:9000 --name docserver asciidoctor:latest Open http://<hostname>:8084 Last updated 2022-09-28 11:20:01 -0500

How to Implement File Locking Feature in Java

How to implement FileLocking feature in java As we know within the java application we can avoid concurrent writes/read from different threads using synchronization/Locks as shown below. Using synchronized keyword we can make complete method thread safe. Using Lock we can make some portion of the code thread safe. Synchronization.java import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Synchronization{ public synchronized void write(){ //write some logic to avoid concurrent writes by different threads. } public void read(){ //some portion of the code Lock lock=new ReentrantLock(true); if(lock.tryLock()){ //some portion of code lock.unlock(); } //some portion of the code } } What if we want to avoid concurrent writes on a file by different applications/processes? java.nio.channels.FileChannel will help us to achieve thi...

Terraform Introduction

Terraform Table of Contents Terraform OCI Provider Terraform Initialization Configuration Generate Keys Scenario-1: Reading availability domains Scenario-2: List OSS Buckets Execution Authentication Providers API Key based authentication Using .tf files Using environment variables Using the SDK and CLI Configuration File Instance Principal Authentication Security Token Authentication Reference Terraform Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage following existing and popular service providers IaaS (OCI, AWS, GCP, OpenStack) PaaS (Heroku) SaaS (Terraform Cloud) OCI Provider OCI provider used to interact with the many resources supported by the Oracle Cloud Infrastructure . The provider needs to be configured with credentials for the Oracle Cloud Infrastructure account. We will discuss different authentication providers later. Te...