teleren/devto huggingface dataset:
Manage dependency versions
Tags: javascript, node, npm, yarn
Published: 2019-06-05 12:04:03

_Original post https://featurist.co.uk/blog/keeping-dependencies-up-to-date/_

In the pre `yarn.lock`/`package-lock.json` era there was only one way to make sure your project does not break tomorrow because of some dependency library introducing a breaking change: setting _precise_ package versions in `package.json`:

```json
  "dependencies": {
    "express": "4.17.1",
    "sqlite3": "4.0.8",
    "left-pad": "1.2.0"
  }
```

There was a glaring problem there however: nothing guaranteed that the dependencies of dependencies wouldn't move on. Every fresh `npm install` - for example when the project is deployed to production - could potentially break. Those were shady times, for the brave to venture.

Now that there is yarn and `package-lock.json` things have finally settled with all versions - not just the explicit dependencies - locked down. As a side effect, there is not much point in keeping versions specified in `package.json`. Indeed, once you add a dependency its version is looked up in the lock file and lock file only. We might as well just set all dependency versions to `latest`:

```json
  "dependencies": {
    "express": "latest",
    "sqlite3": "latest",
    "left-pad": "latest"
  }
```

As the time goes on you keep updating dependencies. You should do anyway. Upgrading everything to latest might break things and sometimes those things are easy to fix. Other times - not so much. And sometimes latest versions introduce bugs that you simply can not do anything about.

So you might choose not to upgrade _some_ dependencies. And this is the time to go back and swap the `latest` on those packages - remember we've set all version to `latest` - to whatever version that was known to work.

The above approach, if applied routinely, will leave you with `package.json` where most of the versions are set to `latest` with may be a handful more strict ones:

```json
  "dependencies": {
    "express": "latest",
    "sqlite3": "latest",
    "left-pad": "1.2.0"
  }
```

This has benefits:
- `yarn upgrade` does not upgrade strict versions. So it can be run often without touching the troublesome ones.
- offending packages are visible at a glance in `package.json`
- `git blame` on the line with a specific version reveals a commit with any details of why upgrading this package was problematic (e.g. link to github issue). This is a nice workaround for the lack of comments in `package.json`.
React tldr; Why Do I Need Keys in React List? 
Tags: react
Published: 2019-06-05 12:18:18

• Lists are performant heavy and need to be used carefully.

• Make sure every item in the list has a unique key.

• It is preferred to not use indexes as a key unless you know for sure that the list is a static list (no additions/re-ordering/removal to the list).

• Never use unstable keys like Math.random() to generate a key.

• React will run into performance degradation and unexpected behavior if unstable keys are used.

Source: https://medium.com/@adhithiravi/why-do-i-need-keys-in-react-lists-dbb522188bbb?fbclid=IwAR09xviOqDHRc7gvvoLXXDgVfVBtxbkCylq0p2Eur-jKrhw9EuMIpZ7c0BQ
Mint 🍃: Environment Variables
Tags: javascript, webdev, mintlang, dotenv
Published: 2019-06-05 11:58:10

_This is the next post in a series that showcases the features of Mint, you can find the previous posts here:_
* _[Mint 🍃: Getting Started](/gdotdesign/getting-started-with-mint-3k2o)_
* _[Mint 🍃: Components](/gdotdesign/components-in-mint-4a4n)_
* _[Mint 🍃: Events and State of Components](/gdotdesign/mint-events-and-state-of-components-3j3a)_
* _[Mint 🍃: Handling HTTP Requests](/gdotdesign/mint-handling-http-requests-2ep3)_
* _[Mint 🍃: Styling Elements](/gdotdesign/mint-styling-elements-295o)_
* _[Mint 🍃: Creating Packages](/gdotdesign/mint-creating-a-packages-5e9b/)_
* _[Mint 🍃: Routing](/gdotdesign/mint-routing-2h69/)_

In this post I will show you how to use environment variables.

--------

In any application, being able to define variables which are [deployment environment](https://en.wikipedia.org/wiki/Deployment_environment) specific is a necessity. Let's say you might want to connect to a local API endpoint during development and remote API on production.

### Defining environment variables

Mint uses `.env` files to store variables specific to the environment, which usually looks like this:

```
ENDPOINT=http://localhost:3001
WSENDPOINT=ws://localhost:3001
GATRACKINGID=google-analytics-tracking-id
```

Here we declared three variables `WSENDPOINT`, `ENDPOINT` and `GATRACKINGID` that we want to use in our code.

### Using environment variables

In Mint you can use the at (`@`) symbol followed by the name of the variable to refer to it:

```
module Main {
  fun render : Html {
    <div>
     <{ @ENDPOINT }>
    </div>
  }
}
```

Essentially the value of the variable will be inlined during compilation with the type of `String`.

In an other example you can see how to use it when making a request:

```
...

response =
 @ENDPOINT + "/api/planets"
 |> Http.get()
 |> Http.send()

...
```

If an environment variable is not defined in the application, then a nice error message is shown:
 
![Error](https://thepracticaldev.s3.amazonaws.com/i/ff6g2spc8eyy8i37rmfr.png)

### Using a different `.env` file

By default the `.env` file in the root of the application is loaded, but you can specify a different file by using the `--env` (or `-e`) flag like this:

```
mint build --env .env.production
```

That's it for today, thank you for reading 🙏

--------------


If you like to learn more about Mint check out the [guide](https://guide.mint-lang.com) 📖

In the next part I'm going to tell you about stores 😉 see you there 👋
Are Premium Domains Bad?
Tags: discuss, webdev
Published: 2019-06-05 10:29:05

---
title: Are Premium Domains Bad? 
published: true
description: 
tags: discuss, webdev
---

I was looking for a domain name for an app I'm working on, and one of the options I tried was *self.app*. To my surprise, it was available! Some time after buying the domain, I got an email from my registrar, saying tha the purchaise failed because *self.app is a premium domain", meaning that the domain vendor will only sell it for a higher price.

Nowin some way, this feels similar to the net neutrality issue. A domain name vendor should sell domain names at a certain rate, no matter the nature of the name being bought. On the other hand, I can see the argument that this is just how markets like this work: short domain names are more valuable, so they're sold at a higher price.

What are your thoughts?
new stuff from postgres learned
Tags: postgres
Published: 2019-06-05 10:24:27

---
title: new stuff from postgres learned
published: true
description: from small commands hacks to greater architecture ideas in postgres
tags: postgres
---


# watch

if you have open `psql` shell and want to have refreshed by n-seconds certain command, after executing this command once just type, e.g 10 stands for refresh each 10 seconds

```sql
\watch 10
```

# SECURITY DEFINER - running procedure/function as OWNER


default behavior: fun is run by executing user, you can easily change it with `SECURITY DEFINER` you add just after defining your procedure e.g:

```sql
CREATE OR REPLACE FUNCTION public.foo() 
RETURNS VOID AS $$

-- do whatever you need here and remember

$$ LANGUAGE plpgsql SECURITY DEFINER;
```

- the `user` inside the scope is the owner of the function - the one who defined it (`effective user`) 
- and to get the user actually calling it you may need to have wrapping function called without `SECURITY DEFINER` grab there user and pass it to the function run as `SECURITY DEFINER`.


just for reference the default modifier is called `SECURITY INVOKER`.

https://www.postgresql.org/docs/current/sql-createfunction.html


# pg_stat_activity

One row per server process, showing information related to the current activity of that process, such as state and current query. Find it useful as lookup for more context info missing in `event trigger` with `ddl_command_start`.

https://www.postgresql.org/docs/9.2/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW


# debug level

```sql
SET client_min_messages TO DEBUG5;
```

all available from `DEBUG5` to `PANIC` described here https://www.postgresql.org/docs/9.1/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS

using it in `PL/PgSQL`:

```sql

RAISE NOTICE `running as user: %', session_user;
```

using it in `plpythonu`:
```python
plpy.debug('query: {}'.format(query))
```
Typed python + typed NamedTuple <3
Tags: python, typedpython
Published: 2019-06-05 09:48:52

---
title: Typed python + typed NamedTuple <3
published: true
description: 
tags: python, typed-python
---

# be aware of limitations:

>Function annotations are nothing more than a way of associating arbitrary Python expressions with various parts of a function at compile-time.

https://stackoverflow.com/a/43977962/953553

# way to use:

- defining a class with typed fields
- specify types of args the functions receive

# how it is checked?

- e.g good IDE like pycharm will do it
- install `pep8` and `mypy-lang` to be warned

# EXAMPLES 

## basic types

(run with `pep8` and `mypy-lang` installed):

```python
def greeting(name: str) -> str:
     return 'Hello ' + name
```

then calling:
```python
greeting(2)
```
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in greeting
TypeError: Can't convert 'int' object to str implicitly
```
```python
greeting('3')
#'Hello 3'
```

## support for classes and inheritance


## more complex types:

### List

```python
from typing import List
```


### Tuple

```python
from typing import Tuple
```


### NamedTuple

```python
from typing import NamedTuple
```


### Dict

```python
from typing import Dict
```

### Union

is the way to allow more than one type for varaible.


### Optional



### more nice examples of typed stuff here:
https://blog.daftcode.pl/first-steps-with-python-type-system-30e4296722af


# typed tuple in python3 is typed version of collections.namedtuple


```python
from typing import NamedTuple


class Employee(NamedTuple):
    name: str
    id: int = 3

employee = Employee('Guido')
assert employee.id == 3
```
plpythonu PL/Python - on snake inside elephant
Tags: whatnewdidyoulearn, plpythonu, postgres, python
Published: 2019-06-05 09:47:26

---
title: plpythonu PL/Python - on snake inside elephant
published: true
description: Week summary of new stuff learned
tags: what-new-did-you-learn, plpythonu, postgres, python
---


![like this but another way around](https://thepracticaldev.s3.amazonaws.com/i/p4sis6tokttjoouczdyv.jpg)

actually we would to something another way around ;) snake inside the elephant, not the other way around like in the little prince story.

good intro can be this talk available on youtube: 


[![pywaw talk on plpythonu by Jan Urbanski](http://i3.ytimg.com/vi/xkzbE5zon18/maxresdefault.jpg)](https://www.youtube.com/watch?v=xkzbE5zon18)

followed by it's slides: https://wulczer.org/pywaw-summit.pdf



# prelude - what do you need to setup in your postgres?

### if you play with plpython3u on fresh postgres instance you will probably need install/setup the following:


```bash
apt-get update
apt-get install postgresql-plpython3-11
```
- be careful to install good version for your postgres version:


### inside psql:
```sql
CREATE EXTENSION plpython3u;
```

### example fun
```python
create function histogram(a float[], bins int = 10)
returns int[]
as $$
import numpy
return numpy.histogram(a, bins)[0]
$$ language plpython3u;
```

- you may need install on postgres machine additional python libraries (e.g `numpy` for above), first install pip:
`apt-get install python3-pip`


## Important things to remember:

- keep you functions in separated module with option to mock plpython magic, so these are GOOD tested
1946 Called.
Tags: history, sre, sysops
Published: 2019-06-05 09:28:17

1946 called us again this year. With a voice hoarse with smoke and ice-calm with the fear of the doomed they asked us to audit our monitoring infrastructure, to schedule response drills, and to confirm that we clearly documented escalation paths for our incidents.


> Chicago, June 5 (AP)
> A 44 year old switchboard operator, though surrounded by smoke and flames which swept through the La Salle hotel early today, called room after room to notify guests of their danger.

> The first firemen to reach the phone room on the mezzanine floor found the operator, Mrs. Julia Berry, dead at her post.

> It was through Mrs. Berry's switchboard that the first alarm was sounded.  W. H. Bradfield, assistant night manager, told Central police that he ran to the phone room and told Mrs. Berry to "get out."

> "No. I'm going to stay at my station.  We've got to give those folks on the top floors a chance." she answered.

> Bradfield ran to rouse guests.  A short time later he remembered Mrs. Berry and tried to get back onto the phone room but was swept back by the flames.

The LaSalle Inferno and the Winecoff Hotel fire in December of 1946 prompted the City of Chicago to mandate automatic fire alarms in all new hotel construction and specialist training of firefighters. 

Julia Curran Berry was declared a heroine of the telephone service by AT&T.
What is Your Favorite Programmer Humor?
Tags: humor, programmer, joke
Published: 2019-06-05 09:10:53

Hi. You probably know [ProgrammerHummor](https://www.reddit.com/r/ProgrammerHumor/) on Reddit.

## Programmer's Lies

This is the first one for me. Actually, this is a list of what programmers say when their codes don't work.

![](https://thepracticaldev.s3.amazonaws.com/i/i5l6jyexk6cm2wcxrwfe.jpg)

## Futurist Technology Companies

The second one is telling us HR companies' behavior when a new technology out. Actually, this behavior depends on technology companies thoughts.

I know this is just a joke. But the expectations of some companies are really like that.

![](https://thepracticaldev.s3.amazonaws.com/i/90vjfnhplzmna6e5hyt0.jpg)

So, what is/are your programmer humor(s)?

**Can you show pictures like that?**
Gatsby Firebase Deployment
Tags: gatsby, firebase, javascript, react
Published: 2019-08-09 17:32:26

---
title: Gatsby Firebase Deployment
published: true
tags: gatsby,firebase,javascript,react
canonical_url: https://mattchaffe.uk/posts/gatsby-firebase-deployment
---

Having recently published my personal site with Gatsby I wanted to set up a basic pipeline with Gitlab to deploy my site when I push changes to the `master` branch. This will be beneficial so that if I create another branch, the deploy process won’t initiate on other branches.

## Gitlab CI
{% gist https://gist.github.com/Mattchewone/baa2989a6d38cebe7847391739728c07 %}

The above `gist` shows how simple it is to create a basic CI pipeline. Let’s break it down a little though. I only have a deploy task, which uses the latest node container image, then using the script section of the job run `npm i` to install all the project dependencies. Then we can install some globals, `gatsby-cli` and `firebase-tools`, these are used to build the static site and for deployment. To create the site files I would run the `gatsby build`, and set up `firebase` to use token authentication. We will come back to this in a minute, and then we run the `firebase deploy` to… well… deploy the site.

## Firebase Token Auth

As we are deploying using CI, we need the deployment to be “hands off” and will need to have an authenticated token for the CI to use to access the project and have permission to deploy. Thankfully firebase has a handy way to generate a token for this exact purpose. If you run the following in your terminal, it will open a browser tab and request you grant access to create this token.

```
firebase login:ci
```

Firebase will then provide you with a handy token within your terminal, which can be used within [Gitlab’s CI variables](https://gitlab.com/help/ci/variables/README)

To use this token we need to add it to Gitlab’s Variables for CI/CD, which can be accessed via Settings \> CI / CD:

[![Gitlab CI/CD Variables](https://mattchaffe.uk/static/62f22f4db94c406ec8c0200accb920e3/f570d/gitlab-screengrab.png)](/static/62f22f4db94c406ec8c0200accb920e3/5dc2c/gitlab-screengrab.png)

You can see that I have two variables, `FIREBASE_TOKEN` and `PROJECT_ID`, these will be injected by Gitlab into the pipeline.

Once you have added the secrets and created the `.gitlab-ci.yml` file, push to `master` and this should kick off a build and deploy to firebase! Woop!

[![Gitlab pipeline](https://mattchaffe.uk/static/0b6c03ad95152cfd498ddae5cb1c2b9b/f570d/gitlab-pipeline.png)](/static/0b6c03ad95152cfd498ddae5cb1c2b9b/de157/gitlab-pipeline.png)

## Create content…

Now you can create your content, commit, push to gitlab and let it deploy whilst you can sit back and enjoy your new article/blog!

Awesome!!

Thanks for reading.
Why I move back to WordPress
Tags: internet, wordpress
Published: 2019-06-07 08:20:00

---
title: Why I move back to WordPress
published: true
tags: internet,wordpress
canonical_url: https://kevinhq.com/why-i-move-back-to-wordpress/
---

A long story about how and why I move back to WordPress after migrating to Netlify service (from WordPress), and now going back to use

[Continue reading why I move back to WordPress](https://kevinhq.com/why-i-move-back-to-wordpress/)

The post [Why I move back to WordPress](https://kevinhq.com/why-i-move-back-to-wordpress/) appeared first on [kevin's tech blog](https://kevinhq.com).
Use Python and Beautiful Soup to find text in HTML
Tags: python
Published: 2019-06-05 05:35:00

---
title: Use Python and Beautiful Soup to find text in HTML
published: true
description: We'll explore how to use Python to download a webpage and extract the text elements from it.
tags: python
---

[(Skip to the tutorial)](https://matix.io/extract-text-from-webpage-using-beautifulsoup-and-python/)

So you're browsing the internet, feeling lonely and low on self-esteem, when suddenly __YOU FIND THIS DANK COLLECTION OF CAT MEMES__.  And you think to yourself:

![](https://thepracticaldev.s3.amazonaws.com/i/uzq8k4f2fcxst621f4hs.jpg)

But these greedy internet cat meme people, they don't have an API.. __why o why don't they have an API?__

__WE HATES IT WHEN THEY DON'T HAVE AN API__

But we takes what we wants anyways.

We scrapes all the dank cat memes, all for ourselves.  Because we're wizards, and we knows how to crawl a website and grab all the photos.


__BUT WHAT IF WE WANTS TO GRAB THE TEXT??__


We check out this tutorial and [use Beautiful Soup to find the text!](https://matix.io/extract-text-from-webpage-using-beautifulsoup-and-python/)
Firebase NOSql Parent-Child logins
Tags: help
Published: 2019-06-05 08:57:43

---
title: Firebase NOSql Parent-Child logins
published: true
tags: help
---

I am in the process of designing a chore app where parents can assign chores, give allowances, rewards for meeting XP points, etc, and the child can keep track of those chores, and how much money they haved saved/spent. Also child can make specific saving goals like a toy or videogame, and put chore money towards those goals.

Anyways I am a bit stuck with the login/creation user in terms of the database side I am using firebase. My original idea was to have one parent be the initial admin, and then he/she can create the other parent and child accounts and share a secret generated code with QR. The other non admin users would be able to login with admins email, and QR code. Only problem with that is that non admin users might not show up in the users database in firebase.

The reason why I wanted to use admin/QR code for children accounts is that some children do not have email accounts yet, or are too forgetful for passwords. 

- Would multiple accounts per email be a better? 
- Are there other methods of dealing with parent/child apps logins?
Entropic: federated JS package registry, announced at JSConfEU 2019
Tags: news, discuss, javascript, opensource
Published: 2019-06-05 08:10:21

Hey everyone! I don't think I've seen this discussed on DEV yet. I'm not the most aware about the JS community (I'm a Pythonista at the core), but I thought it'd be interesting to have a chat together about this.

C J Silverio gave a talk at JSConfEU 2019 a few days ago:

{% youtube MO8hZlgK5zc %}

The talk is super interesting and very well crafted — I highly recommend you watch it! But here's a modest tl;dr.

In this talk, Silverio discusses the reasons behind the Entropic project.

The first reason is that a part of the "JavaScript commons" (the package registry) is owned by a private company (npm Inc), whose sole purpose is to "take money and turn it into more money".

She makes the point that having *another* private company (Microsoft) run the Node package ecosystem isn't going to be the solution either.

(We previously discussed the GitHub Package Registry on DEV:)

{% link peter/github-announces-github-package-registry-3a27 %}

Plus, still according to her, building any other *centralized* package registry — even owned by a foundation like [OpenJS](https://openjsf.org/) — wouldn't work either, because the flow of package downloads in the Node.js ecosystem is *humongous*. It simply costs way too much to host and serve all packages from a central location.

With all the reasons in mind, at the very end of the talk Silverio introduces **Entropic**, a "federated package registry for anything, but mostly JavaScript". It comes with a CLI called `ds` (like "delta entropy" — a of bit of a physics joke).

From the words of C J Silverio herself, Entropic is still very young ("don't use it yet!"), but a handful of people are working on the Entropic project already. The main repository is here:

{% github entropic-dev/entropic %}

So, **what are your reactions to this announcement?**