teleren/devto huggingface dataset:
Defensive SQL Query Writing
Tags: sql, database, datascience
Published: 2020-06-01 15:44:59

Derived from defensive programming, defencive query writing is a practice which tries to make sure that a query run doesn't fail. Just like in application development, try to remove the scope for silly mistakes and control unforseen circumstances. Sometimes the decision comes down to whether you want your query to fail or you want it to run even if with some incorrect data. I'll share a couple of simple examples where we can employ these practices while writing queries. 

##Checking If Objects Exist

Take the very basic example of creating and dropping database objects. Rather than using a `CREATE TABLE xyz`, use `CREATE TABLE IF NOT EXISTS xyz (id int)` or if you want to recreate the table losing all the data you can run `DROP TABLE IF EXISTS xyz` and then `CREATE TABLE IF NOT EXISTS xyz (id int)`.

The same practice can be used with the creation and deletion of databases, views, indexes, triggers, procedures, functions and more. I have come to realize that in most cases, using this is helpful.

##Using database and column aliases

Prevent yourself from getting _ambiguous column_ errors. See in the example below, the column `city` might be present both in `TABLE_1` and `TABLE_2`. How do you expect the database to know which field you want it to pick up.

{% gist https://gist.github.com/kovid-r/6cf4d423d37e73fe40ee80766626a0a1 %}

It's generally a very good practice to create aliases for database objects and then access those database objects and their child objects using the alias rather than the complete name. Obviously for doing this efficiently, you'd need to follow a SQL Style Sheet.

##Using LIMIT

No, I'm not talking about using `LIMIT` to restrict the number of records in your final query. Rather, I am talking about queries like this.


{% gist https://gist.github.com/kovid-r/91f8b0756aeafdeb9bf70ee118212e79 %}

The `LIMIT` clase in the subquery returning a column is important because it prevents the query from failing if the subquery returns more than one row, that is, if there is more than one record in `TABLE_2` for every record in `TABLE_1`. This is a really useful trick to write better queries.

These are three of the most common scenarios which, if not taken care of, can prevent your query from running at all. Obviously, all of these come with an asterix. More on that later.

Please feel free to share other practices that you have followed!
Testing an API with Laravel.
Tags: laravel, api
Published: 2020-06-01 15:30:41

---
title: Testing an API with Laravel.
published: true
description: The basics to test an API with Laravel.
tags: Laravel, API 
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/qg2u9fubkv5273zi7qw0.png
---

Hi, we are going to see some helpful methods to test an API.

## Authenticate with API driver:

```php
$this->actingAs(factory(User::class)->create(), 'api');
```

## Hit an endpoint:

```php
// instead of $this->post('/api/users', []);
// do this
$this->json('post', '/api/users' ,[])
```

An advantage of using this method is that at the background Laravel validate if a request require a json response (if request is an ajax request) or it requires an http request.

If you use the "json" method you can get the "validations/form request" messages as json, so it is easy to test what you need to return to an ajax/fetch request;

## Get response

This is a very helpful method, to see the response in json format you can use:

```php
$response = $this->json('get', '/api/users');
dd($response->getContent());
```

Thats all, I love short posts, you are welcome to comment, thanks for reading.
How to pull image from private Docker Registry in Kubernetes cluster 🤔
Tags: kubernetes, docker, devops, tutorial
Published: 2020-06-01 15:23:53

## The question 🤔 ##
How do you get Docker images 🐳  in your Kubernetes cluster from private Docker registries like AWS ECR, Nexus, etc?

## Context ##
For images like Mongodb, Elastic, that are hosted on Docker Hub, it’s straightforward because they are hosted in a public repository and anyone can access them.
 
But your own application lives in a private repository and **needs explicit access from the cluster**. So how do you pull the application images from your private docker repository on Kubernetes cluster?

##How to do it 🙌🏼 ##
There are 2 steps to take to achieve it.

1) you create a **Secret component** that contains access token/credentials to your Docker registry.

*Example Secret config:*
![Secret component](https://dev-to-uploads.s3.amazonaws.com/i/jpl97bz0gj18tq5qtimq.png)  

2) you configure your **Deployment component** to use that secret using a specific **imagePullSecrets** attribute.

*Example Deployment config:*
![Deployment component](https://dev-to-uploads.s3.amazonaws.com/i/6v9mh3brp8udn7pbzzs0.png)

Note: Pods can only reference imagePullSecrets in their own namespace, so this process needs to be done one time per namespace!

In the demo video 🎬 I show you the whole process step by step:
{% youtube asIS4KIs40M %}

Hope it's helpful some of you 🙂

-----------------

### I'm excited to host my first **LIVE Webinar on Kubernetes ** 🤓 👩🏻‍💻 ###
**Date:** The webinar is on Saturday June 13, 2020
**Topic:** Deploy Elasticsearch StatefulSet and Kibana with Helm on a Cloud platform
- [Find out more and register here](https://www.digistore24.com/product/328046)
Python Zero to Hero - Ep.9 - Strings and Regex
Tags: python, beginners, tutorial, video
Published: 2020-06-01 15:15:29

---
title: Python Zero to Hero - Ep.9 - Strings and Regex
published: true
description: String operations are very useful in handling data, either input from a file or by the user. Today we have covered how to use the strings methods and the re module in Python to manipulate strings.
tags: python, beginner, tutorial, video
---
String operations are very useful in handling data, either input from a file or by the user. Today we have covered how to use the strings methods and the re module in Python to manipulate strings. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho/python-decorators/) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
Javascript Promise explained with a metaphor
Tags: javascript, beginners
Published: 2020-06-01 14:37:46

This was sparked by a sudden thought.

First, let's see how [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) defines Promise. 
> A Promise is a proxy for **a value not necessarily known** when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method **returns a promise to supply the value at some point in the future**.

![confused gif](https://media.giphy.com/media/1X7lCRp8iE0yrdZvwd/giphy.gif)

Think of it this way -- you participate in a lucky draw contest which offers a prize of $1000 voucher. You are given a ticket as a record.
```js
let ticketPromise = new Promise(() => luckyDrawProcess());
```

You really hope that you win this lucky draw so you can buy the newest noise-cancelling headset 🎧 Else... maybe you'll just get an ice-cream to cheer yourself up 🍦
```js
ticketPromise
  .then((thousandDollarVoucher) => {
     buyHeadSet(thousandDollarVoucher);
  })
  .catch(lostHope => buyIceCream());
```

Basically, a Promise is an object that _promises_ you a result in the future. You can pre-determine your actions based on the result you get and whether it is resolved or rejected. 

Promises are more than just this though, and the rest is for you to find out ;)
Building my first Django project with a Database
Tags: python, django, sqlite
Published: 2020-06-01 15:14:30

I'm working through [Django for Beginners by William S. Vincent](https://djangoforbeginners.com/). Chapter 4 starts using a database to act as a data store for a Message Board app.

This seemed very related to what my buddies do with Laravel, where migrations are run when the data Model in the backend needs to be changed. I was actually a little surprised that at no point did I need to write any SQL though. As someone who has spent their professional life asking databases for info, I was actually a tiny bit disappointed 😜. 

I'm starting to become curious about this `manage.py` file though. All I have in my workspace to represent it is:

```py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blog_project.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
```

So it's obviously getting some morecode under the hood, but I'm starting to think it has super powers. It starts projects and apps, it makes users, it runs migrations and tests as well as the local server. For something that hasn't even really been mentioned other than a line of text to type into the CLI my curiosity is definitely rising. Unfortunately `python manage.py makecoffee' is the only thing that hasn't worked so far. What are your favourite powers of `manage.py`?
Easiest way to add Vue and authentication on Laravel.
Tags: laravel, vue
Published: 2020-06-01 15:13:27

---
title: Easiest way to add Vue and authentication on Laravel.
published: true
description: Create a project with Vuejs and auth with a single command.
tags: Laravel, VueJS
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2hg6id092k8pog51qn60.png
---

Hi, there are many ways to install VueJS in a Laravel project, you can create a project and then install "laravel/ui" package, but there is a simpler way to work with Laravel + VueJS:

The composer Laravel installer has an update to add a flag when you are creating a Laravel project:

### To update the laravel installer:

```
composer global update laravel/installer
```

### Now you can use the new auth flag:

```
laravel new myapp --auth
```

That's all, thanks for reading.
Match my donation #BlackLivesMatter
Tags: blacklivesmatter
Published: 2020-06-01 15:10:57

I've been staring at my phone brokenhearted with a pit in my stomach for the past several days.

Here are some Twitter threads I recommend if you too are wanting to do _something_  or _learn more about being an ally_ but don't know where to start:

{% twitter 1266575719381024768 %}
{% twitter 1266258250489454599 %}
{% twitter 1266797966498684928 %}
{% twitter 1266053291684827138 %}
{% twitter 1266071139115241473 %}
{% twitter 1265314497151078402 %}
{% twitter 1267247647527706624 %}
{% twitter 1267252980882997249 %}


## Match my donation

I've made some local donations, and also set up a monthly donation to Campaign Zero (WeTheProtestors).

![receipt for $10 monthly donation](https://dev-to-uploads.s3.amazonaws.com/i/f8e7whil4kfg9ty2coys.jpg)

**Match me here**: [joincampaignzero.org](https://joincampaignzero.org)

Check this thread for more info from a co-founder:

{% twitter 1180655701271732224 %}

A thread of other recommendations of orgs to support:

{% twitter 1266399116797468673 %}
We made a community.... using the DEV.to source code
Tags: gamedev, opensource, news
Published: 2020-06-01 14:49:07

Hey DEV community!

I wanted to take a minute to share with you something my team and I have been working on for the past few months... [Lets Build](https://letsbuild.gg)! 

Lets Build is a community of indie game developers that share and collaborate with one another. It was inspired by our love for DEV and the culture this community brings. 

For those of you who don't know, DEV is open source!
{% twitter 1262758611157053442 %}

Our hope is to spread the many great aspects of DEV to smaller community of creators who don't really have a great space to share their art, music, tools and games.

I plan on writing about our experiences working in the DEV code-base soon, so please follow so you don't miss out on that. Until then please checkout our platform and drop a comment. There is a whole world of artists, musicians, animators and coders out there that don't yet know how great communities like these can be <3
Build a beautiful, draggable kanban board with react-beautiful-dnd
Tags: react, tutorial
Published: 2020-06-01 14:41:45

---
title: Build a beautiful, draggable kanban board with react-beautiful-dnd
published: true
description: 
tags: react,tutorial
---

In this tutorial, we are going to see how to create a beautiful kanban board with simple drag and drop features with react-beautiful-dnd.  

[Click here for the CodeSandbox.](https://www.youtube.com/redirect?q=https%3A%2F%2Fcodesandbox.io%2Fs%2Fjovial-leakey-i0ex5&event=video_description&v=uHO3mQgs-e8&redir_token=7aDLhhqn_Cdix0zZz4FKCyOafUV8MTU5MDE2MjE1MkAxNTkwMDc1NzUy)

Drag and drop UI has become an integral part of most modern applications. It provides richness in UI without comprising the UX. There are many use cases of drag and drop UI. The most common ones are:
- Using drag and drop in the browser to upload files
- Moving items between multiple lists
- Rearranging images or assets

[Click here](https://dev.to/bnevilleoneill/the-ultimate-guide-to-drag-and-drop-in-react-5955) for the related blog post on drag and drop in React.

* * *
### LogRocket on [YouTube](https://www.youtube.com/logrocket) 🎬
 
![](https://dev-to-uploads.s3.amazonaws.com/i/2eacqscox237qibs7cho.jpg)

If you enjoy in-depth video tutorials on frontend topics, [check out LogRocket's YouTube channel](https://www.youtube.com/logrocket). Make sure to give us a like if you find the video helpful and subscribe to stay updated on when we post new videos. 
* * *
Smallest popular Javascript Library
Published: 2020-06-01 14:35:51

---
title: Smallest popular Javascript Library
published: true
description: discussion, opensource, javascript
tags: 
//cover_image: https://direct_url_to_image.jpg
---
# Which is the most used smallest Javascript Open Source Library?

I am going to start with reading source codes. Can you help me in listing out the popularly used Javascript library?
TEAM HOVE STYLES 20..... MORE
Tags: hoverstyle, html, csshover, svgbutton
Published: 2020-06-01 14:26:37

https://codecanyon.net/item/teamhover/23079636



The Responsive Team-hover-layout is ready for Desktop, tablet and mobile devices. Simple to implement. Just copy the HTML and link to the CSS file. No JavaScript required! You can easily edit, change and customize them for yourself.
How to Fix QuickBooks error 1904?

Tags: quickbookspointofsale, quickbooksdesktopservices, quickbooksenterprisesolutions
Published: 2020-06-01 12:05:04


The accounting software QuickBooks suffers from the error code 1904 when the user tries to access a damaged or corrupt file on the device. The error code could also occur if the location of the file is not proper. The QuickBooks error code 1904 usually occurs during the process of installation of the application software. The user may also suffer from this issue when trying to upgrade the accounting software QuickBooks Enterprise to the latest edition. Hence it is necessary to eliminate the error code to upgrade the application software to the latest version. Users of the accounting software can download and run the QB repair utility to remove the error from the device. Using an outdated version of Windows is also responsible for different errors and issues in the accounting software. So updating the windows to the latest edition also proves to be a healthy way of eliminating the error code from the accounting software. QuickBooks point of sale is also affected by the error code 1904 and may bring financial loss to the business organization. Users of the accounting software may avail of the help of QuickBooks desktop service team for a quick solution to the error code 1904.

Cadda Rim is a creative person who has been writing blogs and articles about QuickBooks Products and Services. He writes about the latest updates regarding Quickbooks point of sale,Quickbooks desktop service and how it can improve the work experience of users. His articles have been published in many popular e-magazines, blogs, and websites.

Source:- https://quick-booksupport.com/how-to-fix-quickbooks-error-1904/
Sort Lists, with and without plugins
Tags: vim
Published: 2020-06-01 13:43:52

A common practice of software developers is to sort lists of things alphabetically. A predictable order makes navigating lists easier and adding new entries faster. When another order isn’t obvious, use alphabetic ordering.

For text editing use cases outside of software, such as data editing and note taking, alphabetical sorting can be even more valuable.

The [sort-motion plugin](https://github.com/christoomey/vim-sort-motion) can make doing this easy, where it is otherwise tedious and involved. From the README:

[sort-motion](https://github.com/christoomey/vim-sort-motion) has four different sorting modes:

* Linewise: sort a sequence of lines (require statements, gem lists, etc)
* Character: sort a comma separated list (argument lists, attribute lists, etc)
* Visual (linewise or normal): provided for continuity, similar to linewise
* Block Visual: By default behaves the same as the other visual modes. Optionally, you can provide a specific sort command which you might use to sort by a column (example: Vissort)

The mode I use the most is visual: Select a block of text and use gs to sort the selection linewise. And if you need to [reselect the same visual selection again](https://vimtricks.substack.com/p/vimtrick-reselect-last-visual-selection), there’s a trick for that!

[Over on VimTricks, I have a screencast and more examples.](https://vimtricks.substack.com/p/vimtrick-sort-lists)
Regex Cheat Sheet
Tags: regex
Published: 2020-06-01 13:30:43

---
title: Regex Cheat Sheet
published: true
description: Regex cheatsheet reference
tags: regex
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/xnmfh7cc5amdzhjvbd2t.png
---

Found this really useful regex cheatsheet.
Checkout their full cheatsheet at [Rexegg Cheatsheet](http://www.rexegg.com/regex-quickstart.html#chars)

<table "="" border="0" style="table-layout:fixed;"><tbody><tr><th class="w100" scope="col">Character</th><th class="w200" scope="col">Legend</th><th class="w150" scope="col">Example</th><th class="w150" scope="col">Sample Match</th></tr><tr class="brown"><td><span class="mono">\t</span></td><td>Tab</td><td>T\t\w{2}</td><td>T&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ab</td></tr><tr class="beige"><td><span class="mono">\r</span></td><td>Carriage return character</td><td>see below</td><td></td></tr><tr class="brown"><td><span class="mono">\n</span></td><td>Line feed character</td><td>see below</td><td></td></tr><tr class="beige"><td><span class="mono">\r\n</span></td><td>Line separator on Windows</td><td>AB\r\nCD</td><td>AB<br>CD</td></tr><tr class="brown"><td><span class="mono">\N</span></td><td>Perl, PCRE (C, PHP, R…): one character that is not a line break</td><td>\N+</td><td>ABC</td></tr><tr class="beige"><td><span class="mono">\h</span></td><td>Perl, PCRE (C, PHP, R…), Java: one horizontal whitespace character: tab or Unicode space separator</td><td></td><td></td></tr><tr class="brown"><td><span class="mono">\H</span></td><td>One character that is not a horizontal whitespace</td><td></td><td></td></tr><tr class="beige"><td><span class="mono">\v</span></td><td>.NET, JavaScript, Python, Ruby: vertical tab</td><td></td><td></td></tr><tr class="brown"><td><span class="mono">\v</span></td><td>Perl, PCRE (C, PHP, R…), Java: one vertical whitespace character: line feed, carriage return, vertical tab, form feed, paragraph or line separator</td><td></td><td></td></tr><tr class="beige"><td><span class="mono">\V</span></td><td>Perl, PCRE (C, PHP, R…), Java: any character that is not a vertical whitespace</td><td></td><td></td></tr><tr class="brown"><td><span class="mono">\R</span></td><td>Perl, PCRE (C, PHP, R…), Java: one line break (carriage return + line feed pair, and all the characters matched by \v)</td><td></td><td></td></tr></tbody></table>
How to Create Instagram Caption Spacing

Tags: webdev, showdev, writing
Published: 2020-06-01 13:18:03

Without adding proper [Instagram](https://blog.elink.io/promote-your-store-on-instagram/) caption spacing, the visual appearance of your posts or feeds will lose the potential to attract and inspire your audience.

Well, adding Instagram caption spacing isn’t rocket science. Still, many people have trouble getting it right. In fact, it’s actually super easy and will take you no extra time.

So, kiss your caption concerns good-bye! Because we’re here to help you on how to create Instagram caption spacing a breeze.

Let’s dig in!

Note: There is a limit on the number of characters for each text on Instagram, for captions, it is 2,200 and every line-space will be counted as a character.

##Write Your Instagram Caption Out on a Note-taking App First
So, how can you add spaces in your Instagram captions for a post?

*Here is a trick* Instead of directly writing your caption on Instagram,try writing it on one of your phone’s Note-taking app (or a similar app – email drafts can be a good option as well!) first.

You can then copy and paste your caption draft into the app while publishing a new post.

##Make Line Breaks using Symbols
The simplest way to add spaces in your Instagram captions is by using symbols.

You can use special characters like a dash (-), star (*) as well as various emojis wherever you require a line break and these special characters will work as a space between caption sentences.

The only issue with this option for adding [Instagram caption spacing](https://blog.elink.io/how-to-create-instagram-caption-spacing/) is that these symbols or characters will be visible to everyone, which might make the caption a little messy for some people.

##Try Hiding Your Hashtags With Period (.)
Even though hashtags are used for placing your Instagram posts on relevant search streams where different users including your followers can view it, they tend to make captions look really messy. 

One common hack is to push your hashtags under the visible area of the caption by including full-stops. i.e “spaces” between the end of your caption and hashtags.

It will hide your hashtags under the “See More” section so that users will have to click on it in order to see the full caption including hashtags. This is a good way to increase user engagement on your post as well!

##Will these practices work for Instagram bios and comments as well?
Yep, these hacks will also work for all [Instagram bios](https://blog.elink.io/instagram-bio-hack-add-multiple-links/) and comments.

But, you still need to keep in mind about the character limits that Instagram has on every single one of these text entries you feed in.

Pro tip- To make your Instagram bio more engaging, you can now add a single link consisting of multiple links like products, affiliate, brand collaboration pages, websites, other social media profiles, videos, and more using elink.