teleren/devto huggingface dataset:
Nomad Migration Manager
Tags: python, database, migrations
Published: 2020-04-20 22:16:38

---
title: Nomad Migration Manager
published: true
description: A user-report on using Nomad to manage database migrations for a Python web project
tags: python, databases, migrations
---

[Nomad](https://github.com/piranha/nomad) is a migration manager written in Python. It is simple compared to things like Alembic, relying on plain SQL script files with accompanying metadata to control sequencing.

One of Nomad's most unusual features is that it only provides "up" migrations rather than the conventional up and down changes.

In Nomad an "down" migration is simply an "up" migration that takes you to a previous structure. This insight should be copied more as it is relatively rare that you ever do a down migration. In my experience, they tend to happen in development when you realise you've made a mistake and reset the database before correcting the migration and re-applying. In Nomad when this situation occurs you would create a new migration to correct the mistake and then apply the whole migration sequence to production.

I find this admirably transparent but for a lot of people keeping "mistakes" in the codebase would make them very unhappy.

Nomad keeps the database connection details in an ini file that can read environment variables so really you probably want to use a dotenv file excluded from source control to provide the connection details.

Once you done this the Nomad CLI provides a pretty simple interface to create new migrations (with optional dependencies), apply an individual migration or apply all due migrations.

Because Nomad relies on just executing the SQL file associated with the migration it is relatively feature-light and creating migrations simply means writing the appropriate DDL SQL for your database (there are no portability features here despite using SQLAlchemy under the hood).

The only problem I've had using Nomad is really getting the initial configuration to work. After that it has been pretty smooth sailing and the resulting SQL has been much more shareable between my hobby projects than other DSL-based migration tools.
Delete an element from a nested array in JS
Tags: javascript, node, frontend
Published: 2020-05-17 01:12:14

---
title: Delete an element from a nested array in JS
published: true
description: How to delete an element from a nested array in Javascript
tags: javascript, node, frontend
---

`Problem Statement:` Delete an element from a nested array in Javascript

Let's discuss. 

Deleting an element from a regular array is easy. 

Option 1  (when you have a predicate) :
```javascript
const newArray = oldArray.filter((element) => /*predicate*/)
```

Option 2 (when you have an index)

Either use filter with an additional `index` argument or make use of splice

```javascript
oldArray.splice(indexToBeDeleted,1)
```

Now, how would you delete an element from a nested array in an object? Say this is your object structure

```javascript

const blog = {
		title : "Hello World",
		post = [
			{
				title: "Article 1",
				references: [
					{
						url: "www.example.com",
						author: "John Smith"
					},
					{
						url: "www.example2.com",
						author: "Kent Dodds"
					},
					{
						url: "www.example3.com",
						author: "Kyle Smith"
					}
				]
			}
		]
	} 
```
This is a typical example we all see everyday. Say the second reference for the first post is no more valid and it has to be deleted for it to be saved to DB. 

Usually, the location of a nested element in an object is specified by its `path`. Here, for our second reference , the `path` is `articles[0].references[1]`. 

How to delete this ? 

The native `delete`option in JS is not valid for arrays as it leaves behind an ugly `undefined` in the array, that is if you can traverse to that nested array. Also, when given a path you will have to write your own logic to traverse through the object. 

Another good alternative is to use `lodash`. It comes with `set`& `get` methods which are just perfect for this usecase when used in conjunction. 

We want to delete the element at `articles[0].references[1]` path from `blog` object . 
Trick is to devide the above path into two parts 

- parentArrayPath : `articles[0].references`
- childIndex : 1

```javascript
const _ = require('lodash') (OR) import * as _ from 'lodash' // depending on where you are using this library

const refs = _.get(blog, parentArrayPath)
refs.splice(childIndex,1)
_.set(blog, parentArrayPath, refs)
```

Now, `blog` object will look like 

```javascript

const blog = {
		title : "Hello World",
		post = [
			{
				title: "Article 1",
				references: [
					{
						url: "www.example.com",
						author: "John Smith"
					},
					{
						url: "www.example3.com",
						author: "Kyle Smith"
					}
				]
			}
		]
	} 
```

Do let me know if you have a better alternative. Happy to discuss.
Text based stand-ups
Tags: management, code
Published: 2020-05-17 05:21:28

---
title: Text based stand-ups
published: true
date: 2020-05-17 00:35:25 UTC
tags: Management,Code
canonical_url: https://lukelowrey.com/text-based-standups/
---

Like a lot of software companies Endpoint IQ runs a daily team stand-up. It keeps the team promotes accountability and transparency. But you don't have to go far to find a developer who loathes the morning stand-up ritual. For some it can cause anxiety while most fail to see the benefit.

![](https://lukelowrey.com/content/images/2020/05/standup-cancelled.jpg)<figcaption>Stand-up cancelled</figcaption>

We used to do the traditional stand up in a circle and talk method but I have found the most effective way to keep everyone informed is switching to simple, text-based updates.

Every morning the team posts an update in our #standup chat channel with something along the lines of:

- **What I did yesterday?**
- **What am I doing today?**
- **Are there any blockers?**

The format itself isn't important as long as we capture where we are up to, what we plan to do and if anything is stopping us.

![](https://lukelowrey.com/content/images/2020/05/image-1.png)<figcaption>Example text stand up update</figcaption>

Writing the update as opposed to just saying it during a meeting is quick and I find it has some real advantages:

<!--kg-card-begin: markdown-->
- It forces me to think before we I start work and make sure my plans are aligned with what the team is trying to do.
- Keeps me focused during the day. Having a record of what I planned to achieve and knowing it will be revisited the next day keeps met accountable.
- Stand-ups are not dominated by loudest voices.
- Allows us to be flexible times. We have people start from 7am - 9:30am as long as you provide your update you never really "miss" a stand-up
<!--kg-card-end: markdown-->

This type of short, recurring daily update lends itself well to collaboration tools like Slack and Microsoft Teams. Endpoint IQ uses a dedicated Teams channel #standups to post the updates. Any questions or updates from the team takes place in the replies to the original post. This keeps the discussions easy to follow over the course of the week. I also encourage people to posts screenshots, videos or gifs of their work.

We tried out a couple of "stand-up bots" which attempt to automate the process by sending reminders and consolidating responses. The bots generally got in the way more than they helped.
Web Monetization for Creatives Update
Tags: gftwhackathon
Published: 2020-05-17 00:33:57

---
title: Web Monetization for Creatives Update
published: true
description: Halfway through the hackathon update
tags: gftwhackathon
---
I believe this is pretty close to the halfway point of the hackathon now, so I wanted to provide an update. You can find the project at {% github https://github.com/jakesweb/incinicreator %}.

During the first part of the creation of the application, which I have foolishly called Incinicreator, I have kept a good pace to be able to finish by the end of the hackathon. This may seem trivial, but one of the number one things that can go wrong on a project is scoping and/or pacing making it impossible to finish by the deadline. My initial idea is still intact, but some of the implementation details are starting to shift.

First of all, the stack has been confirmed as Node.js with Express for the server and MongoDB for datastore. Authentication is being provided from Auth0. Front end deployment is being handled by Vue.js. I was nervous with the Vue.js at the start since I have never used it before, but I wanted this hackathon to be a way for me to learn a new skill (along with the knowledge of web monetization platform). Google Cloud Platform is where I am currently working to store user data. Over the last 2 days, I have been researching how to get the data stored and protected.

So far I have been happy with Vue.js. The learning process isn't very complicated and the way views and components are built seems to be intuitive. I have enjoyed building the pages out for my application so far. Also, the Auth0 authorization script makes the route protection simple.

I am starting on the back stretches now. I am working on the user interaction for uploads and beginning testing of that. After that, I will just need to build up template sites for creative users to select from and, finally, to finish the help page to assist with getting wallets setup. I believe this should be able to be completed by the end of the coming week, allowing me plenty of time for testing and security assurance. With enough time, in the end, I hope to have a user dashboard where they can see page hits, monetization stats, which works are the most popular, etc.
Streaming Content Suggestions!
Tags: java, cpp, rust
Published: 2020-05-17 00:15:55

A while back someone inspired me to start streaming live coding sessions. I've always kinda toyed around with this idea but never really got into it, until now. I have the free time to start streaming reliably, so I need some ideas on what the community would prefer in terms of streaming platform (YouTube, Twitch, Mixer), frequency, length, project suggestions, and language preference (as the tags suggest I plan on focusing on Java and C++ until I learn Rust at which point I may switch to that).
Weekly Roundup 28
Tags: weekly, links
Published: 2020-07-16 07:44:59

---
title: Weekly Roundup 28
published: true
date: 2020-05-17 00:00:00 UTC
tags: weekly, links
canonical_url: https://www.ankursheel.com/blog/weekly-roundup-28
---

Every week I come across some great articles. Here are some of the posts I feel you will enjoy reading as much as I did.

It is tedious to fill forms on mobile devices. **Alex Holachek** shows how you can [properly configure inputs](https://css-tricks.com/better-form-inputs-for-better-mobile-user-experiences/) to make filling in forms more convenient for your users on mobile devices.

How do you decide whether you should go for a [static website or a server-side software](https://css-tricks.com/static-or-not/)? **Chris Coyier** outlines good and bad reasons to choose one rather than the other.

Is test-Driven-Devoplment(TDD) even possible for UI? **TK** uses [TDD to build a React component](https://www.freecodecamp.org/news/tdd-functions-and-react-components/).

**Ruth** from the **The Happy Saver** talks about the [lifecycle of an investor](https://www.thehappysaver.com/blog/the-life-cycle-of-an-investor) and the rough path that everyone should follow when it comes to investing starting from when you are born.

Ever wondered how hackers find security vulnerabilities in a computer system? **Sonya Moisset** has a [walkthrough to solve the CTF Challenge **_Lame_**](https://www.freecodecamp.org/news/keep-calm-and-hack-the-box-lame/) presented by [Hack the Box](https://www.hackthebox.eu/) for making online penetration practices.

**Sarah Drasner** has a great [tool to generate the CSS code for a hero](https://hero-generator.netlify.app/).

Hope you enjoy reading these articles as much as I did.
Adding Jest for testing
Tags: jest, testing, webdev
Published: 2020-05-21 04:38:52

---
title: Adding Jest for testing
published: true
date: 2020-05-17 00:00:00 UTC
tags: jest, testing, webdev
canonical_url: https://hiltonmeyer.com/articles/jest.html
---

This is a quick and simple way to get [Jest](https://jestjs.io/) up and running in a project. This can either be done by adding it at the beginning of a project and then doing TDD development which is something I will be looking at in the upcoming weeks. The option is to add this to an existing application and then add tests to new code or write retroactive tests. So first step is to install Jest and supertest, supertest is what I use for testing http endpoints and seeing as I'm doing quite a bit of development using [Netlify Functions](https://hiltonmeyer.com/articles/articles/setup-fauna-netlify-functions.html) so I use this to test those API's.

```
npm install --save-dev jest supertest

```

Add the following section to your package.json to create a script for running your tests. I use the `watchAll` parameter to be able to not have to restart the tests continually. This means that as I write the tests or develop my application the tests run and tell me if something is not working. Basically I get a heads up if I break something somewhere else in my code by using previous tests. The other advantage is that I can then write the tests and start working on the solution in my code base. This cycle can just continue and I have someone looking at my code all the time throwing up a flag if something isn't quite kosher.

```
{
  "scripts": {
    "test": "jest --watchAll"
  }
}

```

Config jest to be setup for node by setting up a `jest.config.js` file and adding the following. This will setup the environment for node and also exclude any node\_modules from being included in the tests. Very basic setup, I am developing in Node for my Netlify functions so I use that as my environment. This is not required as out of the box Jest works.

```
module.exports = {
  verbose: true,
  testEnvironment: 'node',
  coveragePathIgnorePatterns: ['/node_modules/'],
};

```
File checksum
Tags: python
Published: 2020-05-16 18:45:05

A checksum is a sequence of numbers and letters used to check data for errors. You can generate a checksum for any file. 

The generation of a checksum is called hashing and is done by a <a href="https://en.wikipedia.org/wiki/Hash_function">hashing algorithm</a>.

<img src="https://dev-to-uploads.s3.amazonaws.com/i/kbhv4s96zf15ft1dm6q2.png" alt="hashing">

You should know that hashing is not encryption. It just creates a hash, but it's impossible to reverse the process, unlike with encryption that requires a key to recreate the plain text.

You can get the checksum of any file in <a href="https://python.org">Python</a>. There are several algorithms you can use. One of the older ones is <a href="https://gitpress.io/u/1246/python-script-get_file_checksum">md5</a>. It's an older algorithm and I recommend newer ones. In fact md5 is from 1992 and it's better avoided.

To see a comparison of algorithms and attacks, check <a href="https://en.wikipedia.org/wiki/Template:Comparison_of_SHA_functions">this page</a>

You could use the sha256 algorithm to find a file checksum:

```python
# Python program to find SHA256 hash string of a file
import hashlib
 
filename = input("Enter the input file name: ")
sha256_hash = hashlib.sha256()
with open(filename,"rb") as f:
    # Read and update hash string value in blocks of 4K
    for byte_block in iter(lambda: f.read(4096),b""):
        sha256_hash.update(byte_block)
    print(sha256_hash.hexdigest()) 
```

<a href="https://docs.python.org/2/library/hashlib.html#module-hashlib">Hashlib</a> has many implementations of hashing algorithms, you can see that in the Python shell:

```
>>> import hashlib
>>> hashlib.algorithms_available
{'sha256', 'blake2s', 'blake2b', 'sha384', 'md5', 'sha3_256', 'sha3_224', 'sha1', 'shake_256', 'sha3_512', 'shake_128', 'sha3_384', 'sha224', 'sha512'}
```
Validate a URL/Domain using Node.js HTTPS Module
Tags: https, node, domainvalidation, certificateauthority
Published: 2020-05-16 23:31:42

## Overview

This post provides guidelines on how to validate a xyz.com domain. By validation, I mean that the domain has a valid certificate signed by Certificate Authority.

## Scenarios

The list given below contains scenarios in which you want to validate the domain/URL:

1. You want to upload data to a server with a URL like this (xyz.com) and you are not sure whether this server is secure or not.

2. You have developed a B2B service and you want to only serve requests from valid domains.

## How to do it?
In node.js there are two ways to do it:

* https module
* ssl-validate module


### 1. HTTPS Module

Nodejs https module’s request method validates the domain provided against the chain of Certificate Authorities root certificate. A code example is given below:

```nodejs
var https = require('https');

var options = {
  hostname: 'github.com/',
  port: 443,
  path: '/',
  method: 'GET',
  rejectUnauthorized: true
};


var req = https.request(options, function(res) {
  console.log("statusCode: ", res.statusCode);
  console.log("headers: ", res.headers);

});
req.end();

req.on('error', function(e) {
  console.error(e);
});
```

**Keypoints**

```
rejectUnauthorized: This means that it will validate the server/domain certificate against the chain of CA's root certificate.
The only problem with this approach is that this chain should be updated regularly otherwise a new domain that is signed by a certificate authority root certificate which is not part of the chain, marked as an invalid certificate(a common example is a self-signed certificate).
```

### 2. ssl-validate Module

It can also be used but it requires another module to get the domain information.
Desktop integration for Tinkerwell (or any AppImage)
Tags: laravel, appimage, ubuntu, tinker
Published: 2020-05-16 23:07:05

If you use Laravel you've probably heard of [Tinkerwell](https://tinkerwell.app/). If that is not the case, Tinkerwell is the `php artisan tinker` on steroids: a powerful REPL that runs your code within local and remote PHP applications, allowing you to tinker with them.

### What are AppImage packages

The Linux version of Tinkerwell is distributed in an AppImage package format. If you have not heard of this format before, you just have to know that it is a universal software package format that tries to be distribution-agnostic, i.e. you can use it in most (if not all) modern Linux distributions. 

The disadvantages of AppImage packages are that, firstly, you have to give them permission to run, and secondly, every time you want to run them, you have to navigate to the folder where you downloaded the file. That is certainly the case for me when I need to run Tinkerwell. 

### Integrate AppImages in your system with AppImageLauncher

AppImageLauncher solves these problems. After installation, it will let you execute AppImages with just one click (without having to make them executable). But most interestingly, it will easily (and optionally) integrate the application with your system, creating shortcuts in the application launcher and on the desktop.

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

Use the folllowing commands to install AppImageLauncher in Ubuntu or go the [repo](https://github.com/TheAssassin/AppImageLauncher/) to find more installing options.

```bash
sudo add-apt-repository ppa:appimagelauncher-team/stable
sudo apt update
sudo apt install appimagelauncher
```

After installing, just execute your desired AppImage file and choose the option to integrate.
Building a coding interview platform from scratch
Tags: showdev, webdev, tutorial, programming
Published: 2020-05-16 22:37:26

Hi, devs! 👋

For the last year, I've been running a side gig interviewing developers for multiple companies. Now I believe I've collected enough learnings to consolidate them in a coding interview platform that I'm about to start building.

The idea is to share the progress as it goes, explaining technical details and decisions made along the way. That will involve building a disperse system with multiple services. I'm planning to share each step here on Dev.

If there's anything you want to know in particular, feel free to share in the comments below so that I include it in my future posts.

Stay curious! ✌️
In support of ugly starts
Published: 2020-05-16 22:34:04

I think about writing, and coding and writing about coding, but often don't write anything at all. Desire isn't the issue. Nor a lack of fundamentals. The number one thing holding me back from daily writing is perfectionism. I had the same problem with learning to code 🖥

I want to write like someone who's written daily for five years, but I'm not even close to that level. The truth is I need to write small, consistent posts and publish weekly. Steady beats perfect every time 💯 

Here are some lessons I learned from attempting multiple #100DaysOfCode that I am applying to writing ✍️

👩🏻‍💻 Getting started is fucking terrifying.

👩🏻‍💻 Getting started takes guts. 

👩🏻‍💻 Getting started means others might see. And judge.

👩🏻‍💻 Getting started means I can fail. Publicly. 

👩🏻‍💻 Getting started means failing more than once.

👩🏻‍💻 Getting started is free. 

👩🏻‍💻 Getting started requires no permission. 

👩🏻‍💻 Getting started means admitting you have more to learn.

👩🏻‍💻 Getting started means the possibility of making a mark, scratch, or dent in the world.

Writing doesn't have to be 1500 words and ten images. Writing can be 100 words and a couple of pretty pictures you found on [Unsplash](https://unsplash.com/) Get your shit out there. Let them see how much you've grown 💪

Coding doesn't have to be a full-featured app or gallery-quality portfolio site. Push some code to Github, connect a domain, and get your janky portfolio out published. Tweak, add, and upgrade often 🛠

(Cover image by https://unsplash.com/@godje )
useTranslator - a React translation hook
Tags: react, hook, language, translation
Published: 2020-05-16 22:14:35

I just wanted to share a little javascript library I developed to use Google translate API for free.  First is the javascript class TranslateApi that you can use independent of react.  Next is the useTranslator hook that makes it super convenient in a React component.  I'm using spanish here, but you can use any language that google supports.  Also, if you have a better API, you can easily substitute it inside the TranslationApi class.

##TranslationApi.js
In raw javascript, it's a simple asynchronous function..
```javascript
   TranslationApi.translate("dog","spanish").then(palabras=>{
      elDog = palabras;
   });
```
<sub>get source [TranslationApi.js](https://github.com/chadsteele/useTranslator/blob/master/src/components/TranslationApi.js)</sub>

##useTranslator.js
In your react component, you use it much like useState...
```javascript
  const [spanish, toSpanish] = useTranslator('spanish');
     ...
  let elDog = toSpanish('dog');
```
<sub>get source [useTranslator.js](https://github.com/chadsteele/useTranslator/blob/master/src/components/useTranslator.js)</sub>

![dogs](https://dev-to-uploads.s3.amazonaws.com/i/srza73mdi777yk5qj2hf.jpg)

¡Hasta luego bebe!

-[ChadSteele.com](http://chadsteele.com)

p.s.
If you like this, you might like this other library 
[Vocabulary.js](https://dev.to/chadsteele/relevance-fuzzy-linguistic-heuristics-286b)