teleren/devto huggingface dataset:
Empty requests data with multipart/form-data when using fetch api
Tags: laravel, php
Published: 2022-09-14 20:15:30

It took me quite some time to resolve this isssue. It was an issue with formData and laravel/php not being able to detect the request payload when I dd or dump the request to check.

There is (and I believe) other solutions but I think this will save you the need to do "messy" workarounds. 

Here you go: {% stackoverflow 71392989 %}
TIL What a Bitmap DB is, 2 months after getting hired to work on one
Tags: database, datascience
Published: 2022-09-14 19:59:51

 
# Oh so that's what a Bitmap DB is
Have you ever started a job with absolutely no idea what the company's software does?

I'm celebrating my 2 month anniversary at [FeatureBase](featurebase.com), and I just figured it out this morning.

More accurately we're talking about bitmap indexes.
It's a different approach to finding data based on its attributes.

As a game designer, my examples will be pulled from the [Pokemon Pokédex](https://www.pokemon.com/us/pokedex/).
Convenient indexing, set number of types, lists of weaknesses and abilities. Perfect all around example.

## Bitmaps for the Pokédex
There are currently... 905! Pokemon. Seems reasonable, glad I picked this.

Let's consider analyzing Pokemon by their types and weaknesses.

### Finding Pokemon by Type
There are 18 types.
For each type, we have a list of bits.
905 bits to be exact. Each bit represents a Pokemon, with the position of the bit being the same as the Pokemon's index.

To find the Pokemon of a given type, you scan the bit array for each position with a 1.
Each Pokemon has a bit in the list, and its position is mapped to their index in the main table.

Then it's a matter of scanning that list and pulling each of the records.
Sounds inefficient, until you realize how little data needs to be actually reviewed.

**Exactly 905 bits.** (theoretically)

No need to load any of the records to perform the search.
No need to do any string comparisons, or hashing, etc. etc.

### Finding Pokemon by Multiple Types

Some Pokemon have multiple types.
Many have multiple weaknesses.

This is where I found these indexes to be fun.

To find all the Pokemon, for example, that are both Fairy and Poison type, we get the list of bits from each.
Then we do a bitwise AND on them.

The resulting list of bits will have a 1 in any position where that number Pokemon is both a Fairy and Poison type.

**Of which there are 0.** ([153](https://www.google.com/search?q=18+choose+2&oq=18+choose+2&aqs=chrome..69i57.2281j0j7&sourceid=chrome&ie=UTF-8) possible combinations, it took me about 23 tries to find one with no Pokemon.)

Now let's find all the Pokemon who are weak to our new #906 Fairy/Poison Pokemon.
Same steps, but we change to a bitwise OR.
Any Pokemon weak to Fairy or Poison type.

## Takeaway
**Bitmaps:**

Take each possibility and create a list of yes or no for each record.
Sounds crazy, but is really small and really fast.
Doesn't work for everything (can't tell you which Pokemon has the most tragic backstory, it's Cubone)

If this still sounds complex, or if you want to see what happens when some smart people make it even faster, then give it a try with [FeatureBase](https://github.com/FeatureBaseDB/featurebase).

Yes I work for them, and my job is to help you understand and work with it.
Let me know if I did a good job on our [Discord Server](https://discord.gg/PFyCFYw4gN), or if you'd like to hear a completely different example.
Build a Rails script watcher/runner using fswatch
Tags: rails
Published: 2022-09-14 19:56:29

---
title: Build a Rails script watcher/runner using fswatch
published: true
description: Watch a ruby file and run it in Rails runner on change
tags: rails
---

I often find myself spending a lot of time in the Rails console testing out code. As my examples get more complex, I often will create a temporary ruby file to write the script, then copy-paste into the console.

Although this works ok, it is tedious and could be optimized.

Rails runner (rails r) will allow you to run a ruby script within the context of the application environment.

For example, if I had a ruby file named `runme.rb` and inside it had some debugging code:

```ruby
puts Member.count
```

I could run that script using `rails runner runme.rb`. This is nice, but I then have to return to the terminal each time I modify the file. What if we could automate this?

[fswatch](https://github.com/emcrisostomo/fswatch) is a cross-platform file change monitor. It will watch any files you specify, then run a script on change.

Let's set up a script within our Rails app to run this file automatically when it changes.

### Install fswatch

It's easy to install fswatch. On a mac, you can run

```bash
$ brew install fwatch
```

### Set up a watcher script

I created an executable bash script at `bin/console-runner`:

```bash
#!/bin/bash

usage() {
    echo "Watch a ruby script and use Rails runner each time it changes"
    echo ""
    echo "For example, you may have a file called \`runme.rb\` that you would"
    echo "run using Rails runner (e.g. \`rails runner runme.rb\`). This script"
    echo "will watch the file and run it each time there is a change."
    echo ""
    echo "Usage:"
    echo "  ./script/console-runner <ruby-script>"
}

if [ $# -eq 0 ]; then
    usage
    exit 1
else
  fswatch -0 -o $1 | xargs -0 -n1 -I{} rails runner $1
fi
```

Be sure to make the script executable:

```bash
$ chmod +x bin/console-runner
```

We can test the script documentation by running the command:

```bash
$ ./bin/console-runner
Watch a ruby script and use Rails runner each time it changes

For example, you may have a file called `runme.rb` that you would
run using Rails runner (e.g. `rails runner runme.rb`). This script
will watch the file and run it each time there is a change.

Usage:
  ./bin/console-runner <ruby-script>
```

### Create your console script to be watched

Next, I created a file in the root folder of my Rails app called `runme.rb`.

```ruby
puts Member.count
puts Rails.env
```

### Run the script

Finally, I can run the script:

```bash
./bin/console-runner runme.rb
```

Success! Now each time I modify `runme.rb`, the script will re-run.
How to configure Hibernate Reactive with Eclipse Vertx 4 (Without XML)
Tags: java, programming, tutorial, architecture
Published: 2022-09-14 19:24:11

---
title: How to configure Hibernate Reactive with Eclipse Vertx 4 (Without XML)
published: true
description: 
tags: java, programming, tutorial, architecture
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

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

The usage of traditional Java ORM frameworks with Eclipse Vertx is a complicated process, due to the fact that these technologies rely under the hood on the synchronous JDBC API. On the other hand, Vertx is based around the reactive programming model and if software developers would like to use blocking libraries, that are required to perform extra steps. Hibernate Reactive is the first Java ORM solution that natively makes use of Vertx reactive clients and combines advantages of ORM libraries with reactivity and non-blocking patterns.

Typically, Hibernate is configured with XML configuration. This approach is also demonstrated by Hibernate Reactive docs and Vertx How-to website. However, XML configuration should be avoided. In this tutorial I will demonstrate essential patterns of using Hibernate Reactive with Eclipse Vertx 4.x.

The first part demonstrates how to configure Hibernate Reactive with Vertx 4.x programmatically (without any XML).
I am writing a stateless control language for smart game agents, and you are going to love it
Tags: ai, gamedev, unity3d
Published: 2022-09-14 19:24:05

Ask game developers how they control their game agents, and they'll probably tell you either of two things:

- If-elses and case logic with control flags/book-keeping; also, event handling, frame updates, co-routines.
- Blueprints or state machines

Before going with C# behavior trees, I used to write my game agents this way. Nested case logic in the form of if-elses is not very readable, and it's annoying to debug.

Control flags add moving parts, and their actual meaning can be obscure because they're often ad-hoc - not to mention that is state which tends to get out of date.

Events... good in deskop/smartphone applications, or to decouple the UI from the actual game. Not ideal in really dynamic game environments.

With blueprints and state machines, technical designers are used to these. But this comes with the danger of writing very large control graphs, which quickly get too big for technical designers to even grasp - and regular developers losing hair over entangling the resulting visual spaghetti.

After using Active Logic for almost three years, I started wanting something that could work as a middle ground for both developers and technical designers. Experience with stateless BTs also provided clear insight into what scripted control should offer:

- Full transparency (execution tree, w. time machine) 
- Dynamically debug AND modify the control graph
- Restricted access to the rest of your agent model (use a facade/blackboard) - but with painless, transparent bindings.
- Reusable modules, weakly tied to no particular game/codebase

With all that, Active Logic can't be implemented gracefully in languages other than C#, because of the (shorting) ternary logic supporting stateless BT implementations. So I thought, what if we had an easy to implement and port language, which would 100% focus on the control layer, and prevent the progressive corruption caused by mingling control with other implementation details.

Moving quickly towards an alpha!

_I am a BT evangelist, Game AI specialist and tool builder; currently available for work_
Build your 'frontend-web' muscles using this 😃
Tags: beginners, webdev, css
Published: 2022-09-14 19:03:18

*Are you a beginner in front-end web development? Then Frontend-Mentor is a great place to sharpen your skills. Recently, I’d complete some challenges for beginners. While I was doing those, I learn some uncommon CSS properties that will definitely help me to build future designs properly with much more interactive way & less code.*⚡
_
• `text-underline-offset` [challenge-solution](https://github.com/M-lakshan/FM_Challenge-Order-Summary-Component-Main/tree/guest)

• `mix-blend-mode` [challenge-solution](https://github.com/M-lakshan/FM_Challenge-NFT-Preview-Card-Component-Main/tree/guest)  

, are some of them. **Even though it took almost 1.5 years to build up my current state but I never knew those simplest CSS properties until I check my skills using Frontend-Mentor.**😅 

This was beneficial to me & will be for you too, whether you are an intermediate or a beginner. No doubt in that📍 You may be free to give any feedback if I need to improve my coding or simply share your ideas.
As vs Prefix (Laravel Route)
Tags: laravel, php, webdev, mvc
Published: 2022-09-14 19:01:31

When we work with a route group, we often find two terms -  'prefix' and 'as'. What's the difference between these two terms? Well, Prefix uses in URL and As is used in name route.

For example, if we write...

`    Route::group(['prefix' => 'admin'], function(){
        Route::get('/index',[DashboardController::class, 'index'])->name('index');
    });`

the Url works like this:

` Route::get('/admin/index',[DashboardController::class, 'index'])->name('index');`

But when we use **As**,such as...
`Route::group(['as' => 'admin'], function(){
        Route::get('/index',[DashboardController::class, 'index'])->name('index');
    });`


This will be work like..

`Route::get('/index',[DashboardController::class, 'index'])->name('admin.index');`

Thanks. Happy coding.
VUETIFY I need to be able to enable 3 buttons for CSV, PDF, and COPY
Published: 2022-09-14 18:50:26

Good afternoon.
Has anyone here used Vuetyfy's v-data-tables? I already have the table consuming information through an api. All good, now I need to be able to enable 3 buttons for CSV, PDF, and COPY

I have already used it with Jquery on Datatables.net
But now I need to use it in Vuetify, I can't find any article referring to it where they have used it, thank you.
these buttons
help for an exercice RXJS
Tags: react
Published: 2022-09-14 17:27:52

hi everyone, 
someone could help me with the end of this programm?
i need to stop the runner when he cross the arrival line so we paly the jingle an we switch to mode2
thansks you for your help

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>RX Demo</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.5.5/rxjs.umd.js">
    </script>
    <style>
     
        pre {
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <input type="text"></input><button>Go</button>
    <section>
    </section>
    <script>

        const sorties = [];
     
        const sectionSorties = document.currentScript.previousElementSibling;
     
        for (var i = 0; i < 5; i++) {
            const elt = document.createElement("pre");
            sorties.push(elt);
            sectionSorties.appendChild(elt);
        }
       
        var input = rxjs.fromEvent(document.querySelector('input'), 'input');
     
        input.subscribe(evt => sorties[0].innerHTML += evt.data);
        
        input.pipe(
         
            rxjs.operators.filter(evt => evt.target.value.length > 4)
            
            , rxjs.operators.map(evt => evt.target.value)
        )
            .subscribe(val => sorties[1].innerHTML = val);
            rxjs.operators.delay(10000)
      
            , rxjs.operators.throttleTime(5000)
            , rxjs.operators.map(evt => evt.data.toUpperCase()))
            .subscribe(value => sorties[2].innerHTML += value);
        var click = rxjs.fromEvent(document.querySelector('button'), 'click');
        click.subscribe(function (evt) { sorties[0].innerHTML = ""; });
        input.pipe(
            rxjs.operators.takeUntil(click) 
            , rxjs.operators.map(evt => evt.target.value)
        )
            .subscribe(value => sorties[3].innerHTML = value);
        rxjs.merge(
            input.pipe(rxjs.operators.map(evt => evt.target.value.length))
            , click.pipe(rxjs.operators.map(evt => " * "))
        )
            .subscribe(value => sorties[4].innerHTML = value);
    </script>
</body>

</html>
Javascript: Referential Transparency
Tags: javascript, beginners, programming, functional
Published: 2022-09-14 18:26:41

An expression in javascript can be replaced by its value is called referential transparency.

```javascript
const add = (x,y)=>x + y;

const multiply = (x)=>x * 4;

// add (3, 4) can be replaced by 7. - Referential Transparency.

multiply(add(3, 4)); 
> 28

multiply(add(3, 4));
> 28
```
```javascript
const arr = [];
const add = (x,y)=>{
    const addition = x + y;
    arr.push(addition);
    return addition;
}

const multiply = (x)=>x * 4;

// Here, we can't replace add(3,4) with 7 as it affects the program
multiply(add(3, 4));
> 28

> multiply(add(3, 4));
28
```

Thanks,

You can follow me here: https://twitter.com/urstrulyvishwak
How to learn Data Structures and Algorithms for beginners (roadmap for dummies)
Tags: beginners, algorithms, programming, tutorial
Published: 2022-09-14 18:14:53

If you are starting to learn programming or computer science student or perhaps anyone who wants to learn any programming language especially Java, JavaScript, Python... having a clear and sound understanding of what Data Structures and Algorithms makes your programming journey very effective. when I first started programming I only knew about Array and Array List which is not enough if you want to become a software development engineer.


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

 
Having the knowledge of Data Structures and Algorithms will help you to solve problems like a real IT professional or you're just another coding monkey who sits at the front of the screen and banging the keyboard. Even the FAANG looks for candidate with the ability to solve problems and solid skill of Data Structures and Algorithms. It also helps you to get a great tech job.

Here's how you can get started with DSA:
1. Assuming you have (no) foundational knowledge of introduction to computer science, i suggest you to get familiar with it by watching this video 
https://youtu.be/zOjov-2OZ0E

2. Next, watch this video first to understand the introduction to Data Structures
 https://youtu.be/zg9ih6SVACc

3. Once you got the birds eye view of what it is then move on to
MIT OCW Introduction to algorithms in the link below
https://youtube.com/playlist?list=PLUl4u3cNGP63EdVPNLG3ToM6LaEUuStEY

4. Incase of any doubts ask questions in public. platforms like stack overflow, reddit, freecodecamp forum. Why ask questions in public? the doubt that you may carrying will help someone who's having the exact same doubt, when you ask questions in public and when someone helps your question a third person with a same doubt can learn easily because of you learning in public.

5. Gradually start reading some books, now atlest 5 to 10 pages as a beginner is a good practice and take notes of it, every weekend revice what you have learned. PROGRAMMING IS ALL ABOUT ACTIVE LEARNING. NOT A SPECTATOR SPORT!

---


BONUS TIPS🚀:

>  DONT FALL INTO THE PITY HABIT OF COMPARING YOUR PROGRAMMING JOURNEY WITH YOUR PEERS OR SOMEONE YOU SAW ON THE INTERNET.

> REMEMBER CONSISTENCY IS THE KEY WHEN IT COMES TO LEARNING A NEW SKILL. YOU HIT THE WEIGHTS IT FEELS PAINFUL AND THEN YOU RECOVER AND REPEAT OVER A PERIOD OF TIME EVENTUALLY YOU BECOME TO COPE UP WITH PAIN AND WITH CONSISTENCY NOW YOU REAP THE REWARDS. MOST PEOPLE QUIT AFTER A FEW MONTHS IT ACTUALLY TAKES A YEAR OR EVEN MORE DEPEND UPON THE INDIVIDUAL ONCE YOU CROSS THE TEMPERORY PERIOD OF PAIN I BET THAT YOU'LL CAN NAIL IT.

> REMBER TO TAKE A BREAK, DONT SIT FOR HOURS WORRYING GO TAKE A CUP OF COFFEE AND ASK FOR PEOPLES HELP WHO ARE ALONG THE JOURNEY.

---
Do not apologize
Tags: mentalhealth, beginners
Published: 2022-09-14 18:13:26

Do not apologize for working, trying to learn new things, or going after what you believe. 

Apologizing in those situations is an attitude usually among juniors learner but can extend to seniors and in all the scenarios of our life. 

**Work**
Do not make sense to apologize when you need to confirm a requisite or a feature because it's part of your job. 

You're not asking for a favor, you are working, what is normally. As I said, it's part of your job and it is part of it ask for help. 

If you work in a company where you need to apologize for asking for help, maybe it is time to find another place. 

The best is working in a team where you feel like you are among friends, of course, not forgetting it's still a professional space.

Working with peace of mind and a good process stabilized is the best a company can offer to you. 

**Life**
Be straight with what you need. Cut the apologies and try to be clean and straightforward. 
[https://dontasktoask.com/](https://dontasktoask.com/) 

Replace for "sorry, can I ask something?" for "Hi, I need help in X thing. I think you can help me" 

---

Follow me on [Twitter](https://www.twitter.com/daniloab_)
If you like and want to support my work [be my patreon](https://www.patreon.com/daniloab)
See more in https://linktr.ee/daniloab.

---

Photo by <a href="https://unsplash.com/@stevedimatteo?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Steve DiMatteo</a> on <a href="https://unsplash.com/s/photos/apologize?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
TypeScript Unit Tests: Access `private` Members
Tags: javascript, typescript, programming, testing
Published: 2022-09-14 18:09:34

Disclaimer: This is not a lengthy discussion. But a small reference type post. [There are other (lengthy) posts](https://dev.to/danywalls/testing-private-methods-in-typescript-3np5) that go into the details. I like it short.

There is some ongoing debate about testing private [members (methods, fields, properties, ...)](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/members). In my opinion there are occasions where it is useful to do that.

{% details It is not possible to *directly* inspect/test private members in languages like C#. But there is a common inheritance based workround, where private members are made protected. %}

In your test code you extend those classes and write wrappers/accessors to access these members. Then you actually test your derived class.

This is cumbersome and also changes the semantics of the class you want to test. `private` members appear to be intended to be accessed in derived classes. Which is not the case!
{% enddetails %}

JavaScript/TypeScript does not require you to do that (at least for TypeScript `private` members, not for ES private (`#`) class fields).

```TypeScript
// mod.ts
export class SomeClass {
    private _somePrivateProp = "foo";
}
```

JavaScript does not care if your member is marked `private` by TypeScript.
The TypeScript compiler enforces that you don't access `private` members from outside the class using dot notation (`inst.prop`).
[But it is possible to access the property using bracket notation (`inst["prop"]`)](https://www.typescriptlang.org/docs/handbook/2/classes.html#caveats).


```TypeScript
// mod.test.ts
import {SomeClass} from "./mod.ts";
test("privatePropIsFoo", () => {
    const inst = new SomeClass();
    expect(inst._somePrivateProp).toBe("foo"); // TS2341: Property '_somePrivateProp' is private and only accessible within class 'SomeClass'.

    expect(inst["_somePrivateProp"]).toBe("foo"); // OK
})
```

This is great because refactoring tools still work. And it saves a lot of redundant code.

But there is a caveat: `jest.spy(inst, "_privateMethod")` will not work, because TypeScript enforces that only public methods are spied on. The simplest workaround is to cast `inst as any`. Until there is a Utility Type that treats all members als public. [As already suggested.](https://github.com/microsoft/TypeScript/issues/22677)
Ansible > AWS IAM Identity Center
Tags: ansible, aws
Published: 2022-09-14 17:42:35

New to Ansible with AWS. Something came up at work about automating some process with AWS SSO. The catch is, we are going to be using the successor to AWS SSO, AWS IAM Identity Center.

I haven't seen any ansible modules or documentation about this.

Is anyone using it? Any new modules being written or will the old ones work?

https://aws.amazon.com/iam/identity-center/