teleren/devto huggingface dataset:
Merge into Master Often? Automate!
Tags: bash, automation, terminal, devops
Published: 2020-03-04 18:11:45

# Working on a Repo

My engineering department is decently sized, about 50-60 engineers all pushing to (typically) the same repository. Changes happen all the time that force us to merge an updated master into a working branch. This is due to a number of different reasons. One being our heavy reliance on tests from a number of different frameworks, across a broad codebase.

Recently, I found myself constantly running `git fetch` and `git merge origin/master`. This redundancy irked me. I, like most sane developers, love the terminal and the command line. So I thought back to my school days were we played around with bash and making our own custom commands. So I decided to make things a *little* easier.

# Automation

*Note: I work on MacOS*

This'll be quick! In my `~/.bash_profile` I put the following code snippet:
```
# Load custom bash functions
if [ -r ~/.custom_cmds.sh ]; then
  source ~/.custom_cmds.sh
fi
```
This simply looks for the `~/.custom_cmds.sh` file, and loads it into every new bash session (by default from `~/.bash_profile`).

Create the custom commands file and inside of it, simply put:
```
merge_master() {
  git fetch;
  git merge origin/master;
}
```
This creates a bash function called `merge_master`. Of course, you can name it anything you want, but I went with this.

Afterwards, I ran `chmod u+x ~/.custom_cmds.sh` to ensure execution rights of the file. Now just restart the terminal, or run `source ~/.bash_profile` and **Boom**. You have your first custom command line function! While simple, it makes me a little happier - run it from any of your repositories with a simple `merge_master`.

With this bash syntax, we can now create any automated function we want that will simplify our command-line-lives. Just add it into your `~/.custom_cmds.sh` file!

What else do you like to automate? Bash is incredibly powerful - the options are limitless!
Securing AWS HTTP APIs with JWT Authorizers
Tags: jwt, aws
Published: 2020-03-04 18:07:40

---
title: Securing AWS HTTP APIs with JWT Authorizers
published: true
description: Learn about securing HTTP APIs built on AWS API Gateway using JWT authorization
tags: #jwt #aws # 
canonical_url: https://auth0.com/blog/securing-aws-http-apis-with-jwt-authorizers/
---
TL;DR: HTTP APIs — a new solution in AWS for building low-cost APIs — support JSON Web Token (JWT)-based authorization, and they integrate with external identity providers such as Auth0 for easy, industry-standard authorization practices. This tutorial will walk you through building an HTTP API using Amazon API Gateway and integrating it with Auth0 to restrict write access to authorized users.

Introduction
Let’s start with an obvious statement: building a modern API isn’t exactly a straightforward process. The list of requirements seems to grow: it should be performant, easily scalable, highly available, secure — and that’s before you get to writing your actual business logic!

Thankfully, there’s a constantly growing ecosystem of tools offering solutions for building, securing, and deploying APIs. The AWS API Gateway service provides several solutions for this exact problem, and their most recent offering, HTTP APIs, is a simple, low-cost, low-latency solution for API configuration and deployment.

Now, if you’re building an API, you’ll likely need to restrict endpoint access to at least some of your endpoints eventually. Identity-as-a-Service (IaaS) solutions, like Auth0, can easily handle authentication and authorization for a variety of applications, but how can they be integrated with services like API Gateway? That answer comes in the form of a new HTTP API feature supporting industry-standard authorization: JWT Authorizers.

[Read on 📖](auth0.com/blog/securing-aws-http-apis-with-jwt-authorizers/?utm_source=twitter&utm_medium=sc&utm_campaign=aws_jwt)
Responsive Web Design 
Tags: doit, getwithit, responsivewebdesign
Published: 2020-03-04 18:03:56

Last Sen night, I was looking into the importance of responsive design. If you are not in the know, I will let you know the importance of implementing this concept. Responsive design is a way of putting together a website so it will automatically scale its content/ elements to match the viewport of the device it is being accessed on. For example, it prevents images from being larger than the screen width. 

Ultimately, the goal is to avoid the resizing, scrolling, zooming or panning that occurs when sites are not optimized to different devices. 
Responsive design also does away with the repetitiveness of having to design different websites for different devices. Now, only one website has to be designed to scale up or down automatically depending on the device it is viewed on.

Responsive design is much more encompassing and overall makes for a better user experience when using a website. It also exudes the aura of a professional business, individual, etc.

At the moment, in this “time” and “age”, responsive design is the way to go in order to broaden your reach and make your website accessible to most if not all.
Repository/Service pattern, did it finally click?
Tags: laravel, patterns, repository
Published: 2020-03-04 17:58:43

If you don't know what the repository and service patterns are, check out this article:

https://www.vodovnik.com/2015/08/26/repository-and-services-pattern-in-a-multilayered-architecture/

While I had made use of the repository pattern before, I still made the mistake of putting the method getOfficeContactData() into a service class, even though the name (the data part) should have made it obvious that this is something that belongs into a repository class. In addition, it was shared by two service classes!

Thanks to my code reviewer who pointed it out to me. I think I now understand the purpose of each layer better and will pay more attention to where I put methods in the future.
React Firebase Hosting
Tags: react, freehosting, firebase
Published: 2020-03-04 17:36:00

---
title: React Firebase Hosting
published: true
description: host your react project for free in Google's firebase. 
tags: react, reactjs, free hosting, firebase
---

Install 'nodejs' if you dont have it in your system . 

create a folder , open terminal / shell there and create a 'react' project with the command: 'npx create-react-app'.

Customize the built in website if you want. 

Go to terminal and type the command: 'npm run build' , That'll create a build folder in your project's root directory.

Download the firebase toolkits with this command: 'npm install -g firebase-tools' , this will install it globally.

Login to firebase with : 'firebase login'  this will open a browser window and you will have to login using your gmail . 

Initialize firebase in the command line with : 'firebase init' . 
It will open the interactive command prompt . 

For the first configuration we'll chose : 'Hosting' , click 'space' to select 
and hit 'enter' to continue. 

What do you want to use as your public directory? 
 -type 'build' and hit 'enter'.

Configure as a single page app? 
 - 'y'

File build/index.html already exists. Overwrite? 
 - 'n' 


Then go to : https://firebase.google.com/

Click on the top right corner : 'Go To Console' .

Add a project and name it anything you like. 

Go to the project and click on : 'setting' icon and select 'project settings' from the popup.  

Copy the 'Project ID' from the page .

In the command line : 'firebase use Your_Project_ID'

Then type in : 'firebase deploy' 

This will show your live react site address in the command line.
Phase - 2, Day - 1
Tags: 100daysofcode, html, design
Published: 2020-03-04 17:17:32

Day - 1
Today I have started to brush up my #html skills again and make a Portfolio website just using #html. It's not so beautiful but by building this I have learned a lot about HTML. 
Github Link: https://github.com/debajit13/PortFolioUsingHTML
Website Link: https://debajit13.github.io/PortFolioUsingHTML/
LIVE // Some Recent App Improvements
Tags: saas, productivity
Published: 2020-03-04 17:07:37

Our dev team  has been working hard recently and made some great improvements to AirSend (https://www.airsend.io/)

*Channel View Sidebar*

To help you stay even more on top of your game, we’ve added a channel view sidebar so you can see all of your channels and notifications in one place.

*File Preview Support*

You can now preview images, videos (mp4, webm, ogv), audio (mp3, ogg, wav), pdfs, pptx, docx, and xlsx files right in the AirSend interface. There’s even a convenient download button in the upper right hand corner so you don’t have to exit the preview screen to download the file to your computer.

*Ability to Send File Attachments from Email*

Want you or your clients to be able to email a file attachment and have it show up in an AirSend channel? That can now happen! Any files that you email in response to an AirSend channel notification email or to your unique channel email address will show up in your channel for easy sharing, download, and organization.

*Push Notification Support*

Push notifications are now available across all platforms so that you don’t miss out on any activities happening in your channels. Originally, push notifications were only available on your web browser, but we recently added this capability to our Android and iOS mobile apps based on user feedback.

*Google Sign-in Support*

If you hate typing in usernames and passwords, this one is for you. You can now sign-in to your AirSend account using the Google sign-in button available on web, iOS and Android.

If you're interested, you can sign up for a free account here: https://live.airsend.io/login
Base CS: Depth First Search Writing
Tags: computerscience, basecs, beginners, codenewbie
Published: 2020-03-04 17:02:40

---
title: Base CS: Depth First Search Writing
published: true
description: We'll learn the basics of the DFS algorithm, and see how to interact with a single node when traversing through a tree.
tags: computerscience, basecs, beginners, codenewbie
series: BaseCS Season 2
---

Today's episode of BaseCS explores depth-first tree traversal on trees!

We'll learn the basics of the DFS algorithm, and see how to interact with a single node when traversing through a tree. Next, we'll investigate the different common strategies used to implement this algorithm: Preorder, Inorder, and Postorder search. Finally, we'll learn about the benefits and downsides of these different strategies and determine when to use one strategy over the other!

This whole series is sponsored by Heroku. A special thank you to Heroku for their ongoing support!

{% organization heroku %}
Project Euler: Problem 5 Overview
Tags: projecteuler, algorithms, problemsolving
Published: 2020-03-08 01:39:35

---
title: Project Euler: Problem 5 Overview
published: true
date: 2020-03-04 17:00:00 UTC
tags: Project Euler,algorithms,Problem Solving,project euler
canonical_url: 
---

Let's take a look at the concepts that we can use to solve project euler problem 5 efficiently. Note that this isn't the actual solution article, in this article I'll just cover the general topics.

The post [Project Euler: Problem 5 Overview](https://jaeheonshim.com/project-euler-problem-5-overview/) appeared first on [Coding with Jaeheon Shim](https://jaeheonshim.com).
Load balancing without a load balancer
Tags: loadbalancing, apidevelopment, spa, frontend
Published: 2020-02-27 17:51:26

---
title: Load balancing without a load balancer
published: true
description: Load balancing on the frontend
tags: load balancing, API development, SPA, Frontend
---



![](https://cdn-images-1.medium.com/max/2190/1*_0X4z-hXatS8QLNwhqqFTg.png)

**What is load balancing?**

Load balancing in web development land is a strategy used to handle high volumes of requests from users by either spreading the traffic evenly or strategically across multiple servers.

**Traditional Load balancing**

In a typical architecture with load balancing, you usually have one or more servers acting as load balancers solely dedicated to spreading traffic across the main application servers.

With this approach there is a single **point of failure** thus the load balancers themselves. Most teams use dedicated third-party load balancing services to improve their odds and also because sometimes they don’t have the capacity to run their own load balancers.

But there are other options teams can explore.

**Another way**

![](https://cdn-images-1.medium.com/max/2082/1*7J4d0PSV8vRqDR0QbyUGfw.png)

If you happen to have a **Single Page App** you might be able to explore the approach of allowing the Frontend to broadcast user requests directly to **all **the application servers, on receiving the first response returned by any of the servers you cancel, the connection to the others. You may also apply different strategies regarding how you broadcast the request. For example, you can have the right number of servers in every region based on the number of users from that region and route said users to those servers only.

The good thing with this approach is that we no longer have a single point of failure since we have no central nodes or load balancers routing traffic.

**Things to note**

If your APIs or web app is not [**stateless**](https://restfulapi.net/statelessness/) having users be served by different servers can be a challenge as the user session might be known by only one server.

**This is not a silver bullet** or a definite replacement for using Load balancers. This approach, for example, works best for small teams with a lot on their hands or a product that is just gaining traffic or apps that have known spike periods were having a load balancing setup might be an overkill.

Also, this approach is **deeply embedded within the architecture of your application** compared to using a load balancer that can be thrown in and thrown out easily, this also means it might be a challenge to tweak an existing app to go this route.

Also, note for user requests that require data modification, it might not be a good idea to broadcast it to all the servers, this can lead to problems like a double purchase or multiple entries. For such requests, you might have to ping one server then the next in case the first fails.

**Conclusion**

This is one example of ways to leverage one's coding skills to skip Ops #infracstructureAsCode
text string matching
Tags: python, beginners
Published: 2020-03-04 16:55:23

In <a href="https://python.org">Python</a> programming, if you have a string you can do comparison or so called *string matching*.

Matches the beginning or end of the <a href="https://pythonbasics.org/strings/">string</a> is generally used in the matching file type or url

## Simple text matching

A simple matching function is the general `startwith()` function.

```python
>>> a = 'http://www.python.org'
>>> a.startswith ( 'http')
True
```

Note: This parameters which can be string, can also be a <a href="https://pythonprogramminglanguage.com/tuples/">tuple</a>. The example below passes a tuple as argument with two values.

```python
>>> a = 'http://www.python.org'
>>> a.startswith (( 'http', 'ftp'))
True
```

As you may have guessed, you can also use the method `endswith()`, with a string or tuple.

```python
>>> a = 'https://python.org'
>>> a.endswith(( '.org','.com' ))
True
>>> 
```

While tuples are similar to lists, lists are not allowed as parameter.

The parameter can not be <a href="https://pythonbasics.org/list/">lists</a> or <a href="https://pythonprogramminglanguage.com/dictionary">dictionary</a>. If you try a list or dictionary, then you get an error

```python
>>> a = 'http://www.python.org'
>>> a.startswith ([ 'http', 'ftp'])
Traceback (most recent call last):
File "", line 1, in
a.startswith ([ 'http', 'ftp'])
TypeError: startswith first arg must be str or a tuple of str, not list
>>>
```

In fact, in addition to the above method, you can also use slices to achieve matching, but the code looks not so good:

```python
>>> a = 'https://www.python.org'
>>> a[0:4] == 'https'
True
>>>
```

## Regular expressions

Of course, we can also use <a href="https://docs.python.org/3.8/howto/regex.html">regular expressions</a> to do this, but on top of it a little difficult to understand a little.

```python
>>> import re
>>> url = 'http://www.python.org'
>>> re.match ( 'http: | https: | ftp:', url)
0, 5), match = 'http:'>
>>> help (re.match)
Help on function match in module re:
      
match (pattern, string, flags = 0)
Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found.
 
>>>
```
reverse string by character or word
Tags: python, beginners
Published: 2020-03-04 16:20:40

In this article, we use Python to reverse <a href="https://pythonbasics.org/strings/">string</a> character by character or word-by-word.

First we look at the string *character by character* reversal, because the python provides a very useful sections, so lets see

## Reverse characters

You can reverse the characters in a string or a list of strings. The example below shows how to do that: 

```python
>>> a = 'abc edf degd'
>>> a [:: -1]
'dged fde cba'
>>> 
```

You can also do this (same, but more clear):

```python
>>> a = 'abcd abcd abcd'
>>> a [:: -1]
'dcba dcba dcba'
>>> 
```

This can also be applied to a list of strings:

```python
>>> a = 'abc abc abc'
>>> a[:: -1].split()
['cba', 'cba', 'cba']
>>> 
```

## Reverse word order

The method `reverse` may be used to reverse item order. In this example the string `a` is converted into a list of strings using the `.split()` method. Then the `.reverse()` method changes the order of the list.

```python
>>> a = 'AAA BBB CCC'
>>> r = a.split()
>>> r
['AAA', 'BBB', 'CCC']
>>> r.reverse()
>>> r
['CCC', 'BBB', 'AAA']
>>> 
```

The `reverse()` method can be applied on any list, so you can also use it for a list of numbers:

```python
>>> a = [ 1,2,3,4,5,6 ]
>>> a.reverse()
>>> a
[6, 5, 4, 3, 2, 1]
>>> 
```
Shell command options you didn't know you needed #1
Tags: shell, linux, unix
Published: 2020-03-04 16:16:58

(The first in an occasional series.)

`mv -t <target> <files>`

Handy for throwing at `xargs`, e.g.:

`find . -name '*.png' | xargs mv -t ~/images/`

Annoyingly, not available on MacOS.
Inception Dev
Tags: watercooler
Published: 2020-03-04 16:15:45

Hey Dev team and contributors!

Question. How often to you find yourselves googling an issue, finding something useful then only realising mid read that you are actually on Dev?

Curious 🤓

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qcpcf4716bya3wmvpkm8.gif)
I'm Waylon Walker, and I support women devs.
Tags: wecoded
Published: 2020-03-04 16:12:32


First of all, if you have not already follow #shecoded and read those articles. They are all very well done and give a far better story than I can.  Follow the women who stood up to write those posts, give them some props 💕 🦄 🔖.  Some of the stories there are really eye-opening to what women in tech go through, and may open your eyes to how some things get interpreted by others.

{% tag shecoded %}

# We are different

Everyone is different, embrace those differences.  Not everyone is the same, but we all deserve some level of being treated equally as our unique selves.  We all deserve the opportunity to have a voice.  If someone is truly introverted and public speaking causes them serious anxiety don't push them to speak up.  If they are afraid to speak up or being a bit shy give a bit of a nudge of confidence.  Confirm that their voice matters too.  We all have different experiences through life that cause us to have different thoughts and ideas.

A book that opened me up to understanding differences was [five languages of love](https://www.5lovelanguages.com/).  It may be a bit different context in our professional lives, but I think some of the ideas still apply.  We are all different people and we want to be treated in our unique ways, given equal opportunity for success.

---

# I am an Ally


I'm an ally and I will Listen
I'm an ally and I will encourage other voices to be heard
I'm an ally and I will let others choose when they want their voice heard
I'm an ally and I will embrace our differences
I'm an ally and I am proud of anyone who can step into this heavily straight white male-dominated industry
I'm an ally and I will congratulate and promote accomplishments
I'm an ally and I will respect the wishes of others
I'm an ally and I will teach anyone who asks for my help

### I'm an ally and I will not take extra credit for it


---


If you made it this far seriously go read some articles from the shecoded tag.
Interactive or non-interactive visualization in Jupyter (R version)?
Tags: plotly, r, jupyter, visualization
Published: 2020-03-04 16:05:29

OK, it's time to use R kernel in our jupyter notebook. Actually, this can be done easily by following the instructions in https://irkernel.github.io/installation/.
Then, let's check if our R kernel is installed well.

```R
library(ggplot2)

p <- qplot(wt, mpg, data=mtcars, geom=c('point', 'smooth'),
     method='lm', formular=y~x, color=cyl,
     main='Regression of MPG on Weight',
     xlab='Weight', ylab='Miles per Gallon')

p
```

You probably see the cover picture after running the R cell which is a non-interactive chart, named ggplot2.

### Non-interactive: ggplot2 (https://ggplot2.tidyverse.org)


ggplot2 is widely used for data scientists because it is fast, simple, customizable and scalable, which is a part of tidyverse. Tidyverse is an ecosystem of packages designed with common APIs and a shared philosophy for data science. You can check https://www.tidyverse.org/.

When you want to make any plots from ggplot2 interactive, you can use _ggplotly()_ function provided by _plotly_.

```R
library(plotly)

embed_notebook(ggplotly(p), height="500")
```

Do not forget to call _embed\_notebook()_ function. The above script changes the non-interactive chart to an interactive one.

### Interactive: plotly (https://plot.ly/r/)

Plotly provides two different methods for scatter plot. One is based on svg and the other is based on webgl. We can convert our svg chart to webgl with _toWebGL()_ function at anytime. Please, refer https://plot.ly/r/webgl-vs-svg/.


```R
# install.packages("babynames", repos="http://cran.r-project.org")

library(babynames)
nms <- filter(babynames, name %in% c("Sam", "Jamie"))
p <- ggplot(nms) + 
  geom_line(aes(year, prop, color = sex, linetype = name))
  
embed_notebook(ggplotly(p, dynamicTicks = TRUE) %>%
  rangeslider() %>%
  layout(hovermode = "x"))
```

The above code produces the time series how frequently "Sam" and "Jamie" are used as names for male and female.

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

The gist included in this article shows several cells how to customize plotly chart and how to highlight the data cross linked with sub plots.


Finally, the code below shows a heatmap with dendrogram thanks to _heatmaply_.

```R
library(heatmaply)
library(dplyr)

mtscaled <- as.matrix(scale(mtcars))
heatmaply(mtscaled, k_row = 3, k_col = 2) %>% embed_notebook(height="800")
```

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

{% gist https://gist.github.com/hkmoon/5635b995c3b6ee4417f124ad2c7b010c %} 

Happy coding!