object oriented – Adding and Retrieving Players for a simple Pre-Flop Poker Hud with JavaScript to Local Storage, Is my design solid?

I am building a browser based Pre-Flop HUD that for now just tracks VPIP, PFR and number of hands played for an opponent (https://pokercopilot.com/poker-statistics/vpip-pfr) and using local storage to store my data. In the future I will use a better persistence strategy, add more features, and find a way to de-couple the user interface without just putting it in the functions I have now. I just wanted to use an object literal approach without classes right now and try out some basic decomposition with simple functions for practice. Any suggestions for improvement are welcome. Right now the only functionality I have is adding a player to localStorage and getting all players from local storage.

I do have a couple questions…

  1. Is there a benefit to using Classes? Right now I don’t see the benefit of having a handle, like, player1 = new Player(arg,arg,etc…), player2 = new Player(arg,arg, etc…)…

  2. If someone thinks there is a better way to store to local storage please let me know, I don’t think
    storing each player with their own key and having a ton of entries would be a good idea.

  3. In my function addPlayer() should I be calling savePlayersToStorage in my localStorageUtils.js?

Thanks!

Main.js file = entry point for my program

    /**********************************
 * This is the program driver, that
 * will call other functions
 * *******************************/

import { addPlayer } from "./player.js";
import {
  savePlayersToStorage,
  getPlayersFromStorage,
} from "./LocalStorageUtilsObjectLiteral.js";

function main() {
  let newPlayer = "Doug Polk";
  const localStorageKey = "stored_players";
  let players = getPlayersFromStorage(localStorageKey); //array of player objects in localStorage
  players.push(addPlayer(newPlayer));
  savePlayersToStorage(localStorageKey, JSON.stringify(players));
}


main();

Player.js addPlayer creates and returns an object literal

function addPlayer(name) {
  let player = {
    uuid: Date.now(),
    name: name,
    vpipActionCount: 0, //The number of times a player voluntarily put money into the pot Pre-Flop, whether calling or raising.
    pfrActionCount: 0, //The number of times a player raised pre-flop, this includes 3-bets.
    vpipPercentage: 0, //The percentage of hands a player has played, can be between 0 and 100%
    pfrPercentage: 0, //The percentage of hands a player has raised pre-flop, can be between 0 and 100%, but can never be higher than vpipPercentage
    totalHandsTracked: 0, //The number of hands tracked for a player

    callAction: function () {
      this.totalHands++;
      this.vpipActionCount++;
    },
    raiseAction: function () {
      this.totalHands++;
      this.pfrActionCount++;
    },
    foldAction: function () {
      this.totalHands++;
    },
    calculateVpipPercentage: function () {
      this.vpip = (this.vpipActionCount * 100) / this.totalHands;
    },
    calculatePfrPercentage: function () {
      this.pfrPercentage = (this.pfrActionCount * 100) / this.totalHands;
    },
    getVpipPercentage: function () {
      return this.vpipPercentage;
    },
    getPfrPercentage: function () {
      return this.pfrPercentage;
    },
  };
  return player;
}

export { addPlayer };

LocalStorageUtils.js Functions to get and save players to Local Storage

function savePlayersToStorage(localStorageKey, playersArray) {
  if (localStorage.getItem(localStorageKey === null)) {
    localStorage.setItem(localStorageKey);
  }
  localStorage.setItem(localStorageKey, playersArray);
}

function getPlayersFromStorage(localStorageKey) {
  if (localStorage.getItem(localStorageKey === null)) {
    localStorage.setItem(localStorageKey);
  }
  let players = JSON.parse(localStorage.getItem(localStorageKey));

  return players;
}

export { savePlayersToStorage, getPlayersFromStorage };

rest api – Retrieving X-WP-Total header using cURL

I am accessing a WP site from an outside app and using the restAPI routes / endpoints to work with posts, pages, comments, users, etc…
I am wondering how I can change / use the below cURL to retrieve the number of elements (eg. the “X-WP-Total” header…) collected:

$token=$this->token;
$endpoint='posts';
$method='GET';
$curl_init=$this->url.$this->resource.$endpoint.'/'.$post_id;
$process = curl_init($curl_init);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$token));
$post= curl_exec($process);
curl_close($process);
return json_decode($post);

…in this case the endpoint is obviously posts, but I use this cURL request for other endpoints…
Many thanks for your help

Is there a search engine with reverse search mechanism: processing multiple queries and retrieving a single result for each of them?

A regular search engine retrieves a number of results matching a single query. I need one that does the opposite: enables to input a number of queries and displays a single match to each of them. If there is no match, I need to know it too. An implementation of this approach exists, but its application is limited to the database embedding it (PubMed). Batch Citation Matcher enables a user to identify unique content in databases covering material also present in PubMed. A user can submit a text file and the engine transforms the content of the file separated in a required way into a number of queries, then displays a table with queries in one column and the information on whether the text of the queries was found in a database being compared to PubMed in another column. Is there an analogues application which can be applied to any website?

Does PostgreSQL have an integrated function for retrieving deleted / updated data?

I often have an annoying problem: I want to restore a deleted record or see what it looked like before the last update. There are of course numerous ways to implement this manually and carefully by creating additional tables to keep deleted records and all changes, but frankly, just Think Dealing with it makes me exhausted and I just forget it.

I've heard of people who never DELETE Records, instead a deleted_at Time stamp or the like and then always take this into account in the application. However, I find this kind of "hack" both messy and fragile. I'm not happy with such a mechanism, no matter how common. Just the idea of ​​not really using it DELETE The SQL keyword for deleting a post feels wrong to me.

Is there any way to tell PostgreSQL about this?

Hello, PostgreSQL. Do you see this table titled "Important"? Well, I want you to keep an eye on all records that are DELETEd or UPDATEd in this table and only delete these "event records" 1 year after they occurred. This gives me a year to look back at changed / deleted data without saving it forever and without having to code my own system. I want to be able to access this data reasonably.

I hope this exists, because it would be nice if I could simply mark a table as "important" and PG could then keep an eye on all of this. Let's face it, if I have to do it myself, it probably won't happen and I will be 100% "blind" to anything that has changed in my tables.

Please don't let me install any additional software or strange extensions. I hate the.

Were SEO keyword tools retrieving data there?

Hi,

When I search for SEO keyword tools, I mostly see software programs that you have to pay for
because Google will no longer allow users to use the Keyword Tool unless you run a campaign
I wonder where these software programs get data from

There are most websites that anyone can access by copying and pasting this information into the software program.

Retrieving parameters from URL in views drupal 8.8.1

I have created two Taxonomy term and one content type name as **Taxo1** **Taxo2** and **content type** Suppose first **taxo1** whose id is like 1,2,3 and so on. Now again I created two views one for **page**(of content type where given reference of above both taxonomy) and path is like **document**, After adding both taxonomy in contextual filter it will be like path/taxo1ID/taxo2ID i.e document/1/23 or document/2/24 and so on. Second view is for taxo2 where I am showing name of taxo2's term name in tablular format.My question is how I will make id of taxo1 dynamic. I am able to make id of taxo2 dynamic that isdocument/**1**/{{id}}. I know my question is not properly but please check attached image for better understanding.(!(how to make id dynamic(!(taxo1(!(taxo2)(1))(1))(1))(1)

woocommerce – product_id is null when retrieving product data in functions.php

I'm creating a custom function to get all the data of the product into one category
in the functions.php

function get_products()
{
  $cat_id = $_POST('category');
  $args = array(
  'post_type'             => 'product',
  'post_status'           => 'publish',
  'ignore_sticky_posts'   => 1,
  'posts_per_page'        => '12',
  'tax_query'             => array(
   array(
    'taxonomy'      => 'product_cat',
    'field' => 'term_id', //This is optional, as it defaults to 'term_id'
    'terms'         => $cat_id,
    'operator'      => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
   ),
   array(
    'taxonomy'      => 'product_visibility',
    'field'         => 'slug',
    'terms'         => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
    'operator'      => 'NOT IN'
  )
)
);
$wc_query = new WP_Query($args);

if ($wc_query->have_posts()) : 
  while ($wc_query->have_posts()) :
    $wc_query->the_post();
    var_dump($product->id);
  endwhile;
endif;
//echo json_encode($products);

wp_die();
}

The result is zero for each ID

What's the mistake?

Windows Powershell – When retrieving folder names and saving them in the array, every letter is sometimes retrieved as an element

I am trying to compile a .ps1 file to scan existing films that are in my Plex memory and compare them to a drive that I use to record films. A series of films that I don't have (determined by the file name) and a series of films that I already have are then created. Before I go into more detail, I will explain in my Plex Media folders how my films are organized.

In the root directory of my folder the type of the saved medium is listed. For example:
Tower.pauk.us Movies, TV shows, Music, Photos, etc.

For this program I only concentrate on the Movies folder.

Within the Movies folder I have a folder for each letter of the alphabet as well as for numbers and symbols. # , A , B , … Z
Sometimes I have a folder in these folders for, for example, "Quentin Tarantino Collection". Even if the movies in this folder do not start with "Q", the collection starts with "Q" so that it is in the / Q / folder.

Okay, now it's over and I can try to explain what my existing code is doing. So here is my code:

$PlexMovieFolders = Get-ChildItem \Tower.pauk.usPlexMovies | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}

$List1 = Get-ChildItem -Path F: -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
$List2 = @()
$Match = @()
$No_Match = @()


for ($i1 = 0; $i1 -le ($PlexMovieFolders.length - 1); $i1 += 1){
    $SubFolders = @()
    $folder = $PlexMovieFolders($i1)
    $List2 += Get-ChildItem -path \Tower.pauk.usPlexMovies$folder -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
    $SubFolders = Get-ChildItem \Tower.pauk.usPlexMovies$folder | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}
    if ($SubFolders.Length -gt 0) {
            for($i2 = 0; $i2 -le ($SubFolders.Length - 1); $i2 += 1){
                $folder2 = $SubFolders($i2)
                $List2 += Get-ChildItem -Path \Tower.pauk.usPlexMovies$folder$folder2 -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
    }
    }
}


for ($i2 = 0; $i2 -le ($List2.length - 1); $i2 += 1){
    Write-Host ($List2.length - $i2) "Items Left"
    for ($i1 = 0; $i1 -le ($List1.length - 1); $i1 += 1){
        if($List1($i1) -eq $List2($i2)){
            $Match += $List1($i1)
        }else{
            $No_Match += $List1($i1)
        }
    }
}

We will proceed line by line, obviously starting from the top.

$PlexMovieFolders = Get-ChildItem \Tower.pauk.usPlexMovies | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}

Here the code navigates to my Plex movie folder and stores each folder name in an array with the name $PlexMovieFolders,

$List1 = Get-ChildItem -Path F: -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg

Since the drive on which I record movies only contains the files directly in the root directory, I only have to save each movie name in an array with the name $List1,

$List2 = @()
$Match = @()
$No_Match = @()

This section defines a number of other variables that will be used later in the script for arrays.

for ($i1 = 0; $i1 -le ($PlexMovieFolders.length - 1); $i1 += 1){
    $SubFolders = @()
    $folder = $PlexMovieFolders($i1)
    $List2 += Get-ChildItem -path \Tower.pauk.usPlexMovies$folder -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
    $SubFolders = Get-ChildItem \Tower.pauk.usPlexMovies$folder | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}
    if ($SubFolders.Length -gt 0) {
            for($i2 = 0; $i2 -le ($SubFolders.Length - 1); $i2 += 1){
                $folder2 = $SubFolders($i2)
                $List2 += Get-ChildItem -Path \Tower.pauk.usPlexMovies$folder$folder2 -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
    }
    }
}

This is a for loop. A loop is performed once for each element in the array $PlexMovieFolders, There's a lot going on here, so I'll try to break it down a little …

$SubFolders = @()

Since I sometimes have subfolders in every letter, I have to have a variable that can have an array of every subfolder for every letter. I'm assuming that the top of the for loop clears the array every time the loop is executed.

$folder = $PlexMovieFolders($i1)

This sets a variable on the individual entry in the $PlexMovieFolders Array in which the loop is located. I did that because with $PlexMovieFolder($i1) gave me problems within the actual command.

$List2 += Get-ChildItem -path \Tower.pauk.usPlexMovies$folder -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg

This section will go through all of the letter folders in my Plex Movies folder. From there, every file name is stored in an array, with the exception of some unnecessary files.

$SubFolders = Get-ChildItem \Tower.pauk.usPlexMovies$folder | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}

This will go to the letter folder and get all folder names and save them in an array called $SubFolders, This is deleted every time the loop is executed, since each letter folder has its own subfolders. This section is the problem section. For some reason, only apparently random, but always the same folders are retrieved when this script is run, and each individual letter of the folder name is saved as separate elements in the array.

For example:
It will save Rambo Movies just like the whole folder name.

However, if it tries to save the "Quentin Tarantino Collection" in the array, it is saved as follows:

Q
u
e
n
t
i
n

T
a
r
a
n
t
i
n
o

C
o
l
l
e
c
t
i
o
n

It's very frustrating because when I run: $SubFolders = Get-ChildItem \Tower.pauk.usPlexMovies@ | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name} It works fine in a Powershell terminal … I'm not sure what I'm doing wrong. and that's why I hope for feedback.

if ($SubFolders.Length -gt 0) {
            for($i2 = 0; $i2 -le ($SubFolders.Length - 1); $i2 += 1){
                $folder2 = $SubFolders($i2)
                $List2 += Get-ChildItem -Path \Tower.pauk.usPlexMovies$folder$folder2 -Name -File -Exclude *.srt,*.DS_Store,*.dat,*.jpg
    }
    }

In this section you can see if the length of the $SubFolders array is greater than 0 and if so it will be moved to this subfolder and each file name will be saved in an array with the name $List2 This array is not cleared every time the loop is executed, because in the end I need the full list of films.

for ($i2 = 0; $i2 -le ($List2.length - 1); $i2 += 1){
    for ($i1 = 0; $i1 -le ($List1.length - 1); $i1 += 1){
        if($List1($i1) -eq $List2($i2)){
            $Match += $List1($i1)
        }else{
            $No_Match += $List1($i1)
        }
    }
}

This is the last section … there is a bit going on. What we're looking at is a "comparator" $List2 and see if there is an element $List1 fits with that. If there is a match, save it in the $Match Check array for me later. and if there is no match, save it in the $No_Match, I'll use that later $No_Match Array to automatically copy these movies to the Plex Movie folder.

TLDR;
$SubFolders = Get-ChildItem \Tower.pauk.usPlexMovies$folder | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}
Sometimes takes the folder name characters instead of the folder name.
For example:

Q
u
e
n
t
i
n

T
a
r
a
n
t
i
n
o

C
o
l
l
e
c
t
i
o
n

However, his command works fine when I enter the variables by hand.
For example:
$SubFolders = Get-ChildItem \Tower.pauk.usPlexMoviesQ | Where-object {$_.PSIsContainer} | Foreach-Object {$_.Name}
Save as Quentin Tarantino Collection