teleren/devto huggingface dataset:
DataGrip: Exporting Data as SQL Batch Inserts (and more)
Tags: database, datagrip, sql, script
Published: 2020-08-13 04:19:52

[gist]: https://gist.github.com/ProjectCleverWeb/d2362b082af1d7054ebfd464f202ec1b#file-sql-batch-multi-line-insert-sql-groovy

## Preamble

This isn't so much a "great new feature" as it is a missing feature from DataGrip. While I could go on with my love/hate relationship with DG's features, (it's **mostly** love) it is fortunately easy enough to manually add some functionality.

I will also take a moment to say this is my first post and would love any feedback on improving it.

*On to the main attraction...* (or just [skip to the script][gist])

## Why Batches?

In short, better performance and limited table/row locks when inserting thousands, millions, or even billions of rows.

#### Batches vs Individual Inserts
Batches perform **orders of magnitude faster** than individual inserts. In SQL, each query is parsed and executed separately; which causes significant overhead between each query. This makes the individual inserts very slow, while batches avoid almost all of this overhead.

#### Batches vs 1 Large Insert
One large insert is **technically** faster than batched inserts; however, this often comes at the cost of locking tables/rows for extended periods of time. Table & row locks block all other queries that modify data (causing a desync) and even some queries that read data (causing request lag). This is particularly harmful in production environments, especially when you need to comply with an SLA.

Inserting in batches gives you a significant performance boost, while still preventing tables or rows from getting locked for too long. Allowing normal queries to run at the same time as the set of batched queries. Additionally, in most cases, the difference in performance is very minor between batched inserts and 1 large insert.

## Installation

1. Go to the "Data Extractors" dropdown. (in results bar)
2. Select "Go to Scripts Directory"
3. Create a new file called "SQL Batch Multi-Line Insert.sql.groovy" (The double extension is important for syntax highlighting)
4. Paste & save the [this][gist] script

That's it! You now have access to exporting rows as batches.

You can also customize the output using the configuration vars at the top of the file, but the defaults should work well for most people.

## Key Features

- Custom batch sizes
- Ability to minify
- Custom formatting options
- Config Preview
- Well formatted & commented code

### *Cheers!* 🍻
Getting Started with Hasura GraphQL & YugabyteDB on GKE
Tags: yugabyte, graphql, kubernetes, postgres
Published: 2020-08-13 03:39:22

In this short video we show you how to install a 3 node YugabyteDB on Google Kubernetes Engine, build the northwind sample database, deploy Hasura, connect it to the sample database and build a simple test query to fetch data.

#What's YugabyteDB? 

[YugabyteDB](https://github.com/yugabyte/yugabyte-db) is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. YugabyteDB is PostgreSQL wire compatible, cloud native, offers deep integration with GraphQL projects, plus supports advanced RDBMS features like stored procedures, triggers and UDFs.
Building a RESTful API Backend with Authentication using Elixir Phoenix
Tags: elixir, phoenix, restful, authentication
Published: 2020-08-13 03:32:55

Two years ago, I wrote an article on how to build a RESTful backend using `Elixir` and the `Phoenix` framework. I really enjoyed that project, specially after working with `Ruby` and `Ruby on Rails` for a couple of years. 

I intent to upgrade that project and explain possible challenges during the upgrade, and also want to add more features to explore recent amazing features of Phoenix such as `LiveView`! Of course, some spec tests would be appreciated!

This is the link to that article: [Building a RESTful API Backend with Authentication using Elixir Phoenix](https://medium.com/@pamit/building-a-restful-backend-with-elixir-phoenix-84fe390975c)

And this is the Github repo of the project: [Phoenix REST backend](https://github.com/pamit/elixir-phoenix-json-api)

Happy coding!
Resolve NPM security vulnerabilities
Tags: npm, security, audit
Published: 2020-08-13 03:22:50

If you have seen your CI pipeline builds failed due to security vulnerabilities in some NPM packages, you have probably tried `npm audit fix` and boom! No sign of those `found N high severity vulnerabilities in scanned packages` messages!

In some cases, that command won’t solve your issue; sometimes the issue is caused by a transitive dependency (sub-dependency) and you can’t or don’t want to wait for a version patch for the package.

For instance, consider the following security vulnerability ([https://www.npmjs.com/advisories/1213](https://www.npmjs.com/advisories/1213)):

![NPM Audit issue](https://miro.medium.com/max/1400/1*qE60s1JqtKaA4GBZL5jWwQ.png)

It says, the `dot-prop` package has a security issue which needs to get fixed, and `serverless-apigateway-service-proxy` and `serverless` depend on it. But if you run `npm audit fix` you’ll probably see a similar message:

```
fixed 0 of N vulnerabilities in X scanned packages
  N vulnerabilities required manual review and could not be updated
```

You have some options here! One option is to ignore that specific vulnerability in your CI pipeline using another NPM package like [audit-ci](https://github.com/IBM/audit-ci) which is basically something like this:

```
npx audit-ci --allowlist 1213
```

That is a good way of skip security issues temporarily, however, **this approach is not always recommended** as your project may still be vulnerable even if it is a `dev` package.

The second option is to [force a specific unaffected version](https://github.com/rogeriochaves/npm-force-resolutions#readme) of that package. This means we need to change our `packahe.json` and add the following:

```
{
  "name": "project-x",
  ...  "scripts": {
    "preinstall": "npx npm-force-resolutions"
  },
  ...   "resolutions": {
    "dot-prop": "5.1.1"
  }
}
```

This will override the affected versions with the specified version. Again, **this is not always recommended** and should be used carefully and only if you have no other option! Normally, we need to wait for a version patch from the package maintainers to fix a vulnerability.

That’s it! Happy coding!
Storybook v6.0 released
Tags: news, storybook, react, vue
Published: 2020-08-13 03:16:42

If you're developing your app using a front-end framework like React, Vue or Angular, [Storybook](https://storybook.js.org/) is a super powerful tool that lets you view all of your app's UI components in one place. They've recently announced the release of v6.0 of their library.

{% twitter 1293550114716282881 %}

They've written an in-depth [Medium article](https://medium.com/storybookjs/storybook-6-0-1e14a2071000) explaining all the cool new features, including **Args**, which will simplify how you write your stories and reduce code duplication.
What is Perfect Code in your heart?
Tags: discuss
Published: 2020-08-13 03:08:37

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ieexr88jr2qo0dv38p7u.jpeg)

What kind of code is perfect?

How to define perfect?

What's your standard?

How do you request yourself?

Do you have some principles to share?
5 Networking Tips for the Introverted Job Seeker
Tags: career, beginners
Published: 2020-08-13 02:47:53

_Original post on the Kickstart Coding Blog: [5 Networking Tips for the Introverted Job Seeker](https://kickstartcoding.online/learn/pro-tips/networking-tips-introverted-job-seeker/)_

Whether you ask a recent coding bootcamp grad looking for your first software engineering position, or a total tech newbie trying to get any position, people will tell you the same thing: It's both _what you know_ and _who you know_. So, how do you know more people? Networking!

**I hope you'll find these tips useful at your next in-person or virtual networking event!**

1. Focus on quality, not quantity. When you take the pressure off yourself to meet as many people as possible at one event, you free yourself up for authentic connection and conversation that makes for even stronger bonds in the career space you’re in or entering.
![](https://media.giphy.com/media/3oEjHV0z8S7WM4MwnK/giphy.gif)
2. Take on a volunteer role. You can make amazing connections and friends by signing up to help at events, and what feels better than giving your time to helping a good cause? Plus, being a volunteer and having responsibilities to take care of creates structure for networking/things to do if you feel awkward or need a minute to yourself. 
![](https://media.giphy.com/media/3oxHQdGBEgFVzA0vIY/giphy.gif)
3. Pace yourself, but also remember to push yourself. If you know huge events (or video conferences!) with lots of people are not your cup of tea, don’t sign up for five of those events in a week (unless you’re going for immersion). Do sign up for them, but maybe go for one in a week, alongside a mix of smaller networking opportunities. 
 ![](https://media.giphy.com/media/jbKbdoKJOFusHTjl80/giphy.gif)
4. Be creative - networking can take place anywhere. Once you start considering networking to be simply connecting authentically about your career with others, all sorts of opportunities will arise. The real thing to look for is any opportunity to meet other people in your field.  
![](https://media.giphy.com/media/xUA7aRuBrh8DNTVcze/giphy.gif)
5. Bring a friend! Not only is it nice to have at least one person you know in a room (or video chat room!) full of strangers, but you can be each others’ accountability buddies and help advance each other’s job search. Set and talk about networking goals together, and introduce each other to people you meet. 
![](https://media.giphy.com/media/WQNjuJkYjeR1BcTHcE/giphy.gif)

_Original post on the Kickstart Coding Blog: [5 Networking Tips for the Introverted Job Seeker](https://kickstartcoding.online/learn/pro-tips/networking-tips-introverted-job-seeker/)_
GitHub Codespaces - Logs
Tags: github
Published: 2020-08-13 02:24:07

I wanted to review the Codespaces setup logs and was wondering how I would see them.  I opened a Codespace instance from a repo, then found there is a command `Codespaces:Export Logs` available (shown below).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/71xr1unz80fbm1ldg8up.png)

You specify a destination directory and a zip file of the logs is created (3 logs in my case).  Just unzip the the zip file and then you can simply `cat` the log files (shown below).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vjdlq4fmyxe3q59o1vk6.png)

As I work to customize Codespaces for teaching, being able to review the setup logs will be quite useful.
Day 73 : #100DaysofCode - Prepared for Assessment
Published: 2020-08-13 01:42:25

What did I do today? I added some of the final touches on my rails project, began to prepare for my rails assessment, and watched some Python videos. 

Here are some of the questions that I reviewed:

<u>What are the four most standard HTTP request?</u>
1. GET
2. POST
3. PUT/PATCH
4. DELETE

<u>What is the difference between authentication and authorization?</u>

"Authentication means confirming your own identity, whereas authorization means being allowed access to the system. In even more simpler terms authentication is the process of verifying oneself, while authorization is the process of verifying what you have access to." 

Pretty much, you may be able to log into the dev.to with authentication, but you should not be able to edit my post because you are not authorized. 

<u>What gem gives you password encryption and what methods does it provide?</u>

Bycrypt gives us password encryption and the two methods that it gives us is the password equals method and authenticate method

```
def password=(pw)
    self.password_digest = Digest::SHA2.hexdigest(pw) #makes the password equal to the hashed pw
end
```

The above hashes the password and sets it equal to pw/password_digest

```
def authenticate(pw) #takes in plain text pw
 Digest::SHA2.hexdigest(pw) == self.password_digest
end
```

Makes sure that user password is correct. Either returns self or false


<u>What does belongs_to and has_many give us?</u>

Belongs_to is a macro that provides the user and user= method. -- user will return a user object.  The method helps you with dealing with objects instead of ids. 

User method

```
def user
    User.find_by(id: self.user_id)
end
```

User= Method

```
User= Method
def user=(obj)
   self.user_id = obj.id
end
```

A has_many association indicates a one-to-many connection with another model. You'll often find this association on the "other side" of a belongs_to association

has_many

```
u.todos #=> returns an array of todo objects
```

<u>How do you make a nested route in rails?</u>

In your config/routes.rb, you would add a nested route with doing something similar to the following: 

```
  resources :reviews do 
    resources :comments, only: [:index, :show]
  end   
```

This will allow you to visit the following urls: localhost:3000/reviews/1/comments and localhost:3000/reviews/1/comments/3

I have more to review, but these are just some that I was told to review before my assessment. 

As always, thanks for reading!

Sincerely,
Brittany
Upgrade your React game with TypeScript: More on Types
Tags: typescript, react, javascript, webdev
Published: 2020-08-13 01:23:50

Types are essentially, defining the data type of our variables.

```
interface Eli {
  name: string;
  age: number;
  likes: string[];
  coffeesDrankToday?: number[]
}
```

For declaring arrays, we state the type of data the array has to contain and then use the brackets. Another way to declare them can be this way `likes: Array<string>`.

Also, remember that you can make a variable optional within an interface writing a `?` before the data type.

But sometimes, we need something a bit more complex.

![My Chi Dulce, contemplating her choices](https://i.imgur.com/qMswRvs.png)
<figcaption>Dulce, contemplating her type choices</figcaption>

Maybe we need to load an interface as an empty object, which we can do like this `daily: <YourInterfaceHere>{}`.

Sometimes we don't know what kind of data we're dealing with when using an API or maybe we want to opt-out of type checking for a particular variable. In this case, we can use `any`. The downside of using it is that we're not taking advantage of what TypeScript has to offer us so it's highly discouraged to use.

The opposite of `any` is using `void`, which is the absence of all types at all. This is common in functions that don't return a value. 

You can even create your own types from an interface!
```
export interface LoadDayAction {
    type: string;
    payload: Day;
}

export interface ErrorLoadAction {
    type: string[];
    payload: Error;
}

export type DailyTypes = LoadDayAction | ErrorLoadAction;
```
Now you could use `LoadDayAction` or `ErrorLoadAction` to define another variable. 

You can read up further on types [here.] (https://www.typescriptlang.org/docs/handbook/basic-types.html)
_

I hope you found this helpful, stay safe and please remember to take a break.

Got something to add? Please feel free to [reach out](https://twitter.com/miss_elliev) for any question, comment, meme or dog photos swap.
Is the description on the landing page clear enough to figure out what the site does ? 🔍
Tags: discuss, webdev, showdev, help
Published: 2020-08-13 01:23:38

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zvhe39kqza9ri8gtm2tu.png)

**Website** : https://www.thedatapond.net
**Demo** : https://www.thedatapond.net/demo

Last week we launched www.thedatapond.net and published our first post on IH ([here](https://www.indiehackers.com/post/an-idea-and-a-mvp-is-it-worth-to-continue-d21bd21898)).

Feedback has been positive so far. The idea seems to be good.

Now we need to focus on the landing page. What do you think about it ?

* is the description clear enough to figure out what the site does ?
* is there better descriptions ? better keywords ?
* is SEO satisfactory ? what can we improve ?

We have difficulties :
* creating a list of keywords we could use to describe the project and could use for research
* clearly define the sectors to target / the niche

We don't know much about marketing, so any help would help us learn faster.

If you find typo or grammatical errors, please, tell us. English is not our mother tongue.

Thanks
Add me to search!
Published: 2020-08-13 00:08:34

Google recently launched this new feature on 11th August for Indian users which allows users to create a People Card on their own. This could be used as a single place to easily search for people and get a short description with tons of ways to connect to them just a search away. I see this no different than a card which comes up when you search a famous personality, but this time it is available for everyone to use and the content matter is filled by the user which solves a lot of problems if they would have gone with an automated system with not enough data for each person from google's point of view.

*Personal opinions coming up* 
This might have been a very calculated move from google's side to improve their position in the field of providing a search engine for searching people the way we used social media to contact people and what better way to allow a single point of view to get all the information about a person from a card created by that person himself linking to his other social media accounts. 
As to why this is launched in India only, some speculate this is maybe due to some sort of A/B testing Google is doing on this feature and what better place to choose than a crowed nation like India which could provide enough data for whatever testing phase this feature is going through.
*Personal opinions end*

## Steps to create your own Card
It would be better to use your phone 📱 for this process due to the below-mentioned issue faced in desktop but if you are feeling adventurous, go ahead use your desktop/laptop 💻 with mobile view. That's what I did :P
{% twitter 1293685193144807429%}

1. Login in to your google account 
2. Search "Add me to search" in google or just type in your name
You should see something like this, if not maybe leave a comment with your problem
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1wys21q7fhijx3v8ryt1.PNG)
3. Click on "Get Started" star
4. Google will ask you to verify your  **phone number**🤙 for the next steps, this is necessary to create your card. So make sure you do that and your phone number won't be displayed publically unless if you choose so. This is done mostly for **security purpose** so that impersonation problems can be dealt with as each card is tied up with a google account and a phone number.
5. Fill in all the information you wish to display, make sure to add a crisp bio and a bunch of social media profiles (gotta get 'em all 🦋)
6. Click on **Preview** to get a view of how your card will look like after being complete
7. Click **Save**✅. Yes, you can come back later to edit any piece of information.
8. Your card should be discoverable in a few hours 🕓

Congrats you have created your own people card 🎉🎉 get ready to receive tons of enquires with this much traction :P

This is how my card looks, for now, maybe search for it to see I ever update my temporary bio 😜
{% twitter 1293685195955027971%}
JS Bits - Destructuring arrays in JavaScript
Tags: webdev, javascript, beginners
Published: 2020-08-13 00:01:02

# Destructuring

Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. (https://dev.to/sarah_chima/destructuring-assignment---arrays-16f)

Rather than getting a whole data, with destructuring we can only retrieve the values we want.

## Destructuring arrays

We have a function groceries which returns us our list of items that we wish to buy next time we go to a supermarket.

The data that groceries function returns is as follows; [bread, apples, cheese]

In a traditional sense we would get a reference to each item in this way;

```
const groceriesList = groceries();
const bread = groceriesList[0];
const apples = groceriesList[1];
const cheese = groceriesList[2];
```

Destructuring allows us to achieve this in an elegant and simple way

```
const [
	bread,
    apples,
    cheese
] = groceries()
```

If you also want a reference to the groceries list all you need to do is;

```
const [
	bread,
    apples,
    cheese
] = groceriesList = groceries()
```

But, what happens if groceries returns us an array with four values?

Simply, we would only get the first three values without touching the fourth value.

What happens when we want to retrieve three values but groceries function returns two values?

Let's say the array doesn't have **cheese value** and we want to reference to this value with the **cheese variable**.

The code would not break and the cheese variable will simply be **undefined**

### Undefined values

Another case is when a value is undefined.

Imperatively if a value can be undefined and we want a default value to it when it's undefined.

We would do;

```
const name = names[0] !== undefined ? names[0] : 'unregistered'
```

Declaratively, using destructuring we do;

```
const [
name = 'unregistered'
] = names
```

### What if we want to get the first three into their own variables and the rest into one variable?

In order to achieve this we use the spread operator.

```
const [
	bread,
    apples,
    cheese
    // get the first three as normal then
    ...others // gather the rest of them and put them into variable others
] = groceries()
```

### Variable swapping with destructuring

Destructuring allows a handy trick for swapping two variables without the need for a temp variable.

```
[x,y] = [y,x]
```

### Destructuring function paramaters

You can destructure an array which is a parameter to a function

```
const arr = [1,2,3,4,5]
const firstThree = ([one = 10, two, three]) => {
	// do something
}
```

The parameter 10 has a default value of 10 if it receives undefined

### Destructuring nested arrays

We can destructure nested array using another pair of brackets inside our brackets

```
const data = [1,[2,3],4]
const [
	one,
    [two, three] = [], // fallback to an empty array if undefined
    four
    
]
```
Thank you for reading! 
If you have any questions please let me know!