teleren/devto huggingface dataset:
MediDoc: Update 4 - Deployment
Tags: dohackathon, django
Published: 2021-01-01 17:59:59

Deploying Django with the Digital Ocean Apps Platform was fairly straightforward. Overall, I followed this video with some minor changes to suit my needs:
{%youtube NUGrTCRoIFk%}

Changes I made:
1. If I let Django generate the secret key using `get_random_secret_key()` function, users have to login every time I made some code changes leading to a bad experience. Thus, I hardcode it in an environment variable.
2. I also have another environment variable `IS_POST` (default to `False`) which is used to control the static file hosting.
3. Since in MediDoc users can upload media, I also had to create DigitalOcean spaces and add the following configuration variables to my `settings.py` file.
```python
if IS_PROD:
    DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
    AWS_S3_REGION_NAME = 'nyc3'
    AWS_S3_ENDPOINT_URL = f'https://{AWS_S3_REGION_NAME}.digitaloceanspaces.com'
    AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
    AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')
    AWS_STORAGE_BUCKET_NAME = 'medidoc'
    AWS_S3_OBJECT_PARAMETERS = {
        'CacheControl': 'max-age=86400',
    }
    AWS_LOCATION = 'media'
```
In the end, I have the following environment variables:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8ro9g909php6yz2as78a.png)

Check out the deployment here: https://medi-doc-njgqo.ondigitalocean.app/

## Try It Out
To try it out, please create a patient account [here](https://medi-doc-njgqo.ondigitalocean.app/accounts/signup) and a medical account [here](https://medi-doc-njgqo.ondigitalocean.app/accounts/signup/medical) (note that admin has to approve the medical accounts, so please wait a bit!).

Alternatively, you can use the following demo medical accounts:
- devto-hospital
- devto-diag
- devto-pharmacy

And the patient account:
- devto-patient

Password for all of them is: medidocpass@abc

Let me know what you think!
From Mac to Linux
Tags: linux, mac
Published: 2021-01-03 02:03:45

---
title: "From Mac to Linux"
tags:
  - linux
  - mac
cover_image: https://images.unsplash.com/photo-1587606605848-7395dfb56d90?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=600&q=80
published: true
canonical_url: https://cri.dev/posts/2021-01-03-mac-linux/
---

**Originally posted on [cri.dev](https://cri.dev/posts/2021-01-03-mac-linux/)**

I am switching from Mac to Linux.

This is how the adventure started to find the best linux distro, with a seemless user experience and minimum maintenance.

In the past months I experimented with various distros:

- bare debian
- Pop!_OS
- Ubuntu
- Elementary OS

Read below to read my experience and to which distro I settled using.

## Experience recap

### with bare debian

Driver support for WiFi and Bluetooth were absent out of the box.

Still too much to adjust and tweak to get a decent user experience.

Not for me.

### with Pop!_OS

Seemed like a fresh approach to the linux distro landscape, but I had major hiccups when it comes to display drivers. 

Weird issues like blank screen after switching to HDMI external display. Troublesome boots when display was attached.

Weird glitches and graphical artifacts when resizing windows.

No issues with drivers.

I bet it works great on System76 machines though.

### with Ubuntu

Glitches when working with external monitors.

Blank screen after booting connected via HDMI.

Weird behaviour when putting laptop in clamshell mode. Either not turning on, or shortly showing the login screen and then going to sleep.

No issues with drivers.

Recurrent issues with the confusing Software center versions not compatible with the applications on it. 

Amazon EKS keeped popping up as a "promoted" application, without the possibility to remove it.

Bye Ubuntu.

### Elementary OS

No issues with drivers.

No issues with external monitor. Wake and sleep with HDMI works like expected.

No blank screen when booting from external monitor.

Decent software center (with donations built in), also using snap was great.

Slight issues when disconnecting the external monitor and using the laptop, works after a few tries.

So far so good.

## Elementary OS is good enough for me

The user experience is stunningly similar to what I was used to with a Mac.

Switching windows is intuitive.

If you forget a shortcut, just press `<SUPER>`.

With `snap` it almost feels like using `brew` and `brew cask`.

Using it in clamshell mode works like a charm.

The system even wakes up from sleep using a Bluetooh logitech keyboard with mouse (namely the Logitech k400 I think).

Still need to find a better Terminal emulator, because I'm not really fond of the one built-in. Perhaps time to try Alacritty?

This is how I am writing this very blog post.

![elementary os preview](https://cri.dev/assets/images/posts/elementary-os-preview.png)

**Originally posted on [cri.dev](https://cri.dev/posts/2021-01-03-mac-linux/)**
btw, I use Arch
Tags: archlinux
Published: 2021-01-03 01:57:00

Take a look at my scrot

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

I will be honest, I fell back to Win10 for a while. Now I am back again on Arch and forgot how much I love it. I edit my grub-customizer configuration so that Arch will auto start instead of Win10.

For my Arch Linux users that uses i3wm, please do yourself a favor and install autotiling.
See my screenshot? It auto tiles each app. It is awesome. I've been using this since forever. I don't even bother with the whole template thing that i3wm offers. Too much of a hassle.

***
I do not remember the full history since it’s been a while. I was always a Window user since 1.3 and using MS-DOS.

Around 2002-2003 I heard about Ubuntu being an intro to Linux so I decided to try to install it on my laptop. A lot of the drivers weren’t compatible for anything. I spent so many hours just trying to install a wifi adapter. It was pretty much impossible for me to use because a lot of software just weren’t on par with the mainstream software. Wine was not as good as today’s Wine. So basically my laptop with Ubuntu was a really crappy DE and all I did was play Tux game where he just slides lol

I eventually switched back to Windows when they came out with Win7. One moment in my life, I ended up getting everything Apple. Eventually I got bored and went back to Win10 because of Oculus Rift.

Two years ago, I didn’t even bother with Ubuntu anymore, decided to just go into Vanilla Arch because I heard you can do a lot and plus this phrase “btw, I use arch” got me curious. I guess it is a type of pride and accomplishment status if you can say that.

I eventually installed it correctly after a few mistakes where I forget to add in a command and then the next time I remember that command and forget another command lol
After being able to do it, I came across ArchLabs and here I am.

I don’t need to do vanilla arch anymore. It is way too time consuming, but I did it before so I can say “btw, I use arch” hahaha
Full-stack Javascript Components
Tags: javascript, node, webdev
Published: 2021-01-03 01:48:25

We’re releasing the first version of Nullstack!

...Yes, another JavaScript framework. This one is made by a very small team, but we have some nice things to offer. Applications built in Nullstack have a [slightly good perceived performance](https://raw.githubusercontent.com/nullstack/poke-poll/master/lighthouse.jpg) and the code tends to be [relatively small](https://github.com/nullstack/nullstack.github.io/tree/master/src) compared to other frameworks.

Nullstack is an isomorphic framework, focused on giving some quality of life (and of code) to freelancers. It’s based on vanilla Javascript. We’ve been using it in our freelancing projects for 2 years now and thought it was time to release it into the world.

Nullstack components interop between both the back-end and the front-end seamlessly allowing you to write code like this:

```jsx
import Nullstack from 'nullstack';

class PokePoll extends Nullstack {

  pokedex = [];

  prepare({project, page}) {
    page.title = `${project.name} built with Nullstack!`;
  }

  static async getTopTenpokedex({database}) {
    return await database.collection('pokedex').find().sort({votes: -1}).limit(10).toArray();
  }

  async initiate() {
    this.pokedex = await this.getTopTenpokedex();
  }

  renderPokemon({ranking, name, sprite, number, votes}) {
    return (
      <li>
        <div>
          <h2>#{ranking}</h2>
          <img src={sprite} alt={name} />
          <span>#{number}</span>
          <a href={`/${name}`}>{name}</a>
          <small>{votes} votes</small>
        </div>
      </li>
    )
  }
  
  render({page}) {
    return (
      <div>
        <h1> {page.title} </h1>
        <ul>
          {this.pokedex.map((pokemon, index) => <Pokemon {...pokemon} ranking={index + 1} />)}
        </ul>
      </div>
    )
  }

}

export default PokePoll;
```

If you’re interested you can check out [documentation ](https://nullstack.app/)or the [application example](https://github.com/nullstack/poke-poll) we’ve built. We hope you enjoy Nullstack as much as we do!
Formatação de moedas em JavaScript
Tags: javascript, braziliandevs
Published: 2021-01-03 01:34:14

Olá pessoal, hoje irei deixar uma dica bem legal para formatar algum valor numérico para a moeda Real, Dólar e Euro.

```js
const currentValue = 1265.8;

const valueBR = currentValue.toLocaleString('pt-BR', {style: 'currency', currency: 'BRL'});
console.log(valueBR); // R$ 1.265,80

const valueUSD = currentValue.toLocaleString('pt-BR', {style: 'currency', currency: 'USD'});
console.log(valueUSD); // US$ 1.265,80

const valueEUR = currentValue.toLocaleString('pt-BR', {style: 'currency', currency: 'EUR'});
console.log(valueEUR); // € 1.265,80
```

Caso deseje realizar a operação inversa, utilize o código abaixo:

```js
const valueBR = 'R$ 1.265,80';

const currentValue = Number(valueBR.replace(/\D/g, '')) / 100;
console.log(currentValue); // 1265.8
```

Valeu pessoal 😎✌!
How much does an IT specialist earn?
Published: 2021-01-03 01:26:29

The specialties with the best salaries are Information Systems Programmer, Information Systems Programmer and Machine Tool Programmer with Numerical Command.


The computer scientist works in several areas, from software development to database creation and computer network maintenance. As our country still has a great demand for specialists in the area of Information Technology (IT), this professional finds a very hot market when leaving university. Companies have had difficulty in filling vacant positions and this scenario will hardly change in the coming years with the increasing computerisation throughout the world. A good example of this process is the advance of e-commerce, in various segments. This has opened the doors of more and more companies to computer scientists, who can develop software that manages the flow of payments to control stocks.
---- more information in Spanish ---
¿Cuánto <a href="https://www.cuanto-cobra.com/un-ingeniero-informatico/">cobra un informático en España</a> ?
Shiny Shelby GT350 Photo (live demo)
Tags: lume, webgl, html, webdev
Published: 2021-01-03 01:14:40

A #NewYear2021 resolution: one demo per day. Here's an #HTML <img> tag in #3D space with shine from a light, featuring my #ShelbyGT350.

This demo defines a new <shaded-image> HTML element that makes it possible to size the element (notably the underlying WebGL object) based on the natural size of the image. This way we don't need to explicitly know the image size.

{% youtube h-K25jt0BI4 %}

{% codepen https://codepen.io/trusktr/pen/dypmvNM %}

Made with #LUME 👇

{% github lume/lume %}

topics: #webgl #css #javascript #webdev #graphics #365DaysOfCode
MongoDB / MERN
Tags: mongodb, mern, react, express
Published: 2021-01-03 01:11:46

I’m going for it, a MERN stack.

But, what are the steps, in order to create info, connection, Schema, ect... untill you send/receive info from the database?

There’s many tutorials, except theres allot of warnings of “out of date”, “soon to be discontinued” ways in MongoDB, so..... if I’m using Atlas, why do I get warnings?, do I need to install MongoDB??
6. DNS
Tags: aws
Published: 2021-01-02 22:03:07

After creating the S3 `static website` and configuring it for a Cloudfront distribution, we got the `HTTPS` security layer, however life is already too stessfull for many to remember Cloudfront Domain name such as `https://d1cs99***.cloudfront.net`

![Alt text](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia1.tenor.com%2Fimages%2F086e1a77c0e349e099cc282ae2f6fc94%2Ftenor.gif%3Fitemid%3D9601871&f=1&nofb=1)

This is where a custom DNS domain name comes into the picture.
`www.komlalebu.com`

#[Route53](https://aws.amazon.com/route53/)
I registered my new domain name on AWS Route53. Route53 is a scalable cloud Domain Name System(DNS) web service where you can register as well as manage your DNS configurations for your domains. 
From the Route53 console I clicked on create hosted zone.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5a8o2nk8p18cyr8ae2nk.PNG)

and named my domain as `komlalebu.com`

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

Once that was done I setup my hosted zone with an `alias` record for sub domain `www` and the alias value pointing to the Cloudfront Domain name which I had previously configured will `SSL certificate` from [ACM](https://aws.amazon.com/certificate-manager/).

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

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

And it was done. The [website](https://www.komlalebu.com) has a simple address now.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0vobgcej8t0ytnl5d9l4.gif)
DS4Windows Profiles folder, and SaveWhere dialogue
Published: 2021-01-03 00:43:18

`%appdata%` in Start > Run

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xk775rz2rsfcy40tgqgg.jpg)
Also could be in program folder.



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

To avoid this dialogue, remove this file:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/w0us3sxjl75tyyqqele7.jpg)
How to: use UUID as Primary Keys in Phoenix
Tags: elixir, phoenix
Published: 2021-01-03 00:08:49

So I decided to use UUIDs as primary keys for the resources I am creating in my webapp. The reason is cause I don't like the default one "auto increment integer".

So how to achieve this in Phoenix?

## 1. Add a custom schema
The idea with the code below is to override `Ecto.Schema` with our new config

```
# lib/your_app/schema.ex

defmodule YourApp.Schema do
  defmacro __using__(_) do
    quote do
      use Ecto.Schema
      @primary_key {:id, :binary_id, autogenerate: true}
      @foreign_key_type :binary_id
    end
  end
end
```

Now, on your schemas you should use `use YourApp.Schema` instead of `Ecto.Schema`

## 2. Fix your Migration!

This one is a very important step. The reason why is because by default when your run your migration it will try to create your tables using the default id (auto increment integer) to fix this is very simple

```
# config/config.exs

config :your_app, YourApp.Repo, migration_primary_key: [name: :id, type: :binary_id]
```
Now when you run your migrations to create your tables the id will be of type binary_id :D.

And that's it. Profit :).
Single-responsibility principle applied to an Organization
Tags: startup, modelling, solid, healthydebate
Published: 2021-01-03 00:00:10

[Single-responsibility principle][srp] says: 

> Every class in a computer program should have responsibility over a single part of that program's functionality, which it should encapsulate. All of that module, class or function's services should be narrowly aligned with that responsibility.
>
> Therefore,
> "A class should have only one reason to change".

---

I have seen this principle being applied to multiple concepts like modules, APIs, Systems, etc. But I haven't seen it applied to an _Organization_ yet. Maybe because it doesn't make any sense at all, but I will try to resonate about it. 

Bear with me, we might not get into any point but worth to try it out 😁

# Let's start replacing computer concepts by organization concepts

> Every ~~class~~ __organization__ in a ~~computer program~~ __society__ should have responsibility over a single part of that ~~program;s functionality~~ __society's needs__, which it should encapsulate. All of that ~~module, class or function's services~~ __organization, product or entity__ should be narrowly aligned with that responsibility.
>
> Therefore,
> "An organization should have only one reason to change".

Does it have any sense at all? It depends.

_Single-responsibility_ seems to only make sense at __Why level__ (company's purpose), not at __What level__ (what the company offers, like products and services).

When I say _why level_ and _what level_, I'm referring to the __Golden Circle__ by [Simon Sinek](https://simonsinek.com/) in his book, [Start with Why](https://www.goodreads.com/book/show/7108725-start-with-why).

![Golden Circle](https://dev-to-uploads.s3.amazonaws.com/i/hearmcsn1xlwqr7kt64a.png)

[Image's source](https://www.smartinsights.com/digital-marketing-strategy/online-value-proposition/start-with-why-creating-a-value-proposition-with-the-golden-circle-model/).

## So, in order to be a SOLID Organization, you need...

to have a __single and well defined organization's purpose__, which it should drive why the organization exists in the first place.

The only reason to an organization to change is that the purpose isn't useful anymore.

It might be that:

- The purpose is already accomplished
- There is no need to exist because there is not a demand
- People don't believe in the purpose anymore

---

## Discussion and feedback welcomed 😁

What do you think? Are you in a SOLID Organization? Does this make any sense? 🤣

![thinking](https://media.giphy.com/media/lKXEBR8m1jWso/giphy.gif)

[srp]: https://en.wikipedia.org/wiki/Single-responsibility_principle
How to delete a branch from a remote repository in Git?
Tags: git
Published: 2021-01-03 00:00:00

---
  title: How to delete a branch from a remote repository in Git?
  published: true
  tags: Git
  date: Sun Jan 03 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/delete-branch-remote-git
  cover_image: https://melvingeorge.me/_next/static/images/main-f6a78aeb9bb78d294e076c07800fbe0d.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/delete-branch-remote-git)
  
In the last post we discussed [how to delete a branch locally in Git?](https://melvingeorge.me/blog/delete-branch-locally-git).

To delete a branch from a remote repository in Git first, you need to delete the branch name from local using the command

```bash
git branch -D <YOUR_BRANCH_NAME>
```

After that you need to push those changes to the remote repository and also by passing the `--delete` flag to delete the branch from the remote repository.

It can be done like this,

```bash
git push origin --delete <YOUR_BRANCH_NAME>
```

That's it. 😃

### Feel free to share if you found this useful 😃.

---
packing / unpacking data in c++
Tags: cpp, opensource
Published: 2021-01-02 23:55:15

Hi there, newbie here, and this is my first post. I decided to restructure some of my github repos since they maybe can be useful to someone :).

The post:

# Packet lib

This is a very short blog post since its a small `c++` `header-only` lib I created, hence the full documentation would be in the [github repo](https://github.com/agudpp/packet).
The `packet` library is intended to provide an easy "API" for packing and unpacking data (messages) so they can, for example, be safely sent over the wire (TCP). Whenever you need to send information over the wire is important to know:

- They are respecting some kind of protocol (otherwise you may want to close the connection).
- What you are getting is complete (need to know when the message start / end).

TCP ensures you that the data will be sent in order, but doesn't ensure that the calls are atomic (reads / writes). Hence, whatever you the data you are sending, needs to be "packed" / "unpacked". For example, `protocol buffers` is a library that serializes messages, but doesn't handle where the message start / end.

## How it works

The packets have the following shape:
`[ head_pattern | pkt_content_len | content | tail_pattern ]`

- head_pattern: (optional) a user defined pattern to detect early wrong or invalid messages over the wire
- pkt_content_len: field indicating the size of the content buffer
- content: the data / content itself
- tail_pattern: (optional) ensure that the packet size was correct and respects the protocol.

The intention of the `packet` library, is to provide an API that let the user read as few characters as needed while checking the validity of the packet while reading it.

# Feedback

As always, very happy to get some feedback, comments, or join forces on the open community.

Salute
Dev Notes #1 - Upgrade to Composer version 2
Tags: composer, php, cli
Published: 2021-01-02 23:54:09

---
title: Dev Notes #1 - Upgrade to Composer version 2
published: true
description: 
tags: composer, php, cli
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/4n13fwwpy7esnk4vlfsd.png
---

Recently I have upgraded to [Composer version 2](https://getcomposer.org/), as well as upgraded all globally installed packages. Here's a list of commands I have used:

* `composer self-update --2` - Update composer to version 2. To read more about Composer 2 benefits, read the [Composer 2.0 announcement](https://blog.packagist.com/composer-2-0-is-now-available/). Read more about `self-update` command [here](https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-).

* `composer -V` - check version
    ```bash
    $ composer -V
    Composer version 2.0.8 2020-12-03 17:20:38
    ```

* `composer global show` - Shows information about globally installed packages. Read more about the `show` command [here](https://getcomposer.org/doc/03-cli.md#show).
    ```bash
    $ composer global show
    friendsofphp/php-cs-fixer          v2.17.3 A tool to automatically fix PHP code style
    laravel/installer                  v4.1.1  Laravel application installer.
    php-cs-fixer/diff                  v1.3.1  sebastian/diff v2 backport support for PHP5.6
    squizlabs/php_codesniffer          3.5.8   PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
    ```

* `composer global outdated` - Shows a list of globally installed packages that have updates available, including their latest version. Read more about the `outdated` command [here](https://getcomposer.org/doc/03-cli.md#outdated).
    ```bash
    $ composer global outdated
    php-cs-fixer/diff v1.3.1 v2.0.2 sebastian/diff v2 backport support for PHP5.6
    ```

* `composer global update` - Upgrades your global dependencies to the latest version according to composer.json, and updates the composer.lock file. Read more about the `update` command [here](https://getcomposer.org/doc/03-cli.md#update-u).

* `composer global update laravel/installer` - Upgrades a given globally installed package to the latest version according to composer.json, and updates the composer.lock file.