teleren/devto huggingface dataset:
Setup aliases and shortcuts for git commands
Tags: git, bash, developer
Published: 2019-12-11 17:06:55

---
title: Setup aliases and shortcuts for git commands
published: true
description: How to setup aliases and shortcuts for git commands.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9qcrev4jhahd7tnafc1l.png
tags: git, bash, developer
---

Here is how you setup aliases and shortcuts for git commands. Edit `.gitconfig` file in your `$HOME` directory.

```yml
[alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  type = cat-file -t
  dump = cat-file -p
```

Refer to the branch you've checked out when you use `git push` and/or `git pull`

```yml
[push]
  default = current
```

Here are some more goodies in your aliases list. Thank me later :sunglasses:


```yaml
[alias]
  # Adds and commits files with a single command
  add-commit = !git add -A && git commit

  # Delete all local branches but master and the current one, only if they are fully merged with master.
  br-delete-useless = "!f(){\git branch | grep -v "master" | grep -v ^* | xargs git branch -d;\}; f"

  # Delete all local branches but master and the current one.
  br-delete-useless-force = "!f(){\git branch | grep -v "master" | grep -v ^* | xargs git branch -D;\}; f"
```

This blog was originally published on my personal blog [Viral Patel](https://viralpatel.blog)
Why use functional style in Java?
Tags: java, lang, beginners
Published: 2019-12-11 16:44:49

---
title: Why use functional style in Java?
published: true
description: Pragmatic Functional Java
tags: #java #lang #beginners
---

While [previous post](https://dev.to/siy/playing-with-monad-or-how-to-enjoy-functional-style-in-java-ijb) shows how to transform traditional code into functional one, it does not provide answer why it is necessary.

There are several reasons and all of them are important and relevant. I believe that the main reason is the code reliability. 

Any approach/tool/methodology/etc. which improves code reliability enables us to create more and more complex systems. This why we adopt every single technology which improves code reliability - testing/static code analyzers/etc. 

By using functional style, as shown in previous post, we involve compiler to help cover both, successful and unsuccessful (or null/non-null), outcome of every single intermediate call. As a consequence, compiler helps us to eliminate whole classes of errors, including, for example, NPE. Yes, it still possible to shoot himself in the foot. But this intent must be clearly expressed in code with this approach.
How to push to a Git repo from a different account without config:
Published: 2019-12-11 16:43:20

I keep having to find the answer to this question way too often, but way too not often enough to remember it...

So i'm just posting it here to remember it....

But if you need it too here it is :

<pre>
$ git push https://Username:Password@github.com/Username/RepoName.git
</pre>
MapKit — Map Pin and Annotation
Tags: ios, swift, mapkit
Published: 2019-12-11 16:42:05

If you want to place Pin and annotation in Mapkit then you can read this article I try my best to describe it in detail what I have learned while implementing I hope it helps you also.

{% medium https://medium.com/@muneeb.ali/mapkit-map-pin-and-annotation-5c7d56439c66 %}
Correctness vs. Behavior
Tags: tdd, testing
Published: 2019-12-11 16:38:20

I recently read [this excellent blog post](https://blog.cleancoder.com/uncle-bob/2019/06/08/TestsAndTypes.html) by Bob Martin about an interesting
debate he had on Twitter with Mark Seeman. The debate centered around
testing in static vs. dynamically typed languages. Uncle Bob made the assertion
that using a statically typed language does not reduce the number of tests
one needs to write because one must still execute the tests to prove that
the system has the correct **behavior**. Mark Seeman made the point via one of
his past blog posts that languages like Haskell that don't have nulls eliminate a
whole class of tests one would need to write in a dynamically typed language or one that allows nulls.

In his article, Martin runs through the same problem that Seeman solves in his blog using
Clojure, a LISP-style dynamic functional language.

Near the end of the article, Uncle Bob makes the following statement:

> This is the crux of the argument between Mark and I. I claim that the number
> of tests required are only those tests that are necessary to describe the correct
> behavior of the system. If the behavior of each element of the system is correct,
> then no element of the system will pass invalid arguments to any other.
> Invalid states will be unrepresented.

I was so happy when I read this because it made an idea clear in my head that
I've been feeling for years, but didn't have the words to express. I now call it
**Correctness vs. Behavior**. I've felt that some developers approach tests in a
similar fashion as Mark Seeman, and feel they need to prove the "correctness" of
their systems by testing that it correctly handles every possible input.
This is why they often prefer statically typed languages. To varying degrees,
these languages are able to guarantee some kind of safety and eliminate
the need for some kinds of tests.

I agree more with Bob Martin's line of thinking. If the whole system is well tested,
why should I feel the need to write tests for states that are never going to happen?
I prefer to focus on the **behavior** of the area of code I'm testing.
In this way, the difference between statically and dynamically typed languages doesn't matter much
at all to me.

I wonder if this different way of thinking is something that turns developers off from TDD.
I wonder if developers that feel they need to cover every invalid argument or state in
their system don't see the benefits of driving the correct behavior of a system with tests.
This mentality could be why many developers prefer to write their production code first and
then use tests to prove **correctness**.

This article is not meant to spark debate about which way of thinking is better or more effective.
I have simply found joy in being able to finally express this dichotomy and expand on it here.
[Devmates.co] Add One by 🚕Bolt
Tags: challenge
Published: 2019-12-11 16:13:19

Hello👋, 
*My name is [Alex](https://twitter.com/alexwawl) and I'm maker of [Devmates.co](https://devmates.co).* 😊

*We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet.* 🍻☕️💬

*I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too 👷‍♂️hard, everything depends on skills but we are trying to resolve all of them and Have Fun.*  🙌 

Today I want to share problem which was asked by 🚕Bolt.

#####Problem:
Given a non-empty array of digits representing a non-negative integer and each element in the array contain a single digit.

Add **one (1)** to this integer and return it as array.

You may assume the integer does not contain any leading zero, except the number 0 itself.

**Note**: Converting to the integer and back to the array is not allowed.

#####Example:
  __Input__: [3,2,1]
  __Output__: [3,2,2]

  __Input__: [9,9,9]
  __Output__: [1,0,0,0]

  __Input__: [5,6,9]
  __Output__: [5,7,0]

🙌 Don't hesitate to share your solutions directly on [devmates.co](https://devmates.co)
Just recieved my hacktoberfest goodies!
Tags: hacktoberfest, showdev
Published: 2019-12-11 16:11:45

It is so awesome! So nice to open them up, a lot of stickers, and awesome T-shirt! Thanks to digitalocean and dev for organizing all this this year! Would love to participate next year too!
![](https://i.imgur.com/S5fY7qe.jpg)
dbForge DevOps Automation Allows Setting Up the DevOps Processes in TeamCity
Tags: devops, database, teamcity, sql
Published: 2019-12-11 16:10:53

---
title: dbForge DevOps Automation Allows Setting Up the DevOps Processes in TeamCity
published: true
description: Devart has announced the tangible improvement to the dbForge DevOps Automation tool –  the cutting-edge addition to the dbForge for SQL Server product line.
tags: devops, database, teamcity, sql
---
*Devart has announced the tangible improvement to the dbForge DevOps Automation tool –  the cutting-edge addition to the dbForge for SQL Server product line.*

![https://blog.devart.com/wp-content/uploads/2019/12/TeamCity-1024x793-2.png](https://blog.devart.com/wp-content/uploads/2019/12/TeamCity-1024x793-2.png)

Devart, a recognized vendor of professional database management software for developers and DBAs, has announced the enhancement of its cutting-edge solution – [dbForge DevOps Automation for SQL Server](https://www.devart.com/dbforge/sql/database-devops/). 

The team of developers extended the range of supported automation systems with TeamCity. Thus, now dbForge DevOps Automation for SQL Server allows setting up the DevOps processes in TeamCity with the help of the just-released dbForge DevOps Automation TeamCity Plugin.

The vendor also plans to extend the range of supported continuous integration systems by adding plugins for Azure DevOps and Bamboo in the nearest future.

dbForge DevOps Automation for SQL Server. Powered by the tools from dbForge Developer Bundle and embracing cutting-edge DevOps practices, the solution brings a new approach to conventional database development. The tool drastically reduces overall database release costs, minimizes deployment risks, energizes quality & update frequency, makes the workflow consistent and safe. 

Learn more about the recent release by visiting Devart’s blog article https://blog.devart.com/dbforge-devops-automation-teamcity.html

**About Devart**

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.
For additional information about Devart, visit https://www.devart.com/
Is Your Engineering Focus on Product or Craft?
Tags: strategy
Published: 2019-12-11 16:03:38

---
title: Is Your Engineering Focus on Product or Craft?
published: true
date: 2019-12-11 16:03:38 UTC
tags: strategy
canonical_url: https://glennstovall.com/code-is-a-liability/
---

The most valuable conversations I have with product leaders are the ones where I fire myself. Sometimes the best solution is not writing more code.

Writing code comes with tradeoffs worth considering before starting a new initiative. All code, even perfect code, requires maintenance. Maintenance includes more than repairs when needed. It also includes hosting the code and reacting to change in others.

Once the code is written, it has to live and run somewhere. Typically, the source will live on a version control platform like Github, and either run on local desktops, on a dedicated server, or a cloud service such as AWS.

If the code interacts with any other piece of software, which almost all software does, you have an increased surface area of risk. Let’s say you integrate your internal software with your email service. What if that service changes their API, or their servers go down, or they go out of business? What if your company decides to switch services? In all of these cases, you’ll incur a maintenance cost.

> If debugging is the process of removing software bugs, then programming must be the process of putting them in. --Edsger W. Dijkstra

If this new code is a new feature that your clients use, then there is also an inherent customer support cost as well. This goes both with answering questions, but all the “give a mouse a cookie” effect new features can take on. If you can integrate with one email service, why not all of them?

## If Not Code Then What?

All this is not to say you should never write code. Instead, you should consider that new development is **one tactic in your arsenal** out of many. What are some others? Instead, consider using off-the-shelf services. For example, building your own marketing automation solution on top of [AWS SES](https://aws.amazon.com/ses/) vs. using an off-the-shelf solution like [ConvertKit](https://convertkit.com/). Then, you can compare the monthly or annual cost of a service with the maintenance and development cost of building it yourself.

Do you have any examples of when you were asked to build a custom solution, but found a different alternative?
Nexus package manager: How to access your NPM packages after securing Nexus
Tags: nexus, npm, docker, node
Published: 2019-12-11 15:47:53

Dear coders,

I joined Medium.com some days ago and I wrote an interesting article there. But then i found out about dev.to and from now on I will start creating content here. But since I already wrote the article there, I will just link it.

https://medium.com/@daniel.pacurici/nexus-package-manager-how-to-access-your-npm-packages-after-securing-nexus-239aa121a96c

Looking forward for your thoughts. Thank you and happy coding !
Day 21 of⚡️ #30DaysOfWebPerf ⚡️: Third-party scripts
Tags: webperf, webdev, performance, javascript
Published: 2019-12-11 15:34:32

{% twitter 1204785961202311169 %}
{% twitter 1204785962167029760 %}
{% youtube V4KolGO6ssQ %}

---

This article was originally published on [sia.codes](https://sia.codes/). Head over there if you like this post and want to read others like it, or sign up for my [newsletter](https://buttondown.email/sia.codes) to be notified of new posts!
Why use React Hooks? Explained
Tags: react, hooks, functional, javascript
Published: 2019-12-11 15:34:13

---
title: Why use React Hooks? Explained
published: true
description: In React, the only way to use state in your component was to write your component as ES6 Class. Now, with React hooks you can use state and other React features without writing a class.
tags: react, hooks, functional, javascript
---

### Start with why?

If you want to use Hooks in `React` in your application. Make sure you update your react version to `>=16.8` since it was introduced in `React v16.8`.

Before React Hooks was a feature in React the only way to use state in your component was to write your component as ES6 Class. Now, with React hooks you can use state and other React features without writing a class.

[Click here to watch a youtube video from React Conf 2018](https://www.youtube.com/watch?v=dpw9EHDh2bM)

#### Completely opt-in

You can try Hooks in a few components without rewriting any existing code. But you don't have to learn or usee Hooks right now if you don't want to. It is 100% backwards-compatible.

#### Hooks don't replace your knowledge of React concepts

Hooks only is an alternative way to use React concepts you already know: props, state, context, refs, and lifecycle but without classes. Hooks allow you to reuse stateful logic without changing your component hierarchy

##### How do lifecycle methods correspond to Hooks?

- Function components don't need a constructor. You can initialize the state in the `useState` call. If a computing the initial state is expensive, you can pass a function to `useState`.

- Instead of using `shouldComponentUpdate` lifecycle, use `React.memo`

- Hook called `useEffect` can express all combinations of all the standard lifecycles like `componentDidMount`, `componentDidUpdate` and `componentWillUnmount`

- There are no hooks yet for handling exceptions in your component.

#### Next steps

Hope this article helps you understanding a motivation behind why Hooks were introduced but many details will be probably unclear. Click [this link to deep dive into Hooks](https://reactjs.org/docs/hooks-overview.html)

This blog was originally published on my personal blog [Viral Patel](https://viralpatel.blog).
Node+JS Interactive
Tags: node, montreal, conf, nodejsinteractive
Published: 2019-12-11 15:33:11

---
title: Node+JS Interactive
published: true
description: Attending the largest OpenJS Foundation conference this week? I'd love to chat 😄
tags: node, montreal, conf, NodeJSInteractive
cover_image: https://thepracticaldev.s3.amazonaws.com/i/fg4m9ohlqu86dljaj060.jpg
---

Hi y'all, this week my home city is hosting the largest OpenJS foundation event [Node+JS Interactive](https://events19.linuxfoundation.org/events/nodejs-interactive-2019/) ❤️ if you're around make sure to stop by and say hi! I might have some **npm** swag too 😁

Feel free to poke me on [Twitter](https://twitter.com/ruyadorno). Have a great conference week for those of you who are around!
Welcome Thread - v52
Tags: welcome
Published: 2019-12-11 15:28:55

---
title: Welcome Thread - v52
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
---

![classic dancing baby](https://media.giphy.com/media/QgabVeAu2NiZq/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
How did you set up your blog
Tags: career, writing, discuss
Published: 2019-12-11 15:27:58

Hello Everyone,

I am trying to set up my blog and I want to be able to track things like reads, page visits and other metrics for analysis.

Do you mind sharing how you set up your blog, tools and technologies you used, and how you tracked analytics? Links to your blogs and links to articles where you wrote about it(if any) would be appreciated.
Docker Cleanup Commands
Tags: docker, sysadmin, bash
Published: 2019-12-11 15:18:01

---
title: Docker Cleanup Commands
published: true
description: Helper bash commands to reclaim and save storage on your machines for that runs Docker
tags: docker, sysadmin, bash
---

If you see **Docker** claiming lot of space on your computer and if you want to reclaim all of your space back from Docker, use following Docker commands for cleanup. Make sure you are aware that this will delete images and containers from your machine, make sure you do not run this on production machines unless you know what you are doing  😎.

## How to remove docker’s unused data?
```sh
docker system prune —force
```

**To delete everything**
```sh
docker system prune -a --volumes
```


## How to delete all docker containers including its volumes use?
```sh
docker rm -vf $(docker ps -a -q)
```

## How to delete all docker images?
```sh
docker rmi -f $(docker images -a -q)
```

These commands helped me to reclaim more than **10GB** of data for only few months of work with Docker.

This blog was originally published on my personal blog [Viral Patel](https://viralpatel.blog).
Daily Challenge #135 - The Wide Mouthed Frog!
Tags: challenge
Published: 2019-12-11 15:09:26

---
title: Daily Challenge #135 - The Wide Mouthed Frog!
published: true
series: Daily Challenge
description: The wide mouth frog is particularly interested in the eating habits of other creatures.
tags: challenge
---

The wide mouth frog is particularly interested in the eating habits of other creatures.

He just can't stop asking the creatures he encounters what they like to eat. But then he meets the alligator who just LOVES to eat wide-mouthed frogs!

When he meets the alligator, it then makes a tiny mouth.

Your goal in this kata is to create complete the `mouth_size` method this method takes one argument `animal` which corresponds to the `animal` encountered by the frog. If this one is an `alligator` (case insensitive) return `small` otherwise return wide.

***
_This challenge comes from nbeck on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
✨ A cool way to handle image lazy-loading, optimizing, UX with React.js 
Tags: react, opensource, img, lazy
Published: 2019-12-11 15:03:55

[react-cool-img](https://github.com/wellyshen/react-cool-img) is a lightweight React `<Img />` component, which helps you handle image UX (user experience) and performance optimization as a professional guy 🤓

It empowers the standard [`img`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) tag by many cool features without breaking your original development experience. Ideally, it can be an `img` tag replacement for [React.js](https://reactjs.org).

⚡️ Live demo: https://react-cool-img.org

Support features:

- 🖼 Placeholders for satisfying various image loading states (e.g. loading image > actual image > error image).
- 🛋 [Smart lazy loading](https://github.com/wellyshen/react-cool-img#the-smart-way-to-load-images) with performant and efficient way, using [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
- 🤖 Built-in auto-retry mechanism. User won't miss out your important information.
- 🚫 Aborts any current image downloads on component unmount potentially saving bandwidth and browser resources.
- 🔍 [Supports server-side rendering / Javascript is disabled / SEO](https://github.com/wellyshen/react-cool-img#javascript-availability-and-seo).
- 📜 Supports [TypeScript](https://www.typescriptlang.org) type definition.
- 🦔 Tiny size ([~ 2kB gzipped](https://bundlephobia.com/result?p=react-cool-img)). No external dependencies, aside for the `react` and `react-dom`.
- 🍰 Easy to use.

---

For more usage details checkout the project's GitHub page: https://github.com/wellyshen/react-cool-img.https://github.com/wellyshen/react-cool-starter

You can also install this package is distributed via [npm](https://www.npmjs.com/package/react-cool-img).

```sh
$ yarn add react-cool-img
# or
$ npm install --save react-cool-img
```
Let's make a small web app by nodejs.
Tags: node, javascript, express
Published: 2019-12-11 14:56:58

Write a small node web app with display a result of a rest api. 

# 1. No framework

## preparation for local server

```
mkdir sample
cd sample
npm init
```

## find a sample rest api server
my recommendation is 
https://catfact.ninja/fact


```javascript
var http = require('http'),
    https = require('https')

http.createServer((req, res) => {
    console.log(req.url)
    https.get('https://catfact.ninja/fact', (r) => {
        console.log(r.statusCode)
        r.on('data', (d) => {
            obj = JSON.parse(d)
            res.writeHead(200, {'Content-Type': 'text/html'})
            res.write(`<h1>${obj.fact}</h1>`)
            res.write(`<h2>${obj.length}</h2>`)
            res.end()
        })
    }).on('error', (e) => {
        console.error(e)
    })

}).listen(8080)
```

# 2. Let's use Express

## Why Express?

Above code has 2 issues.
1. Unexpected 2 request to the catfact occurs because of favicon.
2. No process deal with http chunk.

Using the Express is easy way to fix 1st one.

## installation web framework

```bash
npm install express --save
```

```javascript
var express = require('express'),
    app = express(),
    https = require('https')

app.get('/', (req, res) => {
    let data = ''
    https.get('https://catfact.ninja/facts?limit=1000', (r) => {
        console.log(r.statusCode)
        r.on('data', (chunk) => {
            data += chunk
        })
        r.on('end', () => {
            objs = JSON.parse(data)
            let msg
            objs.data.forEach((obj) => msg += `<h1>${obj.fact}</h1>`)
            res.send(msg)
        })
    }).on('error', (e) => {
        console.error(e)
    })
})
app.listen(8080)

```

# Appendix

If you want to pack your app in a docker container.
Read below.

https://nodejs.org/en/docs/guides/nodejs-docker-webapp/