teleren/devto huggingface dataset:
How to downgrade Composer via homebrew?
Tags: composer, php, developer
Published: 2021-05-18 20:57:18

---
title: How to downgrade Composer via homebrew?
published: true
description: Using Mac to develop PHP applications without Docker might be tricky sometimes. A useful thing to know is how to easily change your Composer version, following this tutorial you might be able to upgrade or downgrade to any version.
tags: composer, php, developer
canonical_url: https://rafaelcg.com/blog/tutorial/how-to-downgrade-composer-via-homebrew/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjiyd777lwbihuve37e1.png
---

Using Mac to develop PHP applications without Docker might be tricky sometimes. A useful thing to know is how to easily change your Composer version, following this tutorial you might be able to upgrade or downgrade to any version.

## Downgrade Composer
The first thing to check is the versions available to you, running this command below you will be able to see and select which version you want to migrate to.

```
brew log composer
```

## Downgrade Composer with Brew on macOS
Then install Composer and change the version, doing the downgrade directly via Composer command.

```
brew install composer
composer self-update 1.10.15
```

## What’s the Composer purpose
**Composer** is an application-level package manager for PHP that provides a standard format for managing dependencies of PHP software and required libraries. Composer is strongly inspired by Node.js package manager npm, and the Ruby one called bundler.

You can run Composer from the command line and installs dependencies. It also allows users to install PHP applications that are available on Packagist, using the main repository containing available packages.

## Thanks!
If you or your team is struggling with your development workflow using Composer, please don’t hesitate to [let me know](https://rafaelcg.com/contact/). We might be able to evolve your development process by seeing how your processes are set up.

This post was a question and answer that I created in the [Apple StackExchange](https://apple.stackexchange.com/a/406149/199010).
The Kafka offset trap in Spring Cloud
Published: 2021-05-18 20:57:01

This morning, I worked as usual with Java Spring apps and Kafka. I wanted to test the kafka configuration **auto.offset.reset**.

---

By default, following the [Kafka documentation](https://kafka.apache.org/documentation/), the value of **auto.offset.reset** is **latest**.

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

**But when I did my test, I saw that this default configuration is not applied with Spring!**

When I looked in the [Spring Cloud documentation](https://cloud.spring.io/spring-cloud-stream-binder-kafka/spring-cloud-stream-binder-kafka.html), I saw that the default value is **earliest**!

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

---

I don't know why it's configured like this, but it's a little bit confusing.

---

I hope it will help you!
NestJS Dependency Injection with Abstract Classes
Tags: typescript
Published: 2021-05-18 20:43:27

_This article was also posted on [eftech.com](https://www.eftech.com)_

A seemingly common complaint regarding NestJS and TypeScript is the absence of interfaces in runtime code (since interfaces are removed during transpilation).  This limitation prevents the use of constructor-based dependency injection and instead necessitates use of the `@Inject` decorator.  That decorator requires us to associate some "real" JavaScript token with the interface to resolve the dependency - often just a string of the interface name:

```typescript
/* IAnimal.ts */
export interface IAnimal {
  speak(): string;
}

/* animal.service.ts */
export class Dog implements IAnimal {
  speak() {
    return "Woof";
  }
}

/* animal.module.ts */
@Module({
  providers: [{
    provide: "IAnimal",
    useClass: Dog,
  }]
})
export class AnimalModule

/* client.ts */
export class Client {
  constructor(@Inject("IAnimal") private animal: IAnimal) {}

  // Later...
  this.animal.speak();
}
```

This approach is adequate, but the "IAnimal" magic string is a little fragile and not actually associated with the interface.  A modest improvement can be made by exporting a token with the interface:

```typescript
/* IAnimal.ts */
export interface IAnimal {
  speak(): string;
}

export const IAnimalToken = "IAnimal";
// or slightly better...
export const IAnimalToken = Symbol("IAnimal");

/* animal.module.ts */
@Module({
  providers: [{
    provide: IAnimalToken,
    useClass: Dog,
  }]
})
export class AnimalModule

/* client.ts */
export class Client {
  constructor(@Inject(IAnimalToken) private animal: IAnimal) {}

  // Later...
  this.animal.speak();
}
```

At least now the token reference is consistent.  Still, manually injecting tokens like this can be cumbersome and conceptually unsatisfying.  What we would really like is a true JavaScript object in the place of the interface, which we can reference universally at runtime.  What we would really like is...an abstract class!

```typescript
/* IAnimal.ts */
export abstract class IAnimal {
    abstract speak(): string;
}

/* animal.service.ts */
// You can implement an abstract class without extending it!
export class Dog implements IAnimal {
  speak() {
    return "Woof";
  }
}

/* animal.module.ts */
@Module({
  providers: [{
    provide: IAnimal,
    useClass: Dog,
  }]
})
export class AnimalModule

/* client.ts */
export class Client {
  constructor(private animal: IAnimal) {}

  // Later...
  this.animal.speak();
}
```

Now a single, "real" JavaScript reference is used throughout the application to resolve the dependency.  Whether or not the minor inconvenience of token-based dependency injection justifies this usage of abstract classes is a separate question.  If you're feeling lazy, though, this is a convenient option!
Distracted Computer Science - P1
Tags: computerscience, webdev, programming, beginners
Published: 2021-05-18 20:19:05



#Good day, future me!

This blog will serve as an open journal in which I will document my journey into self-teaching Computer Science.

These posts are not meant to be used as tutorials in any way! Consider them more as study notes that, potentially, will be of some benefit to you!

I'm now learning Web development with [Scrimba](scrimba.com) Bootcamp and studying part-time at [OSSU](https://github.com/ossu/computer-science) for a self-taught (unaccredited) Computer Science degree.

I'm looking forward to engaging with others in what seems to be a fantastic community!
I went to the day 1 of the virtual Google IO 2021. What did I learn?
Tags: webdev, google
Published: 2021-05-18 19:49:18

I have never been to a Google IO event in person but wow! What a start to the conference! 
The first Google IO keynote covered topics like: Smart Canvas, Google photos, laMDA, Quantum computing, Privacy, Search, Maps and Shopping. 

One topic that was often mentioned was AI. It's no secret Google has a massive load of data and they are using that data to bring us amazing products and new features. 

Here are a few mentions that I thought were amazing!

## Google Photos - 'Little Patterns'
A new feature is using machine learning to make a moving photo from 2 photos that have been taken in close succession. The example was using 2 photos of their children and filling in the frames using machine learning. There is also a feature to group similar photos together which will discover stories in you photo gallery.

## Skin condition analyser
One project that peaked my interest was a feature in search to detect 288 skin conditions using AI and Image recognition. This feature is hoped to be released by the end of the year and can be achieved by uploading a few photos of the skin from different angles.

## Project Starline
I'm sure like me you have had your fair share of video calls over the last year and google has noted this and they have been researching with a depth camera to compose an realtime video call that looks 3D.

## Material You
Have you used Material Design? It's great! I've used Material UI with React and this new update adds more customisability. One feature that Google demoed was creating a custom color scheme from the lock screen image. 

## Password Manager updates
This tool is a life saver and build into Chrome. And with the new update it will be available in android apps. Passwords can now be imported from other password managers. Highly recommend this tool to suggest passwords aswell.

## Sustainability
Google really wanted you to know their goals of being more sustainable. They became one of the first big companies to be Carbon neutral in 2007 and in 2017 they used 100% renewable energy. And their next goal is being Carbon free energy by 2030, this will be achieved with updates to their data centers and one of their new campus' has a Dragon Scale Solar skin and use a Geothermal pile system underneath.

This was my first Google IO keynote as a junior developer and it was fascintiating to see where google is going and learn about some of the latest breakthroughs. It's clear that AI is not going anywhere and I need to get on that train! Any resources to get up to speed?

Google IO is from 18th - 20th May 2021.
Watch the remaining Google IO 2021 [here](https://events.google.com/io/?lng=en)
Solución a ERROR #1115: Unknown character set: utf8mb4
Tags: mysql, heidisql, laragon
Published: 2021-05-18 19:47:56

# Base de Datos + Error 1115 + Laragon!

Estaba tratando de importar una base de datos de mi máquina local a otra y me encontré con el siguiente error: 
**“ERROR #1115: Unknown character set: utf8mb4”.**
![ERROR #1115](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w2u36y7rb3kaj2547xw.png)

Este mensaje se debe a incompatibilidades de versiones de MYSQL, en un lenguaje mas sencillo es que la versión que utilizamos en local es superior a la que disponemos en el hosting, servidor, etc. (en mi caso en otra máquina local).

# Solución con Visual Studio Code

Para solucionar esto, lo que vamos a hacer, es abrir el fichero **.sql** con un editor de textos plano, en este caso con [Visual Studio Code](https://code.visualstudio.com/Download), y usaremos la herramienta de **“Buscar y reemplazar”**. Vamos a buscar **utf8mb4** y lo vamos a reemplazar por **utf8**.

![visual-studio-code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4jcdp0het3pz4vlpxb7.png)

# Solución Laragon

Como estoy utilizando Laragon, este trae integrado como administrador de base de datos [heidisql](https://www.heidisql.com/download.php)

![heidisqlImage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebmbsaj0ebah97t685h4.png)

Para solucionar esto, lo que vamos a hacer, es abrir el fichero **.sql** en el editor de consultas, y usaremos la herramienta de **“Buscar y reemplazar”**. Vamos a buscar **utf8mb4** y lo vamos a reemplazar por **utf8**.

![buscar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od28lpfpzms6g344ctav.png)

Nuestro archivo quedara de la siguiente manera.

## Antes

![antes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls1wtaq3bln7pazttrv7.png)

## Después

![después](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgnftsiizmin9q48ce6f.png)

# Conclusión

En este post hemos visto dos formas de como podemos corregir el **“ERROR #1115: Unknown character set: utf8mb4”.**, espero te sirva de mucha ayuda.

¡Listos para importar sus Bases de Datos, sin miedo al éxito!
Node.js Streams Quick Introduction
Published: 2021-05-18 19:39:22

Curious to try the streams but you don't know if they can serve you? Let's see its uses together!

## What are Streams?
In an event-based platform such as Node.js, the most efficient way to handle I/O is in real-time, consuming the input **as soon as it is available** and sending the output as soon as the application produces it.

Streams allow us to process the data as soon as it arrives from the resource. This is **different** from buffering, where all the data that comes from a resource needs to be collected into a buffer until the operation is completed.

## What are the advantages of Streams?
Stream has some advantages which can be useful in some use cases:

- **Spacial Efficiency**
You have a super-duper big file to process, with streams you can do it without going out of memory because streams keep going with constant memory utilization.

- **Time Efficiency**
During a multi-step operation, like compressing a file and after, store it, with streams you don't need to wait that the compression has been finished to start with the store operation, every chunk is compressed and stored as soon as is available.

- **Composability**
With the `pipe` command, you can compose all your streams operation to have functions each responsible for one single functionality.

## How Streams are made?
Stream in Node.js is the implementation of one of these classes:
- Readable
- Writable
- Duplex
- Transform

Every stream is also an instance of **EventEmitter**, which is why it is possible to concatenate the `on` function of the classic events in Node.

Streams also support *two* operating modes: 
- Binary Mode
- Object Mode

Let's see an example in Binary Mode:

```javascript
// Our File words.txt
$ cat words.txt 
This
is
an
article
from
dev.to!

// Our code
const fs = require('fs');

const stream = fs.createReadStream('words.txt');

stream.on('data', (chunk) => console.log(chunk.toString()));
stream.on('end', () => console.log('Stream is ended! :)'))
```

And also in Object Mode:

```javascript
const { Readable } = require("stream");

const people = [
  { name: "Renato", surname: "Pozzi", twitter: "@itsrennyman" },
  { name: "Bill", surname: "Gates", twitter: "@BillGates" },
  { name: "Tim", surname: "Cook", twitter: "@tim_cook" },
];

const stream = Readable.from(people);

stream.on("data", (person) =>
  console.log(
    `Hey! This is ${person.name} and this is my Twitter: ${person.twitter}`
  )
);
```

As you can see, you can use streams also to process very big arrays.

In the next article, we will go into the various sub-branches of the streams in order to discover them all!

Thank you for your reading!
Zmsg: Zero-knowledge Messaging on the Blockchain
Tags: rust, cryptocurrency, blockchain, sideprojects
Published: 2021-05-18 19:27:39

Last weekend I've finally finished a functional proof-of-concept command line tool called [zmsg](https://github.com/firmalabs/zmsg) which is built on [Zcash](https://z.cash/), a cryptocurrency focusing on anonymous payments. I've been experimenting with ways to build a social platform that focuses on total anonymity that's censorship-tolerant.

The tool allows anyone with a Zcash [shielded address](https://z.cash/support/faq/#difference-between-t-and-z-addrs) to send a 512-byte maximum ASCII or Unicode message to any recipient with a shielded address with very small possibility of any middleman knowing the identity of either party and the content of the message.

Zcash is built on [Z-snark](https://www.investopedia.com/terms/z/zksnark.asp), a very complex mathematical cryptography which makes it fast and trivial to a prover to prove an ownership without revealing any information about themselves and the owned entity.

The fallback here is the cumbersome experience of spinning up a Zcash daemon, creating and maintaining addresses, and very importantly the time it takes for a message to be verified on the blockchain (which can take several minutes).

I would appreciate if anyone of you could star the project or contribute in anyway. That would greatly motivate me!
Optimization in importing
Published: 2021-05-18 19:22:23

I want to discuss about optimization.
Here are 2 kinds of importing components.

- first case
import { Accordion, Button, Modal } from 'react-bootstrap';

- second case

import Accordion from 'react-bootstrap/Accordion';
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';

Which is better in optimization scope? Or same?
Thanks
WAO: How do you test software?
Tags: watercooler, discuss, wronganswersonly
Published: 2021-05-18 19:12:08

_Cover photo by [Michal Matlon](https://unsplash.com/@michalmatlon?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/wrong-answer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)_
 
---

# Wrong Answers Only

How do you test your software?

---

Comment your wrong answer!
How to configure Nginx configuration file in ubuntu for localhost port forwarding
Tags: nginx, node, docker
Published: 2021-05-18 19:12:07

# `First`
```sh
cd ..
cd etc/nginx/
```
This takes you to the root dir of the Nginx server
then 
```sh
cd sites-available
vim YourSiteName
```
Now,
```vim
server {
        listen 3000 default_server;
        listen [::]:3000 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }
}
```
To save and exit from the vim use this command
```sh
:wq
```
Now, We want to update the sites-enabled dir
```sh
cd ..
cd sites-enabled/
vim YourSiteName
```

```vim
server {
        listen 3000 default_server;
        listen [::]:3000 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                try_files $uri $uri/ =404;
        }
}

```
Now, Rur your project/application and forward the port.
In the given example the defeat port is 3000.

```sh
cd
cd yourProject 
npx http-server -p 3000
```

Check out more on in-depth guide through [Nginx](https://avinash-sharma.com) The Nginx is a reverse proxy that enables the user to host a static and dynamic website
What's your opinion on data-first frontend ?
Tags: watercooler, react, codequality
Published: 2021-05-18 18:55:34

[Read first](https://kea.js.org/blog/2021/05/14/data-first-frontend-revolution/)

2 years into my front-end career, I'm handling projects that I really feel like I need to be studying hard CONSTANTLY in order to reduce technical debt to a minimum.
And then I come across this post which almost convinced me it's the right way to go.
> It's time for a revolution in data-first frontend frameworks, which relegate React to what it does best: rendering and diffing DOM nodes. Values in, actions out. No useState. No useEffect.

...

> It's time for a change. It's time for a paradigm shift. It's time for a revolution in data-first frontend frameworks that control the view layer and not the other way around.

Reading the above 2 paragraphs, I was almost convinced I needed to refactor everything in order to make this possible.

The topic is not whether Kea is the framework to use - but whether this is the right mindset. Throughout my career, my coding style focused on trying to keep as much of the application state non-global as possible. *This post was challenging the very fiber of the thought-process I've been trying to perfect through my frontend career.*

> From that moment forward, I would see this everywhere. If ever I felt like my program was getting too complicated or hard to read, it was almost always a data structure problem

This part honestly - I agree 110%. It actually feels exactly like the state of a project that is increasingly getting harder to develop / maintain.
### But is this what I should be focusing on?
Since my thought process has started to really jump out of the box, maybe I'm focusing on the first seemingly radical idea that I randomly came across that seemingly fits?

Namely,
**Is this Input-Data-View layer parallel hierarchy the way to go?**

What are your thoughts?
Get images instantly while prototyping a website (unsplash.it)
Tags: webdev, html, css, javascript
Published: 2021-05-18 18:28:08

I know many of you Already know about [unsplash](unsplash.com) , from unsplash anyone can get freely-useable images.

But this article is about a shortcut which is the easy-version of [picsum.photos](picsum.photos).

So, basically you can get random image links using these links

`
unsplash.it/width-in-px/height-in-px
or
picsum.photos/width-in-px/height-in-px
`
just what you have to do is add a <img> tag and in source place this link it will give you random images.

### Sample unsplash.it image below
![unsplash image](http://unsplash.it/400/300)

<hr>
# Save this so if you forgot you can check it
Cool Way to Compare Features in Note Apps
Tags: tech
Published: 2021-05-19 08:01:11

---
title: Cool Way to Compare Features in Note Apps
published: true
date: 2021-05-18 18:28:03 UTC
tags: ["tech"]
canonical_url: https://www.sheldonhull.com/microblog/cool-way-to-compare-features-in-note-apps/
---

Nice little site I came across for comparing various popular knowledge & note taking tools with ability to select features most important to you.

[NoteApps](https://www.noteapps.info/apps/compare?note_app=bear%2Bnotion%2Bobsidian&selected_group=appearance#compare-preface)

Note typically a fan of compare based tools, as they often feel like marketing junk, but this was a a pretty cool little implementation.
SWAGGER TO POSTMAN
Tags: programming, webdev, beginners, showdev
Published: 2021-05-18 18:27:30

Convert Swagger documentation to Postman Collection

This article demonstrates step by step process on how to convert swagger endpoint into a postman collection.

**Step 1: Go to the swagger documentation endpoint and click on the link highlighted below.**

![Swagger Doc Indicating which link to be clicked](https://cdn-images-1.medium.com/max/3830/1*C19SuFDLpbxFsUri-bS4EA.png)

**Step 2: Copy the URL**

The user will be redirected to the below route where swagger documentation JSON will be visible. Just copy the URL address.

**NOTE: URL may differ, as currently, I am running in localhost.**

![URL to be copied](https://cdn-images-1.medium.com/max/2000/1*fObY-FNMgOFHBGaRZVZVlA.png)

**Step 3: Open Postman > Import (Top-Left corner)**

Then click Link tab & paste the copied URL from Step 2 & click “Continue.”

![Postman Import using the link](https://cdn-images-1.medium.com/max/2118/1*HGFNeyN96DZQ5tBymYHkoA.png)

**Step 4: Use default settings & click Import, as shown below.**

![Import settings](https://cdn-images-1.medium.com/max/2132/1*_uM9dxPuWs2yr0tYAt2TOg.png)

### A new collection will be created with all the methods shown in Step 1.

![Imported collection from swagger](https://cdn-images-1.medium.com/max/2000/1*-Vm8RZWLTrrDIbxOXLLRgw.png)

The published version of the Postman Collection
[SwaggerUI_CoreExample](https://documenter.getpostman.com/view/12286385/T1LHG9NY?version=latest)

Thank you for reading. Keep visiting and share this in your network. Please put your thoughts and feedback in the comments section.

Stay tuned with me on [Medium](https://singhsukhpinder.medium.com/) 


<a href="https://www.buymeacoffee.com/sukhpindersingh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>