teleren/devto huggingface dataset:
Reinforcement learning with Q-learning
Tags: watercooler
Published: 2021-12-22 09:27:21

Like other machine learning algorithms, a reinforcement learning model needs to be trained before it can be used. The training phase centers on exploring the environment and receiving feedback, given specific actions performed in specific circumstances or states.


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

The life cycle of training a reinforcement learning model is based on the Markov Decision Process, which provides a mathematical framework for modeling decisions. Let's use an autonomous car parking as an example.

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

A simulator needs to model the environment, the actions of the agent, and the rewards received after each action. A reinforcement learning algorithm will use the simulator to learn through practice by taking actions in the simulated environment and measuring the outcome.

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

Initialize the environment: This function involves resetting the environment, including the agent, to the starting state. Get the current state of the environment: This function provides the current state of the environment, which will change after each action is performed.

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

Apply an action to the environment: This function involves having the agent apply an action to the environment - the environment is affected by the action, which may result in a reward.

Calculate the reward of the action: This function is related to applying the action to the environment. The reward for the action and effect on the environment need to be calculated.

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

Determine whether the goal is achieved: This function determines whether the agent has achieved the goal. In an environment in which the goal cannot be achieved, the simulator needs to signal completion when it deems necessary.

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

After many cycles of simulation, and the agent taking actions, the Q-table will be trained with sequences of actions that are favourable to get to the destination. Note: Without varying environment data, the model will be overfitted and perform poorly in real-world situations.

Learn more about reinforcement learning in Grokking AI Algorithms with Manning Publications: [http://bit.ly/gaia-book](http://bit.ly/gaia-book), consider following me - [@RishalHurbans](https://twitter.com/RishalHurbans), or join my mailing list for infrequent knowledge drops: [https://rhurbans.com/subscribe](https://rhurbans.com/subscribe).
Cleanup Azure DevOps pipelines retained by releases
Tags: azure, devops
Published: 2021-12-22 15:55:38

One situation I've come across a while ago was not being able to remove some deprecated pipelines due to the following error:

![One or more builds associated with the requested pipeline(s) are retained by a release. The pipeline(s) and builds will not be deleted.](https://nunobarreiro.com/images/devops-pipeline-retention-lease-error-onremoval.png)

Going through the [builds REST documentation](https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/get?view=azure-devops-rest-6.0), I was able to check that Builds do have a property "retainedByRelease". Not only that, but digging further and looking at the [leases REST documentation](https://docs.microsoft.com/en-us/rest/api/azure/devops/build/leases?view=azure-devops-rest-6.1) I also noticed a boolean property named "protectPipeline" that, according to its very relevant description states that:

> If set, this lease will also prevent the pipeline from being deleted while the lease is still valid.

Now I was finally getting somewhere, and I've attempted to patch the lease and set that property to false. Surprised, or maybe not, when you set that property to false for all the leases associated with the build, then the build own property "retainedByRelease" also turns out to false, allowing you to finally delete it permanently!

To automate things, since I had multiple builds with the same state, I've created the below python script, that you are invited to read and use. 
At the time I was using [Fiddler](https://www.telerik.com/fiddler) to check the requests, but you can remove the "fiddler_proxies" related stuff from there if you don't need that.

Please follow the [instructions](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page#create-a-pat) on how to create a Personal Access Token and encode it using a base64 encoding tool like [this](https://www.base64encode.org) one.

Make sure to fill in the "project_url", the "encoded_pat" and the "build_definition_ids" variables, before running the script. You can get the build IDs from the URL when you enter a build definition using the DevOps portal

The project url can also be get from the address bar, and for this script it needs to be in the format: `https://dev.azure.com/{org name}/{project name}`.

{% gist https://gist.github.com/nuno-barreiro/b14ec7ee58c718400dbb14a8860716c6 %}
Explore API
Tags: javascript, tutorial, beginners, codenewbie
Published: 2021-12-22 17:48:55

**Today we will learn What is an API? And The purpose of API & CRUD Operations.**

### What's an API 
**API** stands for **Application Programming Interface**. It’s a way to connect two applications for talking with each other. It helps you to embed content on your website from any website in a more efficient way. API is simple, flexible, and easier to use. The main purpose of the API is to create communication between two applications. API lets you call to send or receive information. The communication is done by **JSON**. We fetch data with API requests in applications. API request has 4 components. They are Endpoint, Header, Method & Data. After calling those individually we can build an API request. 

###CRUD Operations
**CRUD** Operations stands for **Create**, **Read**, **Update** & **Delete** operations. The fours basics and important methods in database operations. The purpose of CRUD operations is to modify the data in an application. Let’s explore CRUD Operations:

 - **GET** - GET method allows you to get information from the source/database.
 - **POST** - POST method allows you to add some information to the source/database.
 - **PUT** - PUT method allows you to update the existing information to the source/database.
 - **DELETE** - DELETE method allows you to delete existing information from the source/database.

###JSON
**JSON** stands for **JavaScript Object Notation**. It’s used to represent data on the server. It’s easy to read for humans and computers. Let’s see an example:
![JSON Example Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36lys18lfkyj9ytkkdqk.png)

###Types of API
There are three types of API:
 - **Open API** - Open API means an API that is free to use and everyone can use it.
 - **Partner API** - Partner API means an API that makes a connection between the server and the clients.
 - **Private API** - Private API means a secure API that can only be used for internal uses like payments.

API is a powerful tool for making connections between client and server applications. API provides more benefits like security, speed, & scalability for eCommerce applications. API helps developers send data to clients and is used every day in today’s world.


Thank you for reading this!
Mini-tutorial Android Studio: Revisar conexión a internet
Tags: android, espanol, minitutorial, spanish
Published: 2021-12-22 18:38:25

## Hola de nuevo a un mini-tutorial de Android Studio.

En esta ocasión les enseñare a revisar si en su dispositivo hay conexión a internet


### ¡¡¡Vamos al código!!!

------
## AndroidManifest.xml

En nuestro **AndroidManifest.xml** agregaremos los permisos para eso tendremos que agregar arriba de nuestro **application** 

```    
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    ....
    <application
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
```

## MainActivity.java

En nuestro MainActivity utilizaremos el objeto **ConnectivityManager** y creamos un objeto **Networkinfo** 

```
ConnectivityManager con = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo networkInfo = con.getActiveNetworkInfo();
```

Ya teniendo el objeto **networkInfo** podremos revisar la conexión.

Ahora con un simple **if** revisamos si hay conexión a internet 

```
    if(networkInfo!=null && networkInfo.isConnected())
        {
           Toast.makeText(getApplicationContext(), "Si hay conexión a internet", Toast.LENGTH_LONG).show();
        }else
        {
            Toast.makeText(context, "Necesitas conectarte a internet", Toast.LENGTH_LONG).show();
        }
```

## Fin
Apama Advent Calendar - 22 Dec 2021 - The MemoryStore plugin
Tags: apama, iot, cumulocity, streaminganalytics
Published: 2021-12-23 13:04:13

---
title: Apama Advent Calendar - 22 Dec 2021 - The MemoryStore plugin
published: true
date: 2021-12-22 16:56:44 UTC
tags: apama, iot, cumulocity, streaminganalytics
canonical_url: https://tech.forums.softwareag.com/t/apama-advent-calendar-22-dec-2021-the-memorystore-plugin/254021
---

_This is Day #22_ _of a short series of brief tips, tricks, hints, and reminders of information relating to the Apama Streaming Analytics platform, both from Software AG as well as from the community._  

Check out some typical use cases for the Memory Store, and learn  to set up the store and describe the tables before you can use them in the original post in the [Software AG Tech Community](https://tech.forums.softwareag.com/t/apama-advent-calendar-22-dec-2021-the-memorystore-plugin/254021).

_Note that some posts may be published a day or two early or late (e.g. Mon-Fri) so you may find you have bonus days with more than one post!_
Number Methods JavaScript 
Tags: javascript
Published: 2021-12-22 20:24:13

**<u>The toString() Method:</u>**
The toString() method retunes a number as a string 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uukmannj7xtgyux0dboy.png) 

**<u>The toExponential() Method</u>**
toExponential() provides a string containing a number that has been rounded and expressed in exponential notation.

The number of characters after the decimal point is determined by a parameter. The parameter is not required. JavaScript will not round the number if you don't provide it.

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

**<u>The toFixed() Method
</u>**
toFixed() produces a string containing a number with a given number of decimals put in it. The toFixed() function reduces the number of digits in an integer to a specified number.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47bml2qxp7iz4zjy6zd2.png)

**<u>Converting Variables to Numbers</u>**
Number()	Returns a number, converted from its argument.

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

parseInt()	Parses its argument and returns an intege

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

parseFloat()	Parses its argument and returns a floating point number

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1r4wkk40tws5uotu053n.png)
SIMPLE CSS ANIMTATION
Published: 2021-12-23 20:34:02

**CSS ANIMATIONS : **

CSS Animation is which is helps to change one style to another style. We can use animation without using javascript. If we want to use animation on CSS we have to use @keyframes. 

There have some advantages to using CSS animations: 
This is easy to use and you can create animation without using javascript.
This animation’s performances are so smooth for their rendering engine use frame0skipping and some other techniques.
Letting the browser control the animation sequence lets the browser optimize performance and efficiency

@keyframes helps to use animation on CSS. @keyframes take a name and curly bracket. On curly bracket, you have to use from and to or 0% and 100%, percentage to changing styles. 0% means the beginning of the animations and 100% means the end of the animation and the from means from where animation start and to means where the animation will end.

**Example of defining:
**—from to—
 
    
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43xmnyeopq1zraf88a74.png)
       
–percentage—
 
   
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zbvcje558eox4ei0su2.png)
 

These two images are showing that how to use from to and percentage in keyframes. Now we will see an example of animation.

Example of animation :
First, you have write an HTML code to make a structure for your animations. Like I had written some HTML code in below. 
 

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


After writing some HTML code and we have to add some styles for positions items and looking beautiful.
Styles
 
     
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqoowu8wblfoy3jjry1j.png)
       


After adding styles on elements we need to take which element you want to make animation. On that element’s CSS you have to write the animation property name on that CSS element’s CSS. you can add delay, how many time loops and etc more options.
 
    
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkwnb44gz9scxcsf3h61.png)
       

After defining the name on that CSS you have to @keyframes Name { } in CSS. inside the curly bracket, you will write code which animation you want to make.

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



**Animation Project and code : 
**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zj3akw69klbh89y9qy4r.gif)
You can check this simple animation on CodePen. [Click here to see](https://codepen.io/pen/?template=QWqqzBJ)
Why I use aqua
Published: 2021-12-23 00:32:46

aqua is a declarative CLI Version Manager written in Go.

https://aquaproj.github.io/

[![asciicast](https://asciinema.org/a/457021.svg)](https://asciinema.org/a/457021)

In this post, I describe why I use aqua.

## Why I use aqua

* Align tool versions in team and CI
  * Solve the problem due to the difference of tool versions
* Manage tools and their versions for projects as code declaratively, and provide an unified way to install tools
  * aqua supports changing tool versions per project
* Stop developing shell scripts and GitHub Actions to install tools per tool and per project
* Update tools with Renovate easily
* Install tools hosted in private repositories

## Why not asdf?

asdf is used for the similar purpose, but I use aqua. Why?

* Some tools don't have asdf plugins for them
* Good Experience
  * You don't have to install plugins
  * Tools are installed automatically
  * Search tools by `aqua g` is useful
* aqua doesn't force to use aqua in other projects and globally
* Easy to support new tools
  * It is easier to contribute to aqua-registry than to develop asdf plugin
* Easy to introduce aqua to teams and projects because aqua is easy and doesn't force to use aqua in other projects and globally
* Easy to update tools with Renovate
* aqua supports splitting configuration files, so it is easy to filter builds in CI by changed file paths

About the difference between aqua and asf, please see [Comparison - asdf](https://aquaproj.github.io/docs/comparison/asdf) too.
Create Stopwatch using javascript
Tags: stopwatch, javascript, html, webdev
Published: 2021-12-23 07:07:40

In this tutorial, we will discuss, how to construct a simple javascript stopwatch. A stopwatch is used on many websites to track time. Moreover, it is also a good standalone project as well.

The stopwatch we are creating is similar to a regular stopwatch that is used to keep track of time. Albeit, it is unique for its ability to track hours, minutes, seconds, and milliseconds.



Prerequisites for this project:

This article requires a basic understanding of HTML, CSS, and a little bit of Javascript. I'll explain the project in a manner that makes it easy to follow even for complete beginners with a basic understanding of the listed technologies.

Live Demo:

Before we start the programming, let's discuss the UI of the project. First, we are creating a stopwatch container that will have a screen to display the current stopwatch time. The stopwatch also has three buttons — Pause, Start, Reset — to control the stopwatch.[read more](https://www.codewithrandom.com/2021/12/create-stopwatch-using-javascript.html)
Advance Laravel 8 Interview Questions and Answers 2022
Tags: laravel, computerscience, programming, tutorial
Published: 2021-12-23 08:49:26

#Q. 1: What is Serialization in Laravel?

It's similar to turning an object into JSON, but with the advantage that PHP will remember the native data type of each serialized item (string, array, integer, float, boolean).

PHP and Javascript can only communicate via strings. You can pass the string "foo" very easily to Javascript. You can pass the number 1 very easily to Javascript. You can pass the boolean values true and false easily to Javascript. But how do you pass this array to Javascript?

The answer is serialization. In case of PHP/Javascript, JSON is actually the better serialization format:

**echo json_encode($array)

[Read Full Blog Here....](https://codexashish.blogspot.com/2021/12/advance-laravel-8-interview-questions.html)
Swagger To Typescript
Published: 2021-12-23 09:03:19

Swagger To Typescript is a plug-in used to convert the types provided by Swagger documents to typescript types automatically.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu9s7aftxd0idxe1dkby.png)
usage
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pil1q1u3xp9avav3tbr.gif)
Keyboard shortcuts configuration.

- Default button configuration (window & mac)
1. Conversion operation `ctrl+shift+k` (Right-click panel also has options)
- You can also make customize settings in the shortcut key setting interface.

PS: [File Teleport](https://github.com/AKclown/file-teleport)File will be updated synchronously together with plug-in.
What is the difference between Node.js and React?
Tags: node, react, programming
Published: 2021-12-23 10:43:13

These two JavaScript frameworks are both popular, but they’re not quite the same thing. So what’s the difference between them? And how can you use each to your advantage? In this article, we’ll compare Node and React and explain when to use each one in order to create an awesome website or application. Let’s get started!

**Why Node.js was created?
**
Node.js was originally created by Ryan Dahl in 2009, with a goal of creating a platform that could enable developers to create real-time applications using JavaScript on both server and client sides. Since Node’s inception, it has been widely used for backend development (most notably for single page applications) because of its lightweight nature and asynchronous processing model as well as for its versatility in handling concurrent operations. Currently, Node has over 170K stars on GitHub!

**How Node.js works?**
Node.js makes it possible to build server-side applications using JavaScript outside of a browser environment, which is advantageous because browsers don’t support some of the more advanced JavaScript features like asynchronous callbacks and highly dynamic code execution. With Node, an application uses a library called Node Package Manager (npm) to install other packages from its community repository – npm currently hosts over half a million open source packages for use in applications built with Node.

**About ReactJS**
The library exposes a set of components and APIs that allow you to build applications using a declarative programming paradigm. As such, it enables you to separate your application's logic from its rendering, making it possible to test components in isolation of one another and thus easily reuse them within different contexts, which increases code maintainability while simultaneously reducing complexity by minimizing inter-component dependencies as well as runtime exceptions [source].

**Comparison of NodeJS and ReactJS**
[Node.js vs react](https://devdojo.com/pixelcrayon2021/a-battle-of-nodejs-vs-react-which-is-better): One of these things is not like the other... but which one, you ask? Well, it depends on your needs, really. While they are both Javascript frameworks used for building apps and websites, each have different strengths that lend themselves to specific types of applications – so it’s best to take a look at how they compare before deciding on what framework might be best for your project!

Also Read: [Node.js vs Python](https://www.pixelcrayons.com/blog/node-js-vs-python-which-is-better/)
Countdown to New Year - [ Updated ]
Tags: codepen
Published: 2021-12-23 15:19:36

<p>Updated:
- Improvement to view complete spin around the sun.
- Earth Solar System sector centered auto in screen.
- Dates of all equinoxes and solstices.
- Added leap year calculation.</p>

{% codepen https://codepen.io/harunpehlivan/pen/NWjxmdy %}
Let's know about Mongoose
Tags: database, mongoose, nosql, backend
Published: 2021-12-23 16:56:12

**Mongoose:**
MongoDB is a nosql, document oriented database program. It stores JSON-like documents with optional schema. But, Mongoose is an Object Data Modelling (ODM) for mongodb and nodejs. It manages relationships between data. It defines a schema for collections. 

**MongoDB VS Mongoose:**

1. DBMS VS Object Document Mapper
2. Stores data VS Manages relationship between data
3. Supports multiple languages VS Only mondoDB
4. Aim - Storing collection in DB VS Defining schema for collections.

Mongoose defines schema and also validates it. It helps to structure the document for better presentation. It enables users to add/ edit properties easily. 

To use this, at first we have to install mongoose, like,

```
npm install mongoose --save
```

Once we define a schema, we can create a Model based on a specific schema in Mongoose. After creation of the model, a Mongoose Model is then mapped to a MongoDB Document and it is done via the Model's schema definition.

The permitted schema types are:

1. Array
2. Boolean
3. Buffer
4. Date
5. Mixed (A generic / flexible data type)
6. Number
7. ObjectId
8. String

**We can create a mongoose model by following 3 steps as:**

**1. Referencing mongoose:**

```
let mongoose = require('mongoose')
```

**2. Defining the schema**

```
let newSchema = new mongoose.Schema({
  variable_name: variable_type
})
```

**3. Exporting a model**

```
module.exports = mongoose.model(collection_name, schema_name)
```

**Basic operations of Mongoose are:**

1. Create record
2. Fetch record
3. Update record
4. Delete record

**References:** 

1. [Introduction to mongoose for mongodb](https://www.freecodecamp.org/news/introduction-to-mongoose-for-mongodb-d2a7aa593c57/)
2. [Mongoose crash course](https://www.youtube.com/watch?v=DZBGEVgL2eE)
3. [Reasons to use mongoose](https://www.stackchief.com/blog/Top%204%20Reasons%20to%20Use%20Mongoose%20with%20MongoDB)
4. [Mongoose tutorial playlist for beginner](https://www.youtube.com/playlist?list=PLNHw_0qv1zy_UEXiWaqSXiLSwwE8mjuj7)

Mongoose documentation can be followed for detailed implementation.