teleren/devto huggingface dataset:
Create a easy test using Model Baker
Tags: modelbaker, django, python, pytest
Published: 2020-02-10 15:07:13




#### Install this guy

```bash
pip install model_bakery
```

#### models.py

```python
class Customer(models.Model):
    name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    love_python = models.BooleanField()
    last_coding = models.DateTimeField()
```

#### test_models.py

```python
from django.test import TestCase
from model_bakery import baker
from datetime import datetime

class TestCustomerModel(TestCase):
    def test_simple(self):
        customer = baker.make('shop.Customer')
        assert customer

    def test_models_fields(self):
        date = datetime.datetime.now()

        person = baker.make(
		        'shop.Customer',
		        name='Lucas',
		        last_name='Castejon',
		        love_python=True,
		        last_coding=date
        	)
        assert person.name = 'Lucas'
        assert person.last_name = 'Castejon'
        assert person.love_python
        assert isinstance(person.last_coding, datetime)
```


```json

pprint(self.person.__dict__)

{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
 'age': 3841,
 'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
 'birthday': datetime.date(2019, 12, 3),
 'happy': True,
 'id': 1,
 'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
 'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx',
 'wanted_games_qtd': 6016}
```
Coronavirus Remover extension in javascript
Tags: javascript, coronavirus, html, opensource
Published: 2020-02-10 15:02:08

CoronavirusRemover👾👽

This is the firefox/chrome extension created in simple javascript and (json: provided by firefox/chrome developer options) simply it removes coronavirus word from any website you visiting

github repo link:https://github.com/krishnadevz/CoronavirusRemover

Firefox extension link:-https://addons.mozilla.org/en-US/firefox/addon/coronavirus-remover/
How to: Call a TeamCity build from OctopusDeploy
Tags: ci, octopusdeploy, teamcity, devops
Published: 2020-02-11 11:13:18

---
title: How to: Call a TeamCity build from OctopusDeploy
published: true
date: 2020-02-10 15:00:00 UTC
tags: ci,octopusdeploy,teamcity,devops
canonical_url: https://seankilleen.com/2020/02/how-to-call-a-teamcity-build-from-octopusdeploy/
---

We have an OctopusDeploy deployment that deploys our code to an automated acceptance test environment. And we have a TeamCity build that executes our automated acceptance tests.

The challenge is: the TeamCity build kicked off after our code was merged, not after the deployment was finished. We wanted the tests to kick off only after the environment was ready.

## Solution

I created an OctopusDeploy step template to kick off a TeamCity build, and then utilized that step template in the Octopus deployment.

It works via crafting an `HTTP POST` request against the TeamCity API.

### Step Template Contents

I created a PowerShell script that utilizes some parameters

```
$parsedUrlString = "$TeamCityServerURL" + "/app/rest/buildQueue" $parsedXmlBody = '<build><buildType id="' + $TeamCityBuildConfigID + '"/></build>'

$HeaderFields = @{} $HeaderFields.add("Authorization", "Bearer $TeamCityAccessToken")
$HeaderFields.add("Origin", "$TeamCityServerURL")

Write-Host "Attempting to run the $TeamCityBuildConfigID build" Write-Host "Connecting to $parsedUrlString"

Invoke-WebRequest -UseBasicParsing $parsedUrlString -ContentType "application/xml" -Method POST -Body $parsedXmlBody -Headers $HeaderFields

```

### The Parameters

From the variables in the script, Octopus will generate step templates:

![Script parameters shown visually](https://seankilleen.com/images/post-images/teamcity_from_octopus/ScriptParameters.png)

### Generating the TeamCity Access Token

- Open TeamCity and head to the settings menu:

![The settings menu](https://seankilleen.com/images/post-images/teamcity_from_octopus/SettingsMenu.png)

- Click to create the access token:

![the menu for creating an ccess token](https://seankilleen.com/images/post-images/teamcity_from_octopus/CreateAccessToken.png)

- Give the access token a name:

![Name entry for access token](https://seankilleen.com/images/post-images/teamcity_from_octopus/AccessTokenName.png)

- Copy the access token

![Access token text for copying](https://seankilleen.com/images/post-images/teamcity_from_octopus/AccessTokenCopy.png)

### Adding the build step

- In OctopusDeploy, open the deployment in question
- Add a deployment step, and select the step template
- Add the applicable parameters

## The Result

Now, when we commit code:

- The build finishes
- The Octopus deployment kicks off
- After the deployment, the last step calls the other TeamCity build
- The TeamCity build kicks off to run our automated acceptance tests

Happy deploying!
⚡ Announcing Byteconf React: a free React conference, streamed online
Tags: react, showdev, webdev
Published: 2020-02-10 14:56:58

Two weeks ago, [Byteconf GraphQL 2020](https://www.bytesized.xyz/graphql-2020) went live - a free remote GraphQL conference, with 12 awesome speakers from around the world. With Byteconf GraphQL under our belt, it's time to announce what I'm expecting will be one of the biggest conferences Byteconf has done to date...

**On May 1st, join us for [Byteconf React](https://www.bytesized.xyz/react-2020), our free, remote React conference!**

I'm thrilled to be announcing the conference today, but it wouldn't be a complete event without a great group of attendees, and of course, an incredible selection of speakers. If you're a React enthusiast, consider submitting a talk via our newly-opened Call for Papers (see the link at the end of this email) for the event – Byteconf is a great place to hone your speaking skills, and we'd love submissions from speakers of all experience levels and backgrounds.

If you're excited to attend Byteconf React, you can help us put on an amazing conference by doing two things: first, RSVP and get your ticket using the link below – we'll add you to the list for the conference and you'll be first to know when we announce new speakers and updates for the conference. Second, share it with your friends! If you're on Twitter, you can retweet our announcement post (below), or if you want to put your own spin on the event, we'd love to see your tweets and retweet them to our audience.

{% twitter 1226880148479324161 %}

Interested in speaking? [Check out the Byteconf React 2020 Call for Papers on Papercall.​](https://www.papercall.io/byteconf-react-2020)

See you in May!

By the way, if you're interested in what Byteconf is all about, check out our past conferences – every talk from every past Byteconf is available to watch on our YouTube channel. Rad!

- B[yteconf GraphQL 2020](https://www.youtube.com/watch?v=c_U0LJ4txRw&list=PLH_Crma-Dc9O3E53ZkTu8YlkEk6X_kBBZ)
- [Byteconf JavaScript 2019](https://www.youtube.com/playlist?list=PLH_Crma-Dc9MVB5yfC1ZwNxv8r4vhvZUQ)
- [Byteconf React Native 2018](https://www.youtube.com/playlist?list=PLH_Crma-Dc9OLKleEIrzuwOmxyGWuZbRW)
- [Byteconf React 2018](https://www.youtube.com/playlist?list=PLH_Crma-Dc9PRM7KxKerImYGUY22wkR3Z)
- [Byteconf Reason 2018](https://www.youtube.com/playlist?list=PLH_Crma-Dc9MmJmvjov5Yo8dfuQYn5Jhf)
Building a web server in Golang
Tags: go, webdev, routing
Published: 2020-02-10 14:54:33

*This post is a solution to the "Adam doesn't know routing" problem on Debugg. Visit Debugg at https://debugg.me*

What we need here is a simple web server and one route, the `/` or "root" route, let's say.

There's a built-in package called `net/http` that can help us here. Open the `main.go` file, and import the package.

```go
// main.go

package main

import "net/http"

func main() {

}

```

The official documentation of the package shows [an example](https://golang.org/pkg/net/http/#example_ListenAndServe) for the function `ListenAndServe`, which is just what we need.

```go
// main.go

...

func main() {
    http.ListenAndServe(":8080", nil)
}
```

which will start an http server on port 8080. Now we need to return "Hello, world!" on the root route. For this we use a [`HandleFunc`](https://golang.org/pkg/net/http/#HandleFunc) and pass it the route path and the handler function.

```go
// main.go

...

func helloHandler(w http.ResponseWriter, _ *http.Request) {}

func main() {
    http.HandleFunc("/", helloHandler)
    http.ListenAndServe(":8080", nil)
}
```
to return "Hello, World!", we invoke `io.WriteString` by passing in the `ResponseWriter` instance and "Hello, World!".

The final file looks as follows

```go
package main

import (
    "io"
    "log"
    "net/http"
)

func helloHandler(w http.ResponseWriter, _ *http.Request) {
    io.WriteString(w, "Hello, World!")
}

func main() {
    http.HandleFunc("/", helloHandler)
    log.Fatal(http.ListenAndServe(":8080", nil))
}

```

Visit Debugg at https://debugg.me
Browser automation with Python
Tags: python, beginners
Published: 2020-02-10 14:37:25

You can automate a web browser with <a href="https://python.org">Python</a> using the selenium module. The selenium module lets you control Google Chrome, Mozilla Firefox and <a href="https://pythonbasics.org/selenium_browsers/">other browsers</a>.

First, what is selenium?

## What is Selenium?

<a href="https://selenium.dev/">Selenium</a> automates web browsers. There are bindings for Python, that lets you use selenium using Python code. The web browser can run on the same computer or remote (another computer or mobile device).

Mainly it is for automating web applications for testing, but is certainly not limited to just that. The selenium module lets you

* do automated testing
* simulate web surfing
* do <a href="https://pythonprogramminglanguage.com/web-scraping-with-pandas-and-beautifulsoup/">web scraping</a>
* do usability testing

Before trying selenium, you should know the <a href="https://pythonbasics.org/">basics of Python</a>

To use selenium, you should <a href="https://pythonspot.com/selenium-install/">install</a> both the selenium module and the selenium web driver.

![selenium web driver](https://dev-to-uploads.s3.amazonaws.com/i/10932wftu8bq55fws366.png)

## Example

The program below starts the Chromium browser from a Python script, types the website url itself in the browser and loads it. Finally it outputs the html source of the web page.

```python
from selenium import webdriver
import time

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://python.org')

html = driver.page_source
print(html)
```
(from <a href="https://pythonspot.com/selenium-get-source/">selenium get source</a>)

If you prefer to use Firefox, just change the driver to firefox. Make sure you have the web driver installed otherwise it will not work. 

```python
# coding=utf-8
from selenium import webdriver
 
driver = webdriver.Firefox()
driver.get("https://python.org")
```

Keep in mind that the version of the web driver must be intended for the version of the web browser. A new web browser version, means you must update the driver.

Once you have selenium working on your computer, you can do anything you can do on the web from Python,fully automated, and more like <a href="https://pythonbasics.org/selenium_screenshot/">take screenshots</a> or <a href="https://pythonbasics.org/selenium_execute_javascript/">execute javascript</a> on the same page..


**Related links:**
* <a href="https://selenium.dev/">Selenium homepage</a>
* <a href="https://gum.co/GjuJxo">Python selenium course</a>
Delete Documents In Cloud Firestore For Web, Update The UI
Tags: firebase, cloud, firestore, crude
Published: 2020-02-10 14:28:03

I have been working on some little **side project** dubbed [Lolfacts](http://lolfacts.web.app/), while learning much more of Firebase for Web and need to CRUD(Create, Read, Update and Delete) has been evident in the tiny project. Really exciting.

If this is the first time exploring [Firebase Cloud Firestore for Web](https://pwafire.org/developer/codelabs/cloud-firestore-for-web/), be sure to have a look at this codelab code snippets and/or take it just to understand how to render each document data into the Front-end using Vanilla ES6.

### 1. Within the delete element

```js
 // 1. grab the delete element say "del" and listen to a click event
  del.addEventListener("click", event => {
  // 2. prompt to confirm delete
    let result = confirm("Want to delete? This action can not be undone.");
    if (result) {
      // 3. logic to delete the element named say, "lolfact"
      event.stopPropagation();
      let id = lolfact.getAttribute("data-id");
      console.log(id);
      // 4. get the collection to delete from
      db.collection("lolfacts")
        .doc(id)
        .delete();
      // 5. delete it from the parent element to refresh the ui
      app.removeChild(lolfact);
    }
});
```

Orginally Posted [on maye.pwafire.org](https://maye.pwafire.org/articles/how-to-delete-a-document-in-cloud-firestore-for-web-and-update-the-ui/)
CSS Animations
Tags: css, html, animation
Published: 2020-02-08 19:51:01

Let's talk about CSS animations! 

A little background, I've been in the sports Creative Services world for the last eight years. Doing everything from motion graphics, graphic design, video production. You know, the fun stuff! With going into Software Development, I've tried to look at building my foundations in many different areas. One area has been CSS, especially CSS animations. Anyways, enough about that, lets get to the fun. 

This is going to be a simple blog on how to do some very easy animations, including manipulations, movement and maybe some more fun! 

Let's get started!

First, a little background:

What are animations? What are CSS animations? Well, with an animation, you are looking to make something animate a certain way on the screen. It can be to change its shape, color, property, location, or just go away all together. But how do we do that? We use what's is known as **@keyframes**.

A keyframe is a moment in time from 0-100 that you mark on the timeline to key up when something is going to change. Will it change once or over time? That's all determined by you, the creator, to when you want it to start and end. 

Let's take a look at a simple animation.

**Simple animation**

In the first Codepen example we are binding the animation to the <div> element and it will last for six seconds, it will change the background-color from green to blue.

{% codepen https://codepen.io/jharrel/pen/KKpwowN %}

We told the @keyframes to change by using the keywords "from" and "to" which represents 0s to however many seconds we tell it to last for. In our case, six seconds (6s).

**Using percentages for time**

You can also break down time even more with percentages.

{% codepen https://codepen.io/jharrel/pen/oNXgqYm %}

As you can see here, we used 0% orange, 25% aqua, 50% blue, 100% green. you can also get more intense and figure out different percentage values. However, they all have to equal to 100%.

**Changing color over time and location**

The final point I'm going to cover in this simple example is that you can also change the animations color and position. Exciting, huh!?

{% codepen https://codepen.io/jharrel/pen/oNXgqYm %}

Inside this animation we see the brick is now longer and starts out black. But what's interesting is now we tell it where on the page to move to and where to keep moving to with each keyframe percentage. 

Of course we could change the positions all we want. One thing to keep in mind is if you look in the @keyframes, you'll notice a piece that says *left*. This is the left side of the object. If we were to change that to *right*, we would see that the right part of the object would reach its destination and the animation would change for that instance only. 

That's all for this simple CSS animation piece. I'll be looking at moving into more advanced CSS animations soon.
Design Patterns in JavaScript
Tags: designpatterns, javascript
Published: 2020-02-10 14:06:22

Just started course, Design Patterns in JavaScript on Udemy.

Here is summary from first section by [@nesteruk](https://github.com/nesteruk) from course.

{% gist https://gist.github.com/SelenGora/549a2c448489f8741de2d41cd4c67246 %}
Can we make array volatile in Java?
Tags: java, career
Published: 2020-02-10 14:03:53

This is one of the tricky Java multi-threading questions you will see in the Interview. 

Yes, you can make an array volatile in Java but only the reference which is pointing to an array, not the whole array. 

What I mean, if one thread changes the reference variable to points to another array, that will provide a volatile guarantee, but if multiple threads are changing individual array elements they won't be having happens before guarantee provided by the volatile modifier.
gmail inbox lockin and how to escape
Tags: email, inbox, webmail
Published: 2020-02-10 14:03:48

i admit i have been using the gmail webmail inbox interface for the last few years but i cant forward multiple emails in one email and i cant work out how to turn off the awful collapsed folder view on my @gmail account (luckily they havent rolled out the collapsed folder view on my @mygoogapp accounts yet but im sure its only a matter of time) and since it ISNT opensource I cant hack it

so im now in the market for a new email / webmail client but i dont need a groupware solution such as [Horde](https://www.horde.org/apps) or [Zimbra](https://www.zimbra.com/email-server-software/product-edition-comparison/) but thanks to a recent article on https://opensource.com/alternatives/gmail i have just come across [Mailpile](https://www.mailpile.is/)

is anyone else using [Mailpile](https://www.mailpile.is/) or is there a great node email / webmail client that you can recommend ? 

ps here's another email / inbox issue that has been raised previously on DEV

{% link https://dev.to/dploeger/get-self-organized-using-inbox-zero-4h3o %}
Getting bit by Python
Tags: python, beginners, tryingmyluck
Published: 2020-02-10 13:55:04

I usually did my coding works in C++ as C was the first language I got introduced to. Even today C++ stands out when it comes to speed of execution of a program. Nevertheless, this is an experiement of how good the Python language is. 

I am going to write down all the learnings from the language as I get to know them. 

Hoping to get a couple of good comments from the experts out there. 

#DaysofPython
Some Other Great Asp.Net Core Tutorials in 2020
Tags: dotnet, tutorial, beginners
Published: 2020-02-10 13:54:52

In the last weeks, I have been looking to further materials and information related to my main subject of study, Asp.Net Core. Even if my main projects are in .Net WPF, I really like the Asp.Net web world, and that's where I am deepening my knowledge.

Before going through the latest tutorials, the material I purchased from the code-maze guys has to be mentioned Asp.Net Core Web API course. This is the most serious course material I probably purchased, but easy to follow, with full support and explanations. https://code-maze.com/ultimate-aspnet-core-3-web-api/
I really prefer this approach vs Udemy or Youtube. I like to have a pdf file with explanations, code snippets and code repo, versus the lengthy youtube videos from any trainer, even if they are free.

In addition to the above, lets's see what I have found and studied (all of them, but not very deeply) in the last couple of weeks:

**1. The blog of Saineshwar Bager, tutexchange.com**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3lfjl1apsjt0hlstwvoj.png)
a)
https://tutexchange.com/creating-grid-view-in-asp-net-core-with-custom-searching/

This one contains a tutorial, how to present tabular data with paging, search and sorting data with asp.net core mvc. Really nice and useful one. Medium difficulty.

b)
https://tutexchange.com/how-to-upload-files-and-save-in-database-in-asp-net-core-mvc/


How to upload file content to a MS SQL database, some new idea, maybe I will further this idea on a later project. Really good quality one, as a), so I can only recommend his blog, which is a true delight for Asp.Net Core learners.

**2. Another great tutorial source https://dotnetthoughts.net**

c) Even if I prepared a Chart.JS tutorial in Dec 2019, this is a great one too, with Google Charts, see
https://dotnetthoughts.net/integrating-google-charts-in-aspnet-core/

d) From the same source, how to deploy an asp.net core app on Heroku:
https://dotnetthoughts.net/hosting-aspnet-core-on-heroku/

Until now I published my small works on Interserver.net, but this time I published my c) and d) learning directly on heroku! :)
https://dotnet-core-chart.herokuapp.com/
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kcplust3ik4kdgxfckck.png)

**3. I always wanted to check the Angular client generation with NSWAG, so I tested this one out:**
e) https://elanderson.net/2019/12/using-nswag-to-generate-angular-client-for-an-asp-net-core-3-api/

I wish the explanations were clearer on this site!

**4. Also tried this one, Angular Chat app with SignalR**

f) https://morioh.com/p/70381fe201a4?f=5c21f93bc16e2556b555ab2f&fbclid=IwAR0i4C9Mw9tfYJKWjTjoEuV8ngIN_lV3oxUevCFlyYXh3IT36NYQzXTjy1I
The idea is great, but the tutorial explanations are a bit superficial.

What would be your additions to the asp.net core tutorial world?
Using CSS Module in Latest React 16.12.0
Tags: css, react, javascript, webdev
Published: 2020-02-10 13:49:39

[It's my **first post**, so please ignore any grammatical mistake] 

In the newer version of reactJS [as per given date 10-FEB-2020 it's 16.12.0], the older way of using **npm run eject will not work**.

So, _to make it work_ what we can do is ---

**Step 1** _Making CSS file_
While making a CSS file, name it in following convention.
e.g name i want is "index", so instead of naming it "index.css", name it to "**index.module.css**"
And write css code as usual you are writing earlier.


**Step 2** _Importing CSS file_
While importing the "index.module.css" file in another file, eg in App.js, use following command;


**import style from './index.module.css';**

_style_ name is upto you, this is used for refering the classes and id inside of css file

**for using CSS codes use** className={style.Col}
_Col_ is the css code inside _index.module.css_