teleren/devto huggingface dataset:
Do we have pointers in python like other programming !
Tags: python, programming, tutorial, codenewbie
Published: 2022-02-16 09:21:22

Pointer is important to understand for the way you’re going to create data structures.

I’m going to start with something that is not a pointer and then compare it to something that does use a pointer.

Let’s say that we have two **variable**  `num1, num2`

    num1 = 11, 
    num2 = num1

    print("Before: ")
    print(num1) #11
    print(num2) #11

    # then let's change num1

    num1 = 22

    print("\nAfter\n")
    print("num1 =", num1) #22
    print("num2 =", num2) #11 

If you realized `num2` is still the same 11, you’re wondering now why `num2` still equals the same number, is it should update to 22 because we update num1!

So when you set `num1 = num2`, these are not linked forever, you are just initializing, and that is what happens when you’re working with something that is not using a pointer.

Now, let’s compare this to something that does use a pointer.

We’re going to use a dictionary in python, when you have something set equal to a dictionary, it’s a **pointer** to the dictionary.
Let’s use the same example and see.

    dict1 = {
        'value': 11
    }

    dict2 = dict1

    print("Before: ")

    print("num1= ", dict1) # {value: 11}
    print("num2= ", dict2) # {value: 11}

    dict1['value'] = 22

    print("\nAfter\n")

    print("num1= ", dict1) # {value: 22}
    print("num2= ", dict2) # {value: 22}

so when you set `dict2 = dict1` , you are literally saying `dict2` points to the exact same dictionary in memory as `dict1`.

There are a **couple of other concepts** I want to show here.

**The first concept is**, let’s just say we have another dictionary called dict3

    dict3 = {'value': 57}

    dict2 = dict3

    print (dict2) # {value: 57}

The pointer can be redirected like this also, and this idea of having a pointer point to a new place is a concept that you’ll use in a data structure.

**The second concept is**, let’s say now we set `dict1 = dict2` now all variables `(dict1 — dict2 — dict3)`
are pointing to `{'value':57}` so you might ask now, what happens to that dictionary `{'value': 22}` which is the old value for `dict1` before pointing to `dict3`. is not a way to get that pointer again `{'value': 22}`? yes no way to get this pointer again, now we should ask **what python does to free this memory up?**

Good question, python will run a process called **garbage collection** to remove this.

If you like the post leave a comment and tell me if you’d like to make a series of posts about data structure and how we can use pointers in it.


Let’s connect on [LinkedIn](https://www.linkedin.com/in/abdlrahmansaber/)
Is Web 3.0 legit? 🤔
Tags: web3
Published: 2022-02-15 15:54:22

Let’s start from the beginning of the Web itself.

🐣 Web 1.0 - static web.

This was the earliest stage of the internet. It contained limited information where no algorithms used to find relevant content. 

🐔 Web 2.0 - social web. 

It solved the Web 1.0 drawbacks, and give the user opportunity to create and edit the content. Which also lead to the bigger problem, where Evil corps (MANGA) took advantage of it and breached the user’s private informations.

🦄 Web 3.0 - decentralized web. 

It solves the privacy issues and is expected to be more interactive than Web 2.0. It’s not stable yet but has the potential to take off.

What is included in Web 3.0? 🤔

🌐 Semantic Web

It already exists. If you listen to Lewis Capaldi or Sam Smith on Spotify, you’ll probably going to see Dermot Kennedy or James Bay on your list the next morning. Their songs categorized as Soft Pop hits and turned into machine readable data. This is how semantic web works.

🤖 Machine Learning

The way semantic web organized is going to be handled by AI itself. Plus, Web 3.0 content will be less biased and junk-free. You won’t be able to increase page rank or buy reviews for a few bucks. Unrelated or biased content will be diminished by bots. This is the most beneficial and amazing part for everyone of us. 

🪐 Metaverse

It gives the user access to everything without the need to connect to smartphones or computers. Your Instagram profile pic turns into a virtual metaverse profile pic and represents you. You can sign documents, attend meetings like before but in a new 3D virtual environment. Yes, it will be a huuuge mess. Social debates about virtual life and real life will be out there for a long time. You can’t stop the progress, can you?

🧩 Blockchain and smart contracts

This is legit. The new web can be almost unhackable and privacy focused. You’ll still see the relevant cat videos but your data always stays in your pocket. Your medical records, passport or ID cards will be included in the blockchain which provides the real safety and control. Cryptocurrency, NFT, DeFi also part of that.

What skills will pay my bills? 🤔

Please, don’t. I know what you’re thinking at this point. You don’t have to stop whatever you’re good at and start learning  Solidity, Python, Unity or so on. Trends come and go. Php never died. There are people who still get paid for Matlab. Kotlin hasn’t replaced Java yet. 

You should just consider learning those Web 3.0 technologies in your free time. I don’t like audacious goals, I like steady and long lasting small changes. If you’re good at any of the programming language, then transition won’t be a problem. 😉

👉  Recap:

Web 3.0 is legit. Get prepared for the next big thing.

@seniortips

For more posts like these visit my telegram channel: https://t.me/seniortips
Memory Hack - Simple Brain Hacks to Improve Your Memory!
Published: 2022-02-16 09:00:39

Evidently, I have an information and have observed an interesting characteristic pertaining to that condition. A most mentors feel this way. They were quite stoic. I gather that you should find an unexpected source of [Memory Hack](https://ipsnews.net/business/2022/02/09/memory-hack-cognitive-brain-formula-ingredients-and-warnings-must-read-before-buy-it-update-2022/) is that it leaves you with more Brain Booster Supplements. I may not be too awed by that ploy. This is a closely guarded secret in regard to doing that. Aren't you among the plenty of folks doing just that? I love to tear away the FUD to get to the essence of Memory Hack. I felt like I had been kicked in the chest. Please, I figured this out by myself. This is all you ought to know. As my buddy puts forth, "No use crying over spilt milk." Last year I shared a series of questions for you to ponder touching on that propensity. Granting all this, Put it in your pipe and smoke it. Honestly, I don't mind that at all. Bummer! 

Visit Hare=> [https://ipsnews.net/business/2022/02/09/memory-hack-cognitive-brain-formula-ingredients-and-warnings-must-read-before-buy-it-update-2022/](https://ipsnews.net/business/2022/02/09/memory-hack-cognitive-brain-formula-ingredients-and-warnings-must-read-before-buy-it-update-2022/)
INTRODUCTION TO COLOUR CODE IN HTML AND CSS
Published: 2022-02-16 08:52:50



Color is the property possessed by an object of producing different sensations on the eye as a result of the way it reflects or emits light.

HTML Color Codes are a way to represent colors in a way that a computer can understand and display. Hex codes are the most often used color codes. Hex codes are three-byte hexadecimal integers (consisting of six variables) that contain a pair of characters that reflect the intensity of red, green, and blue in the color.

The sign "#" is followed by six alphabets or numerals in each Hex color code. The hexadecimal system is used to represent numbers. There are a total of 1,67,77,216 color combinations to choose from. The lowest color intensity is represented by the 00 value range, while the highest color intensity is represented by the FF value range.

Meaning of a Hex code:
•	The 1st and 2nd variable in Hex color code represents the intensity of red color.
•	The 3rd and 4th variable represents the intensity of green.
•	The 5th and 6th variable represents the intensity of blue.
•	By combining the intensities of red, green, and blue almost any color can be made.
####Note
The white color is a mixture of the three primary colors at full intensity representing the Hex color code #FFFFFF.

The black color is a mixture of the three primary colors at the lowest intensity representing the color code #000000.

These color codes can be used to change the color of a web page's background, text, and tables. They can also use photo editing apps like Adobe Photoshop to reference specific hues.

###MAJOR HEXADECIMAL COLOUR CODES
Some of the most frequent color names and codes are shown below. You can also use the color name with these colors. You could, for example, use "red" instead of "#FF0000" in HTML tags and CSS that employ color codes.


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


####References
https://www.geeksforgeeks.org/html-hex-color-codes/
https://www.computerhope.com/htmcolor.htm#major-color-codes
https://www.educba.com
Error Free Laravel Migrations
Tags: laravel, migrations
Published: 2022-02-16 08:31:57

If you're trying to modify `database table`, use following code for migrations:

```php
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class [class_name] extends Migration
{

    public function table()
    {
        return '[table_name]';
    }

    public function columns()
    {
        return [
            [
                "type"=>"integer",
                "column"=>"[column_name]",
                "after"=>"[after_column_name] (optional)",
            ]
        ];
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        $table = $this->table();
        $list = $this->columns();

        foreach ($list as $item)
        {
            if(!Schema::hasColumn($table, $item['column'])){
                Schema::table($table, function (Blueprint $table) use ($item)
                {
                    $type = $item['type'];
                    $column = $item['column'];
                    if(isset($item['after']))
                    {
                        $table->$type($column)->nullable()->after($item['after']);
                    } else
                    {
                        $table->$type($column)->nullable();
                    }
                });
            }
        }

    }

    /**
    * Reverse the migrations.
    *
    * @return void
    */
    public function down()
    {
        $table = $this->table();
        $list = $this->columns();
        foreach ($list as $item)
        {
            if(Schema::hasColumn($table, $item['column'])){
                Schema::table($table, function (Blueprint $table) use ($item)
                {
                    $column = $item['column'];
                    $table->dropColumn($column);
                });
            }
        }
    }
}


```
REACT APIS WITH EXAMPLE
PART1:React.memo()
Tags: react, javascript, functional, performance
Published: 2022-02-16 08:23:28

### introduction

A fast and reliable user interface (UI) is an important factor in modern web development. To improve performance React offers several APIs.

`React.memo()` is a high-order component that wraps around our functional component and returns a memoized version. whenever users interact with the UI React re-renders the component and compares the previous component to the next one.
if it is not the same then React would update the DOM with the new one (re-rendered component).

```javascript
const MemoizedComponent=React.memo(Mycomponent)

```

let's explore this API through an example. let's say we want to present a input wuth a heading or labels
whenever we change the input whole section get re-rendered(the heading or any other component) but in fact it's a unnecessary re-render

this is where React.memo() comes to the rescue!.it wraps around the Heading component and gives us a [memoize](https://en.wikipedia.org/wiki/Memoization) result back.in simple terms, it gives us a rendered component and it will use the result on the next DOM update unless the component `props` have changed.
type something in the input. heading wrapped around memo is not re-rendering
{% codesandbox react-memo-obowp %}

### areEqual

`React.memo()` accepts a second argument:

```javascript

const memoizedComponent=React.memo(MyComponent,function areEqual(prevProps,newProps) 
        {
		// compare logic
		// return true of false
       })


```

it passes `prevProps` and `newProps` to the function giving the ability to the developer to decide when to re-render the component.

>💡 areEqual function must return **true** or **false** 
> returning **true** means no re-rendering returning **false** cause re-rendering

Remember `React.memo()` does a shallow comparison, it means if there are complex arrays or objects as props it always returns false, therefore, need to add a custom function(areEqual) to compare complex objects and arrays

#### when to use
whenever dealing with middle or big size components that consist of a couple of small size components and they keep re-rendering the same result over and over 

#### when not to use
if the component updates occasionally and it wouldn't make much difference using a memoized version.

###conclusion

although React does a lot of optimization internally but `React.memo()` gives the ability to the developer to define more suitable optimization. remember using `React.memo()` is not the solution to every performance issue. implementing a good design pattern and data structure is the key factor in optimization.


_follow me on [twitter](https://twitter.com/k1_kh89)_😎
Pagination with JPA queries
Tags: java, jpa, codever, snippets
Published: 2022-02-16 08:13:05

Use the `firstResult(int startPosition)` and `setMaxResults(int maxResult)` of the JPA `Query` interface.
The `firstResult()` method sets the **offset** value in SQL lexicon, meaning the position of the first result to retrieve.
The `setMaxResults()` method sets the **limit** value in SQL lexicon, meaning the maximum number of results to retrieve:

```java
@Stateless
public class PartnerInitialLoadRepository {

  @Inject private EntityManager em;

  public List<PartnerInitialLoad> getNextUnprocessed(Integer pageSize, Integer offset) {
    var jpqlQuery="select p from PartnerInitialLoad p where p.status = 'UNPROCESSED' order by p.partnernumber asc";
    var query =
        em.createNamedQuery(jpqlQuery, PartnerInitialLoad.class);
    query.setFirstResult(offset);
    query.setMaxResults(pageSize);

    return query.getResultList();
  }
}
```

JPA with Hibernate translates this in the following SQL statement in Oracle dialect which uses **offset** and **limit**:

```sql
select partnerini0_.PARTNER_NUMBER as PARTNER_1_13_,
       partnerini0_.COMPLETED_AT as COMPLETE2_13_,
       partnerini0_.STATUS as STATUS3_13_
from T_PARTNER_INITIAL_LOAD partnerini0_
where partnerini0_.STATUS is null
   or partnerini0_.STATUS = 'UNPROCESSED'
order by partnerini0_.PARTNER_NUMBER asc
offset ? limit ?;
```

An alternative would be to use **native queries**, the major drawback is that you make your code dependent on the underlying RDBMS:

```java
  public List<PartnerInitialLoad> getNextUnprocessed(Integer pageSize, Integer offset) {
    var sqlNativeString =
        String.format(
            "select * from T_PARTNER_INITIAL_LOAD where STATUS = 'UNPROCESSED' order by PARTNER_NUMBER asc OFFSET %s LIMIT %s",
            offset, pageSize);
    var query = em.createNativeQuery(sqlNativeString, PartnerInitialLoad.class);

    return query.getResultList();
  }
```

<hr/>

> Shared with :heart: from [Codever](https://www.codever.dev/snippets/620bde4ee102f148ceb9f6eb/details). Use :point_right: [**copy to mine**](https://www.codever.dev/snippets/620bde4ee102f148ceb9f6eb/details) functionality to add it to your personal snippets collection.
Log Request Body in Guzzle
Tags: middleware, guzzle
Published: 2022-02-16 07:57:01

Debugging when using [Guzzle](https://docs.guzzlephp.org/en/stable/overview.html), is quiet easy by providing the `debug` key in the payload:

```php
$client->request('GET', '/url, ['debug' => true]);
```

This is quiet easy and not an issue if your are not passing any body content, using only query string to dump what's been request.

It will different story if you are sending JSON content - you need to know the write data send to your URI destination.

You can create a [middleware](https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware) for this purpose.

**TLDR**

```php

use GuzzleHttp\Client;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Psr\Http\Message\RequestInterface;

$stack = new HandlerStack();
$stack->setHandler(new CurlHandler());

$middleware = Middleware::tap(function (RequestInterface $request) {
    if(config('services.api.debug')) {
        $body = (string) $request->getBody();

        if(!empty($body)) {
            $body = json_decode($body, JSON_OBJECT_AS_ARRAY);
        }

        logger()->channel('api')->info([
            'url' => $request->getUri(),
            'body' => $body,
            'headers' => $request->getHeaders(),
        ]);
    }
});

$stack->push($middleware);

$client = new Client(
    [
        'base_uri' => config('services.api.base_url'),
        'handler' => $stack,
    ]
);

$client->request('GET', '/url', ['json' => ['abc' => 123]]);
```

With this piece of codes, it helps you to debug what kind of data being send before request is send.

p/s: I'm using Laravel, hence some of the syntax related to Laravel.
Advice from a junior developer to a new freshly starting developer
Tags: beginners, programming, career, productivity
Published: 2022-02-16 07:56:24

## Introduction

I have been working as a software developer close to 1 year now, and I have noticed some stuff during my time as a developer that could probably help a developer that is starting out completely fresh in this industry. Here are 5 tips I have for new developers coming to the scene.

## Have some projects under your belt

Currently I myself am in progress of making more projects to better represent my skills, but even before I had any job, I still had some CRUD apps to show to an employer. It doesn't really matter what projects it might be - a calculator app, GUI app, what matters is that you are able to show your competencies as a developer with some sort of projects you have made.

## Utilize the power of networking

I probably could go even more in depth about utilizing LinkedIn to get a job, but I cannot stress enough how important is making connections. Most of the time, it is not me applying to companies, it is companies messaging me, asking me to come for an interview. That comes when you have tons of connections on LinkedIn or in real life as well. I would recommend going to various meetings for technologies or while in university, making as many acquaintances as possible.

## Select your first workplace wisely

While having your first job is great and all, it is much better to apply to your first place, where the team would support you in achieving greatness by teaching you how to write proper code and giving you all of the resources to improve. If it so happens, that you are in a workplace environment where the company doesn't curate your improvement, then I have a good quote for you 

> If the job doesn't pay well, or you're not learning anything useful, then it is time to leave.

## Do some research on the technology stack where you are based in

I once made a web scraper to understand what I would need to learn to land a job fast. It so happened to be react, and that is the technology I am sticking with, which brings me to another tip...

## Find your favorite technology, and stick with it

For me, it was react, because I am a fairly creative person and I love creating stuff with code, before that, I had used C#, Python and other languages. But I believe, that once you start programming, you should stick with one technology, learn it well, and then other languages will be much easier, due to them just being so similar to each other most of the time
Twitter meta clone by Quasar + Vue + SCSS + TypeScript + Vue Router
Tags: webdev, scss, javascript, vue
Published: 2022-02-16 06:44:59

I've just deployed a [twitter clone web](https://twitter-meta.vercel.app/#/).
This project is written by me in Vue3 on **Quasar CLI** + **TypeScript** combined with **SCSS**+ **Vue Router**+ **Prettier** + **Eslint**.
Stay up-to-date with tweets from news and entertainment highlights to sports and politics, fully informed with all live commentary. Free widely available online for everyone.
Currently, I am still continuing to develop it to become a finished product as soon as possible. Follow us.
Please support me by giving this repository 1 star at: https://github.com/thuongtruong1009/twitter-meta
How to use Private Git Repo as an NPM Package?
Tags: node, package, javascript, typescript
Published: 2022-02-16 06:43:07

History in short: I was about to build a project in MERN stack. The architecture I chose was micro-service. I had to put some shared code in shared package. I looked onto npmjs.com which asks for money to publish private packages.

I taught of using private git repository as npm package. Here is the guide to use a private package as npm package.

Create a private git repository. And push your code. Optional : Add.npmignore. My shared code was built using typescript and I didnt want those ts files in the package.

Go to your repository and copy the repo link as http. (ssh didn't worked for me.). Then come back to your project and run 
`npm install repo_link`
Example: `npm install https://github.com/expressjs/express.git`
If you want separate branch as package then install the package like: `npm install https://github.com/expressjs/express.git#4.x`

You can also use specific commit too:
`npm install https://github.com/expressjs/express.git#commit_id`

Whenever you push some code to that specific branch then just upgrade the package using `npm upgrade repo_link`

So I found this free real estate. Enjoy Devoloping :computer:.