teleren/devto huggingface dataset:
Prevent updating query updates all records in GORM
Tags: go, gorm
Published: 2020-08-03 11:57:26

Finally, I found that prevent updating all records when I forget with a primary ID in [GORM](http://gorm.io/).

Sometimes, we forget primary ID for updating a record in a query. This query will occur the problem that all records in the table will be updated because the query does not specify a primary ID.

A query below will update one record with a company ID.

```go
var db *gorm.DB
db, err = gorm.Open("mysql")

company := &Company{
   Model: gorm.Model{ID: companyID},
   Name:  request.Name,
}

_, err := db.Model(&company).Update(company)
if err != nil {
   ...
}
```

This query works well wholly.

In contrast, the blow query without a primary ID will update all records.

```go
var db *gorm.DB
db, err = gorm.Open("mysql")

company := &Company{
   Name:  request.Name,
}

_, err := db.Model(&company).Update(company)
if err != nil {
   ...
}
```

If this code is deployed to production service with no test, I don't want to imagine that it will do to our database.

So we can prevent this behavior with [func (*DB) BlockGlobalUpdate](https://godoc.org/github.com/jinzhu/gorm#DB.BlockGlobalUpdate).

```go
var db *gorm.DB
db, err = gorm.Open("mysql")

db.BlockGlobalUpdate(true)
...
```

Again, the same query with not primary ID.

```go
company := &Company{
   Name:  request.Name,
}

_, err := db.Model(&company).Update(company)
```

If we forget primary ID like that, we will get an error from GORM like below.

```
2020-08-03T07:45:14.011Z  ERROR  logger/logger.go:58  missing WHERE clause while updating
```

`BlockGlobalUpdate()` can prevent updating all records in a table.

Wrapping up, we should use `BlockGlobalUpdate()` when we create a gorm DB instance. Otherwise, someday your query could destroy your user's data entirely.
Taming network with redux-requests, part 9 - External libraries and promises
Tags: webdev, react, redux, javascript
Published: 2020-08-03 11:36:51

In the [previous part of this series](https://dev.to/klis87/taming-network-with-redux-requests-part-8-mocking-and-multiple-drivers-2h9a) we discussed mocking and how to use multiple drivers at the same time within one app.

In this part we will cover how to integrate `redux-requests` with external libraries or if you would like to use it with promises directly.

## External API libraries

Sometimes, as a front-end developer you will just get a ready to use library which handles connection with server. Then, you won't be able to use `axios` or `fetch API` driver, you need something else. If the library you received is promised based, which is usually the case, then you could use `promise` driver.

## Using `promise` driver

To install it, just run:
```bash
npm install @redux-requests/promise
```

Then, as for any driver, you must pass it to `handleRequests`:
```js
import { createDriver } from '@redux-requests/promise';

handleRequests({
  driver: createDriver({
    AbortController: window.AbortController,
    processResponse: response =>  ({ data: response }),
  }),
});
```

`AbortController` is optional, by default it will use `AbortController` if available, with fallback to `DummyAbortController` which does nothing. If your environment doesn't support `AbortController`, you could pass a [polyfill](https://github.com/mo/abortcontroller-polyfill).
If you don't, requests aborts won't work (but the app will still work, you will just lose the possibility to use automatic aborts feature).

`processResponse` is also optional, the default is `response =>  ({ data: response })`, it is useful if your promises resolve to more things than `data`, then you could for instance use `response =>  ({ data: response.data })`, or even `response =>  ({ data: response.data, headers: response.headers })`

Once you have done that, you can use promises in request actions:
```js
const fetchPhoto = id => ({
  type: FETCH_PHOTO,
  request: {
    promise: axios.get(`/photos/${id}`),
  },
});
```

Also note, that just like for `mock` driver, for mutations you need to pass `meta.asMutation: true` in your request actions, so the core library could know whether a request is a query or a mutation. For many drivers like `axios`, `fetch` and `graphql` it is not usually necessary as the library can deduct whether something is a query or a mutation by looking at request config, like `GET` request method will be typically a query while `POST` a mutation.

## What's next?

In the [next part](https://dev.to/klis87/taming-network-with-redux-requests-part-10-server-side-rendering-and-the-future-53g8) we will discuss **server side rendering**, **SSR** in short and how `redux-requests` can help you writing truly universal code between client and server.
7 steps to design a website covered in a web designing course


Tags: webdesigningcourse
Published: 2020-08-03 11:21:37


 


What are the steps to design a website covered in a web designing course?
A web designing course outlines the 7 steps to design a website. They are:
1.	Goal identification
A web designing course would tell one that this is the first step . It is where the designer works collectively with the client to form new goals for the website. It would mostly cater to what is the purpose of the website. So, a web designing course trains a designer for this huge step.
2.	Outlining of scope for the project
       The second step for focus of a designer would be to outline the scope of the project. A web designing course would give some parameters for the scope. They include what would be the different web pages and features required by the website to accomplish a specific goal. In addition to that, they would include a particular timeline for building a website. Learn more about these in a web designing course.
3.	Sitemap and wireframe creation
        A web designing course would then tell one how to go ahead with sitemap and wireframe creation.  Designers would then have to start creating the sitemap .After that, they start outlining how the content and features will correlate with each other. These were the same features that were defined in the scope definition  by a web designing course.
To know more visit - https://www.technobridge.in/

4.	Creation of content 
        A web designing course would then move on to creation of content once they have created a picture of the website. Once they have done this, they can start the process of content creation for individual pages.  At the same time, they have to apply search engine optimization to keep webpages concentrated on a specific topic. Also, one needs to have content for the next stage. One can get SEO tips in a web designing course.
5.	Visual elements
     Once the web designing course would teach one the creation of sitemap and content, they start working on the visual brand. It may be already structured from the client’s perspective but the designer may outline the visual style from the beginning. Learn design tips from a web designing course.
6.	Testing 
     The sixth step taught by a web designing course would be to test whether the site is in working condition 
7.	Launching the website

The students from a web designing course are successful when their elements are working perfectly and then can execute their launch.
Convert Mac OLM to PST file format
Tags: olmtopst, convertolmtopst, olmtopstconverter
Published: 2020-08-03 11:17:21


You can Convert Mac OLM to PST file format, if you will use this amazing third party solution Regaintechnologies OLM to PST Converter tool. This tool easily Convert your Mac OLM emails to PST file format with all mailbox items like: notes, contacts, draft, calendars, tasks, attachments etc. This software comes with so many advanced and unique features for users to easily migrate OLM files to PST file format. You can easily use this software without any technical expertise.

Download this software free demo version from here: https://www.regaintechnologies.com/olm-to-pst-converter.html
OLM to PST Converter-Export Mac OLM to Windows Outlook PST
Tags: olmtopst, convertolmtopst, olmtopstconverter
Published: 2020-08-03 11:16:24

Try this Regaintechnologies OLM to PST Converter tool and Export Mac OLM to Windows Outlook PST file format. This Software easily Convert your Password protected OLM file to PST file format without any error. This software provides so many advanced features and benefits, such as a selective process, folder structure maintenance, retains e-mail data storage, data filter, Preview option, free trial version etc. try free trial version and check the compatibility of this tool.

Try this software free trial version from here: https://www.regaintechnologies.com/olm-to-pst-converter.html
VALORANT PARA PC EN ESPAÑOL
Tags: valorant, todovalorant, juegavalorant
Published: 2020-08-03 11:16:20

Valorant es un juego de disparos en primera persona (FPS) multijugador 5v5 donde un equipo ataca y el otro defiende. El modo de juego principal es muy similar a CS: GO. El objetivo del equipo atacante es colocar una bomba (llamada SPIKE) y hacerla detonar, mientras que el equipo defensor trata de evitarlo.


 
Independientemente de si la espiga está plantada o no, si un escuadrón es eliminado antes de que se cumpla cualquier otra condición de victoria, el escuadrón contrario ganará.

Los partidos duran 25 rondas, y cada ronda dura 100 segundos. El primer equipo en ganar 13 rondas gana el partido en general. Al comienzo de la ronda, tendrás 30 segundos para comprar armas y equipo para esa ronda. Si mueres en una ronda, tendrás que esperar hasta la próxima ronda para reaparecer.


 
Suena como el modo de juego Defuse de CS: GO, pero Riot tiene un giro en la fórmula. Además de comprar armas, también elegirás un Agente al comienzo de cada ronda. Cada agente tiene una habilidad, que va desde curar aliados hasta hacer que las paredes aparezcan de la nada. Teniendo en cuenta que Valorant adopta un enfoque basado en MOBA para los agentes, es probable que necesites una buena variedad de habilidades si quieres ganar una partida. Sin embargo, ten en cuenta que deberás comprar algunas habilidades al comienzo de una ronda.

¿Cuánto cuesta y Como Descargar VALORANT en Español para PC?
Valorant es totalmente gratuito y esta disponivle en la pagina oficial de Valorant. Solo tienes que descargartelo y seguir sus instrucciones.
Using the HTML `picture` element to show a WebP image
Tags: html, webdev
Published: 2020-08-03 11:09:38

The WebP image format has been around since 2010 when the standard was first announced. One benefit of using WebP images is that they are smaller than both JPEGs and PNGs, sometimes significantly.

WebP is supported in *almost* all modern browsers, as can be seen [here](https://caniuse.com/#feat=webp). However, it currently is not supported in Safari and IE11. So we can't use a standard `<img>` element, as the image will not display in these browsers.

Luckily there is a solution with the HTML `<picture>` element. This is a very powerful and flexible element that lets you define multiple sources for an image.

First, convert your image to WebP. There are several easy online converters that can do this. Next, use a `<picture>` element:

```html
<picture>
  <source type="image/webp" srcSet="/my-image.webp" />
  <img src="/my-image.jpg" />
</picture>
``` 

The last child of a `<picture>` element is a fallback `<img>` element. This will be used if the browser does not support WebP. This also allows the image to be shown on browsers that do not support the `<picture>` element.

Speaking of browser support, it's pretty decent. All modern browsers (Edge, Firefox, Chrome, and Safari) support `<picture>`. It's not supported in IE11, but the fallback `<img>` element will be used instead.
OrgChart maker - what do you think?
Tags: webdev, vue
Published: 2020-08-03 11:02:27

Hi all, 
I created an easy to use and install organizational chart maker and publisher.

Do you have any good tips to improve further?
- the landing page
- the application itself, or the source code

I am curious what you think,

[https://freeorgchart.netlify.app/](https://freeorgchart.netlify.app/)
Regards,
Michael
What  are some examples of less obvious web development features/technologies worth learning?
Tags: webdev, help, career, beginners
Published: 2020-08-03 10:44:20

I've been working as a bona fide junior developer for almost 6 months now and I've got a reasonably good handle on the foundations of web dev stuff and know the big obvious things to learn.

But what are some useful but maybe lesser-known technologies worth looking into? One example I saw would be WebSockets which I only really noticed after seeing them in an interview task example. Another would be looking deeper into ES Modules and trying to understand how they actually work.

Love to hear what you think and recommend!
5$ SALE
Tags: udemy, webdev, webpack, tutorial
Published: 2020-08-03 10:42:32

Hi folks, Join me on this course. Limited Time HUGE Discount!!!
# **Web Development - Interview Cracking Crash Course: 2020**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bsxb5frtarxlqbclf982.jpg)
## Use the link to avail Special Discount
https://www.udemy.com/course/web-dev-interview-prep/?referralCode=4912CA88E55CEA9D56B6

**Support me, guys**, ``I'm giving valuable content at a very minimal cost!!``
Quick Redux Optimization Tips
Tags: react, redux, javascript, reactnative
Published: 2020-08-03 10:35:33

There are some places you might need to dispatch many actions

Example:
```javascript
const doSomeAction = () => {
  dispatch(updateStatus(True));
  dispatch(setAction());
  dispatch(DoSomethingelse());
};
```


The downside to doing this is your redux store is going to be updated multiple times and causing (some) components to re-render multiple times.
<br/>
A more optimized way is to use the "batch" API from redux.


Optimized Example: 
```javascript
import { batch } from 'react-redux';

const doSomeAction = () => {
 batch(() => {
   dispatch(updateStatus(True));
   dispatch(setAction());
   dispatch(DoSomethingelse());
 });
};
```


Wrapping our dispatches in batch API ensures that they are dispatched outside of React and the store is updated only once, resulting in a single rerender. 

Just think of "batch" like [Promise.all](https://v8.dev/features/promise-combinators#promise.all) for promises


<br/>
For more read:
- https://lnkd.in/gPyAw8K
- https://itnext.io/redux-ruins-you-react-app-performance-you-are-doing-something-wrong-82e28ec96cf5

image credit: [itnext](https://itnext.io/redux-ruins-you-react-app-performance-you-are-doing-something-wrong-82e28ec96cf5)
How to make CSS containers go under each other when on mobile?
Tags: html, css
Published: 2020-08-03 09:59:22

I'm trying to make the second container go under the first container when the page is viewed on a tablet or mobile device, but I can't get it to work. So if someone can help that would be great! Code: https://codepen.io/Sampsa96/pen/JjGVwKw
#100DaysOfCode | Day 10(Starting to make a twitter bot)
Tags: 100daysofcode, python, beginners, challenge
Published: 2020-08-03 09:50:47

Hey everyone, today is my 10th day of __#100DaysOfCode Challenge__!
Yesterday was not really satisfying for me cause I failed to solve a problem.
I know this is a part of coding journey, but as far as I know myself, I'll become a __BEAST__ when I fail to do something especially about learning a new skill!
So today I decided to start a project and I though it would be nice to do something _cool_, _funny_ and useful so after finishing I can take advantage of it!
You may ask me,
What do I want to do? 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qnlwo43ido7eic44uhjt.gif)<figcaption>_YesSSSS! I wanna make a_ __Twitter-Bot__</figcaption>

I thought it can be a great project to do and learn a lot out of it.
So cause I have a twitter account, it can be useful to automate some of the repetitive tasks.
I'm so excited to start this project and I'll share my code and work on __Gitlab__ and here with all of you to know your point of view about my codes and __BOT__! 
Thank you for reading my posts and being with me and encouraging me in this journey.


Keep Moving Forward __ツ__

Code with __💛__

__🅑🅐🅝🅙🅘__
Free admin dashboard template https://adminlte.io in Asp.net MVC
Tags: dotnet, asp, csharp, template
Published: 2020-08-03 09:50:45

Url : https://github.com/mak-thevar/AdminLTEAspNetMVC
An admin template based on the adminlte implemented in ASP.net mvc 
with the following features:

## Features
- Uses [Owin](https://docs.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/owin-startup-class-detection) based startup class.
- Web API is configured and uses [Token based authentication](https://www.c-sharpcorner.com/UploadFile/ff2f08/token-based-authentication-using-Asp-Net-web-api-owin-and-i/).
- Can be easily customized to use [external authentication](https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/external-authentication-services) services like Google, Facebook, etc.
- [Autofac](https://autofaccn.readthedocs.io/en/latest/getting-started/)  is configured as a dependency injection.
-  [Entity framework 6](https://docs.microsoft.com/en-us/ef/ef6/) with basic User entity and the authentication service is configured.
- Follows [Repository pattern](https://deviq.com/repository-pattern/) for the database operations.
- Custom HTML helpers has been added to support this specific template. Will be adding more HTML helpers in the future releases.


## Screenshots
![AadminLTE](https://i.imgur.com/mHSXd4P.png)

![AadminLTEASP.NET](https://i.imgur.com/50ZTcKk.gif)

![LoginAPI Postman](https://i.imgur.com/uREBifI.png)
JS:Snippets — Copy text to the clipboard using javascript in 5 minutes.
Tags: javascript, html, webdev
Published: 2020-08-03 09:44:59

In this article, we are going to build the functionality of copying the text to the clipboard using javascript in 5 minutes.

## HTML STRUCTURE
```html
<div>
  <input type="text" id="text" placeholder="Enter text"/>
  <button onClick="copyTextToClipBoard()">Copy To ClipBoard</button>
</div>
```

##JS Function
```javascript
function copyTextToClipBoard(){
  //Input Element with id "text"
  let textToBeCopied = document.getElementById('text');
  //Select the content in the input element
  textToBeCopied.select();
  textToBeCopied.setSelectionRange(0, 99999);
  //copy the text inside the input element to clipboard
  document.execCommand('copy');
  alert('Text copied to Clipboard');
}
```
###Buit-in Functions used
> select
> setSelectionRange
> execCommand

## Full code 
{% gist https://gist.github.com/saravanakumarputta/6981fbdb22b603c69e5abd316b399821.js %}

## Codepen

{% codepen https://codepen.io/saravanakumar2701/pen/zYrXegK %}


This article is made with :heart:. Please let me know what content you want me to write. Always for you.
Inheritance in python
Tags: python, machinelearning, datascience
Published: 2020-08-03 09:38:06

Object-oriented programming creates reusable patterns of code to prevent code redundancy in projects. One way that recyclable code is created is through inheritance, when one subclass leverages code from another base class.

Inheritance is when a class uses code written within another class.

Classes called child classes or <a href="https://www.pythonslearning.com/2020/08/event-handling-in-python-tutorials-point.html">subclasses</a> inherit methods and variables from parent classes or base classes.

Because the Child subclass is inheriting from the Parent base class, the Child class can reuse the code of Parent, allowing the programmer to use fewer lines of code and decrease redundancy.

Derived classes are declared much like their parent class; however, a list of base classes to inherit from is given after the class name −

class SubClassName (ParentClass1[, ParentClass2, …]):
'Optional class documentation string'
class_suite
References: https://www.pythonslearning.com/2020/08/inheritance-in-python-tutorials-point_3.html
Best of luck!!!
Habit tracker API: Get & Post
Tags: 100daysofcode, javascript, mongodb
Published: 2020-07-27 20:28:35

The journey continues

Moving on with the [habit tracker API](https://dev.to/mtee/habit-tracker-api-project-setup-ji9), I modified the Get function to find and retrieve all habits else return an error.
```javascript
router.route('/habits')
  .get((req, res) => {
    Habit.find((err, habits) => {
      if (err) {
        return res.send(err);
      } else {
        return res.json(habits);
      }
    });  
  });
```
Since the database has no data sending a get request to postman returns an empty object.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v205pjc9i98gngg4mfz0.png)


I'll set up a [post function](https://dev.to/mtee/http-post-verb-5b57) to add and save data to my database. 
```javascript
 .post((req, res) => {
    const habit = new Habit(req.body);

    habit.save((err) => {
      if (err) {
        return res.sendStatus(404);
      }
      return res.json(habit);
    })
  })
```
Adding data from postman sends back the data with an with an Id.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0u7t1gdilfnqhghkv730.png)

I'll eventually need to update the habits which creates the need for put, patch and delete function. I'd have to first retrieve data by Id in each of the functions, which would result in duplicate code. To avoid this i'll create middleware to find data by id and pass that data to my route handler.
```javascript
router.use('/habits/:habitId', (req, res, next) =>  {
  Habit.findById(req.params.habitId, (err, habit) => {
    if (err) {
      return res.send(err);
    }
    if(habit) {
      req.habit = habit;
      return next();
    }
    return res.sendStatus(404);
  })
});

router.route('/habits/:habitId')
  .get((res, req) => { 
    res.json(req.habit);
  });
```

I'll test this in postman.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hunqvzggf95iuh3pp50o.png)
And Boom, an error!

After hours of googling i still couldn't fix it so i'll call it a day and try again tomorrow. 

_Day 11_
Learn how to access AR via our Unity SDK
Published: 2020-08-03 09:20:49

We are delighted to be announcing the release of Zappar’s Universal AR for Unity SDK and invite you to join our CTO and co-founder, Connell Gauld and Platform Developer, Jordan Campbell for a live demo. Where they will be taking you through our core computer vision support and demonstrating the easy integration.

https://zap.works/webinars/universal-ar-unity/?utm_source=link&utm_medium=pr&utm_campaign=unity_sdk_webinar