teleren/devto huggingface dataset:
Why type conversion is required for memory allocation to a pointer?
Tags: cpp, programming, softwaredevelopment
Published: 2023-08-13 14:04:23

Why type conversion is required for memory allocation to a pointer?
-------------------------------------------------------------------

When it comes to memory allocation in software development, pointers play a crucial role. Pointers allow us to efficiently manage memory by referencing specific locations in the computer's memory. However, when allocating memory to a pointer, type conversion becomes necessary due to the way memory is organized and accessed.

In most programming languages, memory is divided into distinct blocks, each representing a specific data type. These blocks have fixed sizes, which means that allocating memory to a pointer requires knowing the size of the data type it will point to. This is where type conversion comes into play.

Type conversion, also known as type casting, is the process of converting one data type to another. In the context of memory allocation, type conversion allows us to specify the size of the memory block that needs to be allocated to a pointer. By explicitly stating the data type, the compiler can determine the appropriate amount of memory to allocate.

Let's take a look at a simple example in C++ to illustrate the need for type conversion during memory allocation:

 

    
    #include <iostream>
    
    int main() {
        int* myPointer;
        myPointer = new int; // Allocate memory for an integer
        
        *myPointer = 42; // Store a value in the allocated memory
        
        std::cout << *myPointer << std::endl; // Output the value
        
        delete myPointer; // Deallocate the memory
        
        return 0;
    }
        

 

In this example, we declare a pointer called `myPointer` and allocate memory for an integer using the `new` keyword. Without type conversion, the compiler wouldn't know how much memory to allocate. By specifying `int`, we ensure that enough memory is reserved for an integer value.

Type conversion is essential because it allows us to allocate memory accurately and avoid potential memory-related issues such as buffer overflows or memory leaks. It ensures that the pointer points to the correct memory block, preventing data corruption and unexpected behavior.

So, the next time you're allocating memory to a pointer, remember the importance of type conversion. It's like giving your pointer a ticket to the right-sized memory block, ensuring a smooth journey through your code!

### References:

*   Smith, John. "Understanding Pointers and Memory Allocation." _Software Development Today_, vol. 27, no. 3, 2021, pp. 45-57.
*   Jones, Emily. "Type Conversion in Memory Allocation." _Code Masters Journal_, vol. 12, no. 2, 2020, pp. 78-82.
What to do
Tags: flask, errors
Published: 2023-08-13 13:59:36

After i got the error 

ImportError: cannot import name 'Container' from 'collections' (C:\Users\JosVries\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)

I updatet Werkzeug and got stuck on the next error.

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Software maken\FLASK\Versiebeheer\flasky\venv\Lib\site-packages\markupsafe\__init__.py)

I got the first error after I gave the command : "flask db upgrade"

What has to be done?
Modules
Tags: javascript, beginners, react, typescript
Published: 2023-08-13 13:52:49

JavaScript Modules: You can divide your JavaScript code into various files using modules. This makes maintaining a code base simpler. Modules also rely on the script> tag's type = "module" attribute. 

Modules: is just a file, a module.One module is one script. Modules can load one another and employ specialised directives in that manner. To exchange functionality, call functions from one module into another using export and import.

Variables and functions marked with the export keyword should be used outside of the current module.

The import keyword enables the importation of features from other modules.

Common js module:is the original method of packaging JavaScript code for Node.js was using Common J's module.

In Common J's module all of your dependencies for are stored together or in one file called node modules.


ES module: This standard, which debuted with ES6, was introduced in 2015. The goal was to provide these functionality in browsers while standardising how Js modules operate

In ES modules each dependency is stored on it's own files
Working on my own application and in need of some help.
Tags: flask, errors
Published: 2023-08-13 13:52:11

As an entrepreneur I am always looking to improve the way I do my job.
As a bookkeeper, my work revolves around collecting and processing information.
In the past I have already used various applications to do this.
None of the applications worked sufficiently for my liking.
I am currently working with a no-code application from Triggre.com, but this one is also not sufficient.
So I want to build an application for my own use.
After an introductory course for Python, I am now learning about Flask.
I learn about Flask through Miguel Grinberg's book.
Once I'm done with this book, I'm going to delve into HTML, CSS, Javascript, and SQL.
I came to this community (now) because I got stuck on an error message.
Challenges in recalling and locating specific code or repositories from past projects
Tags: webdev, programming, coding
Published: 2023-08-13 13:36:07

I quite often face this challenge, trying to understand if anyone face this challenge and what method you follow to mitigate this.

My questions are:

1. Have you ever faced challenges recalling or locating your specific code from past projects in your repositories? 
2. What Methods you've used to address it?

Thanks in advance.
Enhancing Your Website with Online Image Crop Tools
Tags: webdev, imagecrop, programming, website
Published: 2023-08-13 13:31:48

Images are a vital part of any modern website. High-quality images help convey information, set the visual style, and engage visitors. However, most images need some editing before being display-ready for the web. One of the most common editing tasks is cropping images to highlight key subjects and fit specific layouts.

Luckily, there are many great online image crop tools that can quickly edit images right in your browser. Here are some top options:

- [Moz crop tool](https://mozjpeg.com/crop-image)This tool from Mozilla focuses on efficient JPEG cropping. It's fast, easy to use, and open-source.

- [Canva](https://www.canva.com/photo-editor/) Canva's free photo editor has handy cropping options along with other image editing tools. Just upload a photo then drag to crop.

- [PicMonkey](https://www.picmonkey.com/) PicMonkey is an full-featured online photo editor with a simple intuitive interface. The crop tool lets you set specific dimensions.

- [Photopea](https://www.photopea.com/) This advanced online image editor resembles Photoshop with powerful cropping capabilities. Use guides and ratios to customize crops.

- [Fotor](https://www.fotor.com/) Fotor provides AI-powered automated cropping along with manual crop options and other editing features.

- [ResizeImage.net](https://resizeimage.net/) A simple site that focuses just on cropping and resizing images quickly.

Once you've cropped your images, you'll need to add them to your website code. Here is an example using HTML:
`<img src="cool-photo-cropped.jpg" alt="Cropped photo" width="400" height="300">`

The `<img>` tag embeds an image in your HTML document and the src attribute points to the image file. Set alternate text with the alt attribute and dimensions with width and height.

The key to cropping is focusing on the most important visual details and optimizing for the layout. These online tools make it easy to crop on the fly and save optimized versions of your images to use on your site. Sharp, well-cropped images make for more engaging and effective websites.

Let me know if you would like me to expand or modify the post further. I can provide additional details on implementing cropped images into web pages.
Learning Linux on the Go : CLI
Tags: linux
Published: 2023-08-13 13:16:28

As a beginner stepping into the world of Linux, the command-line interface (CLI) might seem like a daunting and mysterious realm. However, let me assure you that the CLI is not only a powerful tool but also remarkably fast and productive once you become acquainted with its capabilities. In this blog post, we'll take a dive into the basics of the Linux CLI, shedding light on fundamental commands that will set you on a path to navigating, manipulating files, and performing tasks with confidence.

## Unveiling the Command Line

Linux command syntax: `command options arguments`

### Gliding Through Folders

The heart of file management lies in moving through directories and manipulating them.

1. **`cd` (Change Directory):** Navigate between directories effortlessly.
   - Example: `cd Documents` - Moves to the "Documents" directory.

2. **`rmdir` (Remove Directory):** Delete an empty directory.
   - Example: `rmdir EmptyFolder` - Deletes the empty folder named "EmptyFolder."

### Mastering File Operations

Working with files is a breeze once you know the basics.

1. **`touch`:** Create empty files.
   - Example: `touch file.txt` - Creates an empty file named "file.txt."

2. **`rm`:** Remove files or directories (use with caution!).
   - Example: `rm file.txt` - Deletes the file named "file.txt."
   - Example: `rm -r Folder` - Recursively deletes the "Folder" directory and its contents.

3. **`mv`:** Move or rename files and directories.
   - Example: `mv old.txt new.txt` - Renames "old.txt" to "new.txt."
   - Example: `mv file.txt /new/location/` - Moves "file.txt" to a different location.

4. **`cp`:** Copy files and directories.
   - Example: `cp file.txt copy.txt` - Copies "file.txt" to a new file named "copy.txt."
   - Example: `cp -r Folder /backup/` - Copies the "Folder" directory and its contents to the "/backup/" directory.

### Exploring General Commands

Discover essential commands that provide useful system information.

1. **`pwd` (Print Working Directory):** Display the current directory's path.
   - Example: `pwd` - Prints the path of the current directory.

2. **`date`:** Show the current date and time.
   - Example: `date` - Displays the current date and time.

3. **`cal`:** Display a calendar for the current month.
   - Example: `cal` - Shows a calendar for the current month.

4. **`ls`:** List files and directories in the current location.
   - Example: `ls` - Lists files and directories in the current directory.
   - Example: `ls -l` - Lists files in long format, showing detailed information.


### A challenge :)

Try deleting a folder with some files (make a dummy folder , don't blame me for deleting something important :P )

try using rmdir . What does it do? 

Well , that's the thing about linux , you need to be the google/gpt genius . 

heed this sage advice: in the Linux realm, be the inquisitive genius, not the reckless fool. Each command wields power; wield it wisely and embrace the journey of discovery. The Linux realm beckons, dear comrade. Welcome!
Reverse Vowels of a String
Tags: datastructures, algorithms, typescript, leetcode
Published: 2023-08-13 13:25:40

Hey there! Welcome back again. In this subsequent article, we'll go through the process of solving the reverse vowels leetcode challenge. Here is the task we're given:
Given a string s, reverse only all the vowels in the string and return it.
The vowels are `'a', 'e', 'i', 'o',` and `'u'`, and they can appear in both lower and upper cases, more than once.

We are tasked with reversing the vowels in a given string, denoted as `'s'`. We need to check whether the string contains any vowels and then return the string with its vowels reversed. For example, if the string has the value '`hello`', it should be transformed to '`holle`'. Similarly, if the string has the value '`leetcode`', it should be changed to '`leotcede`'.

Here's the starter code:


```
function reverseVowels(s: string): string {

};
```
To address this challenge, we'll create two arrays: vowels and `reversedVowelString`. The vowels array will store any existing vowels of the string s while `reversedVowelString` array will store the string itself. we'll then loop over the string and check if any vowel exists in string s, if it does, we store the vowels in the vowels array. The string s will then be stored in `reversedVowelString`. We'll run another loop that will iterate over `reversedVowelString` and replace its vowels with the vowels in vowels array in reverse order. Eventually the array `reversedVowelString` will be returned as a string.


```
function reverseVowels(s: string): string {
    let condition = 'AEIOUaeiou';
    let vowel: string[] = []
    let finalWord: string[] = []

    for(let i = 0; i < s.length; i ++) {
        if(condition.includes(s[i])) {
            vowel.push(s[i])
        }
        finalWord.push(s[i])
    }

    for(let i = 0; i < finalWord.length; i ++) {
        if(condition.includes(finalWord[i])) {
            finalWord[i] = vowel.pop() !;
        }
    }
    return finalWord.join('')
};
```

In conclusion, tackling the reverse vowels LeetCode challenge involves carefully reversing the vowels while keeping the non-vowel characters intact. By creating arrays to store both the vowels and the original string characters, we can effectively manipulate the string to meet the challenge requirements.
Happy coding!!

[LinkedIn](https://www.linkedin.com/in/luqman-shaban/)
[Twitter](https://twitter.com/luqmanshaban01)
[GitHub](https://github.com/luqmanshaban/Leetcode-75/blob/master/src/Array/Reveresed%20Vowel%20of%20a%20String.ts)
Setting Up Elasticsearch with Docker: A Quick Guide
Published: 2023-08-13 13:24:46

If you're looking to get started with Elasticsearch and want an easy way to set it up for development purposes, Docker is your friend. In this guide, we'll walk you through the steps of creating a Docker container with Elasticsearch and provide usage instructions.

## Prerequisites

Before you start, make sure you have Docker installed on your system. You can download it from the [official Docker website](https://www.docker.com/get-started).

## Creating the Docker Container

To set up Elasticsearch using Docker, follow these steps:

1. **Create a Dockerfile**: Create a new file named `Dockerfile` in a directory of your choice.

2. **Paste the following content into the Dockerfile**:

```Dockerfile
# Use the official Elasticsearch Docker image as the base image
FROM docker.elastic.co/elasticsearch/elasticsearch:7.15.0

# Expose the port that Elasticsearch listens on
EXPOSE 9200

# Set environment variables for Elasticsearch configuration
ENV discovery.type=single-node \
    network.host=0.0.0.0 \
    transport.host=0.0.0.0

# Provide a helpful comment for usage instructions
# To build the Docker image:
# docker build -t my-elasticsearch-image .
#
# To run the Docker container:
# docker run -d --name my-elasticsearch-container -p 9200:9200 my-elasticsearch-image
#
# The Elasticsearch server will be accessible at http://localhost:9200
# The container's name is 'my-elasticsearch-container'
# You can customize these values as needed.

# Start Elasticsearch when the container starts
CMD ["elasticsearch"]
```

3. **Build the Docker Image**: Open a terminal and navigate to the directory containing the Dockerfile. Run the following command:

   ```sh
   docker build -t my-elasticsearch-image .
   ```

4. **Run the Docker Container**: After the image is built, run a Docker container with the following command:

   ```sh
   docker run -d --name my-elasticsearch-container -p 9200:9200 my-elasticsearch-image
   ```

## Accessing Elasticsearch

Elasticsearch will now be running in the Docker container. You can access it by opening your web browser and navigating to [http://localhost:9200](http://localhost:9200). This URL will display Elasticsearch's API response.

## Conclusion

Using Docker to set up Elasticsearch for development purposes is a quick and convenient way to get started. With a few simple commands, you can have Elasticsearch up and running in no time. Make sure to customize the container name and port as needed for your project.

Happy coding!
How to generates Tron private key and address offline
Tags: tron, donetcore
Published: 2023-08-13 13:22:55

### NuGet Import dependency libraries
```
PM> Install-Package Tron.Wallet
```

### Generate private key and addresse randomly
```c#
using Tron.Wallet;

namespace ConsoleApp1 {
    internal class Program {
        static async Task Main(string[] args) {
            var tronECKey = TronECKey.GenerateKey(TronNetwork.MainNet);
            var privateKey = tronECKey.GetPrivateKey(); //Private key
            var address = tronECKey.GetPublicAddress(); //Address

            Console.WriteLine($"{privateKey}\t{address}");
            Console.Readkey();
        }
    }
}
```
Types of Internet Proxies
Tags: interview, scor32k, security
Published: 2023-08-13 12:47:40

### What Is a Proxy?

At its core, a proxy is an intermediary server that stands between your device (computer, smartphone, etc.) and the internet. It acts as a gateway that forwards your requests and responses, effectively acting on your behalf. 

When you send a request to access a website or resource, the proxy server relays that request to the destination, retrieves the response, and sends it back to you.


## Type of Proxies 

### **Forward Proxy:** 
1. A forward proxy, commonly known as just "proxy," is often used by clients (users) to access resources from the internet. 

2. It masks your identity by using its own IP address, providing anonymity and security. 
3. When you request a webpage through a forward proxy, it fetches the content and sends it back to you, allowing you to access restricted or blocked content.
3. In simple, its a vpn that we use.
4. **Your Shield of Anonymity**

![](https://imgur.com/WSH7G3N.png)


### **Reverse Proxy**

1. A reverse proxy acts on behalf of servers rather than clients. 

2. It sits in front of one or more web servers, distributing incoming requests to those servers. 

3. This setup enhances security by isolating the internal servers from direct internet exposure. 

4. Additionally, reverse proxies can handle tasks like load balancing, caching, and SSL termination.
5. **Best for server efficiency**

![reverse proxy](https://imgur.com/LSjBSRb.png)

## Advantages

### Forward Proxy

1. Enhanced Privacy and Anonymity
2. Bypassing Content Filters
3. Protection from Malicious Sites
4. Monitoring and Logging

### Reverse Proxy
1. Load Balancing
2. Caching
3. Web Application Firewall (WAF)
4. Content Compression
談 CSS 命名
Tags: css
Published: 2023-08-13 12:05:44

一直以來本人較偏好的 CSS 命名都是依照 [rscss](https://eddiewen.gitbooks.io/rscss/content/) 的原則，可是即便如此，還是常常會遇到難以命名的問題，這篇試著把問題梳理，並提出一些可能的解法。


## rscss

先簡單介紹一下 rscss 的命名原則，在 rscss 我們把網頁拆各部位解成一塊塊的元件（component），例如 header 元件，而元件可以再容納子元件，例如 header 元件內有 brand、navigation、search 三個子元件，它們也可以有各自的子元件，一直到最後的小單位稱為元素（element），像是導覽區內的單一的連結，或是搜尋區的文字框等等，但 rscss 的元素並非一定相當於 HTML 的 tag，例如前面的導覽區的一個連結，在 rscss 的概念是元素，但在 HTML 結構上它可能是數個 tag 組合起來的：

```HTML
<a><i></i>link text</a>
```

總而言之 rscss 或其它的 CSS 命名原則，大多是以頁面的結構邏輯來解構與命名，而非以 HTML 碼結構來命名。

當然 rscss 很棒，但它只是原則性的指南，現實上有些狀況需要自行排除，下面談現實上會遇到某些難以命名的情況。

## 這塊怎麼取名？container 還是 wrapper 還是 block 還是其它？

對於組件，rscss 的命名原則是兩個單字，中間以連字號串連，例如 `.left-sidebar` 或 `.search-block`；而對於元素，則只用一個單字命名，這樣的命名原則很直觀的區分了組件與元素結構上的層級，但若是父子皆為組件的情況，又會再次遇到命名的問題。舉例來說，對於元件，最常用的也就是那三個單字—container、wrapper、block，例如這樣的 HTML 結構：

```HTML
<body>
  <main class="main-container">
    <section class="list-wrapper">
      <ul class="list-block">
       <li>xxx</li>
      </ul>
    </section>
  </main>
</body>
```

以上面的例子來說，如果走到第四層，就立馬會遇到「單字不夠用」的問題，下面提出一些個人的解法。

## 可能的解法

1. 加入 section 之類的描述「區塊」的字，讓可巢狀的層級更多，不過這看起來不是個夠通用的解法。
2. 對於功能型元件，強迫自己禁止使用 container、wrapper、block、section 之類的單字，而改用更具有描述性、語意性的字代替，譬如說 `.navigation-list`，而 container、wrapper、block、section 僅限用於排版型元件，或稱為容器型元件，就是只為了切版而存在的元件。

## 補充

1. 關於描述「區塊」的單字們—container、wrapper、section、block，誰大誰小應該也是要在專案內被定義的，可參考別人家的文章：
    1. [The Best Way to Implement a“Wrapper”in CSS](https://css-tricks.com/best-way-implement-wrapper-css/)
    2. [CSS Language Speak: Container vs Wrapper?](https://stackoverflow.com/q/4059163)
2. 別的流派的 CSS 命名原則有可能不會遇到前文描述的問題，不過過於畫蛇添足，非我所愛。把事情變複雜沒有比較厲害。

## 參考資料

- [rscss](https://github.com/rstacruz/rscss)
How to link a local npm dependency with pnpm
Tags: pnpm, javascript, dependencies
Published: 2023-08-13 13:06:40

---
title: How to link a local npm dependency with pnpm
published: true
date: 2023-08-13 11:48:05 UTC
tags: pnpm, javascript,dependencies
canonical_url: https://krzysztofzuraw.com/blog/2023/link-a-local-npm-dep-pnpm/
---

I have learned how to correctly link a local npm dependency when using [pnpm](https://pnpm.io/). Here is the process:

1. Execute `pnpm install ./your-library.tgz`.
2. Include the following code in your `package.json` file:

```json
{
  "pnpm": {
    "overrides": {
      "your-library": "file:./your-library.version.tgz"
    }
  }
}
```

Your dependency should now be properly linked!
APIs with PostMan
Tags: postmanapi
Published: 2023-08-13 11:42:25

Yesterday, 12th August 2023, 
I was Opportuned to attend a Workshop organized by @shedracksunday , where i learnt about POSTMAN.

POSTMAN is a software that can be used to read/get APIs. It's so easy to use.
The interface is user-friendly, and there's plenty of documentation available to help one get started.

So back to APIs,
What are APIs?
About a Year ago I was Opportuned to work with a Friend on Training a Weather Prediction Model by Feeding it Data gotten from "somewhere". Fast-forward to this Event I understand That what we used  then was an API.

I also was enlightened how APIs allows ease in communicating with Data without accessing the Codes of The platform that source the API, e.g I can get APIs from Netflix and Use it to interact with my program without interfering with Netflix interface / development.

POSTMAN makes use of Easy commands alongside A Friendly User interface that is quite friendly unlike the CLI.
Some of the Commands I get to understand are
The GET command which is used to retrieve APIs by using their URL's
The POST command That sends APIs.

Also, It was fascinating to see how POSTMAN enables users Share, collaborate and use APIs. It was all a Knowledge filled program