teleren/devto huggingface dataset:
Automatic Deployment using Travis-CI
Tags: node, webdev, todayilearned
Published: 2019-11-21 00:44:22

I’ve been working on a NodeJS project over the last few months, and decided that I wanted to host it using Firebase and their, in my opinion, amazing suite of tools including Firebase Hosting, and Firebase Cloud Functions. 

There is plenty of [documentation](https://firebase.google.com/docs) in regards to getting started with these tools, but there was something, inconvenient, about my workflow: 

Write/edit code, push code to GitHub repository, then run the command:  `firebase deploy` , which publishes the associated directory to your Firebase app. 

This was a totally fine process, except that it sucked. Then I found a [Medium](https://medium.com/@bartwijnants/continuous-deployment-to-firebase-hosting-using-travis-ci-e7d9c798ead4) article about how to link your Firebase account to your Travis-CI account, and on every `git push`, you could automatically have Travis deploy your code. 

What I think is so important about this process, is that using an app like [Working Copy](https://apps.apple.com/us/app/working-copy-git-client/id896694807), or [Play.js](https://apps.apple.com/us/app/play-js-javascript-ide/id1423330822) you can (almost) completely develop a website or web app using something like an iPad Pro.

Finally! 

I don’t know, maybe you’re not as excited about this as I am, but I think it’s pretty cool 🤷🏼‍♂️.

P.s. Travis-CI can also deploy to other services! 
https://docs.travis-ci.com/user/deployment/
Day 38 : Late Night
Tags: hiphop, code, coding, lifelongdev
Published: 2019-11-21 00:11:31

_liner notes_:
- Professional : Got up early to sit in on a Talk prep session. Had a late night, so I took a nap afterwards. haha. Got back up and had a video call introduction with a team member. Really nice guy that lives in New York doing some cool work for the company. Then there was another quick Talk prep session. For the rest of the day, I worked on the admin section for my current application. Decided to scrap trying to add a user through the CLI tool I made and do it through the Client SDK. I tried to get too fancy. haha

- Personal : Going to continue going through tracks for this week's radio show. Spent some time creating a mockup for how I'd like things to be laid out on my side project. Now that I was able to get the main functionality working, time to make it look nice. haha

![Storm clouds and rainbows over the fields and mountains of Silverton Colorado Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6s068n17uv13fpaoatgd.jpg)

Going to work more on the admin section on my app and finish it up. Pretty close. I want to start working on the main frontend tomorrow. Also, my Google Stadia package is supposed to arrive. Time to get my professional gaming career started! haha

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube L0GYlT2fFHQ %}
Day10:Read CSV with csv crate - 100DayOfRust
Tags: rust
Published: 2019-11-21 00:07:43

In last article, I wrote how to read CSV file content, split fields from line, etc.

Instead of reading and processing CSV file manually, Rust has a `csv` crate can help us.

Let's bring back to our `examresult.csv`:

```
Alice, 90
Bob, 85
Chris, 92
Delan, 88
```

The goal is the same: we read the content, get the second column to calculate the total score and average score.

Let's create a project `cargo new csvreader`

Then add `csv` crate to the dependencies section:

```
[dependencies]
csv = "1.1"
```

Now let's code our `main.rs`:

```rust
fn read_csv() {
    let mut reader = csv::ReaderBuilder::new()
                        .has_headers(false)
                        .from_path("examresult.csv")
                        .expect("Cannot read fild");
    let mut total_score = 0;
    let mut total_count = 0;
    for record in reader.records() {
        total_score += record.unwrap()[1].trim().parse::<i32>().unwrap();
        total_count += 1;
    }   
    println!("Total score: {} Avg score: {}",
             total_score,
             (total_score as f32) / (total_count as f32));
}


fn main() {
    read_csv();
}
```

First we create a csv reader from the crate `ReaderBuilder` function and tell reader our CSV file doesn't have a header, such that our reader will not skip the first line.

Then we iterate `reader.records()`, record is a type of Result, and the unwrap type is `csv::string_record::StringRecord`, which we can index field by number like array or vector.

Run the code `cargo run`, we got:

```
Total score: 355 Avg score: 88.75
```

Click to see more information about the [csv crate](https://docs.rs/csv/1.1.1/csv/index.html).
How to send mail using mailable in laravel 6
Published: 2019-12-18 09:39:21

---
title: How to send mail using mailable in laravel 6
published: true
date: 2019-11-21 00:00:00 UTC
tags: 
canonical_url: 
---

Hi DevToday I want to give you example of how to send email using markdown mailable class in laravel 6 It is very easy to send mail with markdown good mail template design in laravel 6markdown mailable provide beutiful email layout by defualt in laravel 6 we can use their template desig
How to access your laptop from anywhere in the WORLD without portforwarding!
Tags: openssh, productivity, shell, linux
Published: 2019-11-20 23:48:19

### Just think how awesome it'd be if you come to your home and see your laptop or any other resource up and working the way you want it to be.

Well that'd be pretty sweet if I get home and see my Spotify playlist playing on my speaker, my laptop up and working and loaded with the ongoing projects with all its virtual environments already loaded.

....all at the end of running a single script.


#### So get this, I live in a hostel right with a public shared wifi which clearly does not allow me fiddling around with its router settings. Of course, why would they :/ 
My only solution to get my little thing done is to expose my local web server to the internet.
#### (safe?! heck yeah!!........eh, just a bit)

## So how the heck do you do it anyway?!
One word answer: **ngrok :)**

### Pre requisites needed:
> Connect bot for android : [download here]("https://play.google.com/store/apps/details?id=org.connectbot")

> openssh for your laptop : `sudo apt-get install openssh-server`

##### Firewall people please remember that since we're going to be using port 22 for our little automation. We're gonna need to keep port 22 open. Please use ``ufw or uncomplicated firewall`` to open the port with
```sudo ufw allow 22```

Now hop on the train once again when you're done,
Follow along and setup your ubuntu or whatever os you are using. I am personally writing this article on zorin os which again is an ubuntu derivative.


- Install ngrok from [here]("https://ngrok.com/download")
- Follow along every step till authenticating your token.
- FIRE IT UP!! with,

```
$ ./ngrok tcp 22

# now look for the line
Forwarding  tcp://0.tcp.ngrok.io:XXXXX -> localhost:22

# the only thing useful to you is 0.tcp.ngrok.io:XXXXX
# where XXXXX is your port number
```
##(Completely Optional)

#### Hit the terminal again
##### Make some aliases for easiness with
``alias ng="./ngrok tcp 22"``




Now open connect bot and make a host

> put ``user@0.tcp.ngrok.io:XXXXX`` in the very first line.

> you can keep post login automation commands but I would not recommend those for then just again a personal preference of mine of if I ever need to do something before running the automated command.

you should get connected now.

# FAQs
### Do I have to keep the command ``./ngrok tcp 22`` running?
 Yes, sadly. So does the have to be your laptop and the ssh service.

### Can't I Suspend my laptop?
 No, you may not. Since that would stop the ssh service and of course other services. You may make it go to sleep put it charge and hit your way to life.

### Do you and I have a very sad developer's life?
 Yes, very!!

### Will my port change every time I close the ngrok terminal?
 Yes. Just change port number on the connect bot.

## Thanks for Reading! ᕙ(⇀‸↼‶)ᕗ
Job Security in Startup-land
Tags: opinion, startup, career
Published: 2019-11-20 23:46:01

---
title: Job Security in Startup-land
published: true
cover_image: https://davejs.dev/static/edc1c73d073ca6a4bd0edd095ad947bb/b44bc/manifold-office.jpg
canonical_url: https://davejs.dev/career-stability-while-working-for-a-startup/
description: Why working for a startup is not be as risky as it might seem.
tags: opinion, startups, career
---

When I started my job at [Manifold](https://manifold.co), my parents warned me about taking a potentially unstable job. Leaving a stable job at [Cvent](https://cvent.com) to go work for a Series A startup seemed like a big risk.

I've worked at Manifold for almost a year now and in that time many people have asked me if I ever worry about losing my job. My response is always: Yes, but I don't really worry about that. Let me tell you why.

> Startup employees have the lowest job security in the tech industry.

For many people, taking a job at a startup is risky. Startups are notorious for having high turnover rates, and more often than not, they go out of business before becoming profitable. Startup employees have the lowest job security in the tech industry. But **job security isn't as important as you might think**, especially when compared with the experience that comes with working at a startup.

Instead of job security, I like to focus on career security. What's the difference? Job security is how likely you are to keep your current job. **Career security is how likely you are to find a new job.**

So what has working for a startup done for my career security? At Manifold, we're working on some of the toughest unsolved problems in the cloud software industry. Getting the chance to work on these problems has allowed me to refine and expand my skills far beyond the average frontend developer. **I get to work with cutting edge technologies** like Web Components and GraphQL on a daily basis. Beyond that, **I've been able to explore new skillsets**: agile coaching, interviewing, product and design, partnership management, and more.

> Working for a startup might be risky in the short-term, but it will lead to far more opportunities in the long-term.

These are all things that I would not have been exposed to this early in my career, or ever, working at a larger, more stable company. **Having had these experiences, I'm far more employable than the average frontend developer.** Working for a startup might be risky in the short-term, but it will lead to far more opportunities in the long-term.
facing depression as a beginner in software development
Tags: advice, depression, beginners, code
Published: 2019-11-20 23:20:15

This is my first post here. I decided to share some of the knowledge I earned through making every mistake you can possibly make as a beginner in software development, I will try as much as I can to cover all a beginner should never try while learning how to code, and how to get over depression if you are already making those mistakes.

1. Never compare yourself with others: One big mistake developers do while learning how to code is comparing their self with other developers, and this is the beginning of depression while learning to code and believe me nobody should tell you he/she learned how to code in 3 months and got a job as a developer(AKA dream world), we all learn at a different speed, the best way to calculate your progress is looking back to a year ago or 3 months ago when you started coding and check how much you know then and now, trust me you will have the zeal to continue coding.

2. Learning without practice: Trust me no matter how many Utube videos, Udemy course you view without practicing and am not talking about taking notes I mean real practice on your pc solve real problems and not monkey see, monkey do, you really need to practice because it only when you practice you will know how much you don't know and how much you need to know.

3. Jumping from one tutorial to the other: Trust me this is what killed 99.99% of my time while learning to code, I can remember how I keep jumping from one Utube video to the other am not saying Utube videos are bad but I see youtube videos as a helper when your stuck on a paid course like Udemy courses(udemy.com) maybe you still don't have a better understanding of what the instructor is teaching, then Utube video is the best option or read the language documentation

4. thinking you need to know it all: An experienced developer then once told me, Ït not all about how much you know, but how much you can do with what you know, Here I will use redux as an example we all know to set up redux template is a pain and learning to set it up writing all the code will actually take time, in this case you don't need to learn how to set it up but how it works and how it should be used eg, what is a reducer, it is called reducer but it just a store were you store all your app local data, learn all it terminology, after learning and having a good understanding of how it works, create a redux template upload it to your Github or any were so whenever you are working on a big application you can just pull it, it will save you the time of creating a store every single time you work.

5. Stop Learning frameworks: Yeah you need to stop learning frameworks until your sure you have a core understanding of the language if you don't do this before learning frameworks trust me you will find it difficult later in the future.

6. Show off: it won't be funny based on horrible replies you would get when you post your work on social media for other developers to see but don't feel bad but take it as an opportunity to learn more and excel as a developer.

Always believe you can.
Faster Than Requests with MultiThread Web Scraper
Tags: python
Published: 2019-11-20 22:15:52

---
title: Faster Than Requests with MultiThread Web Scraper
published: true
description: Faster Than Requests v0.9 with Multi-Thread Web Scraper Built-in
tags: python
cover_image: https://thepracticaldev.s3.amazonaws.com/i/h1lwwbwl1h4vul7si8h0.jpg
---

![](https://thepracticaldev.s3.amazonaws.com/i/tvucq4enrk03ccvubs6w.png)

- Alternative HTTP Client, new version `0.9`, API for Humans.
- Added Multi-Thread web scraper Built-in one-liner.
- Added Multi-Thread file downloader Built-in one-liner.
- 1 file, 0 dependency, ~100 Lines of code, `2.7` to `3.8`, Alpine & ARM.
- GitHub Actions CI building from scratch.
- GitHub Actions CI running Unittests from scratch.
- Examples for web scraper and file downloader.
- Extras for Data Science, Web Scrapping, HTTP REST JSON APIs.
- Examples, Dockerfile, tests, FAQ, CoC, Debug helpers, JSON helpers.
- Docs has all functions with detailed arguments and returns with types.

| Library                       | Speed    | Files | LOC  | Dependency       | Devs | Scraper |
|-------------------------------|----------|-------|------|-----------------------|------------|-----------------------------|
| PyWGET                        | `152.39` | 1     | 338  | Wget                  | >17        | No                          |
| Requests                      | `15.58`  | >20   | 2558 | >=7                   | >527       | No                          |
| Urllib                        |  `4.00`  | ???   | 1200 | 0(std lib)           | ???        | No                          |
| Urllib3                       |  `3.55`  | >40   | 5242 | >5(SSL) | >188       | No                          |
| PyCurl                        |  `0.75`  | >15   | 5932 | Curl,LibCurl         | >50        | No                          |
| FTR |  `0.45`  | 1     | 99   | 0                     | 1          | Yes, 2 |


![](http://feeds.feedburner.com/RecentCommitsToFaster-than-requestsmaster.1.gif)


# Hello World

```python
requests.get("http://httpbin.org/get")
```

- `GET`, `POST`, `PATCH`, `PUT`, `DELETE` and more.


# Multi-Thread Web Scraper Built-in

```python
requests.scrapper(["http://example.org", "http://example.io"], threads=True)
```

- Theres 2 ready-made Web Scrapers built-in, easy to use one-liner.


# Multi-Thread File Downloader Built-in

```python
requests.download2([("http://example.org/foo.jpg", "output.jpg"), ], threads=True)
```

- `delay=1000` for 1 Second delay sleep between downloads.


# Multi-Thread Bulk GET

```python
requests.get2str2(["http://example.org", "http://example.io"], threads=True)
```

- `threads=False` for No Multi-Thread.


# GitHub

- https://github.com/juancarlospaco/faster-than-requests#faster-than-requests

🐍😼👍
AWS protect SSRF vulnerabilities with new EC2 Instance Metadata feature
Tags: aws, security, ssrf
Published: 2019-11-20 21:39:50

After the annonce on the AWS Security blog for protecting AWS instance from SSRF attack, we should test and implement this new security feature: https://aws.amazon.com/fr/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service/

AWS documentation about this feature : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#configuring-instance-metadata-options

There is 2 methods in order to use it :
- Add a policy to your users/geoups with this example policy :
```
{
	"Version": "2012-10-17",
	"Statement": [{
		"Sid": "RunInstanceWithImdsV2Only",
		"Effect": "Allow",
		"Action": "ec2:RunInstances",
		"Resource": "*",
		"Condition": {
			"StringEquals": {
				"ec2:MetadataHttpTokens": "required"
			}
		}
	}]
}
```
- Modify a running instance metadata :
```aws ec2 modify-instance-metadata-options --instance-id i-1234567898abcdef0 --http-token required```


*We need to enforce this best practice if possible by design using AWS Organization SCP.*

Here a first try for a policy to Enforce EC2 Metadata Token :
```
{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "EnforceEC2metadataTOKEN",
			"Effect": "Deny",
			"Action": "ec2:RunInstances",
			"Resource": [
				"*"
			],
			"Condition": {
				"StringNotEquals": {
					"ec2:MetadataHttpTokens": "required"
				}
			}
		}
	]
}
```

Seems working for me, I need to try more when Terraform or CDK will implement the  feature to completely validate:
- https://github.com/aws/aws-cdk/issues/5137
- https://github.com/terraform-providers/terraform-provider-aws/issues/10949


[@ejcx_](https://twitter.com/ejcx_) wrote an article about this feature with a incomplete satisfaction, here why with explanation: https://ejj.io/blog/fixing-capital-one
Which Single Resource Has Most Affected How You Code?
Tags: discuss
Published: 2019-11-20 21:37:01

There are so many programming resources available. With that said, is there a single one that had the biggest effect on your code?

For me, it would be [Practical Refactoring by Llewellyn Falco and Woody Zuill](https://www.youtube.com/watch?v=aWiwDdx_rdo).

{% youtube aWiwDdx_rdo %}

On the face of it, this video should be extremely dry -- it's literally just a couple of guys refactoring code for two hours. In spite of that, those  two hours shook me to my legacy-coding core. Refactoring has since become vital to my work and (dare I say it) fun!

So how about you? Be it book, blog, video, or whatever -- which single resource has most affected how you code?
How to structure API for creating content with parent/child relationship?
Tags: help, api
Published: 2019-11-20 21:30:20

---
title: How to structure API for creating content with parent/child relationship?
published: true
description: How to structure API for creating content with parent/child relationship?
tags: help, api
---

I need some advice on deciding which endpoint to use in order to create an article and have that article be assigned to a publication.

Say I have two API endpoints:
1. /v1/publications
2. /v1/articles

If I want to create a new article and have it automatically assigned to a publication, should I:

1. Make the call to <code>POST /v1/publications/article</code> and have that endpoint create the new article as well as its assignment to the specified publication or
2. Make the call to <code>POST /v1/articles</code> to create the new article and have that endpoint assign the new article to the publication

Ex:
```javascript
Publications.createArticle(publicationId);
// creates a new article
// publication id is required and auto assigns the new article to publication id
```
vs.
```javascript
Articles.create(publicationId);
// Creates a new article
// publication id is optional. If it exists, assign it to the publication
// If it does not exist, just create the article
```
Flask Web App on Raspberry Pi Using Docker
Tags: help
Published: 2019-11-20 21:15:52

I hope this question is not to broad. If so I apologize. I would just like some opinions and input, and I have been struggling to find anything relevant elsewhere. Please feel free to correct me if my question does not make sense or I have issue with the terminology etc. I am quite new to all of this.

I want to to deploy my first attempt at a Flask web application. I have Raspberry Pi at home running Pi-Hole and PiVPN on Raspbian Lite, on which I would also like to run my web server. I wonder if there is any advantage of running the web server on a Docker container on the RPi?

Can / should Docker run along-side Pi-Hole and PiVPN on the RPi, and if so what kind of docker image / web server is it recommended that I use? Or should I skip using Docker and just deploy the Flask application and its requirements directly on Raspbian with Pi-Hole and PiVPN.?