teleren/devto huggingface dataset:
CAFE BABE, if you know , you know JVM enthusiast.
Tags: java, linux, programming, reverse
Published: 2023-12-30 22:04:20

CAFE BABE, if you know , you know JVM enthusiast.

Each program has a magic word in it's machine code representation that defines it's identity among multiple other files .

if you open a compiled java file aka file.class with a hex editor like xxd tool in Linux , you'll find the first hex words : CAFE BABE .

But why it is so magical that it has to add in each class file is probably the most important question to be asked.
Well, James Gosling explained why: –

We used to go to lunch at a place called St Michael’s Alley. According to local legend, in the deep dark past, the Grateful Dead used to perform there before they made it big. It was a pretty funky place that was definitely a Grateful Dead Kinda Place. When Jerry died, they even put up a little Buddhist-esque shrine. When we used to go there, we referred to the place as Cafe Dead. Somewhere along the line, it was noticed that this was a HEX number. I was re-vamping some file format code and needed a couple of magic numbers: one for the persistent object file, and one for classes. I used CAFEDEAD for the object file format, and in grepping for 4 character hex words that fit after “CAFE” (it seemed to be a good theme) I hit on BABE and decided to use it. At that time, it didn’t seem terribly important or destined to go anywhere but the trash can of history. So CAFEBABE became the class file format, and CAFEDEAD was the persistent object format. But the persistent object facility went away, and along with it went the use of CAFEDEAD – it was eventually replaced by RMI.
Setting up VSCode, Git, and GitHub
Published: 2023-12-30 21:36:14



## Opening files in VSCode from the command line

Open the Command Palette and then type `shell command`.

Select `Shell Command: Install 'code' command in PATH`.

## Install Homebrew

From the terminal, run:

`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`

Follow Homebrew's next steps to add Homebrew to PATH.

## Update Git

`brew install git`

`git --version`

Make sure Git version is at least 2.28.

If necessary, run

`brew doctor`
`brew cleanup`

## Configure Git and GitHub

```
git config --global user.name "Your Name"
git config --global user.email "yourname@example.com"

git config --global init.defaultBranch main

git config --global pull.rebase false

echo .DS_Store >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
```

### SSH Key

Check if Ed25519 algorithm SSH key is already installed

`ls ~/.ssh/id_ed25519.pub`

To create a new SSH key:

`ssh-keygen -t ed25519 -C "your@email.com"`

### Link your SSH key with GitHub

Create new New SSH Key on GitHub

Copy your public SSH key. 

`cat ~/.ssh/id_ed25519.pub`

Paste the key into GitHub. 

### Testing your key

`$ ssh -T git@github.com`
What are Types in TypeScript
Tags: webdev, typescript, javascript, fullstack
Published: 2023-12-30 21:15:31

##The Definition 🥸

In TypeScript, Types are an easy way of to refer different properties and functions that a value has.


##Let's break this sentence.


###what is a value 🤔 : 


Now, a value in TypeScript is anything that we can assign to a variable well we can assign numbers, strings, boolean, arrays, objects, and functions. all of these assignable entities have a type.

for example, let's take "Red" we might say it is a string or alternatively we can say that this is a value that will have all the properties and methods we assume a string can have.

Now a string has many functions and properties such as charAt(), concat(), and many more. length is one of the common property

`console.log('Red'.length); // 3`
`console.log('Red'.chatAt(0)); // 'R'`


![two ways to look at a value](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/slde8iiae1gvq9jzf8f9.png)

##Conclusion 🤨

Now if we have to summerise "Red" by using all the properties and methods associated with it, that will be very inefficient.
A shorter way to refer to a value is to assign it a type. In this example, you say the 'Red' is a string. Then, you know that you can use the properties and methods of a string for the value 'Red'

thus Every value that we create has a type assigned to it, in some cases, it is very obvious such as the string in the example.

in Conclusion,
       a type is a label that describes the different properties 
       and methods that a value has

##Categories of types

Now in the world of TypeScript types are mainly characterised in 2 categories.

. primitive type
. Object type - Type that we build or are already built-in 
                TypeScript


![categories of types](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sm2im2exbs7jul1zdj35.png)

##Need of Types ✨

There are two main purposes of types in TypeScript:

1. Types are used by the TypeScript compiler to analyze your code for errors

2. Types allow us to understand what values are associated with variables and what values are flowing around in our codebase


![Need of Types](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8czi4u6y1xy8aqv64il.png)


##Example of Types in TypeScript 😎

`const color = 'red';`

The TypeScript compiler knows that the type of `color` is `string`


![example of type string](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahsn1nc9kamtjmx778th.png)

And it shows a list of methods of the `string` type that `color`  can access:


![list of methods on string](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izljb56x3vsjfczy79ms.png)

If you try to access a property or method that doesn’t exist, the TypeScript compiler will show an error. For example:


![error for unknown property name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbe76qrrgxk67aaabuez.png)


##Summary

- Every value in TypeScript has a type.

- A type is a label that describes the properties and methods that a value has.

- TypeScript compiler uses types to analyze your code for hunting bugs and errors.
Deploy React.js APP on Render for a free
Tags: webdev, react, render
Published: 2023-12-30 21:04:18

## Step 1: Create a Render Account.

First,  create an account on [Render](https://dashboard.render.com/).

 Once you have signed up, you will be taken to the Render dashboard.

> It is best to log in to GitHub

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42b31lseuhwnqvhquspe.png)


## Step 2: Create a New Web Service.

Click on “New” button ,then select “Static Site” from the list of options.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7vlfn0eqg3mmmak5e9rl.png)




## Step 3: Connect to GitHub Repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9p1ggqan3rdw19sfv19.png)





## Step 4: Configure the Build Settings.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bbciz2k27hzok1ykzgb8.png)


 
## Step 5: Deploy Your React.js Application.

Don't forget to go here and shake the settings to avoid a problem
I did " Not Found "

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sszd65kia8e2aacntwpc.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6y7a4ln26d4gphenw8j.png)
RSA Algorithm Supermacy
Tags: webdev, cybersecurity, cryptocurrency, programming
Published: 2023-12-30 20:45:12

Have you ever wondered how your online messages are kept secure? RSA has the answer!

 What's your go-to cybersecurity superhero?"



Imagine the digital world as a complex puzzle, and at the heart of keeping our online secrets safe is the RSA algorithm.

 It's like a superhero trio named after its creators – Ron Rivest, Adi Shamir, and Leonard Adleman. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmlnk99cs0rmqwbyeiaw.jpg)
This RSA superhero is our go-to guardian for secure communication in the internet age. 
Using a clever dance with special numbers, it creates a strong shield around our messages and data. 
Just think of it as a superpower 
that keeps our online world safe and sound – a brilliant creation by these three digital superheroes!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqwmzjp263egfj3r8gg0.png)
Difference between Scripting and Programming Language.
Tags: webdev, javascript, programming, learning
Published: 2023-12-30 19:57:24

I was going through important JS interview questions, and came across a topic , Difference between scripting and programming language.

Let's have a look into it :-

Before comparing we have to know about how your code gets executed:-
Our source code is written using  human language that computers cannot understand, so this source code is converted into bytecode, which the computer can understand.

In between this conversion, there comes either of the two things: a compiler or an interpreter.
A compiler first optimize the entire code(source code to bytecode), and then it gets executed.
But in an interpreter, the code will run line by line, and at the same time, the lines will be converted into bytecode.

 Now, the main difference between a programming and a scripting language lies in the use of a compiler or an interpreter.

A scripting language uses an interpreter for source code conversion, whereas a programming language uses a compiler. Every scripting language is a programming language, but not all programming languages are scripting languages.

Example:-
Scripting language: JavaScript, Python
Programming language: C, C++ , Java

But,but,but , here comes JIT compilation into play.
What is JIT??

Just in time compilation  was added to JavaScript to improve code execution. The V8 JavaScript engine introduced it for the first time. So how does this work, and why was there a need for a it? 
The use of interpreters in JavaScript made code execution slow because the code is executed line by line while converting it into bytecode.
However, a JIT compiler converts the JavaScript code into bytecode just before it is executed, this makes the execution faster. In simple words:- JIT compilation=Interpreter + Compiler.
Basic of useState hook in react.
Tags: webdev, javascript, react, learning
Published: 2023-12-30 19:56:37

The useState hook is used to update and display data on the web page. If a component has a value that is changeable , we use the useState hook to handle the change.

useState has a state variable and a function to update that variable.
The state variable holds some data of the component that can be changed.
The function is used to update the variable.

Example: const [count , setCount] = useState(1);
Here count is a variable that holds some data and setCount is a function that will update the variable(count) when needed. 1 is the default value we have given to the count.
Why we use useCallback hook in react ?
Tags: javascript, webdev, react, learning
Published: 2023-12-30 19:55:49

It took me a while to understand the purpose of the useCallback hook.

Let's take an example: imagine you're making your favorite dish, and you're using your favorite recipe for it. Now, whenever you make your favorite dish, you don't want to think about and rewrite the entire recipe each time. Instead, you make a photocopy of your favorite recipe and use it whenever needed. You only update the copy when you want to improve your recipe.

In React, components have functions, which are similar to the recipe for your food. These functions get recreated whenever the component is re-rendered, much like writing your recipe every time you make your favorite dish. This can make the process time-consuming.

useCallback(callback, [dependencies])

Here, the callback is a function that only gets recreated when there is a change in the dependencies. Otherwise, it memoize the function data if the function dependencies are not changed.

The main benefit of the useCallback hook is that it helps in avoiding unnecessary re-renders. This, in turn, aids in optimizing the performance of the webpage.
Context API: What and Why?
Tags: javascript, react, webdev, learning
Published: 2023-12-30 19:54:36

Wanted to share my learning related to Context API.

Before going into what  Context API is, we need to understand why there was a need for it.

Let's take an example:

Imagine an web app with a homepage featuring a dashboard. The dashboard is divided into two parts: the left and right sides. The right side further divides into an upper and lower part, with a card component  in the upper part.

In the card component, we require a title. Let's assume we are fetching data from an API, and the title comes from this API. The title, initially received from the API, first pass to the App component, then moves to the dashboard component, followed by the right side, and then progresses to the upper side component. Finally, it reaches the card component.

In this process, the data is passed through different components to reach its original destination. All these data pass-on are inefficient and not an optimized way of handling this.

To address this issue, we can create a global object that stores all the necessary data or the fetched data required by different components of the app.

This is where the Context API comes into play.

Think of the Context API as a global object where different data or Fetched data can be stored, and this data can then be directly accessed by specific components.

Using the Context API can make handling data and managing states in React apps simpler. This is especially helpful when different parts of your app need to use the same data.
What is cloud based forensics
Published: 2023-12-30 19:32:14

Cloud-based forensics is a subfield of digital forensics that deals with the investigation of digital evidence in cloud computing environments. It involves the application of forensic techniques to cloud computing systems to identify, preserve, collect, analyze, and present digital evidence in a court of law. The goal of cloud-based forensics is to investigate and analyze digital evidence in cloud computing environments to detect, prevent, and mitigate cybercrime.

According to the National Institute of Standards and Technology (NIST), cloud-based forensics is defined as “the application of digital forensics techniques to collect, process, preserve, analyze, and present digital evidence in a cloud environment”. Cloud-based forensics is a rapidly growing field due to the increasing use of cloud computing services by individuals and organizations.

Digital forensics in the cloud involves the use of forensic techniques to investigate digital evidence in cloud computing environments. Digital forensics in the cloud is similar to traditional digital forensics, but it has some unique challenges due to the distributed nature of cloud computing systems. Some of the challenges of digital forensics in the cloud include the lack of physical access to cloud computing systems, the complexity of cloud computing systems, and the dynamic nature of cloud computing environments.

Cloud storage forensics is a subfield of cloud-based forensics that deals with the investigation of digital evidence stored in cloud storage systems. Cloud storage forensics involves the use of forensic techniques to identify, preserve, collect, analyze, and present digital evidence stored in cloud storage systems. Some of the challenges of cloud storage forensics include the lack of physical access to cloud storage systems, the complexity of cloud storage systems, and the dynamic nature of cloud storage environments.

There are several cloud-based forensics tools available that can help investigators to collect, preserve, and analyze digital evidence in cloud computing environments. Some of the popular cloud-based forensics tools include Cado Security, AWS CloudTrail, Azure Monitor, and Google Cloud Audit Logs . These tools can help investigators to identify and analyze digital evidence in cloud computing environments and present the evidence in a court of law.

In conclusion, cloud-based forensics is an important subfield of digital forensics that deals with the investigation of digital evidence in cloud computing environments. Cloud-based forensics involves the application of forensic techniques to cloud computing systems to identify, preserve, collect, analyze, and present digital evidence in a court of law. There are several challenges associated with cloud-based forensics, including the lack of physical access to cloud computing systems, the complexity of cloud computing systems, and the dynamic nature of cloud computing environments. However, there are several cloud-based forensics tools available that can help investigators to collect, preserve, and analyze digital evidence in cloud computing environments.
Cloud Forensics: Navigating the Challenges and Best Practices in AWS, Azure, and GCP
Published: 2023-12-30 19:29:21

What is Cloud Forensics?
Cloud forensics is a branch of digital forensics that deals with the recovery, analysis, and presentation of digital evidence collected from cloud computing environments like AWS, Azure, and GCP. It's a critical field in the modern era of cloud computing, where more and more data and applications are hosted remotely on cloud servers.

Challenges of Cloud Forensics
Loss of Physical Control: In cloud environments, data and devices are managed by third-party providers, leading to a loss of physical control over critical digital evidence.
Complexity and Diversity: The varied architectures and services offered by cloud providers add complexity to the forensic process.
Dependency on Third Parties: Relying on cloud providers for access to data poses unique challenges in a forensic investigation.
Jurisdictional and Legal Issues: Data stored in the cloud can cross international borders, leading to legal and jurisdictional complexities during investigations.
Cloud Computing Forensics in AWS, Azure, and GCP
Each cloud platform has specific tools and strategies tailored to its environment:

AWS Forensics involves tools like AWS CLI, Amazon CloudWatch, and Amazon Inspector. AWS also emphasizes the importance of minimizing human interaction in forensic investigations by using templates and automated tools.
Azure Forensics includes Azure CLI, Azure Log Analytics, and Azure Security Center. Microsoft provides specialized tools through Azure Sentinel for investigating security incidents within Azure environments.
GCP Forensics focuses on automated project creation for forensic purposes using tools like Terraform and emphasizes the importance of restricting access to these projects to relevant personnel only.
Best Practices for Cloud Digital Forensics
Forensic Readiness Policy and Plan: Establish a comprehensive policy and plan outlining roles, responsibilities, and procedures for incident response.
Training and Education: Educate staff on digital forensics principles and evidence handling.
Implementing Cloud-Native Tools: Leverage tools provided by cloud providers for evidence collection and analysis.
Regular Audits and Testing: Conduct regular audits to ensure the effectiveness of forensic readiness plans and update them as needed.
Automation in Cloud Forensics
Automation is becoming increasingly important in cloud forensics. It includes continuous environment assessment, tagging suspect assets, automating evidence acquisition, and ensuring consistent remediation processes. Tools like AWS Config and cloud-native features aid in these processes.

Conclusion
Cloud forensics is a dynamic field that addresses the challenges posed by cloud computing environments. By understanding the specific requirements of each cloud service provider and implementing best practices and automation, organizations can effectively prepare for and conduct forensic investigations in the cloud.
Apache Kafka Kraft Protocol
Tags: kafka, performance, kraft
Published: 2023-12-30 19:16:22

This document that I created was mostly for self reference, I wanted to try out the shiny and new Kafka Kraft protocol where you dont need to deploy Zookeeper and Kafka containers themselves are self-sufficient, which simplifies deployment and improves on performance as well.

Before going through with this article, I would highly recommend that you go through the following video to get familiarized with what Kraft is all about, its a very brief and to the point explanation of the topic:
<br>

{% embed https://www.youtube.com/watch?v=lysFHBWLrME %}

---
### The Setup using docker-compose

>***Pre-requisites:***
>- Machine with sufficient resources for 3 docker containers.
>- Docker and docker-compose setup.
>- Kafka binaries setup on a seperate machine, for performance tests on the cluster.

The docker-compose.yaml needed to setup and some basic configurations are provided at my github repo:
https://github.com/vishalendu/kafka-kraft-cluster-setup

Please go through the readme file to setup the Kafka Kraft cluster.


>#### Disclosure:
>I have used a mini-pc having a Ryzen 7 5800H (8-core/16-threads) with 32GB of RAM and 2TB of M.2 NVME SSD with Sequential Read/Write up to 3,500/2,900 MB/s as my testbench. The docker containers deployed share the same SSD for storage (which can be IO limiting). Max network transfer from this machine reached 110 MB/s, so it could also be Network limited.

---
### Some performance tests on producer/consumer

Just to checkout the performance of the consumers and producers I have provided some basic commands in the repository 

https://github.com/vishalendu/kafka-kraft-cluster-setup/blob/main/benchmark.md

---
### Just for fun -- compared producer performance with different compression algorithms


![Kafka Producer Compression algorithm comparison](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3enyqa758nk3600e6n9y.png)
You can find the comparison in the compression-comparison.xlsx in the repo.

---
### Summary:
The Kraft protocol is going to be the only option from Kafka 4.0 onwards, so its definitely good to get some hands-on exercise to look at what changed and how the performance characteristics of Kafka have evolved.

The Kraft protocol has improved Kafka performance beyond the point where a small cluster can support millions of partitions, whereas older Zookeeper based implementation had major performance limitations with higher number of partitions.

It was also nice to run some producer compression tests to confirm that 'zstd' is the suitable compression algorithm that gives the most bang for the buck in terms of CPU utilization and the compression ratio.

---
### Things to do:
- Would like to look at migration to Kafka 3.6 from older versions.
- Will need to read documentation on consumer/producer properties if any have changed between versions or for Kraft protocol.
- Need to do some High Availability tests to look at how brokers and controllers are going to handle failures. I expect better recovery performance with Kraft protocol.
Next.js 14+ starter template with app router, shadcn/ui, typesafe env, icons, and configs setup
Tags: showdev, nextjs, typescript, webdev
Published: 2023-12-30 19:07:06

Simple next.js 14 starter template with everything pre-configured to get you started with development right away.

This template has all the simple things setup for you to get right into development with minimal configuration.

All my projects follows this structure, so I made a template for personal use. Thought it would help other devs who wants to start a new Next.js project.

## Features

This template uses [shadcn](https://github.com/shadcn)'s Next.js app structure from [shadcn/ui](https://ui.shadcn.com/).

- Next.js 14+ `/app` router
- TypeScript
- Tailwind CSS
- shadcn/ui (Radix UI + Tailwind)
- Prettier (w/ auto sort imports and tailwind classes)
- SEO optimized
- Typesafe env, icons, and config
- Ready to use - jump right into development

## Usage

```bash
pnpm create next-app -e https://github.com/redpangilinan/next-entree
```

You can check the repo here: [Github Repository](https://github.com/redpangilinan/next-entree)