Skip to content

Instantly share code, notes, and snippets.

View juliettegodyere's full-sized avatar
🙅‍♀️
Cracking the bricks

Juliet Nkwor juliettegodyere

🙅‍♀️
Cracking the bricks
View GitHub Profile
@juliettegodyere
juliettegodyere / Spring Cloud Config Server
Created April 13, 2024 18:43
Secure Configuration Management with Spring Cloud Config Server
## I've implemented a Microservice architecture where I've leveraged Spring Cloud Config Server for managing externalized configurations. To ensure the security of sensitive data, I needed a solution for encrypting and decrypting configurations before storing them on GitHub. Fortunately, Spring Cloud Config Server offers robust encryption and decryption capabilities out of the box.
Here's how I implemented encryption using the Symmetric key method:
Generated a 32-character alphanumeric encryption key.
Added the encryption key to my configServer-service application.properties file:
`encrypt.key = ${ENCRYPT_KEY}`
Note: ${ENCRYPT_KEY} references the value stored in the 'ENCRYPT_KEY' environmental variable.
@juliettegodyere
juliettegodyere / logarithm-laws.java
Created February 5, 2024 12:41
Solving the "Digits in Factorial" Problem Using the First Law of Logarithms
Today, I tackled the algorithmic challenge of counting digits in a factorial, and I initially approached it using the naive method—calculating the factorial of a number and then counting the digits. However, I encountered a hurdle with overflow despite the O(n) time complexity.
Fortunately, I found a solution by applying a simple yet powerful formula known as the First Law of Logarithms. Here's the straightforward approach to solving the "Digits in a Factorial" problem:
We know that log(a*b) = log(a) + log(b). Therefore, we can express the logarithm of n! as the sum of individual logarithms:
log( n! ) = log(123……. * n) = log(1) + log(2) + …….. + log(n)
This approach efficiently addresses the challenge and avoids the issues associated with overflow.
@juliettegodyere
juliettegodyere / main.java
Created January 29, 2024 12:19
Optimised Bubble Sort
Bubble sort progressively moves the largest element to the last position by iterating through the array and swapping adjacent elements until the entire array is sorted. During each iteration of the outer loop, the largest element finds its way to the last index. To enhance efficiency, the inner loop only needs to run up to n-i-1, where n is the total number of elements and i is the current iteration of the outer loop.
public void sort(int arr[]){
int n = arr.length;
for(int i = 0; i < n; i++){
for(int j = 0; j < n-i-1; j++){
if(arr[j] > arr[j+1]){
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
@juliettegodyere
juliettegodyere / gist:1a1112f5551cfc2555d94b5f477f9e5c
Last active January 24, 2024 13:53
Understanding the Relationship Between Algorithms and Data Structures
As I navigate my journey of job hunting and skill enhancement after a recent job loss, I find myself on a quest to reinforce my proficiency in algorithms and data structures. Despite dedicating a month to this pursuit, I still encountered challenges with certain algorithmic questions, prompting deeper reflections. What exactly is an algorithm? What constitutes a data structure? How do these fundamental concepts interrelate, and how can one effectively learn and apply them separately?
## Algorithm:
An algorithm stands as a systematic set of instructions or rules meticulously crafted to execute a specific task or solve a particular problem. It encapsulates a step-by-step approach to problem-solving, often involving the manipulation of data. Vital in computer science and programming, algorithms act as guiding principles, directing computers to perform tasks with efficiency and accuracy. The evaluation of an algorithm's efficiency typically revolves around time complexity (its runtime) and space complexity (memo