teleren/devto huggingface dataset:
Strongly-typed consuming of public API
Tags: typescript, node, restapi
Published: 2020-07-25 13:27:05

I know it can be done in TypeScript + Node.js. Not sure about other programming languages (most common case seems to be Python?), or even Deno.

If you can get your hand on `openapi.json` (e.g. `/v1/openapi.json`), it is as simple as this post.

{% post https://dev.to/unhurried/typescript-rest-api-client-4in3 %}

However, there is no `openapi` file, I prefer to write [TypeScript interfaces with generic, and `AxiosInstance`](https://github.com/patarapolw/wk-extra/blob/master/packages/scripts/src/wk/wanikani.ts); when the API is getting complex.

```ts
import axios, { AxiosInstance } from 'axios'
import rateLimit from 'axios-rate-limit'

export const api = rateLimit(
  axios.create({
    baseURL: process.env.API_BASE_URL,
    headers: {
      Authorization: `Bearer ${process.env.API_KEY}`,
    },
  }),
  /**
   * Requests per minute 60
   */
  {
    /**
     * Per second
     */
    maxRequests: 1,
    perMilliseconds: 1000,
  }
) as AxiosInstance
```

Another important aspect is getting rate limited. Sending simultaneous 1000 API requests, and you will get a 429, Rate limit exceeded.

```ts
await Promise.all(
  Array.from({ length: 1000 }).map((_, i) => api.post(`/${i}`, { i }))
)
```

So, what are other techniques you have tried, and possibly in other programming languages?
Global up-to-date packages or local pinned dependencies?
Tags: discuss, healthydebate, node
Published: 2020-07-25 14:05:21

What do you think is better, and when?

If it is global in your PC, how do you allow contributors? How do you manage global with local exceptions?

If it is local in your repo, how do you keep up with sizes (especially, multiple copies of `node_modules` with multiple copies of `eslint`)?

Now, I think about it, what about multiple version of the same package in global (e.g. Nuxt needs TypeScript ~3.8, but in general, you want to use @latest (^3.9))
Creating a Webflow <-> dev.to <-> GitHub cross-post integration tool 🚀
Tags: discuss, help
Published: 2020-07-25 13:51:26

# Webflow Blog Integration

Ease the creation of webflow blog posts for developers and cross
posting across different channels.

## We are testing 🔭 🧪 🔬

I'm sorry you are seeing that because you shouldn't see this top-secret creation! With a bit of patience, you will have your integration at your fingertips soon ;)

This test document is used to check the rendering on the different platforms. If you are seeing it, we most likely pushed it somewhere public
by mistake 😬 Fail hard, fail fast, but fail!

## Overview

Have the source of truth in your own space at **webflow**. Then automate or make
it easier to cross-post at:

## lists

* dev.to
* Medium
* codementor

1. Minimal
2. Viable
3. Product

```javascript
function go() {
  console.log('this is awezzzommme');
}
go();
```

And of course, the `inline code` is not different.

We will manage it, though!

> Sigue, insist, persist!

It's not a coincidence that we are [Egg Laying Wool Milk Pigs](https://fullstack.coach/post/what-is-a-full-stack-developer-or-how-to-become-an-egg-laying-wool-milk-pig)!

![Eierlegendewollmilchsau by Claire Adele](https://uploads-ssl.webflow.com/5ea830d684c5067b65e3cef4/5ee2543a19eb834da989837a_fpAh6_ClAjFU2GRv5ccwVZKPmHK5vs1Cggn78r_Gz898kv6zsV5--sdnVIATtN5la92fWAC4Dv5eZkheCGrKSOx7qiQ-5piHqNx-GaFYJDQLT1N5WHQhXYKIcD5eQNkufafsdslj.png)
Deploying React App With Router On Netlify
Tags: webdev, react, html, beginners
Published: 2020-07-25 13:46:58

Netlify has made it easy to deploy react projects for free, amazing right?. 
When I first tried to deploy an app with a router I came across a slight obstacle, this was an easily solved issue but at that moment, it was a little hard for me to get through it. 
This article is to help the next newbie that might come across such issues.

The solution to getting your routing to work on Netlify lies in one file, the netlify.toml file. This is the netlify configuration file, for mor information on this check [here](https://docs.netlify.com/configure-builds/file-based-configuration/).

All you have to do is create a netlify.toml file in your root folder and inside the file include this code:

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

This will catch all the redirects and your React app should work just fine. 

You can run npm build and manually upload your files or link it to your GitHub/Gitlab/Bithub repository and netlify will handle the continuous integration for your app(i.e all new changes pushed to your repository will be reflected online without you having to rebuild the app)

I hope this article helps someone and if you have any inquiries or questions you can leave a comment, thank you.
Convert a Dataframe into a pretty HTML table and send it over Email
Tags: python, devops, html
Published: 2020-07-25 13:39:34

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pi9y6kim6yz1c9ficsdi.jpg)
My first post in dev.to.
I have learnt how to automate the creation of nice html tables using [pretty-html-table](https://pypi.org/project/pretty-html-table/) package. This package is embedding very nicely with other packages used to send emails.
In this post I am going to cover:
1. Sending Email using SMTP
2. Convert pandas dataframe to pretty HTML table
3. Sending the email with HTML content

### <u>Setup SMTP to send Email</u>
Python comes with the built-in smtplib module for sending emails using the Simple Mail Transfer Protocol (SMTP). I have used Gmail SMTP server to send emails, but the same principles apply to other email services. Google’s Gmail SMTP server is a free SMTP service which anyone who has a Gmail account can use to send emails.
* Gmail SMTP server address: smtp.gmail.com
* Gmail SMTP username: Your Gmail address
* Gmail SMTP password: Your Gmail password (Unique 12 letter password). [Click here to set your password](https://myaccount.google.com/apppasswords)
* Gmail SMTP port (TLS): 587
```
from smtplib import SMTP
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart


def send_mail(body):

    message = MIMEMultipart()
    message['Subject'] = 'Top 5 Economies of the World!'
    message['From'] = '<sender>@gmail.com'
    message['To'] = '<receiver>@gmail.com'

    body_content = body
    message.attach(MIMEText(body_content, "html"))
    msg_body = message.as_string()

    server = SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(message['From'], 'Unique password')
    server.sendmail(message['From'], message['To'], msg_body)
    server.quit()
```
### <u>Create a Dataframe</u>
```
import pandas as pd


def get_gdp_data():
    """
    GDP data
    :return:
    """
    gdp_dict = {'Country': ['United States', 'China', 'Japan', 'Germany', 'India'],
                'GDP': ['$21.44 trillion', '$14.14 trillion', '$5.15 trillion', '$3.86 trillion', '$2.94 trillion']}
    data = pd.DataFrame(gdp_dict)
    return data
```
### <u>Convert pandas dataframe to HTML table</u>
Pretty HTML table package integrates very well with other python packages used to send emails. Just add the result of this package to the body of the email.
```
from send_email import send_mail
from get_data import get_gdp_data
from pretty_html_table import build_table


def send_country_list():
    gdp_data = get_gdp_data()
    output = build_table(gdp_data, 'blue_light')
    send_mail(output)
    return "Mail sent successfully."


send_country_list()
```
Done!
Octocat will take you to my GitHub repository...
[![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9vq4d02xo1f1m7jwi8gh.png)](https://github.com/siddheshshankar/pyHTML)
One life - one career?
Tags: career, codenewbie, testing, beginners
Published: 2020-07-25 02:20:50

  In today's era of information and extremely fleeting lives, the change of profession is no longer strange to anyone. It also happened to me. After 15 years of office management career growth in different fields, I found something that can keep my attention for hours long, and I enjoy doing more than anything else - testing the software and coding. Can you imagine?
  I was a little sad that I did not know about it before, but wait, maybe I did?
  Back in college, I was the best student in my informatics class, and I loved informatics even though we worked with MS-DOS 6.22 OS without a mouse using keyboard commands and coursing buttons for navigation...Yes, that's how old I am :) 
  My college taught remembers me and, when sees by my mother, keeps asking if I succeeded as a programmer. I am just smiling instead of explaining how long it might take to go back to the institute to get my secondary education. I don't have that time credit anymore. I used it all when I was 18 when my parents fully hosted me and did not realize yet what I want to do in my life. 
  Luckily our World improved significantly.
I am so happy that today I can use the full benefit of today's education digitalization and get an excellent education from the best teachers and constant live practice without even leaving my house. 
I am glad to see that companies are becoming more "talent-oriented" and launching different apprenticeship opportunities for people like me. 
I am pleased to see professionals who made a fantastic career, becoming mentors, and helping those who are just starting it and always ready to share their career pathway. 
 After a whole year of self-educating and taking different training courses, boot camps, and internships, I am one hundred percent confident to announce that I am ready for a new project and will be happy to join the friendly team with whom I could learn and grow professionally. 
I feel like a new journey is about to begin, and I am thrilled to share my steps and resources with folks in the same shoes as me.
How manage your Repos?
Tags: discuss, github
Published: 2020-07-25 13:26:57

![Repo Sprawl](https://dev-to-uploads.s3.amazonaws.com/i/evhkfy9ch9lum5m043i2.png)

I find myself using GitHub for much more than source code.  Lately, when I start a new project - any project, I create a new GitHub Repo.

Now I am thinking ways to combat my new problem: Repo sprawl.

1) Implement repo naming conventions
2) Include repo metadata - description, URL, taggs
3) Build for repo indexing - use common folder structure/names
4) Use rich README.md files at multiple levels in each Repo

What about you?  Do you face this issue?  What do you do to address it?
Bash script for regular CodeForces participants
Published: 2020-07-25 13:25:09

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5n54sp4kn1tr9w4s6o4c.png)
Soon after I started regularly participating in CF rounds, I noticed I was creating a folder with files named A, B, C and typing the same python template before each contest.

So I decided to automate this process, created the bash script takes the round name as input and creates a folder with that same name, create 3 files (A.py, B.py, C.py) and copies a fixed template to each one of them and opens this folder in VSCode. Sure you can change anything to everything in this script, add your C++ script or open the folder with your prefered editor!

Find my bash script [here](https://gist.github.com/jai-dewani/bfad17e728bf90ba75ab0d6246ac1cf5). There are so many more things that can be done, so I am sharing this with everyone and hoping to see your own versions of it too :)
Deploy AWS Lambda right from Your IDE
Tags: aws, lambda, intellij, plugin
Published: 2020-07-25 13:23:45

---
title: Deploy AWS Lambda right from Your IDE
published: true
description: Release a plugin that lets you deploy AWS lambda right from your IDE (JetBrains)
tags: aws, lambda, intellij, plugin
cover_image: https://miro.medium.com/max/1400/1*5yHkTd49VTahkg__kttAdA.png
canonical_url: https://www.therdnotes.com/projects/aws-lambda-deployer
---

Leveraging AWS Lambdas for coding microservices or better say utility functions over API, for different projects has been my go-to option.

but deploying them after making changes is a bit brain tiring loop.

therefore i developed a plugin for JetBrains IDEs which includes Intellij IDEA, GoLand, PyCharm and many others.


### Old routine 🤕, dealing with lambda

```
Open IntelliJ
 ↳Write code (AWS Lambda)
 ↳ Build artifacts
 ↳ Switch from IDE to browser
 ↳ Head to AWS Console and sign in (One time step)
 ↳ Open AWS Lambda or AWS S3 web page in console
 ↳ Browse to file/folder to upload your artifact to cloud and hit save
 ↳ If deploying more than one lambda artifact
 ↳ Open another tab, open AWS console, browse artifact and hit save
 ↳ Repeat last two steps for all lambdas to be deployed
 ↳ Switch back to IDE
 ↳ Continue coding
<Repeat till EOD>
```

### New routine 🤩

```
Open IntelliJ
 ↳ Write code (AWS Lambda)
 ↳ Build artifact
 ↳ Deploy directly from IntelliJ IDE
<Repeat till EOD>
```

### Bonus 🎄
This plugin also helps in case you are deal with multiple AWS Named Profiles or AWS Organization


### Demo
YouTube: {% youtube FgwptHeace4 %}

### Plugin Link
https://plugins.jetbrains.com/plugin/14742-aws-lambda-deployer

Originally posted on [theRDnotes.com](https://www.therdnotes.com/projects/aws-lambda-deployer)

---

Follow me on [twitter](https://twitter.com/raevilman) 🎉, i generally post about different projects i am coding and their journey of development
Why are you afraid of DevOps?
Tags: discuss, devops, webdev
Published: 2020-07-25 13:18:42

Many developers I know are intimidated when they hear the phrase "DevOps". Docker, Kubernetes, clusters, bash scripts, cloud, and others can make them take a step back and get all insecure. I personally find DevOps super interesting, exciting, and attractive. Modern front-end development can be also very complex but still many devs are facing this challenge.

Why do you think devs are "afraid" of DevOps?
Lack of public knowledge?
Prejudice?
Anything else?
Parallel Testing - Selenium Standalone Service | WebdriverIO
Tags: testing, javascript, tutorial, webdev
Published: 2020-07-25 13:17:58

WebdriverIO supports parallel testing out of the box when you run your tests. For example: if you have 3 spec files and you run your tests, it'll open up 3 separate chrome windows and each spec file will run on its own window. This reduces test run time significantly and allows you to get quicker test feedback. 

You can also run tests in parallel when running tests on multiple browsers, this can be done easily using [Selenium Standalone Service](https://webdriver.io/docs/selenium-standalone-service.html). The advantage of using this service is that you don't need any other driver services as it has the support for the following drivers:
* ChromeDriver
* FirefoxDriver
* IEDriver
* Edge WebDriver

#### Installation 
`npm install @wdio/selenium-standalone-service --save-dev`

#### Configuration 
Make the following changes in `wdio.conf.js`
```javascript
  // add selenium-standalone in services 
  services: ['selenium-standalone'],

  // add the necessary browsers
  capabilities: [
    {
      browserName: 'chrome',
    },
    {
      browserName: 'firefox',
    },
    {
      browserName: 'internet explorer',
    },
  ],
```

That's all you need to run your tests parallel in multiple browsers. 🙌 

***
#### Check out this video to see a detailed explanation on how to run tests parallel in multiple browsers:

{% youtube HTY4nug83As %}

***

#### To learn more about WebdriverIO, check out my free tutorial series here - 
https://www.youtube.com/watch?v=e8goAKb6CC0&list=PL6AdzyjjD5HBbt9amjf3wIVMaobb28ZYN.

***

I hope this post helped you out, let me know in the comments below! 

Happy testing! 😄 

...

Follow [@automationbro](https://twitter.com/automationbro) on Twitter
Subscribe to my [YouTube](https://www.youtube.com/channel/UCjugV5pnY6WjvTGYm7U1ucg?sub_confirmation=1) channel
Published my first flutter package
Tags: flutter, dart, android, ios
Published: 2020-07-25 12:55:08

Hello developers, Today I have published my first flutter package **flutter_insta** to [pub.dev](https://pub.dev).


Using this plugin you can get details of the Instagram user.

# How to Use ?

**LINK : https://pub.dev/packages/flutter_insta**

First add in dependency
```dart
dependencies:
  flutter_insta: ^0.0.6
```

You can install packages from the command line:
```dart
$ flutter pub get
```

Import it 
```dart 
import 'package:flutter_insta/flutter_insta.dart';
```

Now you have to create object of FlutterInsta class 
```dart
FlutterInsta flutterInsta = new FlutterInsta("coding_boy_");
```
and inside constructor pass the username.

Now you can get all details like this

```dart
print("Username : ${flutterInsta.username}");
print("Followers : ${flutterInsta.followers}");
print("Folowing : ${flutterInsta.following}");
print("Bio : ${flutterInsta.bio}");
print("Website : ${flutterInsta.website}");
print("Profile Image : ${flutterInsta.imgurl}");
```

Thanks for reading :) , if you found it useful then please like the plugin and give your valuable feedback.
Add Haml validation to CI/CD
Tags: haml, devops, rails
Published: 2020-07-25 12:48:02


#### TL;DR

Add this to your `.gitlab-ci.yml` or whatever CI/CD system you are using.

```bash
find . -name "*.haml" -type f -print0 | xargs -0L1 sh -c \
  'for arg do echo -n "$arg .. "; haml --check "$arg"; done' _
```

#### Explanation

Use `find` to find all `.haml` files in current directory recursively. Pass paths of find files to `xargs`. Use `\0` symbol as file delimiter. For each file, run `sh` command. In `sh` command print path of the file and run `haml --check` on it.

`find` is necessary, because `haml` utility is unable to search for files on its own. `xargs` is needed, because [`find` can not detect if executed program failed](https://stackoverflow.com/questions/14871147/how-to-exit-from-find-exec-if-it-fails-on-one-of-the-files). `sh` is needed, because [`haml` can not report the filename being checked](https://github.com/haml/haml/issues/1035).

#### Credits

* https://stackoverflow.com/questions/14871147/how-to-exit-from-find-exec-if-it-fails-on-one-of-the-files
* https://stackoverflow.com/questions/6958689/running-multiple-commands-with-xargs
Grabbing version strings with PowerShell
Tags: java, powershell, regex, windows
Published: 2020-07-25 12:42:31

The `jpackage` tool, which is part of OpenJDK since Java 14, can create, well, native packages. Some time ago I wrote a small piece about it, called [A quick look at jpackage](https://dev.to/tkuenneth/a-quick-look-at-jpackage-lli). In that article I showed how to grab a version string from a Java source file and pass it to `jpackage` which has an option called `--app-version`. This is how the version is defined in Java:

```Java
public class Clip4Moni {

  public static final String VERSION = "1.3.3";

  public static void main(String[] args) {
```

And grabbing it might look like this:

```bash
VERSION=`sed -n -e 's/.*VERSION = \"\(.*\)\".*/\1/p' < $BASEDIR/src/main/classes/com/thomaskuenneth/clip4moni/Clip4Moni.java`
$JAVA_HOME/bin/jpackage --name Clip4Moni --icon $BASEDIR/artwork/Clip4Moni.icns --app-version $VERSION --type app-image --module-path $BASEDIR/build/modules -m main/com.thomaskuenneth.clip4moni.Clip4Moni
```
As you can see I am using the `sed` commandline tool. This was designed for macOS but should run on any other Unix-like system. But what about Windows? Windows has the ancient (no offense intended) `cmd.exe` and the much much more modern PowerShell. PowerShell has a lot of great builtin capabilities, and handling regular expressions is among them. So it should be easy to do something similar, right? Right.

```PowerShell
$version = "???"
$source = Get-Content -Path $base_dir\src\main\classes\com\thomaskuenneth\clip4moni\Clip4Moni.java
foreach($line in $source) {
    if ($line -match "version = `"(.+)`"") {
        $version = $matches[1]
        break
    }
}
```
The version string will be stored in a variable called `$version`. I initialize it to `???`, just in case... `Get-Content` gets the contents of the source file. As you surely have guessed it is an array of strings. I iterate over it until my regular expression matches. `(.+)` is a group, which can later be accessed through `$matches[1]`. `break` exits the `foreach` loop.

Well, and that's all about it. Really nice, isn't it?

---
Cover image Copyright (c) Thomas Künneth
Announcing the Structurizr diagram review tool
Tags: architecture, productivity
Published: 2020-07-25 12:27:41

---
title: Announcing the Structurizr diagram review tool
published: true
description: 
tags: #architecture #productivity
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/a80g1thlu3u78bdytkw7.png
---

Prior to the COVID-19 pandemic, I'd been running my software architecture diagramming workshops at organisations all around the world. With many offices closed, that's all been suspended temporarily, although a number of organisations have adopted my [online workshop](https://architectis.je/#training-c4model-online) instead. Part of the workshop involves reviewing some diagrams, which is easy to do in-person (sticky notes work great on a whiteboard or flip chart paper), but reviewing diagrams online/remotely isn't as straightforward. Collaboration tools like Miro and Mural are an option (I've used them myself), but I wanted something a little more dedicated to my use case. So I built some tooling. 👨‍💻

Structurizr's new [diagram review feature](https://structurizr.com/help/diagram-review) allows you to package up one or more diagrams for review by other people. It's designed to offer a quick and lightweight immutable review process, so there's no support for "resolving" comments, or having threaded discussions, for example. It's ideal for a quick general diagram review, or when you want to run a remote [risk-storming](https://riskstorming.com) session. The review feature can be used with diagrams from an existing Structurizr workspace, or any other PNG/JPG files (as illustrated below).

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

The minimal UI lets you add comments to a diagram, and submit them once you're done. Reviews with a single diagram are free to create after signing up for a Structurizr account, although reviewers don't need an account to leave comments. Structurizr users with premium accounts can create reviews that contain multiple diagrams. See [Structurizr - Help - Diagram review](https://structurizr.com/help/diagram-review) for more details, and there's also a [demo review](https://structurizr.com/review/f722bf0c-1e52-4ef0-bcb1-9fc2f1612cf4).

I hope you find it useful!
Daily Developer Jokes - Saturday, Jul 25, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-07-25 12:00:05

---
title: "Daily Developer Jokes - Saturday, Jul 25, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Saturday%2C%20Jul%2025%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258d992c4e.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ How do programming pirates pass method parameters?

___A:___ Varrrrarrrgs.
 -->