teleren/devto huggingface dataset:
Zustand - better redux-devtools middleware
Tags: zustand, react, redux, devtools
Published: 2022-11-16 23:11:32

👋 Hi all,

Today I wanted to share with you a small improvement that I've made for [Zustand](https://github.com/pmndrs/zustand) for local react state management.

# Warning
> NOTE: the feature described in this post is already included in `zustand` version `v4.2.0`. So go ahead and update your zustand version to use this feature. You can still read this post for fun.


Zustand is a great tool, and it has a built in redux devtools integration.
We all know that it can be used like this:
`import { devtools } from 'zustand/middleware'`
It already has great features built in out of the box, but lacks some functionality that you may be used to find in redux devtools.

## Current zustand devtools middleware problem
Zustand is meant to be used to create as many stores as you want with `create`.
In current implementation in order to use a rewind feature of redux devtools extension, you will need to select in a dropdown different stores in which you can do time traveling. So switching back and forth for each store in redux devtools is not really convenient and you would want to have a time travel in one tab for all stores. Besides, redux-toolkit has this feature built in out of the box.

![Demo with a current problem of zustand devtools middleware](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3iyjzt4mqwfuicjqbwre.gif)*Demo with a current problem of zustand devtools middleware*


## Solution
In order to use one redux devtools extension connection for all your zustand stores you can use this package `@pavlobu/zustand` instead of `zustand`.

```
npm i @pavlobu/zustand
```

*NOTE: this package can be used temporarily. Zustand developers may include `@pavlobu/zustand` devtools middleware feature in future with a PR that I’ve opened.. I will update this post in case it will be merged.*

The `@pavlobu/zustand` has the same interface for zustand devtools middleware.
Just use
`import { devtools } from '@pavlobu/zustand/middleware'`
or
`import { devOnlyDevtools } from '@pavlobu/zustand/middleware'`
`devOnlyDevtools` can be used if you need redux devtools only for development builds. [More details](https://github.com/pavlobu/zustand/tree/%40pavlobu-zustand-devtools-middleware/examples/dev-env-devtools-many-stores#note-on-devonlydevtools-usage)
### [Refer to this demo project on how to use `@pavlobu/zustand`](https://github.com/pavlobu/zustand/tree/%40pavlobu-zustand-devtools-middleware/examples/dev-env-devtools-many-stores)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/162k7welxcoym0c42h8q.gif)*Demo of a solution. One redux devtools extension connection can be used for all zustand stores*

That's it, hope you've enjoyed this tiny little improvement on an awesome zustand devtools middleware.
Stay tuned, because who knows, maybe his feature will be approved by zustand developers and will be included in the next release :)

Have a nice day! 👋
eBook sobre Python
Tags: python, ebook, embarcadero, estudiar
Published: 2022-11-16 21:56:09

Comenzando en Python GUI 2.1 --Embarcadero Tech--
[https://twitter.com/EmbarcaderoTech/status/1592940680950689792?s=20&t=smFJ4asUYqOmlj9fcREvXQ](https://twitter.com/EmbarcaderoTech/status/1592940680950689792?s=20&t=smFJ4asUYqOmlj9fcREvXQ)
Typescript Single Import Type Equality Check
Tags: webdev, programming, tutorial, typescript
Published: 2022-11-16 18:41:05

background: [type equality check](https://stackoverflow.com/questions/53807517/how-to-test-if-two-types-are-exactly-the-same)

Typescript power users often find themselves in the need of type equality check, and this is the usual way to do it

```ts
export type IsEqual<T, U> =
  (<G>() => G extends T ? 1 : 2) extends
  (<G>() => G extends U ? 1 : 2) ? true : false

export const IsTrue = <T extends true>() => {
} 

const a = {a:1,b:2,c:3}
const b = {x:7,y:8,z:9}

IsTrue<IsEqual<typeof a,typeof b>> // error
IsTrue<IsEqual<typeof a,typeof a>> // ok
```

We always need to import `IsEuqal` and `IsTrue`, why can't we just import `IsEqual`? 

This is because `IsEqual` only return the result, to show the error (the red line), we need `IsTrue`, IsTrue can be another utility type or function, function is preferrable because we write less code with it.

So can we make life easier, can we combine `IsEqual` and `IsTrue` so we only need to import one type/function?

The answer is yes and this is how you do it:

check variable type:
```ts
export const IsEqualIsTrue=<T,U>(v:T extends never ? T: T extends never ? T : T, u:U extends never ? U : IsEqual<T,U> extends true ? U : "fail equality check")=>{
  //
}

IsEqualIsTrue(a,b) // error
IsEqualIsTrue(a,a) // ok
```
I will explain why we need `T extends never ? T: T extends never ? T : T` in my another post

check type:

```ts
export const IsEqualIsTrueType=<T,U>(...args: IsEqual<T,U> extends true ? [] : ["fail equality check"])=>{
  //
}

type A = {a:1,b:2,c:3}
type B = {x:7,y:8,z:9}

IsEqualIsTrueType<A,B>() // error
IsEqualIsTrueType<A,A>() // ok
```

[playground](https://www.typescriptlang.org/play?#code/PTC848BcHcHsAEBLAtgBzgJypXAoAUwA8NsEoBPNAhASQGcBRARwFcBDAGwB4AVAGgQBVAHwJQeBAgAU3AOIjpASnFi5CYlAIA7ACb0EvBAH4EARgQAuBACYVmnfskz5ilaDUaiWvQaEnzK1sVUyhMVhprADMuegI8QhIsKAQAYzhtehSGXnCaUAQ+Lx99cjy3VQQAbzwAXwQE9MyU9nFq9kszfgAjSxt+VMsAZlq8JqyEbraqoksAdn4KSwAOfgAvSwBOUbwcvO4GFg4eSmo4KIR2flOCc8mRMRANTEwsXfpciIOmNi5uG7uVwBF3YDwSIFwkAyNFQpBwkISxDhaQyE0Ov04ewioD4-FE0gAbpYjA5fAhtAQCQRMAFeNYSd5HAYKVSaaYjPT+KxLP5SaUWdSAv5rOjjrjRMUmWUIkKggAiGJITgaDFIShpAAWBFSAGs5UoPDUpCA6glRVwsQRpFduiontTXph3kcLR88tb+Ow7cAEHAdeCwJDwNDkOhkuQqAQg4ikmRxtkfsdLbxIziBPiAHRZ9iYADm9BFib+6bEfIMYRlpgA2gBdIJVhXsJUq45qiia7V6msGkRGhAmnY3BAAQWmHS6vX6gxGeCHACFprMFktVhttmai5i3REU9RuMP+HOKvaXm9zVvPgRdwR9-xh8efX68EA)

You still need to write one type and one function, but you only need to export the function.

Enjoy!
Getting Started on Elixir and Ecto Part 7
Tags: elixir, database, programming, webdev
Published: 2022-11-16 21:30:18

## Deleting Data

Similar to [updating](https://dev.to/itskenzylimon/getting-started-on-elixir-and-ecto-part-6-64k), we must first fetch a record from the database and then call `Taskers.Repo.delete ` to delete that record:

{% embed https://gist.github.com/itskenzylimon/95a55f0cf5ac776bd979f80039ef6687 %}

Similar to insert and [update](https://dev.to/itskenzylimon/getting-started-on-elixir-and-ecto-part-6-64k), delete returns a tuple. If the deletion succeeds, then the first element in the tuple will be `:ok`, but if it fails then it will be an `:error`.

This marks the end of our 7 part **Elixir Ecto tutorial**, if you’ve missed some parts, feel free to go through [My profile posts](https://dev.to/itskenzylimon) and you can find a detailed scope of the topic.
Software Development Trends for 2023
Tags: softwaredevelopment, trends
Published: 2022-11-16 20:44:25

As software is taking over the world, the development strategies we use have to evolve in lockstep to keep pace. With development teams constantly looking to innovate and improve their efficiency, there are a few defining software development trends emerging that will influence how we deliver software in 2023 and beyond.

> **To find out about the key trends defining software development in 2023, continue reading on Symflower's blog:**
[**Software development trends for 2023**](https://symflower.com/en/company/blog/2022/software-development-trends-2023/)
Over 40% And Counting
Published: 2022-11-16 20:32:14

Today I tried to wrap my head around the concept of 'closure'. The lecturer said, the students argue that closure must be the most complicated concept to understand. It is frankly quite comforting to know that probably this will be the most difficult part to grasp when it comes to JavaScript. 
Things went impressively well up to this point, in the overall process, yet the only sad part is, I tend to forget the tiny details that were taught earlier, and the lecturer said "When you understand all the aforementioned concepts, then it must be fairly easy to get the concept of closure.", then the lecturer added, at the end of the lecture, "When you know how things really work, then you'll be a confident developer", and that's exactly what I want to be! That's why I'll go back when necessary, and at the end of the course I'll make sure that I got the best out of this wonderful course. And when I can demonstrate that I internalized and can implement the concepts, then I am supposed to find an entry-level job, right?
DevSearch as a tool for developers (Beta 2.0)
Published: 2022-11-16 19:50:14

Are you frustrated when you want to search for things for developers, but Google or other searcher aren't sufficent enough because you have to go through all the videos and completely endless articles?  If the answer is yes, you can go to our new website we made specifically for developers - DevSearch...this Search Engine is designed for developers and will give you only relevant tools and informations. **https://devsearch.publishlife.repl.co/**
Turning your Rails App into an API
Published: 2022-11-16 19:49:02

When you generate a scaffold in Rails you'll get the method 
**respond_to**, this method would let you render data in other formats including **JSON**. To service the same data you are rendering on HTML as an end-point, you could make the following change under your controller using your own variables:
```
def index
# Using an @task model
respond_to do |format|
  format.json do
    render json: @task
  end
end
```
Alternatively, you could do this to render more formats and also use a shorter syntax:

```
def index
  @tasks = Task.all
  respond_to :html, :json, :xml
end

```
Microsoft Teams Monitoring and Diagnosis in 3 Clicks or Less!
Published: 2022-11-16 19:41:24


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htt3b50t5la5rvjadysx.jpg)

Watch this [Teams monitoring video](https://www.exoprise.com/resources/microsoft-teams-troubleshooting-diagnosis-3-clicks/) and learn how to obtain real-time Microsoft Teams diagnostics, hop-by-hop insight, and network path performance visibility with just three clicks or less.

Your end-users can be distributed and work from anywhere. Ensuring a superb call-quality experience with Teams is a business-critical requirement.

Using a combination of proactive synthetics and real user monitoring (RUM), IT teams can gain comprehensive visibility into Microsoft Teams performance and use those insights for [optimizing the digital experience](https://www.exoprise.com/solutions/digital-experience-monitoring/).

No matter what unified communication app you use, **only Exoprise delivers deep network diagnostics and troubleshooting capabilities for Microsoft Teams, Zoom, RingCentral, and WebEx.**
TL;DR: Code ergonomics
Tags: programming, productivity, beginners
Published: 2022-11-16 19:10:25

When you have competing conventions it can help to choose to check which convention has better **ergonomics**.

I am going to provide my own definition ([another definition of code ergonomics](http://www.club.cc.cmu.edu/~cmccabe/blog_the_ergonomics_of_computer_code.html)).

> Code ergonomics is **everything beyond the solution** to a product problem: it is syntax highlighting, readability of variable names, easy-to-understand small functions, meaningful composition, great file names, etc.

Ergonomics also means productivity.

Now let's see a real-world example.

## The `index.js` convention vs. "smurf-naming"
Let's say your architect made a decision to neatly put the most important code into the `index.js` (or `.php`, `.ts`, whatever) file of a descriptive folder, i.e. `controllers/publish-draft/index.js`

Importing it into another file would be very neat:
```javascript
import { PublishDraftController } from 
 './controller/publish-draft';
```

Now compare this with the file, same controller but smurf-named:
`controllers/publish-draft/publish-draft.ts`

Importing it and it looks like someone stammering:
```javascript
import { PublishDraftController } from
 './controllers/publish-draft/publish-draft';
```

**Clearly first version is the winner, right?**

Wrong!

> When you code you only look at `import` statements _once_ to make sure you imported the right thing (if there are several entities with the same name). On the other hand you are going to very frequently read the tabs of your IDE, and the name of files in test results and so on.

Take a look at this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uw0fseibox69ifi37clu.png)

Which one do you think is more informative?

## Summary
When you make decisions keep the IDE you and your colleagues use in mind. The code that plays nicely with it will also increase the productivity of your team.

(Art was generated by MidJourney AI)
VIDEO 2022 Tech Layoffs: Experts on hiring freeze & job cuts
Published: 2022-11-16 18:50:37

One of the most discussed topics and big news right now is tech layoffs: Twitter layoffs with over 50% of staff cut in one day, as well as Meta layoffs and others. Apple and Amazon “paused almost all hiring” and announced hiring freeze for 2023. Lyft and Stripe said they are laying off hundreds of employees.

More detailed info about the job cuts on the layoffs tracker site: https://layoffs.fyi/ 

Other tech companies started to hunt for top developers who just lost their jobs. But is it really the right strategy right now? And how startups can attract top tech talent besides offering huge salaries?

We asked experienced tech leaders about how it will influence smaller tech companies and startups and what should developers do in this situation.
Basic template for creating an API project with node/typescript/swagger
Tags: beginners, tutorial, node
Published: 2022-11-16 18:43:22

## Getting Started

Clone the repository and install the dependencies.

```bash
git clone https://github.com/jsalio/ExpressWebApiTemplate
cd ExpressWebApiTemplate
pnpm install
```

### Prerequisites

- [Node.js](https://nodejs.org/en/)
- [TypeScript](https://www.typescriptlang.org/)
- [Nodemon](https://nodemon.io/)
- [Express](https://expressjs.com/)
- [Swagger](https://swagger.io/)
- [tsoa](https://tsoa-community.github.io/docs/getting-started.html)

### Folder structure

```bash
├── README.md
├── package.json
├── lib
│   ├── app.ts
│   ├── server.ts
│   ├── app-router.ts # App router
│   ├── controllers # Controllers
│   │   ├── HomeController.ts
│   ├── models
│   │   ├── Response.ts
├── Public
│   ├── swagger.json # Swagger file (autogenerated)
├── nodemon.json
├── tsconfig.json
├── tsoa.json
├── tslint.json
```

### How to run
* For build and run the project
    ```bash
    pnpm run start:dev
    ```
* For update swagger file
    ```bash
    pnpm run swagger
    ```
* For run in watch mode
    ```bash
    pnpm run start
    ```
What is a blockchain address?
Tags: video, blockchain, bitcoin, ethereum
Published: 2022-11-16 18:36:18

A blockchain address is a special identification number that acts as a digital location where cryptocurrency can be sent to and received. In this video, we go into greater detail regarding the subtleties of blockchain addresses.

Full Article: https://dspyt.com/what-is-blockchain-address

{% embed https://youtu.be/MoQa_zdmoKs %}

The blockchain address is a key that allows the owner to send or receive bitcoin from other users. These addresses contain information about the recipient who can access the bitcoin sent to this address. It ultimately proves that you control the private key to a bitcoin address and are allowed to send a valid transaction from it.

About Dspyt Channel:
We are Data Science with Python DAO
Homepage: https://dspyt.com
GitHub DAO Page: https://github.com/dspytdao
PHP OR Operator (||)
Tags: programming, php, webdev, beginners
Published: 2022-11-16 18:15:04

The PHP or operator used to check for only one true result of many expressions So that means only one operand should has a true result to show you a true result value. Otherwise it will show you a false Boolean value.

Lets take an example.

```php
<?php
  $val = 52 || 20;
  Var_dump($val); // true
?>
```

This example will show you a true value because any positive or negative number means it has a value but if it has 0 it will show you a false value.

That means the interpreter will use the [PHP type juggling](https://codedtag.com/php/php-type-juggling/) to convert the integer value to Boolean value during the execution, so, the true take any positive or negative value and 0 means false Boolean value.

To analyze this example the 52 is not zero number and not empty.

The value will be true and the 20 value will be the same result as a true Boolean value so the final result will be true.

In in the next example will use another integer expression.

## PHP OR with Integer Data Types
```php
<?php
  $x = -10 || 0;
  var_dump($x); // true;
?>
```
In this example, you will see two values with OR logical operator, as I mentioned before, the full result will determined according to true boolean operand.

So -10 means not empty and not zero value that will convert the integer type to true and 0 converted to false value.

The final result will true.

## PHP OR with a String and NULL Data Types

Anyway, in the following block I will use the same operator with another string data type.

```php
<?php
  $string = null || "";
  var_dump($string); // false 	

?>
```

These two operands will return a false value which will return a false boolean value.

Anyway, there are two empty values so it will show you a false boolean value.

```php
<?php
  $value =  "value 1" || null;
  var_dump($value); // true;
?>
```

In this example I will show you a true boolean value because there is an operand has no empty value.

## Wrapping Up

[PHP OR](https://codedtag.com/php/php-or-operator/) operator is a logical operator used to check if one operand has a true value so it will show you a true boolean result. 

That’s all, thank you for reading.

## Resources
[CodedTag](https://codedtag.com/)
What is useContext?
Tags: beginners, javascript
Published: 2022-11-16 18:00:49

Just what is useContext good for and how do we use it? Luckily it's simple in React!

useContext is a great tool to manage state globally in JavaScript. It is used to pass state between components without having to "prop drill" or pass information between a bunch of components as props, which can quickly get more confusing than it needs to be.

A simple example is if we want to keep state for a user across components, which we'll take a look at now.

In this example, we'll presume you are in the App.js file, but you can use useContext wherever you'd like! You can import useContext from React, declare your useContext, export it all in one simple line:

```
export const UserContext = React.createContext()
```

From here you would declare the state that you'll be passing on, which in our example is you, the cool reader:

```
  const [currentUser, setCurrentUser] = useState("Cool Reader")  

```

Within the return of the function you'll use the useContext to wrap your components. A simple solution would end up looking like:

```
function App() {
  const [user, setUser] = useState("Cool Reader");

  return (
    <UserContext.Provider value={user}>
      <h1>{`Hello, ${user}!`}</h1>
      <Example Component />
    </UserContext.Provider>
  );
}
```
Our UserContext.Provider could easily be wrapped around many components and save us a lot of time with props. I recommend giving it a go Cool Reader!

For more info, please check out:
[ReactJS.org](https://reactjs.org/docs/hooks-reference.html#usecontext)
[W3 Schools](https://www.w3schools.com/react/react_usecontext.asp)
Apache Spark SQL: CTAS USING CSV with specific delimiter
Tags: sql, spark, database, tips
Published: 2022-11-16 17:53:15

To use CTAS (Create table as Select) in Apache Spark with a specific `delimiter` using the `OPTION` syntax:
```sql
CREATE TABLE sample_table
USING CSV
OPTIONS ('delimiter'='|')
AS
SELECT ....
```

[SparkSQL Documentation](https://spark.apache.org/docs/3.0.0/sql-ref-syntax-ddl-create-table-datasource.html)


**<u>PS:</u>**
I wrote this to also help myself retrieve the solution faster.
Releasing Rust Binaries with GitHub Actions - Part 1
Tags: rust, github, opensource, webdev
Published: 2022-11-16 17:38:48

GitHub Actions is an amazing tool for CI/CD. Having it built in directly with where your code lives is super convenient. Like most CI/CD systems I've used it can sometimes be tough to build stuff on it in a timely manner. For me it can take a bit of experimentation and time to actually get something to work. Once it does work though it's rock solid.

In this two part post I'm going to go over the process I went through to release new Rust binaries for our open-source project [Nitrogen](https://github.com/capeprivacy/nitrogen).

## GitHub Marketplace

GitHub Marketplace has a ton of Actions that can be used right off the shelf and this is where I first go when I'm looking to add a new Action to our CI. 

For Nitrogen I wanted to get binaries released as fast as possible and I found a [Rust Binary Release](https://github.com/marketplace/actions/rust-release-binary) action in the marketplace. This action was incredibly easy to use and got us binary releases generated almost immediately. One issue with this action though was that it only supported a limited amount of Rust targets (i.e. OS and CPU architecture triples. See [here](https://doc.rust-lang.org/nightly/rustc/platform-support.html) for more details.). There were two more targets we wanted to support.

- MacOS Arm - with the new Mac CPUs people running on top of the ARM architecture is becoming more and more common so supporting this is becoming more important.
- Windows MSVC (Powershell) - while using [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) or even something like Git Bash would've worked we wanted to make it possible to use more natively with windows.

In the next post I'm going to go over how to added these new targets to our releases and some issues I ran into along the way.

Thanks for reading! Nitrogen sounds cool to you check it out and give it a star [here](https://github.com/capeprivacy/nitrogen), check out the quick installation guide [here](https://www.capeprivacy.com/nitrogen?utm_source=devto&utm_medium=blog+post&utm_term=nitrogen&utm_content=blog+educational&utm_campaign=blog+ongoing) and come see what's going on on [Discord](https://discord.gg/nQW7YxUYjh).