teleren/devto huggingface dataset:
Journey of creating a programming language: Bat Lang
Tags: programming, python, learning, development
Published: 2024-01-21 08:41:57

## Quick Access

If you're eager to dive into the Bat Lang playground without delay, just click here: [Bat Lang Playground](https://bat-lang.vercel.app/)

## The Birth of Bat Lang

In the vast and creative universe of programming languages, where each line of code tells a unique story, I embarked on a journey to create something different—something that not only brings functionality but also a smile. Being a longtime fan of Batman, I couldn't resist the idea of gifting the Dark Knight his very own programming language. And thus, Bat Lang was born.

## Design and Inspiration: Crafting the Bat Code

Bat Lang, being a toy language designed for fun, took shape as an interpreted language. The design philosophy draws inspiration from iconic elements of the Batman universe—Batarangs, the Bat Signal, and the utility belt. It's not just about writing code; it's about weaving a narrative with each line.

## Implementation Adventures

Choosing Python as the canvas, I initially experimented with third-party lexer and parser tools. However, the journey became more frustrating than anticipated. So, I pivoted and decided to build everything from scratch. The lexer was a breeze, but crafting the Abstract Syntax Tree (AST) and the parser brought its set of challenges. The interpreter and environment creation, while relatively straightforward, presented some intricacies. Dealing with bugs in the parser became an ongoing quest. The main challenge? Understanding and implementing the execution order of code blocks. Adding features like functions and arrays added complexity, but perseverance won the day.

## Features that Make Bat Lang Soar

Bat Lang allows you to perform the usual programming tasks—printing, variable declarations, conditions, loops, arrays, and functions. However, what truly sets it apart is not just what you can do, but how you do it. Every syntax element is Batman-themed. For instance, to print something, you use a function called `BatSignal()`, and to declare a variable, you employ the keyword `batarang`.

## Future Plans: Unveiling the Road Ahead

In the spirit of continuous improvement, the first order of business is cleaning up the codebase. Looking forward, plans include incorporating more features into Bat Lang, such as Object-Oriented Programming (OOP) and expanding the repertoire of built-in data structures and functions.

## Explore and Share Your Thoughts!

Ready to experience Bat Lang? Dive into the live playground: [Bat Lang Playground](https://bat-lang.vercel.app/)

If you have any question or feedback about Bat Lang I would be more than happy to hear them out. Let's make coding an extraordinary journey together!
TwoSum Example in C#: Print and Count Pairs with Given Sum
Tags: csharp
Published: 2024-01-21 08:47:27

In C#, the two-sum problem refers to finding pairs of integers in an array that sum up to a given target value. This is a common coding exercise that tests your ability to efficiently manipulate arrays and solve problems with two pointers.

In this post, we will discuss an example of how to implement a two-sum solution in C#. We will focus on printing and counting the pairs that satisfy the given sum.

First, let's define a method called `FindPairs` that takes an array of integers `arr` and a target sum `target` as parameters. This method will iterate through the array using two pointers, one starting from the beginning and the other from the end. For each comparison, we will determine if the elements sum up to the target and increment our count if they do.

```csharp
public static int FindPairs(int[] arr, int target)
{
    int count = 0;
    int left = 0;
    int right = arr.Length - 1;

    Array.Sort(arr); // Sorting the array allows efficient two-pointer traversal

    while (left < right)
    {
        int currentSum = arr[left] + arr[right];

        if (currentSum == target)
        {
            count++;
            Console.WriteLine($"Pair found: {arr[left]}, {arr[right]}");
            left++;
            right--;
        }
        else if (currentSum < target)
        {
            left++;
        }
        else
        {
            right--;
        }
    }

    return count;
}
```

In this method, we initialize our count, left pointer (`left`), and right pointer (`right`). We also sort our array using `Array.Sort(arr)` to optimize the two-pointer traversal.

Inside the while loop, we calculate the current sum of the elements at the left and right pointers. If the current sum is equal to the target sum, we increment our count, print the pair, and move both pointers toward the center. If the current sum is less than the target sum, we advance the left pointer to explore larger elements. Conversely, if the current sum is greater than the target sum, we decrement the right pointer to explore smaller elements.

Let's see an example usage of the `FindPairs` method:

```csharp
public static void Main()
{
    int[] arr = { 1, 4, 2, 3, 5, 6, 7 };
    int target = 8;

    int count = FindPairs(arr, target);

    Console.WriteLine($"Total Pairs: {count}");
}
```

In this example, we have an array `[1, 4, 2, 3, 5, 6, 7]` and a target sum of `8`. Running this code will output:

```
Pair found: 1, 7
Pair found: 2, 6
Pair found: 3, 5
Total Pairs: 3
```

As we can see, the method successfully finds and prints the pairs that sum up to the target value and returns the count of pairs found.

In conclusion, implementing a two-sum solution in C# efficiently requires the use of two pointers and sorting the input array. The provided example demonstrates how to print and count such pairs using the two-pointer approach. Understanding and practicing these techniques will enhance your problem-solving skills in C#.
Merge Sorted Array - Leetcode 88 - TypeScript
Tags: leetcode, typescript, algorithms, dsa
Published: 2024-01-21 08:33:44

Here's the Leetcode 88 solution using TypeScript.

[Watch on YouTube](https://youtu.be/p1Rul9s4XPE?si=UpXoUC3U7kFcqzzm)

## Leetcode 88 - [Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/description/)
You are given two integer arrays `nums1` and `nums2`, sorted in non-decreasing order, and two integers `m` and `n`, representing the number of elements in `nums1` and `nums2` respectively.

Merge `nums1` and `nums2` into a single array sorted in non-decreasing order.

## Approach

Since both arrays are sorted, you can use two pointers to compare elements from the end of both arrays.

You'll use two pointers (`m` and `n`) initially set to the lengths of `nums1` and `nums2`. 

Then you can compare the elements at these positions, and the larger element is placed at the end of `nums1`. 

Then you'll decrement the pointers and the position in `nums1` accordingly. 

You should continue this process until either of the arrays is fully merged. 

If there are remaining elements in `nums2` after the first loop, you'll add them to the beginning of `nums1`. 

![My excalidraw board which represents the solution of Leetcode 88](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2c0ls02i275wlopl5rk.png)

[View on Excalidraw](https://excalidraw.com/#json=bG4zx5lZ3O-OWXnk6sQt6,kv1BdCmknXaVXZKMWpYbSw)

## Code Implementation

```Typescript
function merge(nums1: number[], m: number, nums2: number[], n: number): void {
  let last = m + n - 1

  while (m > 0 && n > 0) {
    if (nums1[m - 1] > nums2[n - 1]) {
      nums1[last] = nums1[m - 1]
      m -= 1
    } else {
      nums1[last] = nums2[n - 1]
      n -= 1
    }
    last -= 1
  }

  while (n > 0) {
    nums1[last] = nums2[n - 1]
    n -= 1
    last -= 1
  }
}
```

## Time Complexity

This solution has the time complexity of `O(m + n)`, where `m` and `n` are the lengths of the input arrays `nums1` and `nums2`. 

The algorithm iterates through the arrays once, and at each step, it compares and places elements in the correct position. 

Since the length of the merged array is `m + n`, the time complexity is linear with respect to the combined length of both input arrays.

## Space Complexity

The space complexity is `O(1)` or constant. 

The algorithm performs the merging in-place without using any additional space that scales with the input size. 

We use a constant amount of extra space for variables like last, m, n, and the loop control variables. 

This makes the algorithm memory-efficient, as the space required to perform this algorithm remains constant regardless of the input size.
Creating Dynamic Menus with Jetpack Compose
Tags: android, jetpackcompose
Published: 2024-01-21 08:03:43


<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcHF0MWo1Y25zbGdzMmk0MDcwcTdtbzU1cmFkbDQ4ZHliMHJmaDR5MCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/zERh33HDjqAbPZOEKr/giphy.gif">


Kotlin and Jetpack Compose stand at the forefront of modern Android application development. Today, I’ll show you how to create an interactive and visually appealing menu structure using this powerful combination.

**Basic Structure of the Project**

Our project contains a main activity named MainActivity, which extends from the ComponentActivity class. On app launch, this activity sets up our user interface with the setContent method.

```
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            CircularMenuGroupTheme {
                MainMenuCanvas()
            }
        }
    }
}
```

**Menu Design**

Our @Composable function, MainMenuCanvas, defines the visual design and behavior of the menu. The main menu is designed as a central circle with sub-menu buttons around it. These sub-menus open and close with an animated effect.

```
@Composable
fun MainMenuCanvas() {
    // Menu items and animations are defined here
}
```

**Dynamic and Colorful Circles**

One of the most striking features of the menu is that each sub-menu item has different color gradients. Kotlin’s Random function dynamically generates these colors.

**User Interaction**

The menu responds to touch inputs. When the main circle is tapped, the sub-menus open, and each sub-menu item can be moved by dragging.

**Conclusion**

This project demonstrates the flexibility of Jetpack Compose and the power of Kotlin. Interactive menus are crucial elements that enrich the user experience in a modern application. This example opens the doors to creating visually attractive and practical interfaces with Jetpack Compose.

[This Full Code ](https://gist.github.com/ardakazanci/24a29183c8efe1c0adc838fc5bfbea9a)

My Profile 

[Linkedin](https://www.linkedin.com/in/ardakazanci/)
SSR React in Go
Tags: go, javascript, react, ssr
Published: 2024-01-21 07:51:51

---
title:SSR React in Go
published: true
description: SSRender React in Go 
tags: Go,JavaScript,React,SSR
---

## Overview

I tried implementing server-side rendering (SSR) with React in Go. Below is a demonstration and the repo.

![](https://storage.googleapis.com/zenn-user-upload/4f86b0635c6b-20240121.gif)

[Go SSR POC GitHub Repository](https://github.com/K-Sato1995/go-ssr-poc)

While working on this, I discovered another project that basically dose what I wanted to achieve.

[Go React SSR GitHub Repository](https://github.com/natewong1313/go-react-ssr)

## Objectives

- Perform SSR using React's [renderToString](https://react.dev/reference/react-dom/server/renderToString) in a Go environment.
- Implement hydration in the browser using React's [hydrateRoot](https://react.dev/reference/react-dom/client/hydrateRoot).

## Tools Used

Firstly, I used [rogchap/v8go](https://github.com/rogchap/v8go) to execute JavaScript in a Go environment. I listed other options below.

- [dop251/goja](https://github.com/dop251/goja)
- [robertkrimen/otto](https://github.com/robertkrimen/otto)
- [rogchap/v8go](https://github.com/rogchap/v8go)
- [quickjs-go/quickjs-go](https://github.com/quickjs-go/quickjs-go)
- [elsaland/quickjs](https://github.com/elsaland/quickjs)


I added polyfills for the [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) used in the React code.

Also, I used [esbuild](https://github.com/evanw/esbuild) (which is built in Go) for transpiling and bundling the React code.

## Process

This is the process I followed:

1. Use [esbuild](https://github.com/evanw/esbuild) to build the React code into a form executable on both the server and client sides.
2. Use [rogchap/v8go](https://github.com/rogchap/v8go) to perform SSR (`renderToString`) on the server-side code.
3. Embed the SSR-generated content and the client-side code for hydration into an HTML template using Go’s standard library [html/template](https://pkg.go.dev/html/template) (props are also injected here).
4. Make the HTML accessible using Go's standard library [net/http](https://pkg.go.dev/net/http).

## Result

Here is the code I ended up with. It should do what I intended to do in the Objectives section above.

[Go SSR POC GitHub Repository](https://github.com/K-Sato1995/go-ssr-poc)
IBM is Offering 21 Courses For Free : No Payment Required
Tags: beginners, python, sql, ai
Published: 2024-01-21 07:03:51

##Here are the links:

1. What is Data Science?
https://lnkd.in/g6YHb2Zx

2. Python for Data Science, AI & Development
https://lnkd.in/gvtD8fST

3. Tools for Data Science
https://lnkd.in/gaPwdzSW

4. Databases and SQL for Data Science with Python
https://lnkd.in/gNF3tt7W

5. Machine Learning with Python
https://lnkd.in/gQqGxSSc

6. Data Science Methodology
https://lnkd.in/gv-iEwx7

7. Data Visualization with Python
https://lnkd.in/gefPVN4r

8. Data Analysis with Python
https://lnkd.in/g8C3xiYJ

9. IBM Data Science Professional Certificate
https://lnkd.in/g-9t4_c7

10. Python Project for Data Science
https://lnkd.in/gg_36kji

11. Exploratory Data Analysis for Machine Learning
https://lnkd.in/gSGx_SVE


12. Introduction to Data Science Specialization
https://lnkd.in/g-VEMct4

13. Excel Basics for Data Analysis
https://lnkd.in/gpWNE73C

14. Fundamentals of Scalable Data Science
https://lnkd.in/ghade8G8

16. Introduction to Data Analytics
https://lnkd.in/gcxWBZG4

17. IBM Data Analyst Professional Certificate
https://lnkd.in/g6Dz84eR

18. Applied Data Science Capstone
https://lnkd.in/grFky2D4

19. Introduction to Artificial Intelligence (AI)
https://lnkd.in/ghbVVMHT

20. Introduction to Cybersecurity Tools & Cyber Attacks
https://lnkd.in/gGv6-GKD

21. IBM Cybersecurity Analyst Professional Certificate
https://lnkd.in/gh4NNgu8

Happy Learning!!!
Brett Markowitz
Published: 2024-01-21 06:18:04

**[Brett Markowitz](https://agerejuvenation.com/)** is an entrepreneur with over fifteen years of experience in the health and fitness industry. Based in Tampa, Florida, Brett has made it his personal goal to improve the lives of those around him. This devotion led Brett to found AgeRejuvenation, where he operates as the Chief Executive Officer.  https://brett-markowitz.com/
Git Config Settings I Always Recommend
Tags: git, productivity
Published: 2024-01-21 06:16:28

[Spanish translation](https://www.brandonpugh.com/es/blog/configuraciones-de-git-que-siempre-recomiendo/)

If you've ever worked on a project with me then I've probably recommended at least one of these config settings in git.

* `git config --global pull.rebase true` - tells git to always pull with rebase instead of merge (the equivalent of `pull --rebase`). This not only saves you having to type the flag every time, but also ensures gui clients will also use rebase when pulling.  
_**Note:**_ You should only enable this if you’re comfortable with rebasing.
* `git config --global fetch.prune true` - tells git to automatically run `git remote prune` after a `fetch`. This will clean up any local objects that no longer exist on the remote like tracking branches that have been deleted from the remote server.
* `git config --global rebase.autoStash true` - tells git to automatically stash when you perform a pull and then attempt to unstash them once the rebase is complete. This is almost always my workflow so it's nice to have git do it for me.
* `git config --global rebase.autosquash true` - tells git to automatically include the `--autosquash` parameter when doing a `git rebase --interactive`. You should [read more about autosquashing][autosquash] commits if you're unfamiliar with it. I use it all the time for fixing up or rewording previous commits.

## Newer settings

If you haven't updated git in a couple years then you should as it's worth it just for these new config options.

* `git config --global push.useForceIfIncludes true` (2.30.0) - This setting makes `push --force-with-lease` even safer. [See the docs][pushdocs] for more info.
* `git config --global push.autoSetupRemote true` (2.37.0) - Git will automatically setup an upsteam tracking when you run `git push` from a new branch.
* `git config --global rebase.updateRefs true` (2.38.0) - the `--update-refs` option [makes working with stacked branches easier][updateref]

## Personal preference

You might find these useful depending on your personal workflow.

* `git config --global commit.verbose true` - Git will include the diff of the changes at the bottom of the commit message template. I like this because your text editor can then autocomplete variable or function names you want to include in the commit message.
* `git config --global rerere.enabled true` - It stands for Reuse Recorded Resolution, and tells Git to remember how you resolved a merge conflict and automatically reapply if it sees it again.

[updateref]: https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs/
[autosquash]: https://thoughtbot.com/blog/autosquashing-git-commits
[pushdocs]:https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-if-includes
Intro to game development
Tags: gamedev, coding, programming, learning
Published: 2024-01-21 06:14:31

So if you want to make your own game, you need to follow a process. Let us discuss the process:

- First, write down all the game ideas you have and then choose one.
- Then select the genre of your game.
- Select your target audience
- Select the IDE and programming language which you will use.
- Decide if you want 2D graphics or 3D graphics in your game.
- Choose the software which you will use to create graphics.
- Start creating graphics.
- Start coding the game.
- Put sound in your game.
- Publish your game.
- Start marketing your game.
- Monetize the game once you have many players.
- Have fun throughout the process!
Join the XposedOrNot Hackathon 2024: Innovate for Internet Safety!
Tags: hackathon, opensource, coding, cybersecurity
Published: 2024-01-21 06:11:32

---
title: "Join the XposedOrNot Hackathon 2024: Innovate for Internet Safety!"
published: true
tags: hackathon, opensource, coding, cybersecurity
---

## 🚀 XposedOrNot Hackathon 2024: A Call to All Devs!

Hello, Dev.to Community!

I am super excited to announce the **XposedOrNot Hackathon 2024**! It's a unique opportunity for developers like you to contribute to an important cause – improving internet safety and data security. Here's everything you need to know:

### About XposedOrNot
[XposedOrNot](https://github.com/XposedOrNot/XposedOrNot-API) is an open-source project dedicated to helping users discover if their personal information has been compromised in data breaches. In today's digital age, our project is more relevant than ever, and we need your innovative minds to enhance its capabilities.

### 🎯 Hackathon Goals
- Engage with a vibrant developer community.
- Accelerate development and innovation in the XposedOrNot project.
- Create new features and improvements, enhancing user experience and security.

### 👩‍💻 Who Should Participate?
- Whether you're a seasoned developer or just starting out, your ideas and skills are invaluable.
- Individuals and teams are both welcome.

### 🏆 Prizes
- Over $3,000 in prizes, with a top prize of $750!
- Community choice awards, early bird prizes, and random draws.

### 🗓️ Key Dates
- **Start Date**: January 22, 2024
- **End Date**: February 12, 2024
- **Winners Announcement**: February 26, 2024

### 📝 Participation Details
- Submit your contributions via GitHub with the tag `#XON-Hackathon-2024`.
- Find more details and guidelines in our [official hackathon blog](https://blog.xposedornot.com/xposedornot-hackathon-2024).

This hackathon is not just a competition; it's a chance to make a real difference in the world of internet security. We can't wait to see the innovative solutions you'll bring to the table.

Feel free to ask questions or share your thoughts in the comments. Let's collaborate to make the internet a safer place for everyone!
Understanding Buffer data in Node js
Tags: webdev, javascript, tutorial, beginners
Published: 2024-01-21 06:01:03

I will keep this article short, the reason behind that is like, there can be so many questions you can explore yourself related to binary, buffer data, etc.

In this tutorial, what I am going to do is, I will help you understand buffer data, how it gets created.

In node js if you want to create one buffer, you can use one method called 
`Buffer.alloc(size)`
However, there are other ways as well as, which you can explore and comment below.

So, when you create buffer, you can create something like this

`const buff = Buffer.alloc(8)`

Here **8** is the size of buffer, means 8 bytes.
1 byte = 8 bits 
 - 00000000 in binary 
 - 00 in hexadecimal

If you print buff in terminal you will see below output
`<Buffer 00 00 00 00 00 00 00 00>`

If you notice we have 8 pairs of zeroes - that represent 8 bytes in hexadecimal.

If you are a UI developer, you might be aware of hex color code where we use FF or AF or 3E etc, these are actually hexadecimal

Lets take an example.

We want to store "hello" in buffer. 
By looking at the word we can easily see, it has 5 characters.
If we can store each character in 1 byte, we will need 5 bytes of buffer.

Lets create a new buffer

```
const helloBuff = Buffer.alloc(5)
//output
<Buffer 00 00 00 00 00>
```

As I told you each pair of zeroes represents one byte of hexadecimal number.

So what we can do here is, we can transform each character of "hello" to hexadecimal number.

To do that first we will have to convert it into it's ASCII value

```
'h' is 104 - 68 in hexadecimal
'e' is 101 - 65 in hexadecimal 
'l' is 108 - 6C in hexadecimal
'l' is 108 - 6C in hexadecimal
'o' is 111 - 6F in hexadecimal
```

To convert a decimal (say 108) to hexadecimal (say 6C ) follow below steps
   
-  Divide 108 by 16.
-  Quotient: 6, Remainder: 12
-  Continue dividing the quotient (6) by 16
-  Quotient: 0 (Stop since the quotient is now zero). Remainder is 6
- Write in reverse order i.e. 6C ( here we can represent 12 as C in hex)



So our buffer data should be like

`<Buffer 68 65 6C 6C 6F>`



Now that we know what will be the output, we can test it now.

```
helloBuff.write("hello");
```
If you try to log helloBuff, your output will be same.

You can also use toString() method to get proper values

for e.g. 
```
helloBuff.toString('utf8'). //output - 'hello'
helloBuff.toString('base64') //output - 'aGVsbG8='
helloBuff.toString('hex') //output - '68656c6c6f'
```

If you want to learn to calculate any string to base64 string. Please check my other article.
https://dev.to/vvkkumar06/converting-a-string-to-base64-manually-4ln2