teleren/devto huggingface dataset:
Weekly 0020
Tags: weeklyretro
Published: 2022-07-10 18:21:40

### Monday

I started the week to work on my productivity workflow.
I decided to reorganize my Notion from scratch and I tried to find inspiration from the book “Building a Second Brain” by Tiago Forte and other online Notion templates.
It’s an hard work but I learnt a lot of stuff about Notion.

I called my template “Digital Garden” and I think the next week I will publish on Gumroad.

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

In the afternoon I did an estimation for a new project for a customer and I did a call with one of my colleague to talk about it.

**Mood:** 😪

### Tuesday

Still working on Notion template for my productivity workflow.

In the meantime I took a look to the Network Guardian collecting data for a Customer.
I discovered a lot of “issues” and I will work on them the next week.
There a lot of problems about disconnection and reconnections during the collecting data phases.
I have to manage that in a better way.

![https://res.cloudinary.com/practicaldev/image/fetch/s--SElE7c0---/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxdqu56rh6lvcvf18wtn.png](https://res.cloudinary.com/practicaldev/image/fetch/s--SElE7c0---/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxdqu56rh6lvcvf18wtn.png)

In the afternoon THE email is arrived.
I have been awarded for another year as a Microsoft MVP and I am very proud of myself, honestly.
You can find more info about in on my blog post: [https://dev.to/kasuken/i-have-been-awarded-for-9-years-in-a-row-as-microsoft-mvp-28a5](https://dev.to/kasuken/i-have-been-awarded-for-9-years-in-a-row-as-microsoft-mvp-28a5)

**Mood**: 😪

### Wednesday

Calls with customers and other annoying activities not related with the development.

**Mood:** 🙂

### Thursday

Unproductive day because of the Long Covid. I didn’t close any tasks during the day. 

**Mood:** 😢

### Friday

I started the day with a new feature implementation on Red Origin. It’s not really a new feature because I have implemented this function a few months ago, but it’s more or less a rewriting and a reorganization of the code. But I decided to implement the function from scratch again, based on my previous experience on that.

I also finished two more Notion templates: a call for papers template for speakers and a content calendar template.

I will share them next week.

**Mood: 😊**
Do you have a favorite keyboard ? [I bought the new pop keys KB from Logitech]
Tags: discuss, community, productivity, watercooler
Published: 2022-07-15 11:41:40

Hello DEV coders and nerds 🙂
In my 5 days vacation to Wroclaw/Poland, I wanted to chill and relax, you know drink cold beer and enjoy the sun for some time, maybe read a book that I wanted to read for long time and I didn't have the chance.

But - there is a But here 😄- I couldn't stay away from electronics shops; and the most famous one here in Poland is a German franchise called "Media Markt", it has always new gadgets, cameras, laptops and so on.. 

{%youtube xr9G2296bvE%}

I noticed this great looking keyboard, a Pop Keys Yellow keyboard from Logitech but I was so hesitant at first, especially when I saw the emojis on the side : 😍😭😄😂, I thought it's for kids and will never have a good clicking sound. 

Considering the price - 138 € - I started to think again, I check the website, I watched some videos, and finally my wife convinced me of buying it / she is an extraordinary saleswoman 😄

Hope you will enjoy this video where I am unwrapping this awesome keyboard 😄

Thank you amazing DEV community for the support!
[Solved] ‘pip’ is not recognized in cmd
Tags: pip, python, programming, py
Published: 2022-07-16 02:32:22

'pip’ is not recognized in cmd is the error shows up on windows when one tries to use pip in the command prompt. To solve this error on windows, you must declare path variable by following these steps:

- 1. Step 1 – Right click on My Computer or This PC
- 2. Step 2 – Click on Properties
- 3. Step 3 – Click on Advanced System Settings

You will find a section called system variables.


Click on Path from the list of variable and values that shows up there.


After clicking on path click edit. You will find a New button in the pop up.


Click that and paste the location of the python35 or python36 folder (The location you specified while installing python) followed by “\Scripts” there.


For me its “C:\Users\a610580\AppData\Local\Programs\Python\Python35-32”
so I type “C:\Users\a610580\AppData\Local\Programs\Python\Python35-32\Scripts”

Click Ok to close all windows and restart your command prompt.

Irepeat – restart your command prompt.

Everything should now be working fine! Make sure you don’t disturb anything else in the path variable and follow the aforementioned steps exactly.
pandas 数字列转换为时间
Published: 2022-07-16 07:34:09


## 背景

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

这种时间阅读起来很不方便 






## 解决

```python
data['ts'] = pd.to_datetime(data['t'],unit='ms')
```

可以根据需要调整unit，不过这个时间转换的时候并没有和时区关联，我们东八区看这个时间就落后了8个点，如果为了显示正确可以在基础的毫秒上加8个小时的毫秒转换

```python
data['ts'] = pd.to_datetime(data['t'] + 8 * 60 * 60 * 1000,unit='ms')
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/63p749hhruhqup598fs3.png)
2141. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-16 08:08:46

```
#define LL long long

class Solution {
private:
    bool check(LL t, int n, const vector<int> &batteries) {
        LL tot = 0;
        for (LL x : batteries)
            tot += min(t, x);

        return tot >= t * n;
    }

public:
    LL maxRunTime(int n, vector<int>& batteries) {
        LL l = 1, r = 100000000000000ll;
        while (l < r) {
            LL mid = (l + r) >> 1;
            if (check(mid + 1, n, batteries)) l = mid + 1;
            else r = mid;
        }

        return l;
    }
};
```


#leetcode
#weekly contest
Here is the link for the problem.....
https://leetcode.com/contest/weekly-contest-276/problems/maximum-running-time-of-n-computers/
Ethernaut: 20. Denial
Tags: solidity, ethereum, openzeppelin, security
Published: 2022-07-16 14:48:54

[Play the level](https://ethernaut.openzeppelin.com/level/0xf1D573178225513eDAA795bE9206f7E311EeDEc3)

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import '@openzeppelin/contracts/math/SafeMath.sol';

contract Denial {
  using SafeMath for uint256;
  address public partner; // withdrawal partner - pay the gas, split the withdraw
  address payable public constant owner = address(0xA9E);
  uint timeLastWithdrawn;
  mapping(address => uint) withdrawPartnerBalances; // keep track of partners balances

  function setWithdrawPartner(address _partner) public {
    partner = _partner;
  }

  // withdraw 1% to recipient and 1% to owner
  function withdraw() public {
    uint amountToSend = address(this).balance.div(100);
    // perform a call without checking return
    // The recipient can revert, the owner will still get their share
    partner.call{value:amountToSend}("");
    owner.transfer(amountToSend);
    // keep track of last withdrawal time
    timeLastWithdrawn = now;
    withdrawPartnerBalances[partner] = withdrawPartnerBalances[partner].add(amountToSend);
  }

  // allow deposit of funds
  receive() external payable {}

  // convenience function
  function contractBalance() public view returns (uint) {
    return address(this).balance;
  }
}
```

In this level, the exploit has to do with `call` function: `partner.call{value:amountToSend}("")`. Here, a `call` is made to the partner address, with empty `msg.data` and `amountToSend` value. When using `call`, if you do not specify the amount of gas to forward, it will forward everything! As the comment line says, reverting the call will not affect the execution, but what if we consume all gas in that call?

That is the attack. We will write a `fallback` function because the call is made with no message data, and we will just put an infinite loop in there:

```solidity
contract BadPartner { 
  fallback() external payable {
    while (true) {}
  } 
}
```

We then set the withdrawal partner as this contract address, and we are done. Note that `call` can use at most 63/64 of the remaining gas (see [EIP-150](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md)). If 1/64 of the gas is enough to finish the rest of the stuff, you are good. To be safe though, just specify the amount of gas to forward.
1074. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-18 05:24:46

```
class Solution {
 public:
  int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {
    const int m = matrix.size();
    const int n = matrix[0].size();
    int ans = 0;

    // transfer each row of matrix to prefix sum
    for (auto& row : matrix)
      for (int i = 1; i < n; ++i)
        row[i] += row[i - 1];

    for (int baseCol = 0; baseCol < n; ++baseCol)
      for (int j = baseCol; j < n; ++j) {
        unordered_map<int, int> prefixCount{{0, 1}};
        int sum = 0;
        for (int i = 0; i < m; ++i) {
          if (baseCol > 0)
            sum -= matrix[i][baseCol - 1];
          sum += matrix[i][j];
          if (prefixCount.count(sum - target))
            ans += prefixCount[sum - target];
          ++prefixCount[sum];
        }
      }

    return ans;
  }
};

```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/
Get always the last version of the github/gitlab software.
Tags: software, linux, cli, opensource
Published: 2022-07-28 02:52:37

Do you use a of software from github ? that not have a packaging system ?

then lastversion its for you!

```
lastversion apache/incubator-pagespeed-ngx 
#> 1.13.35.2

lastversion download apache/incubator-pagespeed-ngx 
#> downloaded incubator-pagespeed-ngx-v1.13.35.2-stable.tar.gz

lastversion download apache/incubator-pagespeed-ngx -o pagespeed.tar.gz 
#> downloads with chosen filename

lastversion https://transmissionbt.com/
#> 3.0

lastversion format "mysqld  Ver 5.6.51-91.0 for Linux"
#> 5.6.51
```
If you follow the awesome cli seria I have wrotten with this software you can get the last version of all 
:>


{% github https://github.com/dvershinin/lastversion %}
For Linux, would you switch to an AMD GPU?
Published: 2022-07-19 12:22:00

I keep hearing that AMD is better for Linux and that Nvidia GPU users may experience serious problems. Would you move from an Nvidia GPU to an AMD one if you were going from Windows to Linux full-time?

[how to find ip address on windows](
https://getinfolist.com/2020/07/02/how-to-find-ip-address-on-windows/
)
Email template service
Tags: typescript, email, microservices, tempalte
Published: 2022-07-20 20:01:00

If we are developing a more serious app, we will probably use some kind of email notification or newsletter, or even just a password change email. In this article, I will present my email / pdf template service.


Code: [https://github.com/MaurerKrisztian/template-api-tm](https://github.com/MaurerKrisztian/template-api-tm)

Demo: [https://template-api-tm-production.up.railway.app/template](https://template-api-tm-production.up.railway.app/template)

The goal was:
- by entering the template-name and the data of the placeholders, I get back the filled-in html page

Thinking about this a step further, since I use it for emails 90% of the time, I have therefore built in the email send feature.

Example body:

```json
{
   "mailOptions": {
      "to": "test@gmail.com", 
      "subject": "test email"
   }, 
   "template": {
      "name": "test_template", 
      "data": {
         "title": "test title", 
         "description": "This is a test description", 
         "color": "#DEB887"
      }
   }
}
``` 

The following must be specified for each request: mailOption, template.name template.data

- Error management: The data part is easy to mess up, so every template has a validator.

- The other problem was that if we have several templates, we can't keep in mind what kind of data it expects, and digging through the code is quite time-consuming. That's why I added an endpoint where you can view the most important information: available templates, example data, etc.

[https://template-api-tm-production.up.railway.app/template](https://template-api-tm-production.up.railway.app/template)

-  You can access a playground for testing templates with different data with the press of a button it will rerender the template.

- Emails can only work with inline css, however writing the entire template with inline css is not very nice and not maintainable, so the css specified in the style tag in the templates is automatically converted to inline when sent out.

- Finally, I also included pdf generation, you can specify what you want: html or pdf when requesting.

This is what your generation process looks like:
   - data validation
   - fills in the template with the data field
   - converting to pdf (if necessary)
   - template inline css transformation
   - email sending

I's not perfect but mine. 🙂 Also my first article. :partying_face:
Angular13 migrate Jest
Published: 2022-08-17 05:52:00

# Start Angular 13

```
ng i -g @angular/cli@13
ng new my-app
npm i --legacy-peer-deps
//or
npm -loglevel info install --legacy-peer-deps -strict-ssl false
```




**migrate Jest**

```
npm remove -D @types/jasmine jasmine-core karma-jasmine karma-jasmine-html-reporter karma karma-chrome-launcher karma-coverage

rm -rf karma.conf.js src/test.t
```
**bun remove**
```
bun remove -d @types/jasmine jasmine-core karma-jasmine karma-jasmine-html-reporter karma karma-chrome-launcher karma-coverage
```

ref: https://www.npmjs.com/package/@angular-builders/jest
```
npm i -D jest @types/jest @angular-builders/jest@13.x.x --legacy-peer-deps
```
**add script to package.json**

    "clear": "rm -rf node_modules *-lock.* *.lock",
    "init": "npm i --legacy-peer-deps",

ref: https://github.com/briebug/jest-schematic

**benchmark bun vs npm vs yarn vs pnpm command line**

```
hyperfine "bun install --backend=hardlink" "yarn install --on-scripts" "npm install --no-scripts --ignore-scripts" "pnpm install --ignore-scripts" --prepare="rm -rf node_modules" --cleanup="rm -rf node_modules" --warmup=8
```
Hello Blog !
Tags: hello, welcome
Published: 2022-07-21 09:24:00

## Hi there 🔥 !

---

Hello blog, hello Dev.to and welcome to **you** !

I'm **camarm**, a French 🇫🇷 Developer 💻 fond of **Linux** 🐧, **server** infrastructures 💾 and development 👨‍💻

I will write for my **blog** 📰 articles about code/tricks/problems I encountered in my beginner/intermediate developer life (all articles will be sent in my [newsletter ✉️](https://www.camarm.dev/#contact)).
You can read them [here 🔗](https://www.camarm.dev/blog) (thanks to dev.to 🎉 for hosting the articles!).

Bye!
How to convert between any two units in Java using qudtlib
Tags: unitconversion, java, rdf, library
Published: 2022-07-21 15:10:00

[We](https://www.researchstudio.at/studio/smart-applications-technologies/) just released version 1.0 of a new project, [qudtlib](https://github.com/qudtlib/qudtlib-java), which offers unit conversion and related functionality for over 1700 units, while being quite small: the jar-with-dependencies is ~400kB in size. The project is based on the [QUDT ontology](https://qudt.org). Currently, this is available in Java only, but more is to follow.

## For example

Let's say you want to convert feet into lightyears, here's what your java code would look like:

```
    Qudt.convert(
        new BigDecimal("1"),
        Qudt.Units.FT, 
        Qudt.Units.LY);
    --> 3.221738542107027933386435678630668E-17ly
```
ok, now how do we know that's correct? Easy: we know that light travels about one foot per nanosecond, so if we multiply that number by the number of nanoseconds in a year, which is...

```
    Qudt.convert(
        new BigDecimal("1"),
        Qudt.Units.YR, 
        Qudt.Units.NanoSEC);
    --> 31557600000000000ns
```

... we should get around 1. Let's try:
```
    Qudt.convert(
        new BigDecimal("1"),
        Qudt.Units.FT, 
        Qudt.Units.LY).getValue()
        .multiply(
            Qudt.convert(
                new BigDecimal("1"), 
                Qudt.Units.YR, 
                Qudt.Units.NanoSEC)
                   .getValue()));
    --> 1.01670336216396744710635782571955168476800000000000
```
That's about 1. Seems to work ;-)

## The Hack

The part of the QUDT ontology we need, including some additional data we generate, is about 3.5 MB in size. The libraries needed to access the data for providing the functionality we want have another 30+ MB. We felt that was too much for something as simple as converting celsius into fahrenheit (or feet to lightyears).

So we moved all the heavy lifting into the preprocessor (ie., maven) to generate a java class that instantiates all the objects representing the relevant part of the QUDT ontology upon startup. No SPARQL queries or other RDF munging at runtime, not a single external runtime dependency, You're welcome.

The big upside of this approach is that it should be relatively easy to port the solution to other languages.

## What's on the Roadmap?

Typescript.

## What else?

Well, you still don't know how many feet is a light year, so why don't you [try qudtlib](https://github.com/qudtlib/qudtlib-java/tree/main/qudtlib-example) and find out?
Getting Started with the Angular Toolbar Component
Tags: angular, webdev
Published: 2022-07-22 04:36:40

A quick overview on how to create and configure the Syncfusion [Angular Toolbar component](https://www.syncfusion.com/angular-ui-components/angular-toolbar) in an Angular project. Angular Toolbar is a collection of clickable icons, buttons, or some input elements that perform specific functions when you click on them. In this video, you will learn how to add a simple Angular Toolbar to an Angular app and then how to set prefix icons, separators, and display modes. Finally, you will learn how to add input-based components like Numeric Textbox and Dropdown List to the Angular Toolbar. 

Product overview: https://www.syncfusion.com/angular-ui-components/angular-toolbar

Explore tutorial videos: https://www.syncfusion.com/tutorial-videos

Download an example from GitHub: https://github.com/SyncfusionExamples/getting-started-with-the-angular-toolbar-component

{% youtube vc65VHyEk_8 %}
100. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-22 05:52:29

```
class Solution {
public:
    bool isSameTree(TreeNode *p, TreeNode *q) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if (p == NULL && q == NULL) return true;
        if (p == NULL || q == NULL) return false;
        return (p->val == q->val) && 
            isSameTree(p->left, q->left) && 
            isSameTree(p->right, q->right);
    }
};
```

#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/same-tree/
Push your code on Github like Pro
Published: 2022-07-22 08:21:23


I never liked to typing 4 commands each time for pushing your code to github.

So i have created a alias for that and with also random commits name.

paste the below code to your default `shellrc` file.
```
#Get random gibbrish word

get_random(){
	random_commit=`shuf /usr/share/dict/cracklib-small | awk 'FNR == 1 { print $1 }'`
}
alias gpm='get_random; git add .; git commit -m ${random_commit}; git push origin main'

```

make sure you have file located at `/usr/share/dict/cracklib-small`. For my system Manjaro `cracklib-small` file consists of lots of english dictionary words.
For you system it maybe different.
How To Create Pages In Shopify Store
Tags: shopify, beginners, tutorial, webdev
Published: 2022-07-23 04:39:41

Shopify is an online Ecommerce platform which allows users to create online store. Using Shopify you can sell digital products, physical products and can also start drop shipping business. Shopify is one of the biggest ecommerce platforms and it is used by biggest companies across the world.

I have shown complete process to create pages and to edit pages in Shopify store, Also to add Google Map to our Shopify website. This is helpful for all the beginners and also to the users who are already using Shopify but have lesser knowledge about Shopify.

To watch the video on creating pages in Shopify, click on below shown image or click on the following link -> [How To Create Pages On Shopify Store](https://youtu.be/lhHw-GP3UnM)

[![How To Create Pages On Shopify Store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qvrhcrscirmkmg3ltty.png)](https://youtu.be/lhHw-GP3UnM)
A Central Clock for Laravel Web Applications with ReactPHP
Tags: php, laravel, reactphp, realtimeweb
Published: 2022-07-23 08:27:00

How to implement a central clock for a [Laravel](https://laravel.com) web application?

# Why A Central Clock is Needed?

Quizzes, time tracking, online education, Pomodoro timers, auctions, and many other web applications need a central clock. 

The time on this clock is what all users see on their web page.

Such a central clock has to be implemented at the server, as this is the only place where we can rely on. It needs to be transmitted to the user's web page. 


# Running the Clock with ReactPHP 


Use [ReactPHP](https://reactphp.org) to implement a timer, either periodic, 

	$timer = $loop->addPeriodicTimer($time, function() use(&$task) {
	   broadcast(new TimeSignal(json_encode(...)));
	});

or one time,
 
 	$timer = $loop->addTimer($time, function() use(&$task) {
          broadcast(new TimedEvent(json_encode(...))); 
	});

where `TimeSignal` and `TimedEvent` are Laravel events.


Events are broadcast using [Laravel Echo Server](https://github.com/tlaverdure/laravel-echo-server), [Laravel Websockets](https://beyondco.de/docs/laravel-websockets/getting-started/introduction), or [Soketi](https://docs.soketi.app). Say on a channel `time`.

# Processing Time Signals in Front-End

## JavaScript

Listen for events with [Laravel Echo](https://github.com/laravel/echo), 

    window.Echo.channel('time')
      .listen('TimeSignal', (e) => {
            
      })
      .listen('TimedEvent', (e) => {
            
      });

## Livewire

Define in the [Livewire](https://laravel-livewire.com) component the listeners:

	protected $listeners = [
		'echo:time,TimeSignal' => 'processTimeSignal',
		'echo:time,TimedEvent' => 'processTimedEvent',
	];