teleren/devto huggingface dataset:
Top 5 GIT commands which will save your day   
Tags: git, bitbucket, terminal, versioncontrol
Published: 2019-11-19 15:23:46

---
title: Top 5 GIT commands which will save your day   
published: true
description: list of git commands which I use daily to solve most of the issues   
tags: #git #bitbucket #terminal #version-control
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bjxfwu5fkf43x6e9g35u.jpeg
---

Here is the list of top five git commands which are most useful in my opinion.

1) Do you want to undo the last commit without losing changes?

```
git reset --soft HEAD~1
```

"~1" is for how many commits you want to undo. let's say we want to undo last 2 commits then we can use 
```
git reset --soft HEAD~2
```
which will return us the files changed in the last two commits

how this can be used with other commands let check that out.
let's say we want to remove the last commit from git history.
then we can simply 

```
git reset --soft HEAD~1
git push -f 
```  
Note: use -f carefully

2) Imagine you are working on some tasks and suddenly the manager came to you and asked you to fix some bug.

this command will help you in saving your changes somewhere safe and you can get back this whenever you wanted.

```
git stash 
```
git stash will temporarily save your changes we can get these changes back by using 

```
git stash apply
``` 
 

3) A case where we don't want to merge conflicts. And we don't want to do any merge using git merge then.

let's say we are in branch XYZ and we made one commit and when we raise PR we are getting merge conflicts. 
```
git reset --soft HEAD~1          ->get's the change of the last commit
git stash                        ->stores them temporally 
git reset --hard origin/develop  ->reset the branch with the develop
                                 ->not current branch files are replaced 
                                   by develop files

git stash apply           ->will get the changes back from the last commit
git commit -m "message"
git push -f                
``` 
Note:
- The same thing can be achieved by using the merge and rebase but I feel it is more comfortable using this.
- Commit message will be removed in this process so we have to add commit message again 
- The same above commands can be used when we want to have a single commit for one task replacement for amend as well. 
   
  
4) Have you ever came across the situation where you need to add the few more files to the same commit without changing the commit message? Then this command is for you.
 
```
git commit --amend --no-edit
```
git commit will commit the files and --amend will add the additional files to the commit and --no-edit will make sure that we use the same commit message.
note: if we use --amend without --no-edit terminal will prompt an option to edit the commit message 


5) Have you wonder how to reset particular file content with the contents of another branch  

let's say we are in branch XYZ and we need to update one file contents with develop branch. 

```
git checkout develop <fileName>
```
Sponsor Prolific Devs ...
Tags: sponsor, prolific, devs
Published: 2019-11-19 15:23:44

---
title: Sponsor Prolific Devs ...
published: true
description: re. dev sponsor buttons & all ..
tags: #discuss #sponsor #prolific #devs
cover_image: https://thepracticaldev.s3.amazonaws.com/i/oftmj1unvbzlmbma1gzr.png
---

There are many options to do that. https://ko-fi.com/ is 1 of them:

![dataPixy ko-fi page](https://thepracticaldev.s3.amazonaws.com/i/2pcsgatnq03zgy3sx24w.png)

Just add `/.github/FUNDING.yml` to your github repo. Here is [mine](https://ko-fi.com/dataPixy) :)

```yml
ko_fi: dataPixy
```
...

from this [#prolificDev](https://twitter.com/search?q=%23prolificDev&src=typed_query) repo: https://github.com/RandomFractals/vscode-data-preview

...

Feel free to join the club! 🤗
Youtube my new beginning, Thankyou guys
Tags: youtube, productivity, vscode, motivation
Published: 2019-11-19 15:20:33

Started my First youtube channel, Thank you guys, you are my source of motivation. I am going to make videos mostly of dev.to topics and programming videos. I work as a full stack developer and will share knowledge about making cool, efficient web and mobile apps. I need your support to grow my channel. Please give me feedback about how I can make my videos better.
If you have a few minutes please check my channel on youtube: https://www.youtube.com/channel/UCmXOnsq1rjtKCa1XBa7b8aQ


do you think I need to maintain a blog also?
Daily Challenge #120 - Growth of a Population
Tags: challenge
Published: 2019-11-19 15:00:52

---
title: Daily Challenge #120 - Growth of a Population
published: true
series: Daily Challenge
description: How many years does the town need to see its population greater or equal to p = 1200 inhabitants
tags: challenge
---

In a small town, the population is `p0 = 1000` at the beginning of a year. The population regularly increases by `2 percent` per year and moreover `50` new inhabitants per year come to live in the town. 

How many years does the town need to see its population greater or equal to `p = 1200` inhabitants?

`At the end of the first year there will be: 
1000 + 1000 * 0.02 + 50 => 1070 inhabitants`

`At the end of the 2nd year there will be: 
1070 + 1070 * 0.02 + 50 => 1141 inhabitants (number of inhabitants is an integer)`

`At the end of the 3rd year there will be:
1141 + 1141 * 0.02 + 50 => 1213`

`It will need 3 entire years.`

More generally given parameters:

`p0, percent, aug (inhabitants coming or leaving each year), p (population to surpass)`

the function `nb_year` should return `n` number of entire years needed to get a population greater or equal to `p`.

aug is an integer, percent a positive or null number, p0 and p are positive integers (> 0)

`Examples:
nb_year(1500, 5, 100, 5000) -> 15
nb_year(1500000, 2.5, 10000, 2000000) -> 10`

Note: Don't forget to convert the percent parameter as a percentage in the body of your function: if the parameter percent is 2 you have to convert it to 0.02.


***

_This challenge comes from Becojo 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!_
Async without await
Tags: javascript, thought, async
Published: 2019-11-19 14:53:11

Some developers get annoyed by async functions that don't use await functionality. There are even [linter rules](https://eslint.org/docs/rules/require-await) that don't allow the usage of async functions if they don't contain the await keyword. I'm curious to know why is this a problem?

For example, I use async functions without the await functionality in some occasions:

1. to indicate that execution will be asynchronous if that's not obvious
    ```javascript
    async function run() {
      return doSomething()
    }
    ```

2. to mock an async call or to simply prepare the code to work out of the box with asynchronous logic if transfer to asynchronous execution is anticipated. Looks cleaner than wrapping the return value with a Promise manually.
    ```javascript
    async function fetchData() {
      return {foo: 'bar'}
    }
    ```

Linter rule that denies the usage of async function without the await forces you to change the beginning of your function definition every time you decide to ditch the await and return something immediately, change the inside logic to handle multiple call in parallel or similar. For every such change you are forced to go back and forth with your function definition and create unnecessary version control mess. That's what's really annoying, at least to me(#opinion).
Do most people use DEV to write their posts or do you post a blog elsewhere and syndicate to DEV?
Tags: discuss
Published: 2019-11-19 14:37:46

---
title: Do most people use DEV to write their posts or do you post a blog elsewhere and syndicate to DEV?
published: true
tags: discuss
---

I'm trying to understand how to best use the DEV platform. 

Thanks!
Load a JSON file to Google BigQuery using Python
Tags: gcp, bigquery, python, json
Published: 2019-11-19 14:35:29



I'm starting to learn Python to update a data pipeline and had to upload some JSON files to Google BigQuery. Hope this helps people in need!

See [GCP documentation](https://cloud.google.com/bigquery/docs/python-client-migration) (for a CSV example).

Steps before running the script:
- Create a Google service account with BigQuery permissions. 
- Download the json key. Do not commit into git! Use .gitignore if needed.
-  Add the key to your .env variable. This will get load via `load_dotenv` library. Again, do not commit .env into git!

Example of your .env

```
GOOGLE_APPLICATION_CREDENTIALS=your-gcp-project-name-aaa333111aaa.json
```
    
- Create the dataset via GCP Console, in the BigQuery section.
- Run the script!

*upload_json_to_bq.py* script:

```python
from google.cloud import bigquery
    
from google.oauth2 import service_account
from dotenv import load_dotenv
load_dotenv()
    
client = bigquery.Client()
filename = '/path/to/file/in/nd-format.json'
dataset_id = 'DatasetName'
table_id = 'TableName'
    
dataset_ref = client.dataset(dataset_id)
table_ref = dataset_ref.table(table_id)
job_config = bigquery.LoadJobConfig()
job_config.source_format = bigquery.SourceFormat.NEWLINE_DELIMITED_JSON
job_config.autodetect = True
    
with open(filename, "rb") as source_file:
    job = client.load_table_from_file(
        source_file,
        table_ref,
        location="europe-west1",  # Must match the destination dataset location.
        job_config=job_config,
    )  # API request

job.result()  # Waits for table load to complete.
    
print("Loaded {} rows into {}:{}.".format(job.output_rows, dataset_id, table_id))
```

---
Note: the file must be a JSON newline delimited file.
How to AND NOT something in a CRD
Tags: kubernetes, crd, openapi, validate
Published: 2019-11-19 14:21:40

This advice is valid for sure if you're working with a Kubernetes CRD with version like this:

```
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
```

It might be valid for other versions too.

If you want to create a structural CRD, and you want to require something not be there when some other value is set one way or another, here's an example.

```yaml
                            prometheus:
                              type: object
                              oneOf:
                              - required:
                                - enabled
                                - uri
                                properties:
                                  enabled:
                                    enum:
                                    - true
                              - properties:
                                  enabled:
                                    enum:
                                    - false
                                allOf:
                                - not:
                                    required:
                                      - uri
                              properties:
                                enabled:
                                  description: Whether or not to enable the Presto-Prometheus connector.
                                  type: boolean
                                uri:
                                  description: URI for Prometheus.
                                  type: string
                                  format: uri
                                chunkSizeDuration:
                                  description: Default size of each Prometheus query chunk.
```

So that means:

We require `oneOf` the subschemas to be fulfilled. Either `enabled` is `true` in which case we require `uri` be defined. Or, `enabled` is `false` in which case, `uri` is not required. The extra `allOf` in there, in this case, is simply a way to allow for the `not` in that 2nd subschema. And just highlight what is meant by subschemas. `oneOf` starts a list of them. So the first is:
```yaml
                              - required:
                                - enabled
                                - uri
                                properties:
                                  enabled:
                                    enum:
                                    - true
```
and the second is:
```yaml
                              - properties:
                                  enabled:
                                    enum:
                                    - false
                                allOf:
                                - not:
                                    required:
                                      - uri
```

And to be structural you must list all the properties again, and you can include any items you're not setting requirements on. Which is the rest of the yaml above.

Happy computing.
Python Standard Deviation Tutorial
Tags: python, tutorial, programming
Published: 2019-11-19 13:59:53

---
title: Python Standard Deviation Tutorial
published: true
description: 
tags: #python #tutorial #programming
---

1 Terminology
2 Standard deviation in Python
3 Calculate for a list
4 Calculate for an array
5 Calculate for dictionary values
6 Calculate for a matrix
7 Calculate for Pandas Series
8 Calculate for Pandas DataFrame
9 Standard deviation vs. mean (average)
10 Standard deviation vs. median
11 Pooled standard deviation
12 Plot standard deviation and error bars

https://likegeeks.com/python-standard-deviation/
I got on featured! (small happy post)
Tags: happypost
Published: 2019-11-19 13:44:35

I've got Featured! Here's the screenshot I took!
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xaobiz6m97hfl4jklxv8.png)
Amazing I'm pretty happy I researched On that one and it paid off!

Happily Said By Ibrahim From TGD Dev
e2e testing environment
Tags: devops, testing
Published: 2019-11-19 13:34:49

How do you manage e2e testing in your organization?
What is the pipeline flow for deploying to production?

In my company we are planning a ci/cd strategy,
and we were wondering when and how should we execute the e2e tests,
how to build the environment (is it dynamic or static test env) etc..

We would like to reach out and see how others are doing it.
(Video) How to start programming - For Beginners
Tags: beginners, codenewbie, webdev, html
Published: 2019-11-19 13:31:52

## "How do I start coding? Where do I begin?"

In this video i answer the question that I get asked often by people that are interested in becoming or programmer:
"How do I start coding? Where do I begin?!"

My answer personal belief and answer may surprise you...

I tell people to learn how to make websites, more specifically learn HTML, JS & CSS. In the video i give 5 solid reasons why i have this belief and tell people this answer. In the rest of the video I want to give complete beginners some brief knowledge about programming from a computer science point of view and then immediately empower them to actually code by giving them a very brief coding tutorial in HTML, JS & CSS and give them a large list of links to follow that will enable them to carry on their own learning, now that they have been show the path to start walking on...

"Once you have learnt the skill of coding with HTML, JS & CSS you will have a nice basic understanding of programming overall and have some of the fundamentals and coding concepts down and will be able to pick up other languages or other approaches with much more ease." - Thats the idea anyway...

Below is the video, if you are an experienced dev then I would love to hear your feedback on my approach, things I did well & things that I didn't do so well.
Otherwise if you are a newbie, then enjoy, hopefully it helps you find your path and gets you starting to walk!

Enjoy...

{% youtube dIipXduKpJw %}

Links from the video ======================

Codepen.io (Live coding in the browser):
https://codepen.io/

VSCode (Plain Text Editors):
https://code.visualstudio.com/download

Sublime (Plain Text Editors):
https://www.sublimetext.com/3

Atom (Plain Text Editors):
https://atom.io/

w3schools (Excellent online resource to learn HTML, JS & CSS):
https://www.w3schools.com/

HTML Tag/Element resource list (w3schools):
https://www.w3schools.com/tags/default.asp

CSS properties list (w3schools):
https://www.w3schools.com/cssref/default.asp

Learn JS (Nice, easy & step-by-step online tutorial) (w3schools):
https://www.w3schools.com/js/default.asp

CodeAcademy (Online FREE courses for all sorts of programming languages, we are interested in the Javascipt ones):
https://www.codecademy.com/catalog/language/javascript

Arnold C (Crazy Arnold Schwarzenegger oneliners programming language):
http://lhartikk.github.io/ArnoldC

Timestamps to certain sections in the video  ======================

03:51 - What is Programming?
08:08 - HTML, JS & CSS
10:10 - Lets do some Code!
12:12 - Coding: HTML
18:09 - Coding: CSS
24:57 - Coding: JS

## Onwards

If you have ANY feedback or questions at all please reach out to me in the comments below or reach out to me on twitter:

[My Twitter (@ben_kadel)](https://twitter.com/ben_kadel)

Thanks for reading and possibly watching!
Voice To Text Using AWS Transcribe With Python
Tags: aws, python, speechtotext
Published: 2019-11-19 13:28:10

---
description: Thinking how to use AWS Transcribe with Python for voice to text? Here’s a quick guide that explains the process in simple steps
---

Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows [Python developers](https://www.botreetechnologies.com/python-development) to write software that makes use of Amazon Web services like S3 and EC2.

Amazon Transcribe is an automatic speech recognition (ASR) service that is fully managed and continuously trained that generates accurate transcripts for audio files. It makes it easy for developers to add speech to text capability to their applications. You can analyze audio files stored in Amazon S3 and have the service return a text file of the transcribed speech using the Amazon Transcribe API. Reach out to learn more about the [web development agency in New York](https://www.botreetechnologies.com/usa/web-development-company-new-york) for the various ways to improve or build the quality of projects and across your company.

* You need to grant permissions to use the Amazon Transcribe console for the actions shown in the following policy:

{% gist https://gist.github.com/chirag-lunagariya/8f9bff1b09567c077619856a90e6e945.js %}

**1. Initialize Client:**

* To run transcribe job initialize client using boto3 with AWS credentials.

{% gist https://gist.github.com/chirag-lunagariya/fecd978ac62700a29a2a3833f2d9e161.js %}

**2. Run Transcribe Job:**

* start_transcription_job(**kwargs) it will start an asynchronous job to transcribe speech to text.

* Required parameters to run transcribe job are TranscriptionJobName, Media, MediaFormat **('mp3'|'mp4'|'wav'|'flac')**, LanguageCode **('en-US'|'es-US'|'en-AU'|'fr-CA'|'en-GB'|'de-DE'|'pt-BR'|'fr-FR'|'it-IT')**.

{% gist https://gist.github.com/chirag-lunagariya/6f07440ed1ff8d46d2661fd657987a38.js %}

**3. Check Job Status:**

* Due to the asynchronous nature of the transcription job, we need to check the job status. The time taken to run the transcription job is depending on the length and complexity of your recordings.

{% gist https://gist.github.com/chirag-lunagariya/3e4e47e78b212bb40c6510654bac1e4d.js %}

* When the transcription job status is completed, the result links to an Amazon S3 presigned URL that contains the transcription in JSON format:

{% gist https://gist.github.com/chirag-lunagariya/930d6de132f15e437e72123edf630f84.js %}

**4. Retrieve Text:**

* On complete transcription, the job result contains the transcription in JSON format. Using python library load JSON response and get the text from the result.

{% gist https://gist.github.com/chirag-lunagariya/990f2b8a220b642c39006e504803ec07.js %}
Why Choose Wix?
Tags: whychoose
Published: 2019-11-19 13:23:59

Hello I'm Ibrahim From TGD Dev ™ Today I've taken the time to research. Sorry About the other episodes I just didn't try hard enough. Now Today's episode we will be discussing Why Choose Wix? (Why Choose? - An Official Dev Series! Episode 3)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/nnyxt3ulxpyfqcorlxn5.png)

So heres some basic info From Wikipedia.

Wix.com Ltd. is a cloud-based web development platform that was first developed and popularised by the Israeli company also called Wix. It allows users to create HTML5 websites and mobile sites through the use of online drag and drop tools. Wikipedia 

Now into the real question Why Choose Wix?

Ok for Freeium Users Aka Free Users Heres what U get


Pros

- Access to most features.

- Very Good Templates 

- Different editing softwares depending on the type of person (For Example Wix Editor For Advanced users And Wix ADI For Basic Users)

- You Can Make A Forums Page Without Premium And It's Pretty Good Including Gifs and images!

- Easy To Learn

- ETC


Cons

- Clunky Domains (For Example https://example.wixsite.com/example

- Lots Of things are Premium 

- If Your Making A Rank on Your Forum Wix ONLY Provides their Minimal Icons!

- Wix Branding Over the top of the ENTIRE website

- Default Social Media is set To Wix,s Social media

- Some images paid Both Free and Premuim

- ETC

Besides That And A couple Others Wix Is Pretty Nice.

Now for Premium Users Heres What you get

Pros

- 1 YEAR FREE DOMAIN! (For example https://example.com

- Google Analytics

- More Access to content

- Very Good Templates

- Different editing softwares depending on the type of person (For Example Wix Editor For Advanced users And Wix ADI For Basic Users)

- No Wix Branding

- Easy to learn

- ETC

Cons

- Default Social Media is set To Wix,s Social media

- Secret Branding Under The site stating "Proudly Created With Wix.com"
  Removable But Still Included.

- If Your Making A Rank on Your Forum Wix ONLY Provides their Minimal Icons!

- Some images paid Both Free and Premuim

I Hope This Episode Was More Well researched Than my others.
If you like this new style Reply in the comments!

For loading reasons I've provided the Title image In the post and as the body image

Now I'll See you all later!

Sincerely Ibrahim From TGD Dev ™