teleren/devto huggingface dataset:
Discard File Changes by VSCode Instead of git stash 
Tags: webdev, productivity, git, codenewbie
Published: 2020-06-25 01:14:30

---
title: Discard File Changes by VSCode Instead of git stash 
published: true
description: VSCode has a simple functionality to discard file changes.
tags: webdev, productivity, git, codenewbie
canonical_url: http://reiyoshizawa.com/discard-file-changes-by-vscode/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/j06by806woorx9623lxj.jpg
---

This is a small tip for anyone who uses git command daily. 

How do you manage when you don't want file changes to be staged but need to checkout another branch? 

I have usually cleared a branch by using git stash. git stash is not for discarding unnecessary files but for storing the file changes for just a temporary moment.

I knew that this way would not be ideal but didn't know the proper way of that.

Lately, I have found a much simple solution to discard file changes. Everyone should use that.

[![Image from Gyazo](https://i.gyazo.com/db4f6dc2f262555cdced2523140b9694.gif)](https://gyazo.com/db4f6dc2f262555cdced2523140b9694)

## Discard file changes

1. Use Visual Studio Code
2. Select `Sorce Control` in the left option (with shortcut key, Control + Shift + G)
3. Click `Discard All Changes`

That's it! If you have specific files to discard, You only need to select that file.

I'm not familiar with this type of superpower of VSCode. If you know about VSCode tips to improve productivity, Please let me know. I would really appreciate it. Thanks!
Gatsby E-Commerce Recipe: Integrate a Cart in a Few Steps
Tags: javascript, webdev, react, gatsby
Published: 2020-07-02 18:30:09

---
title: Gatsby E-Commerce Recipe: Integrate a Cart in a Few Steps
published: true
date: 2020-06-19 09:56:23 UTC
tags: javascript, webdev, react, gatsby
canonical_url: https://snipcart.com/blog/gatsby-recipes-ecommerce
---

![Gatsby E-Commerce Recipe: Integrate a Cart in a Few Steps](https://snipcart.com/media/204904/gatsby-snipcart-ecommerce.png)

No tool in the [Jamstack ecosystem](https://snipcart.com/blog/jamstack) has made more steps towards an optimal developer experience than Gatsby.

What started as a simple, albeit performant, static site generator is today so much more than that.

One recent example of this ongoing progress was the release of Gatsby Recipes, which allow even more automation in the site-building process.

When we stumbled upon this, we automatically thought: “Here’s the perfect occasion to ease up an e-commerce integration for Gatsby projects!”

So today, we’re glad to present to you our new Gatsby e-commerce recipe.

**This post will explain how we’ve built it and how you can use it for your own Gatsby e-commerce website.**

Let’s start by clearing up what are Gatsby recipes exactly.

## What are Gatsby recipes?

![gatsby-recipes](https://snipcart.com/media/204903/gatsby-recipes.png)

**A [Gatsby recipe](https://www.gatsbyjs.org/blog/2020-04-15-announcing-gatsby-recipes/) is scripted as a series of steps taken to configure your site to the desired state, or to quickly add new things to your site.** 

It enables the automation of multiple tasks such as creating pages and layouts, setting up TypeScript, run npm installs, adding data to GraphQL, etc. Or, in our case, installing and setting up a plugin.

Oh, and Recipes are run directly from Gatsby’s CLI!

Under the hood, these “steps” are defined in a single [MDX](https://www.gatsbyjs.org/docs/mdx/) file&mdash;a combination of Markdown and React components. Using Markdown allows the steps to complete a task to be listed in a human-readable way. That will undoubtedly simplify the process for many users.

Out of the box, Gatsby offers many official recipes. Find out which tasks you can already use recipes for by running `gatsby recipes` in your terminal.

If you don’t find something you’d like to automate for your Gatsby projects, it’s quite easy to create your own recipe. The tutorial below will show you how to do so. Our example allows the installation of a Snipcart plugin that enables e-commerce on Gatsby websites quickly.
  

→ Read the full post [here](https://snipcart.com/blog/gatsby-recipes-ecommerce)
Check a String is Palindrome in Python
Tags: python
Published: 2020-07-08 18:25:08

---
title: Check a String is Palindrome in Python
published: true
date: 2020-04-02 00:00:00 UTC
tags: python
canonical_url: https://tech.serhatteker.com/post/2020-04/check-string-palindrome-in-python/
---

A palindrome is any number or string which remains unaltered when reversed.

The most pythonic way to determine if a given string is a palindrome would be:

```py
def is_palindrome(string):
    return string == string[::-1]
```

- `[::-1]` slice reverses the string. It is equal to:
`''.join(list(reversed(string)))`.
- With `==` we compare the equality, then returning `True` or `False`.

Yes it is so simple and elegant in python.

### Type Check
Actually for a better program before that method we should check that the given value is `string` type or not:

```py
def is_string(string):
    if not isinstance(string, str):
        raise TypeError("Input must be a string.")
```

### Manual Testing
If we want to see all of them in action together:


```py
#!/usr/bin/env python3
# check_palindrome.py


def is_string(string):
    if not isinstance(string, str):
        raise TypeError("Input must be a string.")


def is_palindrome(string):
    return string == string[::-1]


def main():
    string = "tenet"
    is_string(string)

    print(is_palindrome(string))
    return is_palindrome(string)


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

if you run this code you will see:

```bash
user@host $ ./check_palindrome.py
True
```

_INFO_:
We should write tests and not use __print__ as debugging, but this is a short showcase.




All done!
Turnkey Solution for Raspberry Pi Remote SSH Access Over the Internet
Tags: raspberrypiremoteassh, iotremotessh, iotremoteconnect, raspberrypifleetmanagement
Published: 2020-06-24 06:47:59

Imagine managing few thousands of Raspberry Pi devices at your work or at your customer site behind firewall or NAT.  How would you configure, setup, access or even debug them from remote locations?

<a href="https://www.socketxp.com/iot/remote-access-iot-ssh-over-the-internet/">SocketXP provides turnkey IoT solution</a> that can bring up hundreds or thousands of RPi devices online for remote SSH connectivity in less than a minute(limited only by your ability to copy paste a command).

Not just that, it is highly secure (uses SSL/TLS tunneling - a lightweight VPN alternative solution)

How the SockeXP turnkey solution for Raspberry Pi Remote SSH Access over the Internet

Just 2 simple steps.

<h2>Step #1</h2>
Copy a single command from <a href="https://portal.socketxp.com/#/devices">SocketXP Portal Page</a> as shown below.

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

<b>Note:</b>  The above command has a unique auth-token assigned just for you and your devices.

Paste the above command on your Raspberry Pi device terminal.  Paste this command on as many number of devices as you want to bring up for remote connectivity.  Just one command for all your RPi devices.

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

<h2>Step #2</h2>
Check if your device is up and connected on the SocketXP portal page as shown below. 

Click the terminal icon next to your RPi device.

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

Provide your RPi SSH credentials in the next screen.

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

Boom... and there you are, now inside your RPi SSH shell.  

Now type any command in the shell.  Say for example "htop".

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

How hard was this?  Easy-Peasy isn't it?

Let me know what you think about this single-touch installation and our SocketXP Raspberry Pi remote SSH connectivity solution in general.

BTW, did I say that it's completely free for adding upto 4 RPi devices?

Got 5 or more devices? SocketXP service is just 20 Cents per device for one full month of remote connectivity ?  And that too backed by a 14-day money back guarantee!!  

Read more about the full solution here:
<a href="https://www.socketxp.com/iot/remote-access-iot-ssh-over-the-internet/"><b>https://www.socketxp.com/iot/remote-access-iot-ssh-over-the-internet/</b></a>
How to Find Which Process using a Networking Port
Tags: networking
Published: 2020-08-21 07:09:27

---
title: How to Find Which Process using a Networking Port
published: true
date: 2020-06-15 08:28:00 UTC
tags: Networking
canonical_url: https://coderscat.com/how-to-find-which-process-using-a-networking-port
---

![2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_162735.png](https://coderscat.com/wp-content/uploads/2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_162735-2.png)

## netstat

Command `netstat` will show the most useful statistic data of networking.

```
netstat -ltnp | grep -w ':8080' 

```

The above command will display the information related to the networking port of 8080.

These are the detailed meaning of options:

```
l – let netstat to only show listening sockets.t – let netstat to display TCP connections.n – show numerical addresses.p – enables showing of the process ID and the process name.grep -w – shows matching of exact string (:80).
```

Note: On MacOs, we’re stuck with the BSD netstat which will not show you the process ID that is attached to a given port.

So, `lsof` will be a choice for Mac.

## lsof

Command `lsof` will display all opened files of a process. We could also use it to find which process used a networking port, since TCP/IP sockets use file descriptors.

`lsof -i` will show which process communicating over the internet.

![2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_161636.png](https://coderscat.com/wp-content/uploads/2020_06_08_how-to-find-which-process-used-a-networking-port.org_20200615_161636.png)

The post [How to Find Which Process using a Networking Port](https://coderscat.com/how-to-find-which-process-using-a-networking-port) appeared first on [Coder's Cat](https://coderscat.com).
Disable Brave Browser Auto Update on a Mac
Published: 2020-06-25 00:09:01

Provided your Brave browser version is the same as mine at the time of writing (83.1.10.93) - if not, substitute the numbers - quit the browser and do the following:

1. Launch the Terminal

2. Type this as one line: 
cd /Applications/Brave\ Browser.app/Contents/Frameworks/Brave\ Browser\ Framework.framework/Versions/83.1.10.93/Frameworks/Sparkle.framework/Versions/A/Resources/

3. Then this: 
mv Autoupdate.app/ Autoupdate.app.OLD

4. Open Brave, go to the three-stripe "burger" menu and select About Brave, you should be able to see the following message: Update failed (error: 11) Error details: An error occurred in retrieving update information. Please try again later.

5. Quit the terminal, you're done
Ruby Readability
Tags: beginners, ruby, readability, cleancode
Published: 2020-06-25 02:17:06

Have you ever looked at someone else’s code and thought, “What on earth is this?”. We’ll you’re not the only one, you can have amazing projects but if your code is written poorly, it won’t matter. Take a look at this piece of code for example.

```ruby
def happy_birthday name,age
  puts "Congrats "+name+" "+"You turned "+age.to_s+" "+"years old today!"
if age>100
  puts "You're full of experience!"
else
  puts "You still have a lot to learn!"
end
end
happy_birthday("Tom", 20)
```
We will be taking this piece of code and transforming it into something beautiful. Let’s begin with..

# Indentation
Sure the code works, even if the two end keywords are right on top of each other. There’s currently a whole war among developers about the proper way of indenting your code. The Spacers believe you should indent with 2 or 4 spaces. The Tabbers believe you need to indent using tabs. Both agree on the importance of proper spacing for readability. Let me show you…

```ruby
def happy_birthday name, age
  puts "Congrats " + name + " " + "You turned " + age.to_s + " " + "years old today!"
  if age > 100
    puts "You're full of experience!"
  else
    puts "You still have a lot to learn!"
  end
end
```
Now compare the if statement block with the code above. Through indentation we can clearly show that the if statement is a block of its own with its own scope. Not only that, the variables are also easier to read now.

##String Interpolation & Ternary Expressions

```ruby
def happy_birthday name, age
  puts "Congrats #{name}, you turned #{age} years old today!"
  puts (age > 100 ? "You're full of experience!" : "You still have a lot to learn!")
end
happy_birthday("Tom", 20)
```
Here, we’ve replaced + and the .to_s method with string interpolation: #{}. We then used a ternary expression to shorten our if statement: You can read more about them [here](https://www.rubyguides.com/2019/10/ruby-ternary-operator/).

You need to be careful when using ternary expressions. Sometimes they can make your code harder to read, use them wisely.

#Keyword Arguments
For our final clean up trick we will add keyword arguments to this code. How does it look? I’ll show you:

```ruby
def happy_birthday(name:, age:)
  puts "Congrats #{name}, you turned #{age} years old today!"
  puts (age > 100 ? "You're full of experience!" : "You still have a lot to learn!")
end
happy_birthday({:name => "Tom", :age => 50})
```
And here’s our initial code for comparison:

```ruby
def happy_birthday name,age
  puts "Congrats "+name+" "+"You turned "+age.to_s+" "+"years old today!"
if age>100
  puts "You're full of experience!"
else
  puts "You still have a lot to learn!"
end
end
happy_birthday("Tom", 20)
```
Notice how our new piece of code looks much cleaner and shorter.

When using keyword arguments the order of the parameters doesn’t matter.

Code readability is important across all languages not just Ruby. So next time you write a piece of code, think to yourself, “is this sexy enough?”.

Thank you for reading!
Building Stacked Area Charts in JavaScript (Shown on COVID-19 Data for Italy, January to June)
Tags: javascript, webdev, datascience, tutorial
Published: 2020-06-25 07:05:51

Stacked area charts are frequently used in data visualization, helping to show how several variables along with the total are changing over time.

Find out how to quickly make interactive JavaScript stacked area charts for web projects [in this new tutorial](https://www.anychart.com/blog/2020/06/10/stacked-area-chart-javascript-tutorial/). While explaining the way (still quite simple to master even if you have very basic HTML skills), the author visualizes the COVID-19 pandemic data for Italy, displaying the number of cases, recoveries, and deaths over time from January 31 when the first 2 cases were officially registered, to June 9 when the total cases in Italy numbered 235,561.

Here's a percent (normalized) stacked area chart to be built by the end of the tutorial:

![Normalized stacked area chart of COVID-19 in Italy, January to June](https://dev-to-uploads.s3.amazonaws.com/i/r0s5m3s4vgy2mle9k833.gif)
Windows Preloader using HTML & CSS
Tags: loader, loadinganimation, loadingscreen, loading
Published: 2020-06-25 08:54:12

What is a preloader? Preloaders (also known as loaders) are what you see on the webpage screen while the rest of the page's content is still loading. Loader helps to entertain the visitors or content's viewers while the rest pages are still loading. And preloader help to maintain the bounce rate of the website.

As you have seen in the Windows Screen while you switch-on of the PC/Laptop there is shown a rotating dots or loader with "please wait" text and while the loader is rotating after a few seconds, those dots are disappeared for few seconds and again appear. 

In this program, this loader is the same as the windows starting loader which rotates clockwise infinitely. When this loader at 76% to 100%, this loader dots are disappeared and again these dots appear when the loader is at 40%.

<a href="https://www.codingnepalweb.com/2020/06/windows-preloader-using-html-css.html">Click here to get source codes</a>
Go - The note on "omitempty"
Tags: go
Published: 2020-06-25 12:40:36

---
title: Go - The note on "omitempty"
published: true
description: 
tags: go
//cover_image: https://direct_url_to_image.jpg
---

`json.Marshal` outputs empty json strings if the struct has a Value-type struct marked "omitempty"

So I usually use Ptr-type struct as a struct field.

```go
package main

import (
	"encoding/json"
	"fmt"
)

type ValueSlice struct {
	Values []V `json:"b,omitempty"`
}

type PtrSlice struct {
	Values []*V `json:"b,omitempty"`
}

type ValueStruct struct {
	Value V `json:"value,omitempty"`
}

type PtrStruct struct {
	Value *V `json:"value,omitempty"`
}

type V struct {
	Value string `json:"value"`
}

func main() {
	v1 := &ValueSlice{}
	v2 := &PtrSlice{}
	v3 := &ValueStruct{}
	v4 := &PtrStruct{}

	bv1, _ := json.Marshal(v1)
	bv2, _ := json.Marshal(v2)
	bv3, _ := json.Marshal(v3)
	bv4, _ := json.Marshal(v4)

	fmt.Printf("bv1: %v\n", string(bv1))
	fmt.Printf("bv2: %v\n", string(bv2))
	fmt.Printf("bv3: %v\n", string(bv3))
	fmt.Printf("bv4: %v\n", string(bv4))
}
```

then

```shell
bv1: {}
bv2: {}
bv3: {"value":{"value":""}}
bv4: {}
```

https://play.golang.org/p/7XKphsEayCN

I have just realized that I can use "The Go Playground" today🤣
Image recognition with NodeJS + AWS Lambda + Rekognition + Translator
Published: 2020-06-25 16:25:52

Hey, guys!

I wanted to share with you an implementation that I made using NodeJS, AWS-Lambda and Serverless-Framework for image recognition and classification.

The objectives are:

1 - Download a certain image
2 - Extract classification labels related to this image using AWS-Rekognition
3 - Translate the labels from step # 2 to another language using AWS-Translate
4 - Return the results as follows:

[EnglishLabel, LabelTranslated] - Percentage of confidence that this label makes sense for the input image.

Ex (en => pt): [Dog, Cachorro]: 99.87%

It's a very simple project, but it shows how easily these services are accessible and simple to be used.

Cheers!

https://github.com/steniowagner/serverless-aws-lambda-studies/tree/master/demo03-image-analysis
My first endeavor with Django...
Tags: beginners, sql
Published: 2020-06-25 18:13:05

Hi, guys! So this is my first blog post, so I'll preface this with a little background before jumping into Django. I'm currently in an accelerated program learning software development in 16 weeks. Quite an endeavor. We just finished a month of learning frontend programming (HTML, CSS, JavaScript), and now we're on backend (Python and Django). All of that to say that these posts will probably lack in complete technical comprehension and are more a way for me to write out my thoughts as I am trying to learn/process all of this.

Our first assignment with Django basically involves breaking things until you figure out how they work together. We have the framework of an app that allows you to add a contact and then edit it. So far, I've been learning about migrations (similar to git push, but only when you change models.py), and the importance of doing them OFTEN, or else you'll end up with an incomprehensible string of errors. I recently created a new HTML page to set up a separate link so that you can click on a contact and each contact has a new page/url according to their respective pk. The difficulty so far is managing the amount of files and how everything is connected, but it's creating an even larger puzzle to solve, which is always exciting.
Learning GitHub - setup
Tags: github, learning
Published: 2020-06-25 19:20:02

{% user kkermode %} and I are remote pair programming to try out features of GitHub that interest us.

For setup of a Github learning environment we recommend:
1. Create a dedicated Repo just for learning
2. Add collaborators to your Repo
3. Use Github desktop as a simple client tool
4. Add metadata to make your Repo findable
5. Make a Kanban board using Github projects

Here's our repo - {% github lynnlangit/learning-github no-readme %}

Here's a short screencast of our work {% youtube u_9ozMYJ3VY %}
Get to know the latest AI that can predict any kind of numerical data
Published: 2020-06-26 02:50:26

Three years ago, I was staring at my screen, trying to analyse what seemed to be a complex problem. The details are not important, but I told myself there must be a solution to it. Apparently not!

Fast forward to the present time we are proud to release [AiSara](https://www.aisara.ai/) to the market. In total, we probably have spent about 8000 working hours (5 man-years) on this. When I said we, it is the hardcore team consisting of a “let me have a crack at this” engineer, “never say die” developer, and many others (mostly interns) that were unfortunate enough to cross our path. My only prayer is that what didn’t kill them made them stronger, lol.  

When people ask me what [AiSara](https://www.aisara.ai/) is, I figured there is no better way to answer than to show what it is. Initially, it was like trying to explain what a touch start button for a car is 20 years ago, except it is 10 times more difficult. What usually follows is a perplexing look, people guessing what they are or even suggesting how it should be. 

What is more important is what [AiSara](https://www.aisara.ai/) does. Earlier this year, after 1 year of working on the algorithm and 1 year developing a web app that many possibly have a mental block to, we figured we need to release [AiSara](https://www.aisara.ai/) as a product. With a user base of 750 million around the world, at least we don’t have to explain the platform, and that is already half the battle won.

What is the other half of the battle? Again, it is much easier. With [AiSara](https://www.aisara.ai/), you can boil it down to two functions we created for which is the ability to learn and predict your numerical data.

With [AiSara](https://www.aisara.ai/), Everyone can do AI
Post/Get request using axios [React and Firebase Tutorial]
Tags: react, javascript, beginners, codenewbie
Published: 2020-06-26 08:22:32

Posting Data to Firebase. A nice guide to get started on react and firebase Realtime database 💥💥

You Enjoy the content? [Help me reach 1k subscribers on my YouTube Channel] (https://www.youtube.com/channel/UCe8uN9zoKksCb1hfw61myRw?sub_confirmation=10)

{% youtube dDVicLcbOZ4%}

Now it's time to fetch the data from Firebase Realtime database 💥💥
{% youtube FkQrrIFSrFs%}
Mojibake 文字化け
Tags: japanese, mojibake, encoding, character
Published: 2020-06-26 14:20:43

[Mojibake - Wikipedia](https://en.wikipedia.org/wiki/Mojibake)
[文字化け - Wikipedia](https://ja.wikipedia.org/wiki/%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91)

主にエンコーディングシステムの食い違いにより、意図していたのとは異なる文字が出力されてしまうこと。

----
[ASCII - Wikipedia](https://en.wikipedia.org/wiki/ASCII)
- 7bit の文字コード。文字化けの原因になる。

[ISO/IEC 8859-1 - Wikipedia](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
- 世界的にデフォルトの文字コードとされる場合が多い。そのため文字化けの原因になる。

日本語 [Japanese language - Wikipedia](https://en.wikipedia.org/wiki/Japanese_language)
- 悪魔の言語。
What is an HTML Attribute | How to use WebdriverIO getAttribute function 
Tags: testing, beginners, webdriverio, getattribute
Published: 2020-06-26 16:17:29

Attributes can be very useful in getting data that may be needed by a tester to verify specific sections of a an application. You can get the attribute value and verify that it changes based on certain actions.

In this tutorial I explain what are HTML Attributes as well as how to use the WebdriverIO getAttribute command in your tests.

{% youtube cVlX5RU14i4 %}