teleren/devto huggingface dataset:
100 Awesome tech talks - 1: Ease at work - Kent beck
Tags: career, motivation, techtalks
Published: 2022-01-05 03:12:55

[Ease at work - Kent Beck](https://www.infoq.com/presentations/self-image/)

## What does ease mean?
* State of comfort
* Freedom from worry, pain or agitation
* Readiness in performance, facility

### State of comfort
We need to have a  sense when working that we are doing the right thing, that we are at the right place, that we are answering our calling.

### Freedom from worry, pain or agitation

* anxiety is kryptonite for programmers
* if we are worrying, we are not doing our best work.
- we are anxious about deadlines, expectations
- we are worrying about technology, looking at new technology

### Readiness in performance, facility

* We should not worry about things that dont matter
* care deeply about things that do matter.
* care deeply about our work -> be fulfilling some kind of purpose

## What causes unease?

* We have to work on the sense of ease
* what is taking it  away?, how to  get it  back?

### Battle between two extremities 

* We are swinging between two extreme states
* We are awesome, the best programmer in the world
* We are bad, the worst programmer
* We need to reduce the amplitude of these swings so that our self image is correlated with reality.
* We need to manage these extremes

## How to be more at ease?

### My work matters

* If we believe that our work does not matter, we are not at ease
* work that does not matter is a place of dis-ease
* Find purpose in different ways
  * Economic : sales go up, company is  more valuable
  * Social impact

### Knowing that the code works

* TDD - designs get better, more feedback, more  documentation
 * I know that my code works.
 * fear is transmuted into boredom.
* Afraid of breaking something, causes  unease

### Pride

* be proud of  your code.
* we can be proud of our code in different dimensions.
 * following best practices
 * writing clean code
 * taking a mess and cleaning it up
 * adding successfully  to a mess
* when we are proud of our work, we are at ease

###  Make public commitments

* make public commitments about  what  you are going to do
* accountability   -> without excuse,  without blaming others
 * not blaming others
* we can fall short sometimes.
* when we  can account for  ourselves   -> we are at ease
* schedule chicken  -> everybody in the table knows you are not going to make the schedule

### Interpret feedback
 
* interpret both positive and negative feedback.
* dont be carried away by  both positive and negative feedback.

### I am a beginner

* learning new things help us see the limits of our knowledge
* we get more feedback  by deliberately putting ourselves in the mindset of a beginner

### Meditate
* Meditation helps us with ease

### Serve

* Deliberately doing things with no sense of reward.
* helping others

> A man cannot be comfortable without his own approval
> - Mark Twain
Laravel 8 Yajra Datatable Example Tutorial
Tags: laravel, laravel8, yajradatatable, crud
Published: 2022-01-05 03:03:11

Today I will show you laravel 8 yajra datatable example tutorial. Datatable provides user to many functionalities like search button, custom button, responsive table, search records, filter data, pagination etc. In this example we will see how to install / use datatable in laravel 6/7/8.

Also we are perform laravel 8 crud operation in datatable. laravel 8 datatables with server side. laravel-yajra datatable example.

Yajra datatable is one of the the famous package in laravel 6/7/8 and php. Datatables is basically jquery plugins that allows you to add advanced interaction controls to your HTML tables data. Datatables also provide ajax for data searching and getting.

So, let's start laravel 8 yajra datatable example tutorial.

```
Step 1 : Create new project in laravel 8

Step 2 : Install Yajra Datatable Package

Step 3 : Create Some Dummy Records Using Tinker

Step 4 : Add New Route

Step 5 : Create Controller For Datatable

Step 6 : Create Blade File
```

---

> **_[Read More : Laravel 8 Yajra Datatable Example Tutorial](https://techsolutionstuff.com/post/laravel-8-yajra-datatable-example-tutorial)_**
Using the Spotify API with Next.js
Tags: webdev, programming, nextjs, javascript
Published: 2022-01-05 02:50:00

It's a fun, unique way for me to showcase various metrics about my life. It's also a playground for experimenting with new technology and APIs. It currently has integrations with YouTube, Unsplash, Firebase, Revue, GitHub, Gumroad, and now Spotify!

I wanted to display what song I'm currently listening to, as well as my top tracks. To accomplish this, I'd need to integrate Spotify's API with Next.js API routes. This post will be a quick tutorial to get up and running with Spotify.

Create an Application
First, we need to create a Spotify application to give us credentials to authenticate with the API.

Go to your Spotify Developer Dashboard and log in.
Click Create an App.
Fill out the name and description and click create.
Click Show Client Secret.
Save your Client ID and Secret. You'll need these soon.
Click Edit Settings.
Add `http://localhost:3000` as a redirect URI.
All done! You now have a properly configured Spotify application and the correct credentials to make requests.

**Authentication**

There are a variety of ways to authenticate with the Spotify API, depending on your application. Since we only need permission granted once, we'll use the Authorization Code Flow.

First, we'll have our application request authorization by logging in with whatever scopes we need. Here's an example of what the URL might look like. Swap out the `client_id` and scopes for your own.

After authorizing, you'll be redirected back to your redirect_uri. In the URL, there's a code query parameter. Save this value.

http://localhost:3000/callback?code=NApCCg..BkWtQ
Next, we'll need to retrieve the refresh token. You'll need to generate a Base 64 encoded string containing the client ID and secret from earlier. You can use this tool to encode it online. The format should be `client_id:client_secret`.

This token is valid indefinitely unless you revoke access, so we'll want to save this in an environment variable.

Read The Complete Article Here:- https://www.epicprogrammer.com/2021/12/using-spotify-api-with-nextjs.html
Create a Dynamic Sitemap with Next.js
Tags: programming, nextjs, javascript, webdev
Published: 2022-01-05 02:45:49


To improve your Search Engine Optimization (SEO), you might need to add a sitemap or robots.txt file to your Next.js site.

A sitemap defines the relationship between pages of your site. Search engines utilize this file to more accurately index your site. You can also provide additional information such as last updated time, how frequently the page changes, and more.

A robots.txt file tells search engines which pages or files the crawler can or can't request from your site.


## Static Sitemaps


If your site does not update frequently, you might currently have a static sitemap. This is a basic .xml file defining the content of your site.

As your site scales, you will probably want to create your sitemap dynamically.

## **Dynamic Sitemaps**
If your site frequently changes, you should dynamically create a sitemap. Let's first look at an example where your site content is file-based (e.g., contained inside the /pages directory).

First, let's add globby so we can fetch a list of routes.


Note: globby might not work on Windows.
Next, we can create a Node script at scripts/generate-sitemap.mjs. This file will dynamically build a sitemap based on your /pages directory.

Finally, add postbuild script in your package.json to run this script after next build completes. Your generated file gets created at public/sitemap.xml which is then accessible from the root of your site.

External Content
If you have externally hosted data (e.g., a CMS), you'll need to make an API request before you can create your sitemap. This implementation will vary depending on your data source, but the idea is the same. To demonstrate, I've created an example using placeholder data.

First, create a new file at pages/sitemap.xml.js

When the route /sitemap.xml is initially loaded, we will fetch posts from an external data source and then write an XML file as the response.

**

## robots.txt
**
Finally, we can create a static file at public/robots.txt to define which files can be crawled and where the sitemap is located.

Read The Complete article here:- https://www.epicprogrammer.com/2022/01/create-dynamic-sitemap-with-nextjs.html
Leetcode diary: 950. Reveal Cards In Increasing Order
Tags: javascript, algorithms, devjournal, motivation
Published: 2022-01-05 01:58:16

This is a new series where I document my struggles of leetcode questions hoping seeing however small of an audience I get gives me the motivation to continue.  

This is first of many to come problems that I did not know how to solve. 

I'll post my code here: 

```
/**
 * @param {number[]} deck
 * @return {number[]}
 */
var deckRevealedIncreasing = function(deck) {
    if(deck.length ===1) return deck;
    
    deck = deck.sort(function(a,b){
        return a > b ? 1 : -1; 
    });
    let orderedN = Math.ceil(deck.length/2);
    let numInverts = deck.length-2;
    
    const orderedDeck = deck.slice(0,orderedN);
    const rotateDeck = deck.slice(orderedN);
    
    let finalUnordered = [];
    while (numInverts--) {
        if(!orderedN) {
            finalUnordered.push(rotateDeck.shift());
        }
        rotateDeck.push(rotateDeck.shift());
        orderedN--;
    }
    finalUnordered = finalUnordered.concat(rotateDeck);

    const finalArray = [];
    orderedN = Math.ceil(deck.length/2);
    while(orderedN--) {
        finalArray.push(orderedDeck.shift());
        
        if(finalUnordered.length) {
            finalArray.push(finalUnordered.shift());
        }
    };
    
    return finalArray;
};
```
Note that this is wrong. My thought process is that I know for Math.ceil(length/2) number of elements, they are simply the ordered array elements that are in 0,2,4... positions. 

The problem was that i did not know how to handle the pushed to the back elements. I tried many things and came up with the mess in the middle of the code for the finalUnordered array. It did not turn up well albeit passing a couple test cases.

This is the code in the solution in Java: 

```
class Solution {
    public int[] deckRevealedIncreasing(int[] deck) {
        int N = deck.length;
        Deque<Integer> index = new LinkedList();
        for (int i = 0; i < N; ++i)
            index.add(i);

        int[] ans = new int[N];
        Arrays.sort(deck);
        for (int card: deck) {
            ans[index.pollFirst()] = card;
            if (!index.isEmpty())
                index.add(index.pollFirst());
        }

        return ans;
    }
}
```

It does not have to be a deque, for js-only developers, it's the same as using a regular array.

Upon looking at this code, it turned out I was definitely on the right track, so fucking close! However, I should not have restricted my emulation on just the later half of the ordered array. It is definitely not necessary to do so. Had I emulated the whole array I would have probably solved this problem already.

My main problem here is that I went down a rabbit hole in trying to figure out some kind of mathematical relationship in the operation when it is just easier to emulate it.

This question brings up the dilemma between mathematical approach vs simple brute force. I definitely need more practice to discern which approach I should initiate with.

Let me know anything on your mind after reading through this, THANKS!
100 Days of Code - Day 4
Tags: 100daysofcode, css
Published: 2022-01-05 01:42:19

More CSS, yay! Completed the next couple of lessons of section 3, CSS Basics of [Modern HTML & CSS From the Beginning](https://www.udemy.com/share/1013eA3@vWdDAwIbTNKVDgdoKRg7QR2jUvRHDQ3ZaF3Dd-HzUhJUlzvcDZZUUPGMPdldaX2q/) and while I do not dislike CSS any less, I can say I have a much better understanding of the box model and floats than I had gained during my bootcamp cohort. I remember not really grasping the concept at all back then and simply using trial and error until I got the look I wanted hopefully causing less of headache. Finished up by a review of pseudo classes and used them to style an anchor tag and button tag to look exactly the same.
Features of Blockchain which makes it useful
Tags: blockchain, crypto
Published: 2022-01-05 01:08:16

## Introduction
Blockchain contains 2 words in itself one is block and the other is chain. The block represents the data which are stored in variety of computers and chain makes the network. So the blockchain is a record of data stored in networks of computers.

**There are 3 features of blocchain which makes it useful:**

1. Decentralization
2. Immutability
3. Transparency

### Decentralization:
Once a data is being created, it gets divided among the network of computers and no particular authority has a hold on it. So, no centralized authority is present in a blockchain platform.

### Immutability
Once a data is being put up in the blockchain network, it cannot be altered or forged. This happens due to advanced cryptography hashing concepts. 

### Transparency
In a blockchain network every action is stored as a transaction and once a transaction is made, the data becomes available to all. Since no central authority remains and the data is also immutable, the data is kept forever and everyone can see  it making it a transparent and trustable system for everyone.
Customize the appearance of your terminal
Tags: linux, ubuntu, terminal, wazaterm
Published: 2022-01-05 01:07:10


> This article is the 4th day of the Advent Calendar 2021 of [Wazaterm](https://www.wazaterm.com), an online Linux terminal for hackers.


It's easy to change the appearance of the terminal in Wazaterm.

After you click the hamburger menu on the top right in the terminal window, the sidebar shows up.


![Menu](https://www.wazaterm.com/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBSZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--d80843dbf653cc71d3ca22ccfd32252858bad948/E7DEE26E-F357-444D-87A5-165273604782.jpeg)  

In the sidebar at the bottom, you see the select box. You can select your terminal theme from 250+ themes.

![Terminal Option](https://www.wazaterm.com/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBSdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--f2bdc0c2fd61db51d0f011b61ffc71af3d0b782c/9BACAD0F-B45B-4500-8083-6D0B3D3F76AE.jpeg)

Also, you can overwrite the color when you change RGB.

Clicking "Save" will save the terminal colors and font size, along with the OS and browser information. And the order in which they are displayed using that information is the below.

```
def current\_terminal\_option(os, browser)
  self.terminal\_options.find\_by(os: os, browser: browser) ||
  self.terminal\_options.find\_by(os: os) ||
  self.terminal\_options.find\_by(browser: browser) ||
  self.terminal_options.last ||
  self.terminal_options.new
end
```

It looks for the OS and Browser, and if they are not there, it shows only the OS, and if they are not there, it shows the Browser, and if they are not there, it shows the latest settings, and if they have never been set, it shows the default.


The system is designed for multi-device use, so you can save and recall settings with different font sizes for iPad and desktop.
Kafka vs. RabbitMQ
Tags: eventdriven, architecture
Published: 2022-01-05 00:54:05

I've written this article for explaining what's the main difference between Kafka and RabbitMQ. I know there are a lot of articles try to compare them on their capabilities like the message routing, performance, persistence, etc. I like [this post](https://tarunbatra.com/blog/comparison/How-to-choose-between-Kafka-and-RabbitMQ/ ) the most, which gives a precise and fair summary to both of them.

Nevertheless, those articles all stand on the server side to consider how to choose Kafka or RabbitMQ. They rarely consider from the client side, i.e the story on workers. In my opinion, both Kafka and RabbitMQ itself work very well on every use case. The most common thing we encounter is not that the server cannot handle messages, but the workers are too slow to process messages. If the workers indeed cannot afford the workload, we usually adopt the horizontal scaling to increase the throughput. 

## RabbitMQ

I demonstrate this scenario as follows:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2q7kqgrl0ocdku2ix3h.png)

The *MQ* represents either RabbitMQ or other message queue systems. In this case, we can extend the amount of workers to handle more messages at the same time. However, the order of messages cannot be preserved. RabbitMQ treats every message as the standalone entity and can be dispatched to any one of unified workers. In fact, you can setup a complex exchange and routing rule to ensure the message ordering manually. If you do so, you will introduce the complexity in a system and significantly make a tightly coupling between producers and consumers.

## Kafka

How to deal with this problem? I mean how does Kafka preserve the message order. The illustration is:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4f2xxea3w0s1qcyl5xyx.png)

The magic is a producer still publishes a message to a topic, but Kafka pushes the message into the corresponding partition based on the key. Consumers can be a consumer group, and the consumers in the same group will be dispatched to the certain partition(s). In other words, the same kind of messages are processed on the same consumer to make sure the correctness of orderings. Furthermore, the participants in a consumer groups can be dynamically adjusted to sort out the run-time workload.

## Conclusion

From my point of view, if the user scenario is the producer generates lots of messages, and you have to add more consumers to digest them, you should use Kafka. Otherwise, Kafka and RabbitMQ both are great tools, you can choose according to the technology stack in your organization.
CREATE PRIVATE KEY AND ADDRESS TRON PYTHON
Tags: python, tron, wallet, programming
Published: 2022-01-05 00:24:18

make and create wallet address and private key in tron network (trx) with help python for batch maker code sample . In this tool, many other models and methods can be used and it can be used for other ways, which I will try in the future for you, dear friends, more and more professional tools in this field. But as far as I could, I sent this tutorial simple so that even beginners can understand it from the beginning tron (TRX). I promise you the future development of this tool.

```
from tronpy.keys import PrivateKey
import time

a=1
while True:
    Private = PrivateKey.random()
    Address  = Private.public_key.to_base58check_address()
    print((a),'\nP:',Private,'\nA:',Address)
# You can change it in seconds. The less it is
# the faster you want the result. The more CPU it uses.
    time.sleep(1)
# You can delete this value if you do not need to number
# and sort the output results
    a=a+1
```
needed install this package "tronpy" can you install this code :
```
pip3 install tronpy
```
10 ReactJS Coding Challenge (💥Coding Interview Prep💥)
Tags: javascript, react, webdev, challenge
Published: 2022-01-05 00:20:37

Last month, I posted 2 ReactJS interview questions 🎤 - [Advance Questions](https://dev.to/frontendengineer/react-interview-questions-part-2-mid-senior-level-cal) and [Commonly Asked Question](https://dev.to/frontendengineer/common-react-interview-questions-50gm) and got a significant welcome by dev.to community. 🤗 🥰 Many thanks to all of you!

I decided to complete the package by creating codepen exercises 📝 and a video 📺 to follow up on that effort as one will need to code following the technical interview questions. Also, I added potential solutions for the exercises which is listed below. 

If you need to brush up 🆙 your ninja ReactJS skills, you can try to answer the exercises below OR click the video below to guide you step-by-step interactively. (No filler, fast, straight to the point as I highly respect/value your time)

{% youtube VzNNjNmbXpY %} 

These exercises and solutions will also be available on the video as well.

### Exercises: 🏋️
#### Display simple JSX 
  - https://codepen.io/angelo_jin/pen/wvrygZa

#### Display array of users to browser
  - https://codepen.io/angelo_jin/pen/QWqQdXE

#### Show/Hide Element on Screen
  - https://codepen.io/angelo_jin/pen/zYERZZL

#### 2 way data binding in ReactJS
  - https://codepen.io/angelo_jin/pen/MWEQmqN

#### Disable a button
  - https://codepen.io/angelo_jin/pen/YzrazGY

#### Update the parent state
  - https://codepen.io/angelo_jin/pen/JjrLjOy

#### Dynamically add child components (React Children)
  - https://codepen.io/angelo_jin/pen/BawrpeX

#### Sum of Two Numbers
  - https://codepen.io/angelo_jin/pen/zYEWZNR

#### Create Counter App
  - https://codepen.io/angelo_jin/pen/mdBxWwN

#### Fetch data from an API
  - https://codepen.io/angelo_jin/pen/oNGqZpm

### Solutions: 🙋
#### Display simple JSX 
  - https://codepen.io/angelo_jin/pen/xxXrZLd

#### Display array of users to browser
  - https://codepen.io/angelo_jin/pen/wvreMpZ

#### Show/Hide Element on Screen
  - https://codepen.io/angelo_jin/pen/abLwyrL

#### 2 way data binding in ReactJS
  - https://codepen.io/angelo_jin/pen/yLzvMop

#### Disable a button
  - https://codepen.io/angelo_jin/pen/dyVmyYz

#### Update the parent state
  - https://codepen.io/angelo_jin/pen/KKXoKgO

#### Dynamically add child components (React Children)
  - https://codepen.io/angelo_jin/pen/MWEVJNb

#### Sum of Two Numbers
  - https://codepen.io/angelo_jin/pen/BawrWzy

#### Create Counter App 🕒
  - https://codepen.io/angelo_jin/pen/yLzKMXX

#### Fetch data from an API
  - https://codepen.io/angelo_jin/pen/zYEWZdW

Happy coding and good luck on your next interview! I hope this material will help you land your next dream job. 💰 🚗 📈
How To Create A Memory Leak In Golang
Tags: gogolangmemoryleak, go, memoryleak
Published: 2023-07-07 14:12:44

---
title: How To Create A Memory Leak In Golang
published: true
date: 2022-01-05 00:00:00 UTC
tags: gogolangmemoryleak,go,golang,memoryleak
canonical_url: 
---

A while ago I was monitoring a containerized application, and noticed an odd pattern in the graph for memory usage. The memory usage would climb steadily until reaching the memory limit set on the container and then precipitously drop to zero. This pattern would repeat as long as the application was running. I had a memory leak. _Cue ominous music_

The cause of the memory leak was a fairly simple thing, but due to multiple changes over time in this area of code I had completely missed it. Here is the relevant code:

```
package main

func main() {
	running := true

	for running {
		defer func() {}()
	}
}

```

_Warning: If you execute this code on your machine, it will max out your CPU and eventually your memory_

I had deferred a function inside of a long running loop. Each time a function is deferred, it gets added to a stack or stack-like data structure (last in, first out). Once the function containing the `defer` is completed the stack for that function is emptied one by one and executed. The issue here is that the loop completing an iteration does not trigger the execution of the deferred functions, nor does exiting the loop.

In my case, deferred functions would continue to be added to the deferred functions stack until the memory footprint finally exceeded what was allowed by the container causing the container to crash. A way around this issue, would be to wrap the `defer` statement in another function like this:

```
package main

func main() {
	running := true

	for running {
		func() {
			defer func() {}()
		}()
	}
}

```

Wrapping the `defer` in a function causes the secondary function’s deferred functions to be executed on every iteration instead of letting them accumulate indefinitely until the program finally finishes. That being said, the solution for my issue was to remove the deferred function from inside the loop.

```
package main

func main() {
	defer func() {}()

	running := true

	for running {}
}

```