teleren/devto huggingface dataset:
Testing NGRX effects without testbed
Tags: ngrx, angular, jest, testing
Published: 2022-10-26 11:26:48

---
title: Testing NGRX effects without testbed
published: true
date: 2022-09-30 09:00:00 UTC
tags: ngrx, angular, jest, testing
canonical_url: https://willpoulson.co.uk/blog/testing-ngrx-effects-without-testbed/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60kghcm9ai440xjtqn14.jpg
---

## The benefits

When testing NGRX effects the testbed is not needed. Dependencies can be mocked and directly passed to the constructor and actions can just be a simple observable stream of any form.

The testbed often creates additional bloat slowing down your unit tests and requiring more boilerplate to be written when mocking injection dependencies.

## How do you mock actions without the testbed?

It's very simple. First remove the testbed configureTestingModule and inject code and replace with a raw constructor.

```typescript
describe('ExampleEffects', () => {
    ...
    let effects: ExampleEffects;

    beforeEach(() => {
        effects = new ExampleEffects();
    });

    ...
});
```

Then we need to create a new observable stream for our action as we can't use ngrx'z included `provideMockActions` anymore.
I like to use a replay subject for this as it allows for jest-marbles tests to run successfully.

```typescript
describe('ExampleEffects', () => {
    ...
    let effects: ExampleEffects;
    let actions$: ReplaySubject<Action>;

    beforeEach(() => {
        actions$ = new ReplaySubject<Action>();
        effects = new ExampleEffects(actions$);
    });

    ...
});
```

Now to dispatch actions all we need to do is call `next` on our replay subject with the relevant action.

Let's see this in action. Below is an effect file which contains an effect that listens for actionA and then spits out actionB.

```typescript
export class ExampleEffects {
    exampleEffect$ = createEffect(() =>
        this.actions$.pipe(
            ofType(ExampleActions.actionA),
            map(() => ExampleActions.actionB())
        )
    );

    constructor(private actions$: Actions) {}
}
```

And below is my spec file.

```typescript
describe('ExampleEffects', () => {
    let effects: ExampleEffects;
    let actions$: ReplaySubject<Action>;

    beforeEach(() => {
        actions$ = new ReplaySubject<Action>();
        effects = new ExampleEffects(actions$);
    });

    it('should be created', () => {
        expect(effects).toBeTruthy();
    });

    describe('exampleEffect$', () => {
        beforeEach(() => actions$.next(ExampleActions.actionA()));

        it('should return the deleteUserData action', () => {
            const expected$ = cold('a', { a: ExampleActions.actionB() });

            expect(effects.exampleEffect$).toBeObservable(expected$);
        });
    });
});
```

## Conclusion
I hope someone finds this useful, removing the testbed is surprisingly simple for NGRX effects and you may notice considerable performance improvements in large effects files.
LOCAL STORAGE
Tags: javascript, webdev, beginners, tutorial
Published: 2022-09-30 08:51:26

Hi Every one this time I want share you about local storage. this quite impressing toipce let us Start.

**Local Storage** 
local storage is a property of the window object that can store data in the user's computer. with this computer will remember information to use everytime use visite the website.

What we could store : _name, note, messsage, preferences and etc._

What we could not store :_password, confidential information becouse localstorage is not a safe places save it._

the data mush store in the from of string it is mostly used in the Todo list. impress the users while using the website.


```
localStorage.user = {name: "John"};
alert(localStorage.user);
```

we can also remove the data from local storage.


```
localStorage.removeItem("mytime");
```


**Session Storage**
Session storage is very similar to localstorage. there is only different that the data is only kept during the session. This means that if the user closes the tab or the browser the information is erased.

session storge is mostily used in the setitem and removeitem methods to store and erase data.

```
// Save data to sessionStorage
sessionStorage.setItem("key", "value");

// Get saved data from sessionStorage
let data = sessionStorage.getItem("key");

// Remove saved data from sessionStorage
sessionStorage.removeItem("key");

// Remove all saved data from sessionStorage
sessionStorage.clear();
```
**This is the related video**
{% embed https://www.youtube.com/watch?v=GihQAC1I39Q&t=239s %}


Thank You for Reading any question can ask me in comment.
Cryptopals-25: use `edit` as keystream
Tags: rust, cryptopals, tag
Published: 2022-09-30 08:36:04

Do you want a slightly simpler solution to #25 "Break "random access read/write" AES CTR"? Did you ever wanted to add a crate release (from git) that isn't at <crates.io>?

As I mentioned on the [previous page](https://dev.to/skaunov/test-3klo) I was detailing challenge point and over-viewed few solutions. Usually I return back to existing solutions to see the alternatives and check my own solution sanity and correctness. This time was a bit different.

Surprisingly I didn't found my solution among those I viewed, so let me share it with you. Not to repeat common part in all of them, I just link [a fresh write-up I liked], and quickly note that instead of getting the key and then deciphering with it, we can just **feed our ciphertext to the `edit` function twice**: as the one we want to edit (basically it will get us right length in most implementations) and the second time as "plaintext" we want to re-encrypt. (Offset should be _0_, of course. So the key-stream would be aligned.) This simple trick/tweak will just apply the key-stream against ciphertext and as the result of "`edit`" we get plaintext.

Rust code of the solution: <https://github.com/skaunov/challenge-25>.

[a fresh write-up I liked]: https://github.polettix.it/ETOOBUSY/2022/09/10/cryptopals-25/

## Bonus

I wondered of a clean way to import a particular version of crate from git, as the one I used isn't available from <crates.io>. And it turned out to be just a few lines to do it neatly.
```toml
[dependencies.ctr]
git = "https://github.com/RustCrypto/block-modes.git"
tag = "ctr-v0.9.1"
```
Setup Docker Container for MySQL to use it with Laravel app
Tags: webdev, docker, mysql, laravel
Published: 2022-09-30 08:18:39

This article is the continuation of my previous [article](https://dev.to/ibrarturi/setup-docker-container-for-mailhog-to-use-it-with-laravel-app-4g00) in which we setup docker container for [MailHog](https://github.com/mailhog/MailHog) to use it with your Laravel app. 

In this article, I am going to explain how to add new container for `MySQL 8.0` that can be used with your Laravel app.

After adding `MySQL` container, your final configuration should look like this:

```
version: "3.7"
services:

  # SMTP Server
  smtp:
    platform: linux/x86_64
    image: mailhog/mailhog
    container_name: docker-workspace-smtp
    logging:
      driver: 'none'
    ports:
      - "8003:1025"
      - "8100:8025"
    networks:
      - docker_workspace_network

  # MySQL Service
  db:
    platform: linux/x86_64
    image: mysql:8.0.28
    container_name: mysql-8
    environment:
      #MYSQL_USER: 'foo'
      MYSQL_ROOT_PASSWORD: 'secret'
    ports:
      - 3307:3306
    volumes:
      - docker_workspace_mysql:/var/lib/mysql
    networks:
      - docker_workspace_network

volumes:
  docker_workspace_mysql:
    external: false

networks:
  docker_workspace_network:
    driver: bridge
```

To setup your Laravel app to use this `MySQL` container, open your `.env` file and change the DB credentials to the following:

```
DB_HOST=127.0.0.1
DB_DATABASE=db-name-here
DB_USERNAME=root
DB_PASSWORD=secret
DB_PORT=3307
```

Now, open your Laravel app and now it should be connected to `MySQL` from docker container
Creating a discord bot on the go to be published soon!
Tags: javascript, beginners, productivity
Published: 2022-09-30 08:06:49

##                Vanitas Music Bot(Self-Hosted)
![Vanitas Music Discord Bot by Babyico](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l0qxknd6cnvr0shx9t7f.png)

You want to listen to music 24/7 on your own discord server with filters, dj role, and more. Don't hesitate and own Vanitas with the full rights to change anything you want.

By purchasing Vanitas, you will get the files of the whole files of Music Bot including everything. And you will be able to change the name, picture, and commands of your new music discord bot. For any questions don't hesitate to ask me.

[Buy Vanitas](https://iconical.gumroad.com/l/vanitas)
How does PyTorch's requires_grad works ?
Tags: pytorch, autograd, programming
Published: 2022-09-30 08:03:15

torch.autograd is PyTorch's automatic differentiation engine that powers neural network training. Let's try to understand from an example.

## Here is a sample PyTorch calculates backward for us

```python
x = torch.rand(1, requires_grad=True)
y = torch.rand(1)
v = x * y
w = torch.log(v)
xGrad = w.backward() # dw/dx
```



## Let's assume our output and move on with this numbers

```python
x = tensor([0.0559], requires_grad=True)
y = tensor([0.5163])
w = tensor([-3.5450], grad_fn=<LogBackward0>)
xGrad = tensor([17.8828])
```

---


### This is an PyTorch generated graph

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

### W calculation

1) Lets create functions from the generated graph by tracing backwards


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

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


```
x = tensor([0.0559], requires_grad=True)
y = tensor([0.5163])
v = 0.0559 * 0.5163
  = 0.02886117
w = ln(0.02886117)
  =  -3.5452581859176
```


---

### xGrad Calculation

This part needs some background with [derivative rules](https://www.math.ucdavis.edu/~kouba/Math17BHWDIRECTORY/Derivatives.pdf) and [chain rule](https://en.wikipedia.org/wiki/Chain_rule).




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


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



### References 
1) https://pytorch.org/blog/computational-graphs-constructed-in-pytorch/
2) https://www.youtube.com/watch?v=c36lUUr864M
3) https://pytorch.org/blog/overview-of-pytorch-autograd-engine/
Today's Daily Dose of Programming Humor
Tags: jokes, dailydeveloperjokes
Published: 2022-09-30 08:00:21

---
title: "Today's Daily Dose of Programming Humor"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259b6d7a73.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Did you hear about the programmer that was scared of IDEs?

___A:___ They retreated back into their shell
 -->
Learn Solidity with me
Tags: web3, solidity, programming
Published: 2022-09-30 07:35:33

## Let's start
I am learning Solidity from [freeCodeCamp](https://www.youtube.com/watch?v=gyMwXuJrbJQ) and [Solidity Official Documentation](https://docs.soliditylang.org/en/latest/index.html). As I learn some new concept I will try to explain to you. This will help me to understand it easily and also maybe you. If you feel something missing comment below. And feel free to ask any queries. All help each other and learn together.
## Basics
I will first begin with the different types or data types in Solidity. There are different types in solidity.
### Integer
- int8 to int256 (8 steps) like int16, int24 etc. 
- uint8 to uint256 (8 steps) like uint16, uint24 etc.

`int` are signed integers and `uint` are unsigned integers. `int256` and `int` are same. Similarly, `uint256` and `uint` are also same. Or `int` is alias for `int256` and `uint` is alias for `uint256`.
### Address
There are two address types. One is `address` and another is `address payable`. The size of `address` is **20bytes** same as the size of **Ethereum Address**. `address payable` is same as `address` but it have some additional information like `transaction` and `send`. We can implicitly convert `address payable` to `address`. But conversion from `address` to `address payable` done explicitly using `payable(<address>)`
### Fixed Point Number 
> ! Not fully support yet

We can declare fixed point number using `fixed` and `ufixed`. But can't assign to or from.

We will discuss how to perfrom operation on these types and other types in another blog.
Let's discuss the structure of a contract.
## Structure of Contract
If you are familiar with object oriented programming like `C++`, `Java` then you can find contract is similar like classes in these object oriented programming.
```solidity
contract SimpleStorage {
    // Code
}
```
A contract can contain -
- State Variables
- Functions
- Function Modifiers
- Events
- Errors
- Struct Types
- Enum Types

State Variables are variables which permanently stored in contract. They store the state of that variable like
```solidity
contract SimpleStorage {
    uint storeValue; // state variable
}
```
Struct Types are user defined or custom defined types which includes several types.
```solidity
contract SimpleStorage {
    stuct Store {
        uint height;
        bool adult;
        address delegate;
        int number;
    }
}
```
Similar is Enum types but have finit set of constant values
```solidity
contract SimpleStorage {
    enum Store {Created, Seated, Locked}
}
```

We will discuss Function, Function Modifies, Events Errors in another blog.
The Learnitive Branding
Tags: beginners, design, news
Published: 2022-09-30 07:29:45

[Originally published at [Learnitive.com/Branding](https://www.learnitive.com/pages/branding)]

## The Learnitive branding

Learnitive.com has always been about bringing people together as a platform designed to connect teachers and students globally. We are going a step further with the launch of our new brand. Our aim to open information to all, from all, and to generate new possibilities permeates everything we do, from the way we speak to the way we seem.  


## Learnitive.com: Possibilities unlimited


![Branding - Learnitive](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cj6o897hlgrgtx1gn0zl.png)

Welcome to Learnitive’s new Mascot which represents the freedom of knowledge, learning experiences in life and its upward path symbolises our upward motion in learning. Ours is known as the **Learning Path**, and we use it to represent the aspiration and progress of each learner, company, and instructor in our neighbourhood.

Get new courses @ [Learnitive.com](https://learnitive.com/)

You will still see our logo with the **stylised "L"** everywhere, because it represents everything we do: Learn and share. Our aim to open information to all, from all, and to generate new possibilities permeates everything we do, from the way we speak to the way we seem. Our dedication to our community of students, educators, and businesses hasn't changed despite our new appearance. 
Colors that set the mood

## The Learnitive: colors that set the mood

![The Learnitive colors that set the mood](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ithz08f0zslwrg9dhmly.png)

With a bright and optimistic palette, we add a feeling of energy and life to everything we do. Our brand color is a vivid, optimistic shade of purple that reminds us of our promise to create growth and possibilities.

So what does this all mean exactly? What does it mean to you personally? You'll notice the changes whether you're teaching or learning. Because, despite how gorgeous it is, our new brand is more than just a look. In order to fulfil our purpose of fostering new opportunities for everyone, we are intensifying all we do. 


## What is Learnitive?

The Learnitive.com (Learn + interactive) is an advanced e-learning platform that not only gives you the opportunity to watch lessons with video, but also allows you to execute codes and commands inside your browser!

![Learnitive.com App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptv6h0z2c95m7mqn5r1e.png)

Ge the latest news! [@learnitive](https://twitter.com/learnitive)

The Learnitive's mission is to inspire and develop people to achieve their goals in **Science, Technology, Engineering and Mathematics (STEM)**. It enables learners to illuminate their soul of scientific curiosity through bite-sized interactive learning experiences.


**Join now!** [Learnitive.com](https://www.learnitive.com/)
STAC & OGC API Features for meteo data
Tags: camptocamp, opensource, opendata, datascience
Published: 2022-09-30 07:15:49

Camptocamp is an Open Source IT company with offices in Switzerland, France, and Germany. To join our growing team, take a look at our [career page](https://www.camptocamp.com/career).

Together with the Federal Office of Meteorology and Climatology [MeteoSwiss](https://www.meteoswiss.admin.ch/home.html) and the Federal Office of Topography [swisstopo](https://www.swisstopo.admin.ch), Camptocamp developed a Proof of Concept for accessing meteorological data using STAC and OGC API Features. The goal was to continuously ingest and serve various kinds of meteorological datasets like current values, weather alerts and predictive models.

## Intro to OGC API Features & STAC

[OGC API Features](https://github.com/opengeospatial/ogcapi-features#readme) is part of a new set of standards by the Open Geospatial Consortium (OGC) which leverages REST principles and a resource oriented approach. Its predecessor is the Web Feature Service (WFS). The [Spatio-Temporal Asset Catalog (STAC)](https://stacspec.org/en/about/stac-spec/) specification builds upon the former and extends it to offer a searchable, catalog of assets to download.

Both specifications feature the concept of a Collection, a simple description of a set of features/items, similar to a layer. While a Feature in the OGC API is considered an abstraction of a real world phenomena, STAC uses the term Item to represent an atomic collection of inseparable data and metadata.

## Results

The project is publicly available in the [oapi-poc repository](https://github.com/camptocamp/oapi-poc#readme) on github. It is based on the georust [ogcapi project](https://github.com/georust/ogcapi#readme) which offers OGC API and STAC building blocks implemented in Rust. A demo server is up and running, including a nice [tutorial](https://github.com/camptocamp/oapi-poc/blob/main/tutorial/howto.md) to gain a deeper understanding of the mentioned standards.
The Best Web Development Company in Vadodara, Gujarat, India
Tags: webdevelopmentcompany, mobileappdevelopmentcompany, softwaredevelopmentcompany
Published: 2022-09-30 07:03:15

Inbox Infotech excels in web design, [web development](https://inboxtechs.com/), software development, web application development, mobile (Android and iOS) app development, digital marketing, and cloud services, a company based in Vadodara, Gujarat (India). 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0i3y4xmw7xis6rdufrx.jpg)
We have an expertise in graphic design such as logo creation, professional brochure design, business cards, flyers, letterhead, and advertisement banners to offer you a one-stop solution for your business. Our experienced developers also handle various industry’s custom software development requirements. Get simple, professional yet full of features web design and development experience for your online business presence.
All India Council for Robotics & Automation
Tags: aicra, technology, startup, gaisa2022
Published: 2022-09-30 06:54:47

AICRA-All India Council for Robotics & Automation sign off MoU with USI to constitute a think tank to explore and study on new technology offerings to Indian Defense, Interface between Technology Startups and Defense (Army, Navy, Airforce) for research and supplies, organizing various activities under Atmanirbhar Bharat Mission for Defense Sector.

Maj. General Pawan Anand from USI and **[AICRA](https://www.aicra.org/)** President Rajkumar Sharma represented respective organizations
Navegadores, muito mais que apenas consumo
Tags: javascript, webdev, braziliandevs
Published: 2022-09-30 06:52:08

[Postado originalmente no meu blog em português](https://br.elias.sh/posts/navegadores-tools-for-thought/)

O navegador é bem mais do que uma simples media para consumo de informação. Graças a add-ons como o Greasemonkey, usuários podem utilizar javascript para personalizar sua experiência na web.

Quando eu trabalhava na Amazon, era bem comum termos que interagir com sistemas internos escritos por outros times para lidar com o serviço deles. Esses sistemas eram pensados de um ponto de vista, mas a maioria das pessoas quando chegavam neles, tinham necessidades diferentes. Por exemplo, a gente no Redshift tinha um website para controlar nosso fleet de máquinas (banco de dados dos clientes). Ele era otimizado para que um engenheiro de plantão pudesse ver o estado da máquina e fazer as ações mais comuns. O suporte também utilizava esse nosso site, mas eles tinham necessidades bem diferentes. Por isso eles tinham uma série de scripts para personalizar as ações.

Outra possibilidade é a criação de add-ons/plug-ins/extensões que é suportada por todos os navegadores modernos. Extensões como https://web.hypothes.is/ e https://memex.garden/ tentam tornar os navegadores em ferramentas para “o pensamento”, possibilitando anotar sites, mais ou menos como pessoas anotam livros.

As pessoas que sabem javascript e sabem como os sites funcionam tem a possibilidade de se empoderar e pegar as rédeas de sua experiência. Você não gosta de um botão? Tira ele. Você prefere um atalho para uma certa página? Adiciona. Você quer que a página seja atualizada a cada 5 minutos? Só fazer!

Infelizmente existe um incentivo a sermos somente espectadores de nossa vida, inclusive na internet. Mas nossa vida não precisa ser assim! Use os navegadores, se empodere! E melhor ainda, compartilhe seus scripts e divulgue aos seus amigos todas as possibilidades que os computadores nos dão! 


Gostou? Me segue lá no insta para mais dicas! @[code_elias_code](https://www.instagram.com/code_elias_code/)
Best Exam Dumps Posts Of 2022 So Far
Published: 2022-09-30 06:44:11

These horrible prep reassets driven our group to make a <a href="https://getalllatestdumps.com/">Exam Dumps</a>effective alternate with inside the Exam area. We were given ill and uninterested in seeing capacity examination applicants get price-gouged over CCNA . We couldn’t take care of understanding that tough employees from throughout the international, in search of new competencies and a higher existence, get tricked into paying absurd quantities for low-pleasant examination substances. Often fabric that become obsolete or at first-rate, to be had on-line thru network  sites with out hurting the wallet. And it needed to forestall. You are geared up to leap in! That’s it, the subsequ ent web page may be complete of exercise questions. <a href="https://getalllatestdumps.com/">Get All Latest Dumps</a>Challenging fabric. And first-rate of all, a danger to hone your competencies. 

Click Here More Info >>>>> https://getalllatestdumps.com/