teleren/devto huggingface dataset:
SQL 50–584. Find Customer Referee
Tags: leetcode, sql, mysql, interviewquestions
Published: 2023-09-19 00:11:11

It’s an easy [problem](https://leetcode.com/problems/find-customer-referee/) part of the SQL 50 interview plan that states:

---

```
Table: Customer

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| id          | int     |
| name        | varchar |
| referee_id  | int     |
+-------------+---------+

In SQL, id is the primary key column for this table.
Each row of this table indicates the id of a customer, 
their name, and the id of the customer who referred them.
```

Find the names of the customer that are not referred by the customer with id = 2.

Return the result table in any order.

The result format is in the following example.

---

This is a good easy example of how it is important to read the schema and make the query on the right way.

At first glance you would just retrieve all names where the referee id is not two right? but through the schema you can see that the ids can also be null, so because of that you will also need to add that condition, with the result being:

```sql
SELECT name FROM Customer WHERE referee_id <> 2 OR referee_id IS NULL;
```

> Runtime: 914 ms, faster than 90.86% of MySQL online submissions for Find Customer Referee.
> Memory Usage: 0B, less than 100.00% of MySQL online submissions for Find Customer Referee.

_What’s the difference between <> and != ?_

The first one is ISO Standard while the second one is not, so I tend to get with the standard, but feel free to use != as well.

Is there a way to have only one condition instead of two? yes there is, you can use coalesce or ifnull checks, but is not faster than two conditions:

```sql
SELECT name FROM Customer WHERE COALESCE(referee_id, 0) <> 2;
```

> Runtime: 1133 ms, faster than 50.93% of MySQL online submissions for Find Customer Referee.
> Memory Usage: 0B, less than 100.00% of MySQL online submissions for Find Customer Referee.

---

That’s it! If there is anything thing else to discuss feel free to drop a comment, if I missed anything let me know so I can update accordingly.

Until next post! :)
Is Debugging Really More Fun Than Coding?
Tags: discuss, beginner, codenewbie
Published: 2023-09-19 00:00:00

---
published_at : 2023-09-19 00:00 +0000
---
🎤🔊 _Hey all tech enthusiasts, it's time to rumble in the digital jungle! In one corner, we've got bold and controversial tech statements, ready to assert their dominance. And in the other corner, we've got you, the fearless challengers, set to prove 'em wrong! Get ready to rumble as we dive into debates, challenge the status quo, and wrestle with some of the biggest questions in tech!_


> Prove me wrong: Debugging is more enjoyable than writing code.

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
ELD MANDATE
Tags: eld, dashcam, besttruckingcompany
Published: 2023-09-18 23:13:59

Best ELD for Owner Operators and Large Fleets
Top Rated ELD Device
ELD Hardware & Software
All Features in one place: HOS, IFTA, DVIR,  GPS Tracking & Back Office

Tablet & Data
8" Tablet
2GB DDR
Quad Core Processor 1.4Gz
4G LTE
1 GB AT&T Data Card
Plus Accessories

Smart Dash cam
Hard Breaking & Acceleration Video
Reduce Insurance Premiums by up to 5%
150 degree wide angle lens roadside  camera
140 degree driver facing camera  (removable)
Three Axis G Sensor
Plus Much More

Trailer Tracking
Track where your Asset is for peace of  mind
Near real time tracking
Location sharing of trailer automatically  to customers
Save time with trip notifications

Bundled Package

No Hardware Cost
Bundle to save
All technology under one Umbrella

Contact Us:-
1-800-601-4511
supportdesk@eldmandate.biz

Website:- https://www.eldmandate.biz/
Looking for Remote full time Job/Internship
Published: 2023-09-18 23:10:42

Hello, Everyone,I am looking for a remote fulltime job,I am sharing my developer profile and would really appreciate if someone can help.
Github-https://github.com/Ash-KODES
Linkedin-https://www.linkedin.com/in/ash-kodes
Resume-https://bit.ly/3JSj1RQ

🙏 Thanks
pcre2.h - file not found. How to fix that when installing PCOV on macOS?
Tags: php, macos, pcov, codecoverage
Published: 2023-09-18 22:23:24

For some reason, I managed to mess up the PHP installation on my operating system. Well, no biggie, let's uninstall and reinstall it, no problem.

I installed the main extensions I use, and when I tried to install `pcov` - boom, a fatal installation error occurred:

![homebrew error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whxxroi3ro6ygdxqex25.png)

Cool, all I need to do is install `pcre2`, right? 🙂

But it wasn't that simple. When I ran `brew install pcre2`, I was informed that it was already installed.

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

## Fixing the Issue

I checked some tutorials but couldn't find anything. I even tried creating a symbolic link for the "missing" file, but without success:

```bash
ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php/8.2.10/include/php/ext/pcre/php_pcre.h
```

So, it was time for the brute force approach. Searching by myself, I found out how to solve that problem:

```bash
ln -s /opt/homebrew/opt/pcre2/include/pcre2.h /opt/homebrew/opt/php@8.2/include/php/ext/pcre/
```

After that, just run `pecl install pcov`, and you're good to go!

![pcov-instalado](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7iq4u5txewep8i1tq9t.png)

Now I'm able to calculate the code coverage of my applications again.

That's all, folks! 😗 🧀
Building a Simple Restaurant Recommendation System with Python and Autocomplete
Tags: python, beginners, programming
Published: 2023-09-18 22:18:35

Are you a foodie looking for a quick way to discover great restaurants? Or maybe you're a Python enthusiast eager to learn how to implement autocomplete functionality in your projects. This blog post will walk you through building a basic restaurant recommendation system with Python, incorporating an autocomplete feature. We'll use Python's capabilities and a sample dataset to make this happen. Have a look at it here(https://github.com/Pharaoh44/user_recommendation)
go-go-web - My txt to html converter!
Tags: opensource
Published: 2023-09-18 22:15:28

I have a released my first open source app, a command-line tool written in Python which converts .txt file(s) to .html. This is my first step to creating a full-fledged static site generator!

In my first release v0.0.1, the tool is capable of:
- converting TIL posts written in a .txt file or a folder of .txt files to .html
- specifying the output folder
- specifying the url of a css stylesheet

[GitHub Repo](https://github.com/kliu57/go-go-web)

## Installation

1. Download and install the latest version of [python](https://www.python.org/downloads/)
   
2. Open a terminal and navigate to where you want go-go-web to be stored. Clone this repository locally
```
git clone https://github.com/kliu57/go-go-web.git
cd go-go-web
```

3. Check that you have the latest version of the app.
```
python convert.py --version
```
------------------------------------------------------
## Usage

### Convert .txt to .html

```
python convert.py -i <file or folder path>
```

```
# Example (Convert one file)
python convert.py -i ./examples/til_post1.txt
```
- [See output](https://kliu57.github.io/gogoweb/til_post1.html)

```
# Example (Convert a folder of files)
python convert.py -i ./examples
```
- Output(s) can be found in til folder

------------------------------------------------------
### Specify Output Location

```
python convert.py -i <file or folder path> -o <folder path>
```

```
# Example
python convert.py -i ./examples/examples.txt -o ./examples
```

------------------------------------------------------
### Specify Stylesheet

```
python convert.py -i <file or folder path> -s <stylesheet url>
```

```
# Example
python convert.py -i ./examples/til_post2.txt -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
```
- [See output](https://kliu57.github.io/gogoweb/til_post2.html)

------------------------------------------------------
### View App Version

```
python convert.py --version` or `python convert.py -v
```

------------------------------------------------------
### View Usage Message

```
python convert.py --help` or `python convert.py -h
```
</br></br>
NEW GLOCK 17 G5 9MM 4.49 INCH 17RDX3 9 MM G17 GEN5 FULL SIZE
Tags: gun, rifl, music, pop
Published: 2023-09-18 22:09:33

**Description**

G17 Gen5 – The latest generation of the initial
The brand-new frame style of the [GLOCK 17 Gen5](url) eliminated the finger grooves for more flexibility but still permits to easily tailor its hold by using the different Beavertail Backstraps. The slide has the superior GLOCK hard-surface nDLC surface in non-reflective black. It comes with front serrations (FS) which offer an added tactile surface area selection when controling the slide offering the driver favorable traction even with damp or perspiring hand.

The flared magwell of the structure gives the individual more rate throughout refilling when split seconds issue. A relatively easy to fix enlarged publication catch, unpredictable at individual degree in addition to the ambidextrous slide stop lever fit left and also right-handed drivers.

Every G17 Gen5 includes the match-grade GLOCK Marksman Barrel (GMB) supplying increased precision with polygonal rifling and a boosted barrel crown.

Caliber: 9mm
Overall Length: 7.95″
Height: 5.47″
Width: 1.34″
Weight With Empty Magazine: 22.26 oz.
Barrel Length: 4.49″
Capacity: 17+1
Chambered in 9mm Luger
5th generation of the first GLOCK model released
Glock Marksman Barrel
Gen5 increased reliability
Ambidextrous slide stop
Reversible mag catch
Front and rear cocking serrations
Beveled front end for easier reholstering
Ion-bonded nDLC coating
Straight front strap
Integral accessory rail
Includes 3 magazines
Flutter: Avoiding the Top Mistakes
Tags: flutter, beginners, dart, programming
Published: 2023-09-18 21:55:31

## Widgets and Layout

- Avoid using SizedBox to artificially constrain size. Use MainAxisSize.min instead.
- Avoid deeply nesting Flex widgets like Column and Row. Extract contents to separate widgets.
- Extract repeating UI components into separate widgets early for better testability and reusability.
- Constrain child widget size to avoid RenderFlex overflow, for example with Expanded or Flexible.
- Provide layout information to widgets to avoid 'RenderBox was not laid out' errors.
- Constraint scrollable widgets like ListView when placed inside Column to avoid unbounded height. 
- Use Expanded or SizedBox to constrain TextFormField inside Row to avoid unbounded width.
- Ensure parent widget is compatible with ParentDataWidget children.
- Don't call setState in build method, for example when showing Dialog, as it can lead to errors.
- Use OrientationBuilder to handle UI issues when orientation changes.

## Architecture and Organization

- Decouple UI components from business logic by using dependency injection, for cleaner code.
- Use state management solutions like Provider early on for more complex apps.
- Learn basics of Android and iOS development to better understand Flutter.
- Implement features yourself before using packages to better learn fundamentals.
- Separate concerns following best practices for clean, maintainable code.
- Use named routes for clearer navigation instead of Navigator.push().

## Testing and Quality

- Write tests like unit, widget, and integration tests to ensure app works as expected. 
- Carefully handle errors to avoid crashes. Validate input and use catchError.
- Use Dart profiler to optimize performance and avoid lag and delays.
- Learn about Flutter widget lifecycles to avoid issues like not disposing controllers properly.
- Remember to fully restart app if bugs appear after adding a native plugin, as hot reload won't update native code.

## Best Practices

- Use linter package for consistent, clean code. Enforce good practices.
- Extract reusable UI into widgets to optimize performance and reduce rebuilds.
- Ask questions! The Flutter community is helpful and wants to see you succeed.
Guia básico da revisão de código
Tags: codereview, dx, braziliandevs
Published: 2023-09-18 21:41:12

Uma pessoa que desenvolve software terá o seu código revisado e revisará o de outras pessoas praticamente todos os dias, e mesmo com essa repetição às vezes esquecemos um ponto ou outro.
Este é um guia com pontos básicos a serem verificados em uma revisão de código, fique à vontade para usar/modificar/melhorar, na sua empresa ou projeto open source.

## Para quem solicita

1. Escreva boas mensagens de commit (seguir o [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) é um bom início);
2. Revise seu pull request antes de abrí-lo, tenha certeza que você não esqueceu algum debugger ou erro de digitação;
3. Deixe seu pull request pequeno, isso o mantém fácil de revisar e menos nocivo ao negócio;
4. Garanta que seu pull request passe nos testes, linters e builds, e não tenha conflitos;
5. Escreva uma boa descrição;
6. Comente no seu próprio pull request caso algum trecho de código não seja óbvio;
7. Espere o revisor terminar para começar a corrigir;
8. Escolha os revisores corretos (exemplo: alguém que já tenha trabalhado na mesma parte do código);

## Para quem revisa

1. Seja gentil;
2. Seja uma pessoa minuciosa (este [documento](https://www.morling.dev/blog/the-code-review-pyramid/) pode te ajudar);
3. Busque contexto. Leia a descrição do pull request, o ticket, verifique até mesmo as telas (se houver);
4. Tenha certeza que você separou tempo necessário para entender e fazer a melhor revisão de código que você puder;
5. Respeite o contexto. Se um pull request resolve um bug, não peça para a pessoa desenvolvedora refatorar todo o componente, isso pode ser resolvido no futuro;
6. Deixe claro que você está fazendo a revisão, comente _Revisando_ ao iniciar, e _Revisado_ ao terminar.

**Esse guia é vivo e está em constante evolução** :wink:
My First Open-Source Project: TILerator
Tags: opensource, programming, javascript, cli
Published: 2023-09-18 21:13:20

TILerator is a command-line tool that will be able to convert `.txt` files  into `.html` files. This tool uses `JavaScript` and `Node.js` to process files that are located at the file path given. The file path can either point to a singular file, or it can be a directory path that contains multiple `.txt` files. I will provide a brief description about the tool's features and how to use it, but more information about this tool can be found here: [TILerator](https://github.com/mismathh/TILerator).

<h2>Installation</h2>
Clone repository and install

```
git clone https://github.com/mismathh/TILerator.git
cd TILerator
npm install -g .
```
> Node.js and npm must be installed on your system

<h2>Usage/Examples</h2>

```
TILerator [flag] <filePath | directoryPath>
```

Pass in a flag
```
TILerator <flag>

--> TILerator -v
```
Pass in a file path or directory path
```
TILerator <filePath | directoryPath>

--> TILerator ./examples/example1.txt
```
Use the `-o` or `--output` flag to generate html files in a custom folder
```
---> TILerator ./examples/til_Sample.txt -o ./htmlFiles
```

<h2>Features</h2>
 - Provide `--version` or `-v` flag to view version
 - Provide `--help` or `-h` flag to view help/usage message
 - Provide a path for a file to generate an html file
 - Provide a path for a directory to generate html files for each text file 
 - Adds HTML markup tags such as `<p>...</p>` to text
 - Outputs files to `./til` folder by default
 - Parses title from text file to enhance HTML with `<h1>...</h1>` markup tags
 - Allows a custom output folder path to be passed using `--output` or `-o` flag

<h2>Flags</h2>

| Flag | Description |
| ---- | ----------- |
| -v, --version | Displays version of tool |
| -h, --help | Display help/usage menu |
| -o, --output | Allows for custom output folder |
> Custom output folder path must be placed right after `-o/--output` flag
Fixing "Can't resolve module 'next/headers'" for Next 12 + Next Auth
Published: 2023-09-18 21:15:02

---
title: Fixing "Can't resolve module 'next/headers'" for Next 12 + Next Auth
published: true
date: 2023-09-18 21:08:29 UTC
tags: 
canonical_url: https://mauriciord.dev/fixing-cant-resolve-module-nextheaders-for-next-12-next-auth
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/newqjtoo86ef0y146qzr.png
---

If you use NextAuth within your Next.js v12.x project, you've probably faced this issue:

```
Can't resolve module 'next/headers'

```

The only way I found it was by applying a `patch-package` to the Next Auth package. Let's fix it:

- Change your **package.json** :

```
// package.json
"scripts": {
    "postinstall": "patch-package"
}

```

Then execute:

```
yarn add -D patch-package postinstall-postinstall

```

After that change, you'll need to change two files inside your `node_modules`:

- `node_modules/next-auth/next/index.js`

- `node_modules/next-auth/src/next/index.ts`

Modify them one by one:

you need to look for "next/headers" and you'll notice two pieces using it.

```
// node_modules/next-auth/next/index.js
// node_modules/next-auth/src/next/index.ts

if (isRSC) {
     options = Object.assign({}, args[0], {
      providers: []
     });

    const {
    headers,
    cookies
    } = require("next/headers");

    req = {
      headers: Object.fromEntries(headers()),
      cookies: Object.fromEntries(cookies().getAll().map(c => [c.name, c.value]))
    };
    res = {
      getHeader() {},
      setCookie() {},
      setHeader() {}
    };
} else {
    req = args[0];
    res = args[1];
    options = Object.assign({}, args[2], {
        providers: []
    });
}

/*
* replace with else only
*/
    req = args[0];
    res = args[1];
    options = Object.assign({}, args[2], {
        providers: []
    });


// node_modules/next-auth/next/index.js
// node_modules/next-auth/src/next/index.ts

// remove this const { headers, cookies } = require("next/headers")
// from async function NextAuthRouteHandler(

cookies: Object.fromEntries(
    Array.from(req.cookies.entries())
        .map(([name, value]) => [name, value])
),
headers: req.headers, // you don't need this as Headers

```

After applying those changes, you must run:

```
yarn patch-package next-auth

```

This will create the patch file. You can also refer to this [gist here](https://gist.github.com/mauriciord/9af1ebd21aa066c9dd73860a90996efa).

That's it. Byte bye!

## P.S.: Troubleshooting

```
rm -rf node_modules yarn.lock package-lock.json .next

yarn

```
function of function & closure
Tags: webdev, javascript, closure, function
Published: 2023-09-18 20:28:20

A "function within a function" and a "closure" are related concepts, but they have distinct differences:

1. **Function within a Function:**
   - This refers to a function that is defined inside another function.
   - The inner function can access variables and parameters of the outer function, but it does not necessarily create a closure.
   - The inner function can be invoked only within the scope of the outer function.
   - Once the outer function finishes executing, the inner function's access to the outer variables may be lost.

2. **Closure:**
   - A closure is created when an inner function "closes over" its surrounding lexical (scope) environment, capturing and retaining access to variables even after the outer function has finished executing.
   - Closures allow the inner function to access and "remember" the variables of its outer function, even outside the outer function's scope.
   - Closures are not limited to being invoked only within the scope of the outer function; they can be passed around and invoked from different places, preserving access to the captured variables.

every closure is an example of a function within a function, but not every function within a function creates a closure. A closure specifically occurs when an inner function maintains access to its enclosing scope, allowing it to access variables from the outer function even after that function has completed its execution.
Textml
Tags: opensource, osdc, github, html
Published: 2023-09-18 19:54:18

I have created my first version of a truly open-source program called Textml. It is a Python program that converts text files to basic HTML files. 

To use the program you provide either a text file or a folder containing text files to be converted to HTML. They will then be saved to a default directory *textml/* for use. 

## Features

- Provide custom output directory 
      - Creates new directory if output directory doesn't exist
- Title parsing from text files (First line followed by 2 newlines only)

The project is located on my GitHub at https://github.com/ijacobs-cpa/textml


## Instructions

To run this program you first need to clone the repository from GitHub and open the repository locally.

```bash
$ git clone https://github.com/ijacobs-cpa/textml.git
$ cd textml/
```

To run make sure that you have Python installed on your system:
`$ python --version`

Once installed you can then run the Python script:

`$ python textml.py [file/directory] <commands> [command argument]`
or
`$ python textml.py <options> `

### Options 

| Command   | Description |
| --------- | ----------- |
| -v, --version | Displays version of the program |
| -h, --help | Displays a help message |
| -o, --output <output-location\> | Specifies the location to save converted files, creates a new folder if location doesn't exist, defaults to textml/ |


## Examples 

Converting a file:

`$ python textml.py myfile.txt`

Converting all files in a directory:

`$ python textml.py mydirectory/`

Running Commands:

`$ python textml.py -v`

Specifying Output Directory:

`$ python textml.py myFile.txt -o newDir/`

## Results

Here is an example of a text file being converted:

command:

`$ python textml.py examples/liveTest/index.txt -o examples/liveTest/`

```
Today I learned


Documenting some information I've learned today

Here is some information:


6502 Assembly Notes (KEY_terms):

#{number} adds a nuber
${hex} adds a hexadecimal

LDA = Load the accumulator

LDY = Load the Y register
LDX = Load the X register

STA = Store the accumulator
STY = Store the Y register
STX = Store the X register

CPX = compare THE x register
```

```HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Today I learned</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Today I learned</h1>
  <br />
  <p>Documenting some information I've learned today</p>
  <br />
  <p>Here is some information:</p>
  <br />
  <p>6502 Assembly Notes (KEY_terms):</p>
  <br />
  <p>#{number} adds a nuber</p>
  <p>${hex} adds a hexadecimal</p>
  <br />
  <p>LDA = Load the accumulator</p>
  <br />
  <p>LDY = Load the Y register</p>
  <p>LDX = Load the X register</p>
  <br />
  <p>STA = Store the accumulator</p>
  <p>STY = Store the Y register</p>
  <p>STX = Store the X register</p>
  <br />
  <p>CPX = compare THE x register</p>
  <br />
</body>
</html>
```

Static site: https://ijacobs-cpa.github.io/textml/examples/liveTest/index.html