teleren/devto huggingface dataset:
Docker, Hello World
Tags: docker
Published: 2022-11-25 19:17:48

If you’ve never used Docker before, this is where to start.

Let’s say “Hello World!” in a Docker container.

## Pre-requisites: Ensure Docker is Installed & Working

It’s important you have Docker Engine and Docker CLI and Docker Compose. How to know if you have these on your system?

Note: [Docker Desktop](https://docs.docker.com/compose/install/) for Linux/Mac/Windows includes all the necessary tools.

You’ll know whether these tools are installed and working if, at any command prompt, the following commands will report the version number of each tool.

```sh
docker --version

My system responds with:
> Docker version 20.10.17, build 100c701
```
```sh
docker-compose --version

My system responds with:
>Docker Compose version v2.10.2
```

---

## Let’s make some containers from an existing image, then remove them from our system.

It’s helpful to know a few basics to keep your environment clean.

1. `docker pull hello-world`: Build a simple image in a docker container and run a “Hello World” application.

2. `docker images`: List all your images. You’ll see a new image, called `hello-world` is added to your local collection.

3. `docker run hello-world`: Run the app within the container.

4. `docker container ls -a`: List all docker containers.

It’s important to know that a new container is produced every time you run the app. For example:

5. Run #3 above, again.

6. Then run #4 above, again, and notice a new container in the list.

(To prevent the creation of a new container every time you want to interact with the app, there are ways to execute commands in a running container, _et cetera_. Those techniques are not described here.)

It's important to know how to clean up your environment.

(These commands **and more** are described in the [“Complete Guide for Removing Docker Images” by Abhishek Prakash](https://linuxhandbook.com/remove-docker-images/).)

7. `docker container ls -a`: List all your containers. (Note the names or container ids.)

8. `docker rm boring_hoover`: Remove a container with name “boring_hoover”.

9. `docker image rm hello-world`: This will remove the hello-world image created in #1 above. Note this will fail if any containers exist using that image. (So remove those images first.)

## Takeaways

- Using `docker`, you downloaded an image, created containers from that image, and ran a program on that image.

- Then you cleaned up the Docker artifacts on your system: the containers and the new image.

## See also

My [next article](https://dev.to/davidsabine/docker-compose-hello-world-1p14) demonstrates how to do all this with `docker-compose`.
Leetcode problem#217: Contains Duplicate
Published: 2022-11-25 19:17:37

### Problem
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Example: 
`Input: nums = [1,2,3,1]
Output: true`

`Input: nums = [1,2,3,4]
Output: false`

---

### Sorting

We can solve this problem by sorting the array. Time complexity for sorting is O(nlogn). After sorting, we loop through the array and match the consecutive numbers to find the duplicate values. 

#### Implementation (Java)


```
class Solution {
    public boolean containsDuplicate(int[] nums) {
        int pointer = 0;
        Arrays.sort(nums);
        
        while(pointer < nums.length-1){
            if(nums[pointer] == nums[pointer+1]){
                return true;
            }
            pointer++;
        }
       return false;
    }
}
```

However, this approach has a time complexity of O(nlogn). So we can follow a better way by using HashSet to optimize the time complexity. 


### HashSet

Java HashSet class implements the Set interface. It stores the elements in the hashtable and only holds the distinct values. For checking duplicate numbers, we can use contains() method. 

#### Implementation (Java)


```
class Solution {
    public boolean containsDuplicate(int[] nums) {
    
        int pointer = 0;
        
        Set<Integer>checkNum = new HashSet<>();
       
        while(pointer < nums.length){
            if(checkNum.contains(nums[pointer])){
                return true;
            }
            checkNum.add(nums[pointer]);
            pointer++;
        }
        return false;
    }
}
```

Here we get the time complexity of O(n).
Artificial Tree Branch with Lights for Indoor Outdoor | Home Christmas Decoration
Published: 2022-11-25 14:16:36

<h1 style="text-align: center;">&nbsp;<span face="&quot;Amazon Ember&quot;, Arial, sans-serif" style="background-color: white; color: #0f1111; font-size: 24px;">Artificial Tree Branch with Lights for Indoor Outdoor Home Christmas Decoration</span></h1><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRyqxnv22rPibPeNOqFrT6_wdkpAGw9Mw06nqgSypt7quC9-IgT9zypvKzkrmQSQZdhNc8Y_kfXU5yTcY5lR1E8VZgBxmQ0uhmlUg7WKdEby7rYgbGIQz48zP0Md5RjScNw2L7x3GGmSxrhRM8BpYqCKdv_EFUbDu3EQ423bWe8H0-ntuxOXnDmM4VmA/s569/ddds.jpg" style="margin-left: 1em; margin-right: 1em;"><img alt="Home Christmas Decoration" border="0" data-original-height="569" data-original-width="569" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRyqxnv22rPibPeNOqFrT6_wdkpAGw9Mw06nqgSypt7quC9-IgT9zypvKzkrmQSQZdhNc8Y_kfXU5yTcY5lR1E8VZgBxmQ0uhmlUg7WKdEby7rYgbGIQz48zP0Md5RjScNw2L7x3GGmSxrhRM8BpYqCKdv_EFUbDu3EQ423bWe8H0-ntuxOXnDmM4VmA/w640-h640/ddds.jpg" title="Home Christmas Decoration" width="640" /></a></div><br /><span style="background-color: white; font-size: 24px;"><span face="Amazon Ember, Arial, sans-serif" style="color: #0f1111;">LITBLOOM Lighted White Birch Twig Branches 32IN 150 LED Plug in with Timer and Dimmer, Artificial Tree Branch with Lights for Indoor Outdoor Home Christmas Decoration.</span></span></div><div><span style="background-color: white; font-size: 24px;"><span face="Amazon Ember, Arial, sans-serif" style="color: #0f1111;"><h2 style="text-align: left;">About this item</h2><h4 style="text-align: left;">LIFELIKE APPEARANCE:</h4><div>The light up twig branch is exquisitely crafted to look like a piece of artwork. Its lifelike bark texture and waterproof feature makes it a perfect décor for both indoor and outdoor use.</div><h4 style="text-align: left;">FIVE FUNCTIONS:</h4><div>The willow decorative light comes with a controller featuring on, on with timer, dimmer, dimmer with timer and off, meeting your different needs and bringing convenience during use, great for home and office decoration.</div><h4 style="text-align: left;">32 INCH 150 LEDS:</h4><div>The twig branch with lights comes with 150 LEDs wrapped to decorate shop window or living room, <a href="https://amzn.to/3EX4zWy">soft long lasting warm</a> white LED creating an awesome festive atmosphere on holidays(VASE NOT INCLUDED, Color of the adapter may vary).</div><h4 style="text-align: left;">DIY STYLE:&nbsp;</h4><div>The branch of our led branch light is waterproof and bendable which allows you to gently twist or pull it up and down as you wish, <a href="https://amzn.to/3EX4zWy">perfect for Christmas</a>, Halloween, weddings, showrooms, galleries and more.</div><h4 style="text-align: left;">BUY WITH CONFIDENCE:</h4><div>White low voltage adapter included assuring your family safely use. IP44 waterproof for indoor and outdoor use. Please contact us if you have any questions. <a href="https://amzn.to/3EX4zWy">We will get you back within 24 hours</a>.</div></span></span></div>
Mock CPU/ISA in Python
Tags: computerscience, beginners, programming, python
Published: 2022-11-25 19:16:06

This project was my final programming assignment within the computer science career path on Codecademy. Utilizing Python my goal was to mimic the way a CPU processes information. I chose to hone in on the memory management and instruction set architecture side of things and establish the processor and it's registers, as well as a cache and main memory. The program works by retrieving instructions from a text file to process and first fetches instructions from the cache (which will fetch them from the main memory) and then decoding them and performing them. My instruction set architecture primarily replicated the MIPS32 architecture with a couple modified instructions that I did not see within the dev documentation. If you'd like to check the project out, it can be found at github.com/Dwayne-Lacey.
sql-export - create .md / .json files from database content
Tags: hugo, json, markdown, sql
Published: 2022-11-25 19:06:22

[Hugo](https://gohugo.io/) (and other SSG, such as [Gatsby](https://www.gatsbyjs.com/), [Next.js](https://nextjs.org/), and [others](https://jamstack.org/generators/)) are great tools to generate static and very fast websites (which are highly rated by google and comfortable for users). But if you have source data in SQL database, you need to generate thousands of markdown files (e.g. one file for each  item you are selling).

[sql-export](https://github.com/yaroslaff/sql-export) export database data into all-in-one JSON file or into many files (one file per SQL result row) in JSON, Markdown with YAML frontmatter or custom format (using [text/template](https://pkg.go.dev/text/template), same syntax as you use is HTML layouts in Hugo)

Very simple:
```shell
# Export query results to JSON file
./sql-export -q 'SELECT title, price FROM libro LIMIT 2' > /tmp/books.json

# Export to many JSON files
./sql-export -q 'SELECT id, title, price FROM libro' -f json -o '/tmp/libro/{{.id}}.json'
cat /tmp/libro/123.json 
{
    "id": 123,
    "price": 45,
    "title": "ALLGEMEINE GESCHICHTE DER HANDFEUERWAFFEN. Eine Übersicht ihrer Entwickelung. Mit 123 Abbildungen und 4 Ubersichtstafeln. - Günther Reinhold. - Reprint Verlag, - 2001"
}

# Export to markdown files with YAML frontmatter
./sql-export -q 'SELECT id, title, price FROM libro' -f md -o '/tmp/libro/{{.id}}.md'
cat /tmp/libro/123.md 
---
id: 123
price: 45
title: ALLGEMEINE GESCHICHTE DER HANDFEUERWAFFEN. Eine Übersicht ihrer Entwickelung.
    Mit 123 Abbildungen und 4 Ubersichtstafeln. - Günther Reinhold. - Reprint Verlag,
    - 2001
---

# Export to any custom template
cat out-template.html 
id: {{.id}}
title: {{.title}}
price: {{.price}}

./sql-export -q 'SELECT id, title, price FROM libro' -o '/tmp/libro/{{.id}}.txt' --tpl out-template.html 

cat /tmp/libro/123.txt 
id: 123
title: ALLGEMEINE GESCHICHTE DER HANDFEUERWAFFEN. Eine Übersicht ihrer Entwickelung. Mit 123 Abbildungen und 4 Ubersichtstafeln. - Günther Reinhold. - Reprint Verlag, - 2001
price: 45
```

Full documentation and git repo: https://github.com/yaroslaff/sql-export
Solution of Collatz conjecture on Exercism with Haskell
Tags: haskell, exercism, feedback
Published: 2022-11-25 19:00:00

I solved the Collatz conjecture exercise from the Haskell track on Exercism and would like feedback on my solution. But first, let's see what I did.

Firstly, I made a function to take care of the operation if the number n given to the collatz function was an odd number. 
```Haskell
oddNumber :: Integer -> Integer
oddNumber n = (3 * n) + 1
``` 

Then I did the same for the even numbers.

```Haskell
evenNumber :: Integer -> Integer
evenNumber n = n `div` 2
``` 

I stumbled to find a way to save the number of operations before getting to 1. But finally, I decided to use the original collatz function as an initializer for the collatz' function that would resolve the problem.


```haskell
collatz' :: Integer -> Integer -> Maybe Integer
collatz' n i
  | n <= 0 = Nothing
  | n == 1 = Just i
  | odd n = collatz' (oddNumber n) (i + 1)
  | otherwise = collatz' (evenNumber n) (i + 1)
``` 

The complete solution can be find in the following link:

{% embed https://exercism.org/tracks/haskell/exercises/collatz-conjecture/solutions/UlisesAlexanderAM %}
3 Gradient Color Background
Published: 2022-11-25 18:57:36


```
const css = document.getElementById("output");
const color1 = document.getElementById("color1");
const color2 = document.getElementById("color2");
const color3 = document.getElementById("color3");
const body = document.getElementById("gradient");

function setGradient() {
  body.style.background = `linear-gradient(to right, ${color1.value} ,${color2.value},${color3.value}`;
  css.value = `${body.style.background}`;
}

color1.addEventListener("input", setGradient);
color2.addEventListener("input", setGradient);
color3.addEventListener("input", setGradient);
```

**website link:** [3-Gradient-Color-Background](https://farhanacsebd.github.io/Simple-3-Color-Gradient-Using-JavaScript/)
In React can I linking directly?
Tags: reactnative, expo, beginners
Published: 2022-11-25 18:22:30

Help me please <3
I want to put a button to make a call without the step that user has to click on call. In another words, I want that when the user clicks the button and it binds the call directly.

CODE:

const handleCallPress = async() => {
   await Linking.openURL("tel:7352120891");
  }
?? in Javascript -Nullish coalescing operator-
Tags: javascript
Published: 2022-11-25 18:22:18

# ?? in javascipt
Nullish coalescing operatior(??) is return right operand when left operand is `null` or `undefined`. if left operand is not nullish it return left operand.

# example basic
```javascript
const foo = null ?? 'default string';
console.log(foo);
// expected output: "default string"

const bar = 0 ?? 42;
console.log(bar);
// expected output: 0
```

# example in react
```javascript
const [who, setWho] = useState(initWho ?? "all");
```

# reference
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing
Email Automation
Tags: automation, rpa, hyperautomation, robotic
Published: 2022-11-25 17:56:05

With more people having access to the internet, there has been a gradual increase in the number of emails sent out each year. An estimated 300 billion emails are sent out each day, with this number projected to increase by 2025.

Emails are the primary form of communication used by businesses worldwide and are a crucial part of any business organization. Using email automation, you can automate your repetitive email tasks, including opening emails, reading and processing them, sorting them, extracting data from them, working on them, and responding to them accordingly.
Email automation lets you increase employee productivity by allowing them to concentrate on tasks that are important to them and stop wasting too much time reading and sending emails.

ElectroNeek offers integrated email activities that are ready to be used for automation across various platforms, including Microsoft Outlook, Microsoft 365, Google, Yahoo, iCloud, Yandex, and others. By selecting the service’s name, users can choose the default settings for any email server on the list with ease.

Find out how you can automate your email activities using ElectroNeek: 
https://forum.electroneek.com/t/email-automation/1102

You can also be part of the community by navigating to: 
https://forum.electroneek.com/signup

**Happy Automation!!!**
-10% On Programming Flashcards
Tags: programming, webdev, javascript, python
Published: 2022-11-25 17:29:06

- 10% on the entire order with the discount code BLACK10. Only on November 25!⏳🎁🖤 #summonthejson

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqrqst274aqp8qp9cj6q.jpg)
Easiest way to optimise images for web
Published: 2022-11-27 08:40:13

---
title: Easiest way to optimise images for web
published: true
date: 2022-11-25 17:12:33 UTC
tags: 
canonical_url: https://www.darraghoriordan.com/2022/11/25/optimise-images-for-web/
---

Here is how I optimise all pngs and jpgs in a folder for publishing to the web.

<!-- end excerpt -->

To get the tools install with brew or whatever you use.

```
brew install imagemagick optipng
```

Then run the following commands to produce optimised images for web sites. This will often reduce the size of the image by 50% or more with no obvious loss of quality for web.

```
# for jpgs
mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% *.jpg

# For pngs and bitmaps
optipng *
```
EXCEPTION (CLASS .... NOT FOUND) while DEBUGGING
Tags: vscode, laravel, php, testing
Published: 2022-11-25 17:07:55

The art of debugging is very important as it could save you lot of time and headaches. Tools used

1. Laravel
2. Visual Studio Code(VSCode)
3. Xdebug
4. PHP Debug extension for Visual Studio Code (Debug support for PHP with Xdebug)
5. Xdebug helper(Browser Extension)

Am going to skip the installation of this tools as once you encounter the "**Class not found exception**" then you have passed the installation stage.

After installing PHP debug extension and accessing its _launch.json_ file from _.vscode_ directory. You will see 3 different settings in configurations which you must take note of base on the **name**.


![launch.json](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5u05dykpgmkwas6rbcy.png)


Without the use of imported Classes in your debugging script you are likely not to experience any issues with any of these configurations. eg. using **name:** _Launch currently open script_


![script without the usage of imported classes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rya65lmwo6qs5yq5woyk.png)



For Laravel application the entry point is the _index.php_ file which is inside the public folder. These file loads all the required files to handle request from the browser. So when we use the browser extension debug helper together with our break points we wont' have the exception: "Class .... not Found"


![Class Not Found](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpf18ebarlf0vxltvte2.png)



**The Solution**
Change the debug configurations option **name** to _Listen for Xdebug_

![Listen for Xdebug](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9p9s124ey7o4kasfc9x1.jpg)


And enable debugger helper extension in the browser.


![enable debugger helper](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fyr7l5fwuu524oyx07hr.png)

After enabling the debug helper extension and refreshing the page again we see that the page keeps loading and never stops because our first break point has been hit awaiting our next action


![first break point hit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjoojs3wrsf0y7lv782r.png)

We can see that our _$user_  variable is not initialized yet from the **_VARIABLES SECTION_**. 

When we click on **continue** to the next break point, we now see the _$user_ variable being initialize which we can now inspect.


![Debug variable set for inspection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svry9on4e91ndxnr3mgy.png)


Congratulations!!!!. Class not found exception during debugging in laravel is sorted. Let me know what you think as sharing helps us learn better.
#PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 3/N
Tags: englishpost, microsoftteams, opentriviadatabase
Published: 2022-11-28 13:31:03

---
title: #PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 3/N
published: true
date: 2022-11-25 16:57:06 UTC
tags: EnglishPost,EnglishPost,MicrosoftTeams,OpenTriviaDatabase
canonical_url: 
---

#### PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 Series

- [Intro to Open Trivia Database API](https://dev.to/azure/powerautomate-flow-to-use-open-trivia-database-questions-in-a-microsoft-teams-bot-1n-1h1e)
- [How to process the API Response and send a question to Teams](https://dev.to/azure/powerautomate-flow-to-use-open-trivia-database-questions-in-a-microsoft-teams-bot-2n-3dlm)
- [How to validate the user response in teams with the Trivia Question correct answer](https://elbruno.com/?p=35989)

Hi !

In previous posts we request a Trivia quesion using the Open Trivia Database API, and sent a mesage to teams so an user can read the question and pick an answer. In today’s post, les process the user’ answer.

The flow is simple:

- Create a new variable [**strQuizResponse**] to store the response for the user.
- Validate the user answer vs the correct answer and complete the string [**strQuizResponse**] with CORRECT or INCORRECT.
- Display the response to the user.

![Create a new variable [strQuizResponse] to store the response for the user.

Validate the user answer vs the correct answer and complete the string [strQuizResponse] with CORRECT or INCORRECT.

Display the response to the user.](https://brunocapuano.files.wordpress.com/2022/11/image-12.png?w=1024)

Once the flow is running, we can see in the history how the variables, conditions and responses are processed.

In example, in this question in the bot, with an incorrect answer.

![question in the bot, with an incorrect answer.](https://brunocapuano.files.wordpress.com/2022/11/image-14.png?w=738)

This is the flow history.

![](https://brunocapuano.files.wordpress.com/2022/11/image-13.png?w=627)

We are almost there ! However, we can improve still this flow a lot 😀

And important: Join me in this 2-week FREE program @MSFTReactor  
and we will learn together about Microsoft Power Pages.  
We will also cover fundamentals of Power Pages architecture, components, features, and tooling.

#### [https://aka.ms/DecPowerPagesBootcamp](https://aka.ms/DecPowerPagesBootcamp)

Starting on Dec 05

Happy coding!

Greetings

El Bruno

More posts in my blog [ElBruno.com](https://www.elbruno.com).

* * *
907.leetcode Solution in cpp
Tags: cpp
Published: 2022-11-25 16:48:32

```cpp
class Solution {
 public:
  int sumSubarrayMins(vector<int>& arr) {
    constexpr int kMod = 1e9 + 7;
    const int n = arr.size();
    long ans = 0;
    vector<int> prev(n, -1);
    vector<int> next(n, n);
    stack<int> stack;

    for (int i = 0; i < n; ++i) {
      while (!stack.empty() && arr[stack.top()] > arr[i]) {
        const int index = stack.top();
        stack.pop();
        next[index] = i;
      }
      if (!stack.empty())
        prev[i] = stack.top();
      stack.push(i);
    }

    for (int i = 0; i < n; ++i) {
      ans += static_cast<long>(arr[i]) * (i - prev[i]) * (next[i] - i);
      ans %= kMod;
    }

    return ans;
  }
};
```
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/sum-of-subarray-minimums/
How to fix ads.txt in AdSense
Tags: adsense, webdev, domainbuy, news
Published: 2022-11-25 16:44:05

How to fix ads.txt in AdSense
ads.txt file some time headache when your site is ready to show ads for the first time then you will facing this type red line error that your Earning at risk show in below image.
[Read more](https://jobinkpk.com/2022/11/20/how-to-fix-ads-txt-in-adsense/ )