How to update the 3rd level of a json

I have a json file that looks like this

    "PL001": {
        "player_name": "Player 1",
        "player_email": "",
        "hobbies": {
          "SP001": {
            "sport": "Soccer",
            "positions": {
                "position": "Goalie"
    "PL002": {
      "player_name": "Player 2",
      "player_email": "",
      "hobbies": {
        "SP002": {
          "sport": "Hockey",
          "positions": {
              "position": "goaltender"

What I need to do is change my positions codes to my new ones so for example my FL2 will be PLFL2

I’ve managed to get to the positions code but I’m not sure as to how I should go about pushing the new code up without loosing data.

Here is my codes

$old_code = "FL2";
$new_code = "PLFL2";

$json = json_decode(file_get_contents(storage_path('/players.json')));

$result = [];
foreach ($json as $key => $value)
  foreach($value->hobbies as $hobbiesCode => $hobby)
    foreach ($hobby->positions as $positionCode => $position)
      $positionCode = $new_code;

and that is where I get stuck. I’m not sure how to now go and update my json file with the new codes

Go to Source
Author: Aurilie

Display a selectable map in wordpress

I have a problem. I bought a theme, I created a page called “Harta”. The page looks like this:

enter image description here

Under the “test” part I want to display a world countries map. The map needs to be selectable, I need to select two countries, after selecting them, their names should be displayed into input elements of a form and then save the data of the form in the database. Any suggestions how to do that? Is there any plugin in wordpress that deals with the maps?

Go to Source
Author: Çlirim Kastrati

SANE not detecting scanner by ID (pipe error) or path (invalid arg)

I have a Canon P-208II, which uses the canon_dr backend [0].

However, I noticed from lsusb that the product ID of mine (0x1660) differs from that in /etc/sane.d/canon_dr.conf and /usr/lib/udev/rules/49-sane.rules (0x165f), so I duplicated those lines, modifying the ID to match.

$ lsusb
Bus 001 Device 017: ID 1083:1660 Canon Electronics, Inc. CANON   P-208II

Despite that, neither sane-find-scanner nor scanimage -L detect the scanner, with verbose logging I can see it trying to access and getting permissions errors, or with root:

could not fetch string descriptor: Pipe error

in the same location.

I also tried sane-find-scanner /dev/usb/001/017, which says failed to open (Invalid argument) – I’m not sure what else to give as ‘devname’ [1]?

Is there somewhere else I need to change the product ID, or something to do to make the changes I have made take effect? Or is the pipe error a smoking gun?

[0] –

[1] –

Go to Source
Author: OJFord

Can’t open GRUB in ubuntu 18.04

Its a dual boot i.e. windows 10 and ubuntu 18.04. Ubuntu is filled as preferred choice hence GRUB doesn’t come by default.
I went through many resources available and they all said press shift before the logo of ubuntu appears i.e. while the manufacturer logo is there in the screen( in my case its Lenovo ).
I have tried tapping shift continuously , long pressed shift and even kept it pressed before turning the computer ON but in none of the cases GRUB window opened. Have tried it with both left as well as right shift.I am trying to open ubuntu’s recovery mode.

Go to Source
Author: Aaryan Gupta

MySQL binlog format change from MIXED to ROW

One of my customer has MySQL master-slave setup at on-premises, where the binlog format is kept to be MIXED. Now, we are planning to migrate the DB to AWS RDS using DMS, the binlog format should be kept as ROW. I am not sure whether MIXED to ROW at this point of time at source will impact the source DB or replications. I see MySQL docs talking about the implication of STATEMENT to ROW change, but not from MIXED to ROW. Can someone help me on this.?

If the above is not doable, another plan is to go with Daisy chain approach, where an EC2 instance is created as slave connected to the slave DB of on-prem. This EC2 slave should have the binlog format as ROW. Even in this case, at on-prem the binlog would be MIXED and EC2 slave would be ROW. I am not sure whether this approach (within the same DB) will work, or anything break.

Any expert suggestion/solution (with MySQL document reference for the solution, if possible) would be much appreciated.

Go to Source
Author: serverstackqns

Correctly installing / configuring locally built qemu / libvirt

On Ubuntu 18.04, the default installation of qemu is something like version 3, and I needed virtiofs which has built-in support in later versions. So I uninstalled the qemu and related packages, downloaded the qemu 5.0 sources and complied it locally.

All worked well, including make install, which put the binaries in /usr/local/ which I guess is the correct default unless told otherwise.

Most things are working OK, but I’m now trying to get graceful shutdown / restart of guests working when the host is restarted, and have hit 2 snags so far.

  1. On host startup, I would see /usr/local/libexec/ 29: .: Can't open /usr/local/bin/ Of course, that’s not where normally lives, but I can get round that by ln -s /usr/bin/ /usr/local/bin/
  2. No failure message there now, but later in the host boot logs I see[2166]: touch: cannot touch '/usr/local/var/lock/subsys/libvirt-guests': No such file or directory

I could go on symlinking things so they appear accessible to libvirt, but I’m wondering if the correct fix is actually to install qemu where it expects to be.

So, first question, is reinstalling the right approach, or have I just missed some basic configuration which would leave the local package where it is, but allow everything to work as expected?

If not, I guess I will have to run ./configure --prefix=/usr and rebuild, but how could I remove the currently installed version in /usr/local/ cleanly first? And, I’d ideally like to keep my current VM configurations. Searching for an XML file for a particular domain, I see 2 versions:

# find / -name 07x2.xml

I’m not sure why there are 2, but I guess I could just virsh dumpxml before removing anything.

Go to Source
Author: dsl101

What naming convention should I use for a JSON RPC client API designed for multiple languages?

This is the documentation with the original RPC client API specification. The naming convention in the specification is camel case with the first letter in lower case.

Naming conventions might differ in subtle ways for different languages (camel case with vs. w/o capitalization of the first letter), but for some conventions like snake case (Python) or Swift’s Fluent Usage API changing the names in the original specification might increase the cognitive load when using the API for those already familiar with the specification.

When searching for different JSON RPC APIs on GitHub, some implementations seem to take advantage of reflection to intercept method calls and pass them to RPC request “as is” so method names for that language are the same as in the original spec. If reflection is not available the names are hardcoded and are mostly the same as the spec, changing only the capitalization of letters for some languages.

Some examples:

Not using Fluent Design in Swift

Not using snake case in Ruby

Changing method names to camel case in C#

Go to Source
Author: rraallvv

Website animations not working properly in browsers

OS: Ubuntu 20.04 LTS; Graphics: GeForce GTX 1060 6GB/PCle/SSE2;

Some website animations aren’t working properly – they’re often jumpy – whereas they’re smooth on my Windows OS on the same PC. Some sites that rely on movement animations are basically unusable E.g. this site.

I’ve tried using Chrome and Firefox and the result is the same in both browsers. I’ve tried reinstalling Chrome too.

Go to Source
Author: House Leto

estimate Log growth in SQL Server

I would like to estimate the log growth consumption for a database with full recovery model for a particular transaction/group of transactions which is filling up my log drive. I would like to forcast this before a transaction is run.Is there a way to find this out in SQL Server(any version)

Thanks in advance.

Go to Source
Author: kevin

Combining Two Containers

I’m working on a Windows laptop and running Docker for Windows on it. I want to run an Ubuntu container with a specific version and a MySQL server on it. So the question is, do I have to download MySQL on the Ubuntu container or can I run 2 containers (Ubuntu and MySQL) and combine them? How do I combine these 2 containers?

Go to Source
Author: user19215

Secure way to send API key

I am developing an SDK which users would use to access my service
The authorization is done using an API key, which is unique to each user.
SDK makes API calls to my server using the provided API Key

My question is how do I secure the API Key passed in as a header in the API calls?
Should I encrypt the key while sending it over the network using RSA? But, then there will be two issues:

  1. Shipping a public key with the SDK
  2. Overhead of reading keys from file for every API call

Is there a better approach to this?

Go to Source
Author: saintlyzero

Creating a DAX sprint column for Kanban Metrics (MS Power BI)


I am trying to create a DAX column within the table above that gives me rolling 3-week sprints for work items that were closed within a certain date period. These are some of the following date periods:

  • 2/10/20 – 3/01/20
  • 3/2/20 – 3/22/20
  • 3/23/20 – 4/12/20
  • 4/13/20 – 5/3/20
  • …etc

With the fields available in my screenshot, how can I make a DAX column for this? Thank you.

Go to Source
Author: ookafor