teleren/devto huggingface dataset:
Learning Python Networking
Tags: python, security, networking
Published: 2019-03-30 19:06:08

---
title: Learning Python Networking
published: true
description: Learning Python Networking
tags: python,security,networking
---

https://www.packtpub.com/networking-and-servers/learning-python-networking-second-edition

![python](https://i.imgur.com/JtYW9ld.png)

https://github.com/PacktPublishing/Learning-Python-Networking-Second-Edition

Network programming has always been a demanding task. With full-featured and well-documented libraries all the way up the stack, Python makes network programming the enjoyable experience it should be.

Starting with a walk through of today's major networking protocols, through this book, you'll learn how to employ Python for network programming, how to request and retrieve web resources, and how to extract data in major formats over the web. You will utilize Python for emailing using different protocols, and you'll interact with remote systems and IP and DNS networking. You will cover the connection of networking devices and configuration using Python 3.7, along with cloud-based network management tasks using Python.

As the book progresses, socket programming will be covered, followed by how to design servers, and the pros and cons of multithreaded and event-driven architectures. You'll develop practical clientside applications, including web API clients, email clients, SSH, and FTP. These applications will also be implemented through existing web application frameworks.

What You Will Learn

Execute Python modules on networking tools
Automate tasks regarding the analysis and extraction of information from a network
Get to grips with asynchronous programming modules available in Python
Get to grips with IP address manipulation modules using Python programming
Understand the main frameworks available in Python that are focused on web application
Manipulate IP addresses and perform CIDR calculations
Labs Week 1: A Review
Tags: lambdaschool
Published: 2019-03-29 18:05:02

---
title: Labs Week 1: A Review
published: true
description: Brief review of Lambda Labs week 1
tags: Lambda School
---

As we complete the first week of Labs at Lambda School there is quite a bit to reflect on. As a team we planned out our project in the product canvas document and got both the front end and back end up and running.

During the first week I setup an AWS account and created a MySQL database running. Used MySQLWorkbench to build out the tables needed along with the foreign keys that it required. While I did spend most of my time troubleshooting AWS connection and table issues I was able to contribute to the front end. Once we had Auth0 setup I added the ability to logout via the profile page. For both the front end and back end I setup some of the environment variables that would be needed and setup the necessary variables on Heroku and Netlify to simplify deployment between local and web.

---

The ticket that i worked on the most this week was the setup of the database on AWS. Having never worked with AWS or MySQL, it was a great experience and would use it again. The following is a brief view of the MySQLWorkbench of the database.

![alt text](https://thepracticaldev.s3.amazonaws.com/i/eiucy2x8vq0p2br0tagl.png
 "Database Tables")


Some of the issues I ran into early on was that i could access the database but nobody else on the team could through the workbench and we couldn't access it via the codebase. After doing research on the issue I realized it was a permission issue on what IP's were allowed to connect to the database. After digging through the AWS settings I was able to open it up to allow the other members to access it as well as the codebase.

Once the database was open this allowed the project to really start moving with seeding data and writing out components to display the data through API endpoints.

---

Our team as a whole did a great job with research and writing the project specification. I personally helped find a competitor (https://www.cronote.com/) and assisted with the writing of the epics/features and the user stories that go along with them. The biggest contribution was researching and investigation the database we would eventually use. We knew how to use SQLite and Postgres from previous projects at Lambda. I personally wanted to go outside of our comfort zone and use an industry tool like AWS to build our application on.

![alt text](https://thepracticaldev.s3.amazonaws.com/i/ybbgqjp6udguaur6tzep.png "AWS Monitor")
To New Experiences
Published: 2019-03-30 18:54:11

---
title: To New Experiences
published: true
description: 
tags: 
---

I've worked for too long in isolation and would like to make more industry contacts. I made a new years resolution to fix that this year. 

This is why I have signed up for the HNG Internship 5 program to see what new opportunities open up.

Fingers crossed.
Javascript This Keyword
Tags: javascript
Published: 2019-03-30 18:24:16

---
title: Javascript This Keyword
published: true
description: Javascript this keyword is confusing for a lot of people. In this tutorial I'll show how "this" keyword in Javascript works in global scope, in regular functions, in object methods and in ES6 arrow functions
tags: javascript
series: Javascript for beginners
---

Javascript this keyword is confusing for a lot of people. In this tutorial I'll show how "this" keyword in Javascript works in global scope, in regular functions, in object methods and in ES6 arrow functions

[Originally posted on youtube](https://www.youtube.com/watch?v=h-pE4C4cXZ8)
You've been doing mapDispatchToProps wrong this entire time
Tags: react, redux, javascript, mapdispatchtoprops
Published: 2019-03-30 18:08:34

---
title: You've been doing mapDispatchToProps wrong this entire time
published: true
description: mapDispatchToProps should be an object and not a function.
tags: react, redux, javascript, mapDispatchToProps
---

Do this:

```js
const mapDispatchToProps = {
  decrement: () => ({ type: "DECREMENT" }),
  increment: () => ({ type: "INCREMENT" })
};

```

instead of this:

```js
const mapDispatchToProps = dispatch => {
  return {
    decrement: () => dispatch({ type: "DECREMENT" }),
    increment: () => dispatch({ type: "INCREMENT" })
  };
};
```

The difference is that we rely on react-redux to inject dispatch on each value that is a function in our mapDispatchToProps object, rather than relying on react-redux to inject dispatch into our mapDispatchToProps function.

If you are not effectively testing your code, then this is an easy way to increase code coverage, but it will also prevent bugs, because then you don't have to worry about forwarding extra arguments.

For a working example on github, see this repo: https://github.com/mcrowder65/map-dispatch-to-props
ClamAV: Fixing freshclam's Hanging Up
Tags: clamav, freshclam, troubleshooting, security
Published: 2019-03-30 18:03:56

---
title: ClamAV: Fixing freshclam's Hanging Up
published: true
description: This post is about a small tip of ClamAV, actually ClamAV Unofficial Sigs in my case, troubleshooting. I found freshclam freezed up in my OpenBSD server the other day. Waiting or retrying didn't make any meaning. The reason is often in the database file.
tags: clamav, freshclam, troubleshooting, security
---

This post is about a small tip of [ClamAV](https://www.clamav.net/), actually [ClamAV Unofficial Sigs](https://github.com/extremeshok/clamav-unofficial-sigs) in my case, troubleshooting.

I found [`freshclam`](https://www.clamav.net/documents/signature-testing-and-management#freshclam) freezed up in my [OpenBSD](https://www.openbsd.org/) server the other day:

```shell-session
# freshclam
ClamAV update process started at Fri Mar 22 22:32:33 2019
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.100.2 Recommended version: 0.101.1
DON'T PANIC! Read https://www.clamav.net/documents/upgrading-clamav
main.cvd is up to date (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
Downloading daily-25378.cdiff [100%]
Downloading daily-25379.cdiff [100%]
Downloading daily-25380.cdiff [100%]

```

Waiting or retrying didn't make any meaning. 

The reason often seems in the database file.
Try to renew it by moving the original file to `/tmp`:

```shell-session
# # OpenBSD:
# mv /var/db/clamav/daily.cld /tmp
# # Manjaro Linux:
# mv /var/lib/clamav/daily.cld /tmp
```

*Note: The directory is up to your operating system.*

Run `freshclam` and check if it works well:

```shell-session
# freshclam
ClamAV update process started at Sat Mar 23 00:28:30 2019
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.100.2 Recommended version: 0.101.1
DON'T PANIC! Read https://www.clamav.net/documents/upgrading-clamav
main.cvd is up to date (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
Downloading daily.cvd [100%]
daily.cvd updated (version: 25396, sigs: 1528057, f-level: 63, builder: raynman)
bytecode.cvd is up to date (version: 328, sigs: 94, f-level: 63, builder: neo)
Database updated (6094400 signatures) from database.clamav.net (IP: xxx.xxx.xxx.xxx)
```

If it's all right, delete the old file:

```shell-session
# rm /tmp/daily.cld
```

I'm happy if this solution would help someone someday : )
Happy securing.
Adding Google reCAPTCHA v3 to your Laravel App
Tags: laravel, php, tutorial, recaptcha
Published: 2019-03-30 17:40:54

Hi There. I want to share with you, how I implemented Google’s reCAPTCHA v3 in my Laravel app.

Securing HTML forms from bots is an essential part of the security of any web app these days. One common and easy solution to this is implementing a captcha system. And Google’s reCAPTCHA v3 makes it quite easy to both implement as a developer and use as a user (with v3 users do not have to select images to verify).

Let's get started.

> Check out [LaravelCollections.com](https://laravelcollections.com/?utm_campaign=captcha-article) - a growing collection of great Laravel resources

### Registering a new Site
First off, we need to register our site in [Google reCAPTCHA Admin](https://www.google.com/recaptcha/admin) and gain usage keys. When you add your site, also add `localhost` in the list of domains, this will allow you to use the same key for development.

![Google reCAPTCHA admin console](https://i.imgur.com/18mCTiS.png)

Once you submit these details, you should see two keys generated for your domain. One is the `SITE KEY` which is used in the front end and the other is the `SECRET KEY` for usage in the server.

### Frontend Setup
Front end setup is pretty simple. Choose the page you want to implement reCAPTCHA, in my case I have a contact form on a page.

Below code shows a contact form with a hidden input named `recaptcha` (it can be any name). Then at the end of that page add the reCAPTCHA's JS library and once it's ready we get a token and set it to the `recaptcha` input.

![Frontend setup](https://i.imgur.com/cPPlmWX.png)

### Backend Setup

![Backend Setup](https://i.imgur.com/bw8FGvx.png)

The above code checks if the current request is from a bot. We do this by sending a post request to Google reCAPTCHA API with the `SECRET KEY` and the `TOKEN` from the frontend.

Resulting JSON has a property `success`that is set to false when Google detects a request from a bot. Below is an example of what is returned.

![JSON from Google Api](https://i.imgur.com/VME4rmf.png)

### Optimizing the Setup
Here's a list of optimizations you could do to the above setup.

 1. Move the configuration keys to the `.env` file
 2. Move the verification logic to a custom validator.

Both of which are covered in the tutorial linked below.

### Conclusion

There you have it. It's pretty simple to add Google's reCAPTCHA to your app. I would suggest you add this to all pages that can be visited by a bot.
If you have any doubts do leave them below, I will try to help you.

That's all for now. More about me at [SimplestWeb.in](https://simplestweb.in/?utm_campaign=captcha-article)
Check out my side project - [LaravelCollections.com](https://laravelcollections.com/?utm_campaign=captcha-article)

Related tutorials
 - [https://medium.com/@welcm/adding-google-recaptcha-to-forms-in-laravel-4be8a4b0e0e9](https://medium.com/@welcm/adding-google-recaptcha-to-forms-in-laravel-4be8a4b0e0e9)
 - [https://stevencotterill.com/articles/adding-google-recaptcha-v3-to-a-php-form](https://stevencotterill.com/articles/adding-google-recaptcha-v3-to-a-php-form)
Protecting Your API Keys - Rails
Tags: rails, security, codenewbie, tutorial
Published: 2019-03-30 17:24:53

---
title: Protecting Your API Keys - Rails
published: true
description: Using ruby gem, dotenv to protect project credentials.
tags: rails, security, code newbie, tutorial
---

From needing to hide API keys to app authorization keys and secrets, `dotenv` is the gem you want to use in order to protect your projects credentials. As a developer, you don’t want your personal project credentials to be used by those who fork or clone your project. 

API keys are vulnerable, as most API’s require them to allow access for each request they receive. Here are a few reasons to protect API keys:

* Some API’s only allow you to make so many API calls a day/month/year before making you pay money to continue to use the API. 

* There are API’s that limit the amount of calls you can make in a specific time period.

* API keys can be suspended due to use outside of their terms of service.

This is where dotenv comes into play. What does dotenv do exactly? As a gem, “dotenv loads variables from a .env file into ENV when the environment is bootstrapped.” In layman’s terms, dotenv takes variables that we place in a .env file and makes them accessible by calling `ENV[‘EXAMPLE_KEY’]`. We protect this .env file and the keys inside it by placing it in our .gitignore file. Now, let’s get into the installation and usage instructions for dotenv.

## Installation 

Add this line to your application’s Gemfile:

`gem ‘dotenv-rails’`

And then run `bundle install` in your terminal.

Create your .env file in the root of your project directory. You could do this manually or by running `touch .env` in your terminal.

## Usage

Write your credentials in .env

`EXAMPLE_API_KEY=YOURAPIKEYHERE`

Upon your application loading, the variables in this file will be available in ENV. You can call them by using:

`ENV[“EXAMPLE_API_KEY”]`

Lastly, you don’t want to forget to protect those API keys. Make sure to include .env in your .gitignore file!!!!

There you go, you are all set to protect your API keys by using the dotenv gem.

Happy coding!

### Resources

[API Key Protection](https://www.approov.io/api-key-protection.html)
[The Simplest and Powerful Ruby Gem — Dotenv](https://medium.com/coffee-and-codes/the-simplest-and-powerful-ruby-gem-dotenv-74d64cbc5d5d)
[Dotenv Documentation](https://github.com/bkeepers/dotenv)
Pushing Left, Like a Boss: Part 1
Tags: applicationsecurity, appsec, beginners, security
Published: 2019-03-30 17:12:22

---
title: Pushing Left, Like a Boss: Part 1
published: true
description: The first of series of articles explaining how to create secure software.
series: Pushing Left Like a Boss
tags: applicationsecurity, appsec, beginners, security
---

###This series, and my blog, have moved! [Check it out](https://wehackpurple.com/pushing-left-like-a-boss-part-1/)!


In all of the talks and articles I have ever written and all the advice I have ever given, I am always telling people they should [“push left”](https://www.youtube.com/watch?v=YGJqpQy79no). When security people say they want to “shift left”, they are referring to the left side of the System Development Life Cycle (SDLC), which is the way software engineers describe the methodology or process for making software. I say "push" because sometimes I am not invited to "shift".

If you look at the image below, the further “left” you look, the earlier you are in the process. When we say we want to “push left”, we mean we want to start security at the very beginning and perform security in every step of the SDLC.

![Behold! The System Development Lifecycle - SDLC](https://thepracticaldev.s3.amazonaws.com/i/n3qj0rv4xxazxak81kul.png)

You might be reading this and thinking “Of course! Doesn’t everyone do that? It’s so obvious.” But from I’ve seen in industry, I have to tell you, it’s not obvious. And it’s definitely not what software developers are being taught in school.


###[Read the rest on my NEW blog!](https://wehackpurple.com/pushing-left-like-a-boss-part-1/)!
My first NPM package: rollup-plugin-hotreload.js
Tags: npm, javascript, node, package
Published: 2019-03-30 16:45:13

---
title: My first NPM package: rollup-plugin-hotreload.js
published: true
description: a Rollup.JS plugin
tags: npm, javascript, node, package
---

[npm package link](https://www.npmjs.com/package/rollup-plugin-hotreload)

![meme](https://i.imgflip.com/2s3lai.jpg)

---

### *Why did I do this*

  There're several reasons:
  
  First, when it came to front end development, I pressed `F5` button to refresh the window to see what happend in the browser. Because of this meaningless behavior, I wanted to come up with the alternative way to fix this inconvenience( which was similar to the concept of automatic refreshing).
Wait?! Webpack has already the feature of hotreload. Why not did I just use it directly? But, I used Rollup.JS and at that time, it seemed it didn't have similar one. Alright, I was going to work on this.

  Secondly, this is an opportunity to build up my skills in developing a JavaScript App.

  Last, I would achieve the goal which my npm package was downloaded for many times. That's awesome!

### *What difficulties did I face*

If you're interested in [issues on GitHub](https://github.com/tingwei628/rollup-plugin-hotreload/issues?q=is%3Aissue+is%3Aclosed) 

First, how did I send the notification to the client from the server? I intuitively wanted to use `Socket.IO`, but its size was way too large compared with my project. Therefore, I checked the [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) and decided to use `SSE`(Server Sent Event)！

Secondly, I found the port used by watch-file server was conflicted with the port used by api-server because Node showed me error logs like this "write after end". After browsing pages on the StackOverflow, I separated two ports to fix the problem. You could check this [Pull request](https://github.com/tingwei628/rollup-plugin-hotreload/pull/9)   

Thirdly, I found `__dirname` was needed to pass to avoid the  error "No found file" and you could check [this issue](https://github.com/tingwei628/rollup-plugin-hotreload/issues/8)

### *Random ideas*

1. How about doing partial bundle to hot reload instead of all bundles hot reloading (?
2. How about using `node-glob` to assign `Bundle` path (?
3. How about to plugin with WebAssembly (?


### Update
2021-07-17: This project is no longer maintained. :)
Video: Minimalism in software 📹
Tags: minimalism
Published: 2019-03-30 16:43:27

---
title: Video: Minimalism in software 📹
published: true
description: I like the idea of applying minimalism to software. I think this can be done by identifying and focussing on the "core" components of your software – the components that really make your product unique and interesting.
tags: minimalism
---

I like the idea of applying minimalism to software. I think this can be done by identifying and focussing on the "core" components of your software – the components that really make your product unique and interesting.
Towel (C#)
Tags: mathematics, datastructures, algorithms
Published: 2019-03-30 11:47:39

---
title: Towel (C#)
published: true
description: mathematics, data structures, algorithms, and more.
tags: mathematics, datastructures, algorithms
---

I have an open source library in C# that I am working on that I want to start advertising. It has generic mathematics, symbolic mathematics, generic data structures, generic algorithms, and more.

Even if you are not a C# developer, much of the code in my project is low-level code that could be useful in any language.

https://github.com/ZacharyPatten/Towel

I want to get people to see it because nearly all the examples I see on GitHub are doing things wrong.

- When writing generic data structures in C#, you should **not** use interfacing. You should use functional programming. This allows you to use any type in your data structures (even primitive types), and you can have multiple data structures of the same type that use different sorting algorithms.

- When writing generic mathematics in C# you should **not** use interfacing with explicit implementations. You should use generic types, runtime compilation, and delegates.

- When writing graph-searching algorithms you should **not** have to build an entire graph in order to perform an A* algorithm. You should use functional programming to build the graph as needed.

- You do **not** need multiple data structures to sort along multiple dimensions. You can use my "omnitree" (and ND SPT) to perform multidimensional sorting in a single data structure (granted I need to optimize it more).

People need to break the barrier between functional programming and object oriented programming. They should be used side-by-side where appropriate.

If you give the code a look, I hope you like it. Feel free to ask me questions. :)
Styling(themeing) with custom properties
Tags: css, var, theme
Published: 2019-03-27 19:13:44

---
title: Styling(themeing) with custom properties
published: true
description: How we can define custom properties to use in our theming
tags: CSS, var, theme
---

##Default theme

Creating variable for default theme or let's say color palette. 
<pre>
<code>
Color palette for our default theme.
[data-theme="default"] {
  --bg-color: #D0DCE9;
  --border-color: #FFFFFF;
  --header-bg-color: #3B71A6;
  --main-bg-color: #FFFFFF;
  --aside-1-bg-color: #82A4C6;
  --aside-2-bg-color: #0ebeff;
  --footer-bg-color: #96D5F1;
}
</code>
</pre>

Now we can apply above created default theme variables to our components.
<pre>
<code>
body{
  background: var(--bg-color);
}
h1{
  color: var(--footer-bg-color);
}
header{
  background: var(--header-bg-color);
}
main{
  background: var(--main-bg-color);
}
.aside-1{
  background: var(--aside-1-bg-color);
}
.aside-2{
  background: var(--aside-2-bg-color);
}
footer{
  background: var(--footer-bg-color);
}

</pre>
</code>

Apply data-theme attribute to the body of our html and you see how your new color palette is applied to the theme. We can add more color palette as we needed and change the color as per the requirements.

<blockquote>
data-theme = "glow"
</blockquote>

##Let's see an example.
If you change the value of data-theme attribute in the `<body>` element you will see new color palette is applied.
{% codepen https://codepen.io/vishangsoni/pen/aMgJrO %}

##Concern
I am not sure how well it scale and how it fits in your requirements. I believe if you're creating small site where you require changes of the theme colors for marketing purposees this approach can save some time.
Pursue a CS Degree or not? As a Front-End Developer
Tags: discuss, computerscience, career
Published: 2019-03-30 14:30:00

I've been considering this for a while, that if I should go pursue a undergrad degree in computer science after I had self-taught myself front-end development and have been working for time for 2.5 years.

I guess it also depends on my career goals: if I want to keep doing pixel perfect performant web stuff, and then become a manager some day in the future, then I probably don't need a degree. But if I want to explore more in the programming world, or even science part of the computer world with other career options, then I probably would want to go back to school for it...

What's your experience? What do you think? 🤔