apt – install libssl-dev on Ubuntu 20.04.1 (upgrade from 18.04.1) reports unmet dependecies with 1.1.1g-1+ubuntu18.04.1+deb.sury.org+1

The issues is with the letter version of libssl1.1 (= 1.1.1f-1ubuntu2) that needs to be downgraded. It was simple to do it with synaptic instead of apt install as follows:

sudo aptitude install libssl-dev

he following NEW packages will be installed:
  libssl-dev{b} 
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1.582 kB of archives. After unpacking 8.005 kB will be used.
The following packages have unmet dependencies:
 libssl-dev : Depends: libssl1.1 (= 1.1.1f-1ubuntu2) but 1.1.1g-1+ubuntu18.04.1+deb.sury.org+1 is installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libssl-dev (Not Installed)                         



Accept this solution? (Y/n/q/?) n
The following actions will resolve these dependencies:

     Downgrade the following packages:                                                   
1)     libssl1.1 (1.1.1g-1+ubuntu18.04.1+deb.sury.org+1 (now) -> 1.1.1f-1ubuntu2 (focal))



Accept this solution? (Y/n/q/?) y
The following packages will be DOWNGRADED:
  libssl1.1 
The following NEW packages will be installed:
  libssl-dev 
0 packages upgraded, 1 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 2.900 kB of archives. After unpacking 8.087 kB will be used.
Do you want to continue? (Y/n/?) Y

Basically don’t accept the proposed solution and carry on the a package downgrade

javascript – Sending HTML reports to a database project

So, I have been recently heavily focusing on Front-End, for data validation, showing errors etc. And a big thank you to CertainPerformance for many reviews hes done for me 🙂

I have created a Report template using handlebars and a MySQL database to store the data, using Node JS to interact between the 2. I have now gained understanding how Node JS can interact with the front end, grab data and send it to a database.

I’d like to hear some reviews to my current code – front, and back end. For me, personally it works and I am extremely happy that I am able to create such thing, whereas before I never thought I could 😀

Just want to hear some reviews – where I can improve, where I’m I lacking, what can be simplified etc..

Node JS

Note: this function is triggered at routing stage, I haven’t included it here.

// 21-TEMP-01a
exports.TEMP01A21 = async function(req, res) {

    // Array to store actual temperature
    var actualTemp = ();
    // Array to store minimum temperature
    var minTemp = ();
    // Array to store maximum temperature
    var maxTemp = ();

    // Array to store actual humidity
    var actualHumid = ();
    // Array to store minimum humidity
    var minHumid = ();
    // Array to store maximum humidity
    var maxHumid = ();

    // Get drying room names
    var roomNames = ();



    // Loop thorugh each req.body values
    for(var key in req.body) {
        // Store req.body key to value var
        var value = req.body(key);

        // For each key that starys with ActualTemp store into array
        if(key.startsWith("actualtemp")) {
            actualTemp.push(value);
        }

        // minTemp
        if(key.startsWith("mintemp")) {
            minTemp.push(value);
        }

        // maxTemp
        if(key.startsWith("maxtemp")) {
            maxTemp.push(value);
        }

        // actualHumidity
        if(key.startsWith("actualhumid")) {
            actualHumid.push(value);
        }

        // minHumidity
        if(key.startsWith("minhumid")) {
            minHumid.push(value);
        }

        // maxHumidity
        if(key.startsWith("maxhumid")) {
            maxHumid.push(value);
        }

        // Room Names
        if(key.startsWith("dryingroom")) {
            roomNames.push(value);
        }
        
    }


    // Get todays date
    var today = new Date();
    // Format the date
    var formatDay = today.toISOString().substring(0, 10);

    // Create an array to create custom MySQL query
    var values = ();

    // For each temperature value, store its output to values array
    for(var i = 0; i < actualTemp.length; i++) {
    values.push((roomNames(i) , actualTemp(i),
                minTemp(i), maxTemp(i),
                actualHumid(i), minHumid(i),
                maxHumid(i), formatDay, 
                res.locals.user.id));
    }

    db.query("insert into 21TEMP01a (room_name, actual_temperature, min_temperature, max_temperature, actual_humidity, min_humidity, max_humidity, time, user) values ?", (values), (error, result) => {
        if(error) {
            console.log(error);
       }
       else{
           res.redirect('/reports/daily');
       }
     });
}

Front-End

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">

<div class="container mt-4">


    <h3>Form:</h3>
    <form id="form" class="mt-4 mb-4" action="/reports_send/21-TEMP-01a" method="POST">

        <div style="border: 1px solid black; padding: 40px; border-radius: 25px;">

            <h4>Select Room</h4>
            <div id="RoomSelect">
                <select id="RoomMenu" class="form-control mb-4"> 
                    <!-- Drying Room 1 -->
                    <option value="dry-1">Drying Room 1</option>
                    <!-- Drying Room 2 -->
                    <option value="dry-2">Drying Room 2</option>
                    <!-- Dry Store-->
                    <option value="dry-3">Dry Store</option>
                </select>
            </div>
            
            <div id="RoomInputs">

                <!-- Drying Room 1 -->
                <div class="form-group" id="dry-1">
                    <!-- Title -->
                    <h4>Drying Room 1</h4>
                    <input type="hidden" name="dryingroom1" value="Drying Room 1">

                    <!-- All temperatures -->
                    <div class="temperatures">
                     
                        <label>Temperature °C - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualtemp1" step=0.01>

                      
                        <label>Temperature °C - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="mintemp1" step=0.01>

                    
                        <label>Temperature °C - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxtemp1" step=0.01>
                    </div>
                    <br>
                    <br>
                    <!-- All humidity -->
                    <div class="humidity">
                         
                        <label>Relative Humidity - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualhumid1">
                        
                        <label>Relative Humidity - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="minhumid1">
                         
                        <label>Relative Humidity - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxhumid1">
                    </div>
                </div>


                <!-- Drying Room 2 -->
                <div class="form-group" id="dry-2">
                    <!-- Title -->
                    <h4>Drying Room 2</h4>
                    <input type="hidden" name="dryingroom2" value="Drying Room 2">

                    <!-- All temperatures -->
                    <div class="temperatures">
                       
                        <label>Temperature °C - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualtemp2" step=0.01>

                       
                        <label>Temperature °C - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="mintemp2" step=0.01>

                       
                        <label>Temperature °C - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxtemp2" step=0.01>
                    </div>
                    <br>
                    <br>
                    <!-- All humidity -->
                    <div class="humidity">
                         
                        <label>Relative Humidity - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualhumid2">
                        
                        <label>Relative Humidity - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="minhumid2">
                         
                        <label>Relative Humidity - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxhumid2">
                    </div>
                </div>

                <!-- Dry Store -->
                <div class="form-group" id="dry-3">
                    <!-- Title -->
                    <h4>Dry Store</h4>
                    <input type="hidden" name="dryingroom3" value="Dry Store">

                    <!-- All temperatures -->
                    <div class="temperatures">
                        
                        <label>Temperature °C - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualtemp3" step=0.01>

                        
                        <label>Temperature °C - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="mintemp3" step=0.01>

                        
                        <label>Temperature °C - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxtemp3" step=0.01>
                    </div>
                    <br>
                    <br>
                    <!-- All humidity -->
                    <div class="humidity">
                         
                        <label>Relative Humidity - <strong>Actual</strong></label>
                        <input type="number" class="form-control" name="actualhumid3">
                         
                        <label>Relative Humidity - <strong>Minimum</strong></label>
                        <input type="number" class="form-control" name="minhumid3">
                         
                        <label>Relative Humidity - <strong>Maximum</strong></label>
                        <input type="number" class="form-control" name="maxhumid3">
                    </div>
                </div>

                <div id="errors" class="mt-2 alert alert-danger" style="opacity: 0; transition: all .5s;">
                    <p>Please complete all required fields</p>
                </div>

                <button id="submit-btn" class="btn btn-primary">Submit</button>
            </div>
            
        </div>
    </form>

</div>


<!-- Errors -->

<div id="myModal" class="modal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Targets not met</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Some temperatures or humidity values have not met their targets.</p>
        <p>- Re-check or continue submitting current data.</p>
      </div>
      <div class="modal-footer">
        <button id="submit-email" type="button" class="btn btn-primary">Submit</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script>

// Store DOM Strings
var DOMStrings = {
    room_options: '#RoomMenu'
};

// On selected option, show specific div element
showActiveElement = () => {
    

    for(const option of document.querySelector(DOMStrings.room_options).options) {
        document.querySelector(`#${option.value}`).style.display = "none";
    }

    if(document.querySelector(DOMStrings.room_options).value === 'dry-1') {
        document.querySelector('#dry-1').style.display = "block";
    } else if (document.querySelector(DOMStrings.room_options).value === 'dry-2') {
        document.querySelector('#dry-2').style.display = "block";
    } else if (document.querySelector(DOMStrings.room_options).value === 'dry-3') {
        document.querySelector('#dry-3').style.display = "block";
    }

}



// Show selected div element from options
document.querySelector(DOMStrings.room_options).addEventListener('change', () => {
    showActiveElement();
});


// Validate data
document.getElementById("form").addEventListener("submit", (e) => {
        
    const inputs = document.querySelectorAll('#form input');
    
    let bool;
        // 1. Check if input fields are empty
        const empty = ().filter.call(inputs, e => e.value === "");

        let notEmpty;

        if(empty.length === 0) {
            notEmpty = true;
        } else {
            e.preventDefault();

            document.getElementById('errors').style.opacity = 1;
     
            empty.forEach(element => {
                element.style.borderColor = "red";
                element.placeholder = "Required";
                element.addEventListener("input", (e) => {
                    if(element.value === "") {
                        bool = false;
                        element.style.borderColor = "red";
                        element.placeholder = "Required";
                    } else {
                        element.style.borderColor = "#fff";
                    }

                    const empty = ().filter.call(inputs, e => e.value === "");

                    if(empty.length === 0) {
                        document.getElementById('errors').style.opacity = 0;
                    } else {
                        document.getElementById('errors').style.opacity = 1;
                    }
                });
            });
        }

    // Validate Temperature and humidity values
    if(notEmpty == true) {
        for (var i = 0; i < inputs.length; i++) {

            // Validate Temperatures for Drying room 1 & 2
            if(inputs(i).name.match(/^(actual|min|max)-temp-(1|2)$/)) {
                validateTempDryingRoom(parseFloat(inputs(i).value), inputs(i), e);
            }

            // Validate Humidity for Drying room 1 & 2
            if(inputs(i).name.match(/^(actual|min|max)humid(1|2)$/)) {
                validateHumidityDryingRoom(parseFloat(inputs(i).value), inputs(i), e);
            }

            // Validate Temp. for Dry Store
            if(inputs(i).name.match(/^(actual|min|max)temp(3)$/)) {
                validateTempDryStore(parseFloat(inputs(i).value), inputs(i), e);
            }

            // Validate humidity for Dry Store
            if(inputs(i).name.match(/^(actual|min|max)humid(3)$/)) {
                validateHumidityDryStore(parseFloat(inputs(i).value), inputs(i), e);
            }
        }
    }
});


function validateTempDryingRoom(value, item, e) {

    if(value < 39.4 || value > 49) {
        e.preventDefault();
        item.style.backgroundColor = 'red';
        $("#myModal").modal();
    } else {
        item.style.backgroundColor = '#fff';
    }
}

function validateHumidityDryingRoom(value, item ,e) {

    if(value < 14 || value > 30) {
        e.preventDefault();
        item.style.backgroundColor = 'red';
        $("#myModal").modal(); 
    } else {
        item.style.backgroundColor = '#fff';
    }
}

function validateTempDryStore(value, item, e) {
    if(value < 10 || value > 27.2) {
        e.preventDefault();
        item.style.backgroundColor = 'red';
        $("#myModal").modal();
    } else {
        item.style.backgroundColor = '#fff';
    }
}

function validateHumidityDryStore(value, item ,e) {

    if(value < 40 || value > 70) {
        e.preventDefault();
        item.style.backgroundColor = 'red';
        $("#myModal").modal(); 
    } else {
        item.style.backgroundColor = '#fff';
    }
}

document.getElementById('submit-email').addEventListener('click', () => {
    const form = document.getElementById('form');
    form.submit();
});


// On load
window.onload = () => {
    showActiveElement();
}


</script>

digital ocean – New Relic reports 280% CPU utilization, DigitalOcean reports 30%, why?

We have an online menu for restaurants web application (laravel back+vue.js front, MySQL) running on Digital Ocean.

The application is starting to get very slow during peak times so we are investigating what could be the cause.

The first mystery we need to solve is to understand whether or not the problem is in our server specifications (i.e., need more cpu/memory) or code/configuration. It is a mystery because we have conflicting information apparently. The New Relic monitor reports 280% CPU utilization during peak time, but Digital Ocean reports only 30% CPU utilization at the same time.

How to discover what information is correct? What other tools can we use to monitor and discover the bottlenecks?

Want to upgrade to Mac OS High Sierra and it shows MediaKit reports not enough space on device for requested operation

Trying to update my MacBook from os El Capitan to High Sierra on reboot it shows MediaKit reports not enough space on device for requested operation

seo – Google tag assistant reports: “Same web property ID is tracked twice”

‘ve added the following Google Tags code on my website. When I checked with Google Tag Assistant (Chrome Addon), I can find a yellow indicator against Google Analytics Tag which says to optimize “Same web property ID is tracked twice.” As well as i can see “2 Pageview Requests”

How could i resolve this? enter image description here

gui design – Best UI approach to align the column titles of reports

  • Numerical data is right-aligned.
  • Textual data is left-aligned because is read from left-to-right.
  • Headers are aligned with their data and center alignment is not recommended.

I know that this question is from 5 years ago, but I saw it has no answer and I found this article, “Design Better Data Tables” very detailed and complete as an answer.

Numerical data is read right-to-left; that is, we compare numbers by
first looking at their ones digit, then their tens, then their
hundreds, and so on. This is also how most people learn
arithmetic — start on the right and move left, carrying digits as you
go1. Therefore, tables should keep numerical data right-aligned.

Textual data is read (in English) from left-to-right. Comparing
textual elements is typically done by sorting into alphabetical order:
if two entries start with the same letter, the second letter is used,
and so on. Trying to quickly scan text can be infuriating if it’s not
left-aligned.

Headers, generally, should carry whatever alignment their data has.
This keeps the vertical lines of the table clean, and provides
consistency and context.

Center alignment causes the lines of the table to become “ragged,”
which makes it much harder to scan entries, often necessitating extra
dividers and graphical elements.

enter image description here

What is the exact difference between Google Analytics Sessions by Type and Top Channels, why am I getting different results on my reports?

In Google Analytics -> Acquisition -> Overview you can get a month to month comparison of Top Channels which shows incoming traffic for direct, organic, etc. In my Customization -> Dashboards I have a custom report that has a widget, it is defined as sessions grouped by traffic type. This should show the same data, right? If so, why am I getting different numbers, and if not, what is the difference between the two? The image below is Sessions by Type, the second image is Top Channels. I have searched for an answer but all I get is instruction on how to set up reports for them, not what the distinction between the two might be.

Sessions by Type

Top Channels

Traffic Type widget definition

Top Channel widget definition

How to exclude URL parameters from Google Analytics reports?

The number of unique URLs on our site exceeds the limit in our Google Analytics. We tried to exclude URL Query Parameters in the View Settings but it doesn’t work, GA continue to record all of them as unique URLs.

How do we limit the number of URLs in Google Analytics by removing the query string from all URLs?

availability groups – Copy DWH for reports

I have a heavy load DWH server.
I wish to create a copy of that server for report purposes (Cognos reports to be exact).
In today’s situation I have many reports and can cause locks on other processes, can be locked or get only 1 thread and take a long time to finish.
The reports run on several huge databases.
I have thought of several ideas, non are good enough:

  1. First thing comes to mind is Always On but something tells me that changing the databases to FULL recovery is not a good idea and perhaps the sync will fail all the time because of the transactions size.
  2. Maybe snapshots? Don’t know if it is a good idea on production and what about the fact it will kill reports once snapshot is switched.
  3. Any hardware solution I’m unaware – files copy or whatever.
  4. 3rd party tools?

Any idea will be much appreciated!
It doesn’t have to be online like always on (it’s preferred of course) but once a day if there is no other choice.

ios – iPhone reports large storage On My Phone, but I can’t find that usage

[iPhone 11 128GB, running iOS 13.6]

In Settings -> General -> iPhone Storage, On My Phone reports there is 1.16GB on my iPhone. However, if I tap into that section and review all the files there, I see at most 23MB worth of data when I add everything up.

Is there some other place I should look to find these “large files?” Is there a known issue of reporting incorrect file sizes? Something else?