teleren/devto huggingface dataset:
Learning One Thing At Least | How to grab everyday little pieces of knowledge
Tags: learningtips
Published: 2021-09-09 10:58:18

It is easy to feel overwhelmed and discouraged by the amount of resources available for web development. The knowledge to be assimilated seems literally endless, and sometimes you just feel lost. 

If I were asked what advice I found most helpful in this situation, it would be this one : every day, after any learning or coding moment, **try to retain one thing at least**.

When I say "retain", I don't mean "memorize". More fundamentally, it means asking yourself at least one time during your day: what did I learn from this blog post? From this debugging session? From this discussion with my colleague or my boss?

If you lack self-confidence, like me some days and about 98% of human beings some other days, you'll often be tempted to answer "Nothing." "Nothing" as in "I don't understand a word of this, it's way beyond my abilities, I didn't learn anything at all, and by the way I hate myself."

And you would be all wrong.

**At the most minimalist level, what you have learned is: "This thing exists and is in some way related to what I do."** 

And believe me or not, that's far from being useless knowledge. What's important here is that in a random day in the future, at the time you need it, you'll know what to look for. When that day will come, the knowledge you have gained in the meantime will help you understand. Maybe not everything, but at least some of it.

Most of the time, it will be more. A new HTML tag or CSS property. A fundamental Web concept. A new tool. A framework method. **The overall understanding will gradually emerge from all these little pieces of knowledge associated with (a lot of) practice.**

This method will help you to gain confidence. By asking yourself on a regular basis "What did I learn?" you will realize that you are actually learning a lot, every day.

Photo by [Renee Fisher](https://unsplash.com/photos/6XFN_rYWrCI?utm_source=unsplash&utm_medium=referral&utm_content=creditShareLink) on [Unsplash](https://unsplash.com/photos/6XFN_rYWrCI?utm_source=unsplash&utm_medium=referral&utm_content=creditShareLink)
Some useful custom utility🛠 functions for cookie handling in javascript
Tags: javascript, tooling, cookies, react
Published: 2021-09-09 10:48:17

For a simple cookie operation I prefer to have my own custom functions(obviously from google) instead of using a cookie library in React.js

### 1. setCookie

```javascript
// setCookie("cookiename", cookieExist, COOKIE_EXPIRY_TIME);
// example - setCookie("username", cookieExist, (0.5 * 60 * 1000)); this cookie expires in 30 seconds.
// the cookie expiry time have to be in seconds so convert your time in seconds and after that pass it.

export function setCookie(cname, cvalue, exdays) {
    const d = new Date();
    d.setTime(d.getTime() + exdays);
    let expires = "expires=" + d.toGMTString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
```

### 2. getCookie

```javascript
// get a cookie and Its value
export function getCookie(cname) {
    let name = cname + "=";
    let decodedCookie = decodeURIComponent(document.cookie);
    let ca = decodedCookie.split(';');
    for (let i = 0; i < ca.length; i++) {
        let c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}
```

### 3. checkCookie

```javascript
// pass the name of the cookie as string which you want to check that if It exists or not.
export function checkCookie(cookiename) {
    let cookieExist = getCookie(cookiename);
    if (cookieExist != "") {
        return cookieExist;
    }
    return false;
}
```
How you find it useful 🙂🙂
Jest: Could not find source file error
Tags: node, typescript, testing
Published: 2021-09-09 10:41:32

Occasionally I've been seeing the following error when running my Jest test suite.

```
> @module/module@1.2.9 test C:\_Development\project
> jest

 FAIL  __tests__/resources/project.router.test.ts 
  ● Test suite failed to run

    Could not find source file: 'C:\_Development\project\__tests__\resources\project.actions.test.ts'.

      at getValidSourceFile (node_modules/typescript/lib/typescript.js:135637:29)
      at Object.getSemanticDiagnostics (node_modules/typescript/lib/typescript.js:135859:36)
      at doTypeChecking (node_modules/ts-jest/dist/compiler/language-service.js:11:35)
      at node_modules/ts-jest/dist/compiler/language-service.js:96:25
          at Array.forEach (<anonymous>)
      at compileFn (node_modules/ts-jest/dist/compiler/language-service.js:94:26)
      at Object.compile (node_modules/ts-jest/dist/compiler/instance.js:90:25)
      at TsJestTransformer.process (node_modules/ts-jest/dist/ts-jest-transformer.js:94:41)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:481:35)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:586:40)
```

The source files always exist in the right location - it seems like actually Jest isnt always calling the real file, but grabbing it from the cache? 

The solution is to pass the following arguemnts
```
jest --clearCache
```
Obviously, alot of the time, we arn't running Jest directly, its in our package.json. In that case you can pass in an extra -- to tell the npm runner to pass the argument down into the underlying call. 
```
npm run test -- --clearCache
```

Hope this helps!
Automating your own home media server with Jellyfin 🎐 + Ubuntu 🐧
Tags: jellyfin, ubuntu, tutorial
Published: 2021-09-09 10:25:51

Building upon [this](https://dev.to/rat/torrenting-in-the-command-line-5gfa) article I wrote on how to torrent from a CLI, we can automate managing a home media server.

Think of self-hosting your own Netflix, where you choose the content you want to have.

Jellyfin is a completely FOSS media server, with customizable CSS themes. It exposes a webapp running on port `8096`, with an easy-to-use admin dashboard. 

By default, this webpage will be discoverable on your local network, but you can run it on a webserver to expose it outside of your network.

Following [this](https://www.how2shout.com/linux/how-to-install-jellyfin-media-server-on-ubuntu-20-04-lts/) guide, we can set Jellyfin up.

Here are the commands in a TL;DR:

```
sudo apt install apt-transport-https
wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | sudo apt-key add -
echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" | sudo tee /etc/apt/sources.list.d/jellyfin.list
sudo apt update
sudo apt install jellyfin
sudo systemctl enable jellyfin
sudo systemctl start jellyfin
```

Once completed, go to `localhost:8069` in a browser, and follow the instructions which Jellyfin presents.

It is good practise to have a media folder ready to point your Movies or Television media to in Jellyfin.

Now, on to automating the download process:

You could either SSH into your device which you will be hosting your media server onto and use [this](https://dev.to/rat/torrenting-in-the-command-line-5gfa) as a guide to torrent into that directory, OR you could use [Radarr](https://radarr.video/).

Radarr is good because it allows for automated file upgrades to a higher resolution, if available.

You can create lists and automate downloads with your favorite torrent application.

Whatever approach you use for building your media directory, just remember to "sync files & metadata" in Jellyfin.

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

Visiting the local network ip followed by port `8069` of the device which you installed jellyfin on will allow you to stream the content on your home media server.

You can grab the local ip of the machine by entering:

```
hostname -I
```

To stop the jellyfin mediaserver at anytime, just enter:

```
systemctl stop jellyfin
```

Enjoy 👍
Create PDF Portfolio in Java
Tags: java, pdf, portfolio, api
Published: 2021-09-09 08:52:18

A PDF Portfolio can contain a wide range of file types created in different applications. For example, it can include Word documents, e-mail messages, spreadsheets and PowerPoint presentations.  In this article, you will learn how to create a portfolio and add files/folders to it programmatically by using Spire.PDF for Java.

**Import jar dependency (2 Methods)**
● Download the [Spire.PDF for Java API](https://www.e-iceblue.com/Download/pdf-for-java.html) and unzip it. Then add the Spire.Pdf.jar file to your project as dependency.
● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
   <repository>
      <id>com.e-iceblue</id>
      <name>e-iceblue</name>
      <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
   </repository>
</repositories>
<dependencies>
   <dependency>
      <groupId>e-iceblue</groupId>
      <artifactId>spire.pdf</artifactId>
      <version>4.8.7</version>
   </dependency>
</dependencies>
```

**Create portfolio and add files**
```java
import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;

public class CreatePortfolioWithFiles {
    public static void main(String []args){

        String[] files = new String[] { "test.pdf", "WordDocument.docx", "ExcelDocument.xlsx","Presentation.pptx","cow.png" };

        //Create a PdfDocument instance
        PdfDocument pdf = new PdfDocument();

        for (int i = 0; i < files.length; i++)
        {
            //Create a PDF Portfolio and add files to it
            pdf.getCollection().addFile(files[i]);
        }

        //Save the result file
        pdf.saveToFile("PortfolioWithFiles.pdf", FileFormat.PDF);
        pdf.dispose();
    }
}
```
![Portfolio1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h3oaga61zz7jehgt0wpr.jpg)

**Create portfolio and add folders**
```java
import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;
import com.spire.pdf.collections.PdfFolder;

public class CreatePortfolioWithFolders {
    public static void main(String []args){

        String[] files = new String[] { "test.pdf", "WordDocument.docx", "ExcelDocument.xlsx","Presentation.pptx","cow.png" };

        //Create a PdfDocument instance
        PdfDocument pdf = new PdfDocument();

        for (int i = 0; i < files.length; i++)
        {
            //Create a portfolio and add folders to it
            PdfFolder folder = pdf.getCollection().getFolders().createSubfolder("folder" + i);
            folder.addFile(files[i]);
        }

        //Save the result file
        pdf.saveToFile("PortfolioWithFolders.pdf", FileFormat.PDF);
        pdf.dispose();
    }
}
```
![Portfolio2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isjuleut2pcwi9yzupnl.jpg)
30 Projects in 30 days
Tags: javascript, beginners, 100daysofcode
Published: 2021-09-09 10:07:18

I have been watching JavaScript tutorials on Youtube recently but I feel like I haven't been making much progress. This is why I have decided to take the 30 Projects in 30 days challenge and created a [github repo](https://github.com/rkhalife/30Days30Projects) for that purpose. I am hoping that building those small projects will help me improve my skills.

I will update this space once a week in order to share everything I learned along the way.
Sending Cosmos DB Diagnostic Logs to Log Analytics with Terraform
Tags: azure, devops, tutorial, cloud
Published: 2021-09-09 09:45:54

---
title: Sending Cosmos DB Diagnostic Logs to Log Analytics with Terraform
published: true
description: 
tags: azure,devops,tutorial,cloud
//cover_image: https://direct_url_to_image.jpg
---

In this video, we cover Data sources in Terraform and how we can use them to reference resources defined either outside of Terraform or in other Terraform configuration files in our Terraform files.

We also talk about Diagnostic Logs in Azure are and how we can configure Diagnostic logs in our Azure Cosmos DB account to be sent to a Log Analytics workspace.

{% youtube 09L0vOxtPps %}

If you have any questions, comment below or reach out to me via Twitter: Twitter: https://twitter.com/willvelida

Resources:
Data Sources in Terraform: https://www.terraform.io/docs/language/data-sources/index.html
Log Analytics (Terraform Docs): https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace#attributes-reference
Diagnostic Logs (Terraform Docs): https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting
Monitor Azure Cosmos DB data by using diagnostic settings in Azure: https://docs.microsoft.com/en-us/azure/cosmos-db/cosmosdb-monitor-resource-logs
GitHub code: https://github.com/willvelida/azurecosmosdb-terraform
DevBox Showcase: JSON Viewer
Tags: productivity, tutorial, json
Published: 2021-09-09 09:14:24

Hi 👋,

This is the first post in the series showcasing tools from [DevBox](https://www.dev-box.app) 🎉, a desktop application or browser extension packed with tools that every developer should have.

-------

Sometimes during development you get a JSON file which is minimized, and you need to get some information out of it. I'll show you how you can use DevBox to view JSON files interactively in a tree view and get that information.

Once DevBox opened, click on the JSON Viewer card: 

![JSON Viewer Card](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2jtxq5ahw9ujailbpmf.png)

You should see something like this:

![JSON Viewer Empty](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9k5l4qlbhnwsqe3qcrrg.png)

We are going to use this minified JSON to view from the Start Wars API:

```
{"name":"Luke Skywalker","height":"172","mass":"77","hair_color":"blond","skin_color":"fair","eye_color":"blue","birth_year":"19BBY","gender":"male","homeworld":"https://swapi.dev/api/planets/1/","films":["https://swapi.dev/api/films/2/","https://swapi.dev/api/films/6/","https://swapi.dev/api/films/3/","https://swapi.dev/api/films/1/","https://swapi.dev/api/films/7/"],"species":["https://swapi.dev/api/species/1/"],"vehicles":["https://swapi.dev/api/vehicles/14/","https://swapi.dev/api/vehicles/30/"],"starships":["https://swapi.dev/api/starships/12/","https://swapi.dev/api/starships/22/"],"created":"2014-12-09T13:50:51.644000Z","edited":"2014-12-20T21:17:56.891000Z","url":"https://swapi.dev/api/people/1/"}
```

And we would like to find out when this entity was created!

After copying and pasting the JSON into the left textarea, you will immediately see the tree view on the right!

![JSON Viewer With Content](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33gw0dsszh4ltibk4g4i.png)

The `created` field is not visible, so we need to scroll down to see it:

![JSON Viewer Scrolled](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7d7w7l33cli2701mg9ra.png)

And now we have the exact date this entity was created!

---------

You can still buy DevBox [here](https://gdotdesign.gumroad.com/l/devbox/earlybird) for **a lifetime price of ~~$25~~ $20 💰**, get it while it's available!

More DevBox showcases are coming, so follow me here if you want to be notified!
Why We Should Use Videos On Our Landing Pages

Tags: landingpage, landingpageoptimization, wordpress, webdev
Published: 2021-09-09 08:45:59

Video landing pages capture attention and drive conversions. When it comes to landing pages, adding video can increase conversion by 86%. But that’s not all it can do. According to FORBES, 90% of customers say product video helps them make buying decisions. According to HUBSPOT, 97% of marketers say video helps increase user understand of their product or service.
.
1. HELP TO BOOST THE CONVERSION 📈🎯

Videos can significant boost conversions. One of the reason is by using videos on the landing page to show case your product or services, your visitor are able to look at the products or services up-close at different angle compared to only image.
.
2. HELP TO ENHANCE ENGAGEMENTS 🧲

Let me ask you, if you are given a choice between a video and long paragraph to texts, which one would you prefer to view? With video, the audience is 10 times more likely to interact with a video. Videos are a great way to keep prospects engaged due to the utilization of both visual and sound element. Also, video is able to deliver information way faster and more efficient compared to texts.

![Why We Should Use Videos On Our Landing Pages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr6slioc9lh8ig1m27hv.png)
.
3. VIDEOS ARE MORE PERSUASIVE 🤩

By using videos, we are able to dive deeper into prospects emotion and state of mind and hence more persuasive compared to texts. Try this out and you will know the stark differences in persuasion.
.
4. KEEPING YOUR AUDIENCE LONGER ON YOUR PAGE ⏰

The goal is to keep your prospects to stay longer on your page, the longer they stay the chances are the more they become familiar with your brand. A video on the landing page gives prospects more time and chances for your offer to appeal to them. Allowing them more time to notice the benefits of your offer to them.
.
5. ESTABLISH TRUST 👍

Videos establish and enhance trust because it allows that extra human touch to your prospects with a human figure, a voice. A moving person definitely is more trustworthy compared to a chunk of texts.

-----

JOIN ME:
Website: https://www.atanudas.com
Linkedin: https://www.linkedin.com/in/digitalmarketinganalystindia
Twitter: https://twitter.com/seoexpertatanu
Medium: https://digitallyatanu.medium.com
Working With Object In Localstorage
Tags: javascript
Published: 2021-09-09 08:39:10

We all love localstorage, no database needed to store simple things for our user.

But what if the data is more than a string or number?

Let’s see how to store and read object in localstorage?

## How to store object in localstorage
We need to turn json into a string with JSON.stringify

```
localstorage.setItem(key, JSON.stringify(val));
```

## How to read/retrieve object from localstorage 
We need to parse into json with JSON.parse

```
JSON.parse(localstorage.getItem(key))
```

## Bonus: Helper for read and write objects in localstorage

```
function getObjectLS(key) {
    return JSON.parse(localStorage.getItem(key))
}

function setObjectLS(key, val) {
    localStorage.setItem(key, JSON.stringify(val));
}
```
Why you should learn Python?
Tags: python
Published: 2021-09-09 08:28:17

Ngôn ngữ lập trình Python là gì?
Nếu bạn muốn tìm hiểu về lập trình thì bắt đầu với lập trình Python sẽ là một sự lựa chọn hoàn hảo. Đầu tiên chúng ta cần hiểu về khái niệm, Python là một ngôn ngữ lập trình cao cấp nhưng rất dễ học, dễ tiếp cận, dễ hiểu và dễ tiếp thu. 

So với C/C++ hay Java, Python Programming thể hiện được ưu điểm vượt trội của mình với sự đơn giản, ngắn gọn thuận tiện cho những người mới học và không quen những câu code dài

Theo trang thống kê Pierre Carbonnelle, ngôn ngữ lập trình Python là ngôn ngữ phổ biến nhất trên thế giới dựa trên tần suất tìm kiếm các thông tin liên quan trên Google.
Cùng MCI tìm hiểu trong bài viết: https://mcivietnam.com/lap-trinh-python/
Using Jest With AngularJS
Tags: angular, jest, wip
Published: 2021-09-09 08:14:54

This is a summary of the exeperiences I had intergrating Jest into an AngularJs project. 

This is a living document - work in progress.

## angular.mock.module is not a function

This took sometime to investigate. There are some info on the web regarding this:

- Mismatch of `angular` and `angular-mock` versions. 
- Order of loading `angular` and `angular-mocks` regarding the test framework.

In my case it was something more sinister. AngularJs itself skip and does not load the nessasery logic for `angular.mock.module` to work.

In `angular-mocks.js` file, Angular load the `mock.module` logic [only if it detects](https://github.com/angular/angular.js/blob/ed30c4d0ea820d79601ca17e2c670e6acae16eb7/src/ngMock/angular-mocks.js#L3046) `Jamsine` or `Mocha` test framework presents.

```js
(function(jasmineOrMocha) {

  if (!jasmineOrMocha) {
    return;
  }

...

})(window.jasmine || window.mocha);
```

They describe it in a oneliner of the [api site](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) also:

> NOTE: This function is declared ONLY WHEN running tests with jasmine or mocha

### Solution

Before loading `angular-mocks`, set the global `jasmine` or `mocha` to truthy value.

`setup-jest.js`
```js
global.mocha = true;
...
```

`jest-config.js`
```js
...
setupFiles: [
  './src/setup-jest.js',
],
...
```
Top 8 website to learn Python online free for newbies
Tags: python, datascience, bigdata, webdev
Published: 2021-09-09 07:58:41

Ngôn ngữ lập trình Python hiện là một ngôn ngữ lập trình thông dụng nhất trên thế giới bởi rất nhiều ưu điểm như dễ học và sử dụng, có nhiều thư viện và framework hoàn toàn miễn phí. Chính vì vậy việc rất nhiều bạn đang tìm kiếm các khóa học Python Online và Offline để tìm hiểu và nâng cao kiến thức phục vụ công việc

MCI xin giới thiệu tới bạn 8 website giúp bạn học lập trình Python Online từ cơ bản tới nâng cao:

1. W3schools.com
Điểm nổi bật của trang w3schools chính là nó luôn miễn phí, các bài học luôn đi kèm thực hành song song. Trong quá trình học, bạn có thể thực hành các bài tập, chỉnh sửa mã nguồn và xem kết quả ngay trên trình duyệt.
Ngoài Python cơ bản thì trang còn cung cấp các tutorial bổ sung về các thư viện phổ biến trong Python. Đây là một trong những website học python online được nhiều người biết đến nhất thế giới

2. Programiz.com
Trang web học python online này cung cấp cho bạn đầy đủ các kiến thức lập trình Python căn bản. Các đầu mục, nội dung được sắp xếp bố cục rõ ràng, kiến thức đầy đủ. Ngoài ra còn có các bài tập (Examples) để các bạn làm trong quá trình học.

3. Coursera.org
Nếu bạn muốn học các khóa học Python từ những trường đại học hàng đầu trên thế giới mà không phải trả một xu nào thì Coursera chính là nơi bạn cần.
Trang web cung cấp các khóa học trực tuyến được giảng dạy trên các trường đại học danh tiếng như Stanford, INSEAD, NUS,…
Tại đây có 1 combo khóa học mang tên Python for Everybody Specialization. Trong đó, khóa đầu tiên trong combo này là Programming for Everybody (Getting Started with Python) – Khóa học này sẽ dạy bạn Python 3 từ con số 0. Bạn không cần bất kỳ kinh nghiệm lập trình nào cũng có thể tham gia vào khóa học này.

4. Learnpython.org
Một website học Python online miễn phí khá hay giúp bạn vừa học vừa tương tác với ngôn ngữ trực tiếp trong nội dung bài học. Trang web này cung cấp cho bạn các khóa học sau:
Learn the Basics (Học Python cơ bản)
Data Science Tutorials (Học thư viện Numpy & Pandas)
Advanced Tutorials (Học Python nâng cao)

5. Developers.google.com
Với sự phổ biến của Python, Google cũng đã cung cấp khóa học Google’s Python Class dành cho các bạn quan tâm đến Python. Trong khóa học này, Google sẽ trang bị thêm kinh nghiệm lập trình và các kiến thức khác về Python.
Lớp học miễn phí này sẽ cung cấp cho bạn các tài liệu, video bài giảng và nhiều bài tập mã hóa giúp bạn thực hành lập trình Python. Nội dung của khóa học python online đến từ Google được biên soạn bởi Nick Parlante, một lập trình viên Python có kinh nghiệm làm việc với nhóm engEDU tại Google. Vì vậy, bạn sẽ có được trải nghiệm thực tế khi học Python với những lập trình viên giỏi nhất của Google [...]

Bạn có thể xem đầy đủ tại: https://mcivietnam.com/hoc-python-online/)