Angular.js, node.js: require or import ? neither work for me :(

I am very new to Angular.js and node.js and I am facing a problem since this morning that has been partially solved. How to update a json file with data entered by a user via a form.

Thanks to some help that I got here, I managed to do that using lowdbwhich looks like an awesome dependency. The thing is, I can only make it work from a test file, like so:

1/ test.js (that I run node test.js)

const FileSync = require('lowdb/adapters/FileSync')

const dbFileName = "database/lexicon.json";
const adapter = new FileSync(dbFileName)
const db = low(adapter)

// Add another entry
db.get('entries')
.push({
    "title": "Here's a new entry",
    "topics": ["ajax", "rails"],
    "content": "This is very complicated",
    "link": "",
    "mainCategory": "Node.js"
    })
.write();

2/ Controller from where I would like it to work:

function EntryController ($http) {
    const ctrl = this;
    const API = '../database/lexicon.json';

    this.entry = {
    title: "",
    topics: [],
    content: "",
    link: "",
    mainCategory: ""
    };
    this.submitEntry = function () {
        
        const low = require('lowdb')
        const FileSync = require('lowdb/adapters/FileSync')
        
        const dbFileName = "database/lexicon.json";
        const adapter = new FileSync(dbFileName)
        const db = low(adapter)
        
        // Add another entry
        db.get('entries')
        .push({
            "title": "Number 1",
            "topics": ["ajax", "rails"],
            "content": "This is very complicated",
            "link": "",
            "mainCategory": "Node.js"
            })
        .write();
    };
};


angular
    .module('app')
    .controller('EntryController', EntryController);

But when running the app and submitting the form I get this error message require is not defined

I tried something similar with import but I get a similar error message: Cannot use import statement outside a module

Can anybody help?

Go to Source
Author: Olivier Girardot

What commands will allow me to programatically enquirer how of a gnome terminal: how many tabs it has, and what are their pwd’s

When I have a gnome terminal open, is there a command that will allow me to programatically enquirer of this gnome terminal:

(1) How many tabs the gnome terminal has open on it?

(2) What is the pwd of each of these tabs?

I loose my virtual machine in the evening, so I want to write a script to store the above information, and then programatically reopen all the gnome terminals the next day, upon log in.

Go to Source
Author: Rory Cornish

How do I dump raw data from a TCP port in Windows using the netsh command?

I have an apparently simple issue which is proving very difficult to find an answer for.

The site has a highly-secured Windows Server 2019 installation and an appliance connected to it running on a certain TCP port.

I need a sample of the raw data coming out of that port, taken for a few minutes, dumped into a binary file. It needs to be as raw as possible (i.e. it needs to resemble what we would read from the TCP stream when we would connect to that same port from a local .NET application).

It is highly preferable to use only built-in Windows tools for this (i.e. netsh), but worst-case windump or telnet are also fine.

Go to Source
Author: Ruslan

Is adding encryption before hashing more secure?

One way to secure a password in the database is to hash it with salt i.e. appending a random string to the password and then hash it and store the value.

Does encrypting the password || salt then hashing it make it more secure? Is it really necessary (or can I skip the encryption part)?

Go to Source
Author: xcoder

Query Product categories what have a custom field

Im trying to build a page template on wordpress that will show a list a categories that have a custom field checked.

So the taxonomy is just the default woocommerce taxonomy product_cat I then have a custom field to the product_cat taxonomy which is a check box called collectable

My set up is
Main Category

  • Child
  • Child
  • Child
  • Child

So for example 2 children categories have the tick box collectable which is set to add the value of 1 into the datbase

So I am doing a page where it will show all categories with the collectable checked.

$args = array(
    'post-type' => 'product',
    'taxonomy' => 'product_cat',
    'hide_empty' => 0
  );
  $c = get_categories($args);
  $c_keep = array();
  foreach($c as  $cat){
 if (get_field('collectable', 'category_'.$cat->term_id)) {
      $c_keep[] = $cat;
    }  
  }
  
  foreach($c_keep as $cat){
    echo $cat->name;
  }

But I am getting nothing at all returned.

I even put a

print_r( $args );

But I am still coming up with a blank (Header and footer Loads and the text above the query)

Can anyone help please

Go to Source
Author: user1348927

SQL Services are off but can access and query from other server on the same domain. Why?

Using configuration manager, I disabled the SQL Server Services for a SQL Server 2008 R2 instance. Yet, I can still connect to the instance from its replacement server, a SQL 2019 box, and query the data! Also, the jobs which I disabled are enabled and appear to have been running, i.e. last run time column. On the SQL Server 2019 environment, I am using SSMS 18.5.1.

What is going on??? Locally, I cannot connect. Is there something else that I need to disable? I’d like to understand why this is occurring.

Go to Source
Author: LeSteelBox

How to model database for system with historic relationships (many-to-many and one-to-many)

I’m working on a system with a main entity, let’s say “Members”, these members have relationships to other entities and it’s important to keep the history to be able to query and know the relationships at a given time in history.

We mainly have two kind of relationships:

  • Company (most exist and can only be on company at a given time)
  • Tags (optional, multiple tags at any given time)

After looking at this I was thinking that I could model the relationships with dates on the “relation table” something like this:

Tag:
- Id
- Text

Company
- Id 
- Name

Member:
- Id
- Name

Member2Tag
- Id
- MemberId
- TagId
- Added (DateTime)
- Removed (Nullable DateTime)

Member2Company
- Id
- MemberId
- CompanyId
- Added (DateTime)
- Removed (Nullable DateTime)

This way I’ve managed to query for relationships at any given time in history, but I started thinking about this and felt a little unsure if the “Removed”-column is really needed, I guess it is since I can’t remove the relation-row (need to keep history).

I just wanted some feedback on the design, what do you think? Have someone else faced a similar problem and used another solution?

All the best!

Go to Source
Author: Markus Knappen Johansson

Conditional Formatting Clear if another cell is not empty

apologies if that has already been answered – I’ve tried searching but nothing that is specific for this.

I am fairly novice with sheets and cant share the whole thing due to potentially confidential nature of the information.

The purpose of my sheet is to monitor dates for projects using colours.
enter image description here

I don’t want to focus too much on the date completed rows, more the rows with the projects on. It has a script in there to count the coloured cells but not sure if this interacts with my requests but thought I would include this in case.

So far, I’ve used to standard conditional formatting that doesn’t require myself to put a formula. So when the date on the (project name) row is today or yesterday (meaning it’s late) it goes red. When the date is tomorrow, it goes orange as warning.
A couple of things that I want to do are

  • I want it to be orange for longer than just the one day but I am not sure what formula to use. I’ve tried simple stuff like conditional formatting, date is tomorrow +4, as that makes sense to me but it doesn’t work, as, quite novice.
  • The second thing I want to happen is, I want to the red to stay longer to, more than just today yesterday. Again, I’ve tried to basic conditional formatting, date is today-5, as again, it just makes sense to me.
  • The final thing I want to happen is, when a date is inputted into the date completed field, I want the colour in the project name row to go clear, as if to say, something has been handed in, it’s no longer upcoming or late. For example, Take the payment holiday approaching exit. It is red, as it was yesterday. When I put the date that it was completed in for this, I want it to go clear because it’s been completed.
    I don’t know if it wont do this as I have 3 conditional formatting over it already.

I hope this is clear enough, I tried to be concise and give context. If anyone can help, it would be much appreciated.

Go to Source
Author: Daniel

Cannot get is_valid() to go back to template with bound form

In the Django docs, it says

“We call the form’s is_valid() method; if it’s not True, we go back to
the template with the form. This time the form is no longer empty
(unbound) so the HTML form will be populated with the data previously
submitted, where it can be edited and corrected as required.”

I am trying to get this behaviour to work.

In views.py:

def test(request):
    if request.method == 'POST':
        form = TestForm(request.POST)

        if form.is_valid():
            return redirect('auctions/test.html')

    else:
        form = TestForm()
        print(form)
        return render(request, 'auctions/test.html', {'form': form})

In forms.py:

class TestForm(forms.Form):
    testnumber = forms.DecimalField(max_digits=1)

In test.html:

<form action="{% url 'auctions:test' %}" method="post">
    {% csrf_token %}
    {{ form }}
    <input type="submit" value="Submit">
</form>

Now, when I submit the form with a number that is more than 1 digit, is_valid() evaluates to False. When that happens, the docs says the template should be rendered with the bound form and the error. Instead, nothing happens, and I get ValueError: The view auctions.views.test didn't return an HttpResponse object. It returned None instead.

Go to Source
Author: Ryan Eom

How can I login to MySQL as 127.0.0.1 or ::1 instead of localhost?

I’ve set different password for 'root'@'localhost' and 'root'@'127.0.01' like this:

mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pswd1');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('pswd2');

but when I try to login like this:

mysql -u root -p -h 127.0.0.1

I still have to use the first password pswd1 even though according to this:

enter image description here

another password pswd2 was set for 127.0.0.1.

What is the problem here? How can I set 3 different passwords for ‘root’@’localhost’, ‘root’@’127.0.0.1’ and ‘root’@’::1′ and login to those accounts with those passwords?

Go to Source
Author: JConstantine

Mate snipping tool faster to display than “mate-screenshot”/Eye-of-Mate

I am a SysAdmin of many decades. I routinely juggle dozens of windows on my Mate desktop when working a crisis. My workstation has 4 monitors, 4 Mate workspaces, and it is not nearly enough! So I use screen captures to help further organize the data.

However, “mate-screenshot –area” has no direct option for “display now”. You have to save to disk and open in “Eye of Mate”. WTF!

Way back, Windows 7 had “Snipping Tool”: one click, one drag, instant display! Of course, Microsoft totally screwed it up in Windows 10 – one of so many reasons my workstations are Ubuntu these days and any Microsoft OS I have to deal with is safely sequestered in a VM!

I am sure I can script/code something that will do all the keystrokes for me but I thought I would ask here first just to avoid possibly reinventing the obviously necessary:

Is there an existing snipping tool for the Mate Desktop that displays with one click and one drag?

Go to Source
Author: Frobozz

Digital Signature for PDF files through Web Application

We are developing a Web Application for manage dental clinics.
The app can generate PDF files through the PHP backend (for example invoices, quotes etc.).

Each of those PDF file needs to be digitally signed by both the app user (the clinician) and the patient.
The sign we are looking for is the Legally Signature European Standard (which requires biometrical parameters or a certificate issued by a trusted provider such as Infocert (but we are not 100% sure how to then use such certificate)).

On average, in our country, each patient signs 5-10 documents and because of this we ruled out third party services such as Docusign, Pandadoc, Eversign.. because the average cost of those api services would be excessive for our needs (and country economy).

Another solution we did think about is to use the signature pads (such as Wacom’s) that are capable to collect biometrical parameters, but we have no idea how to integrate such devices with our Javascript frontend (assuming it is even possible to interface those devices through the web browser).

Assuming our backend displays the PDF already generated to the client, what would it be the best approach to apply a digital signature to it through the client (which would then send back the signed PDF to the server for storage) ?
Is there a way to interact with signature pads devices through the browser (to extract the biometrical parameters together with the visual signature) ?

Thanks

Go to Source
Author: Nite

How to remove the search field in custom taxonomy ui?

In recent versions of wordpress I see a new search/autocomplete text field on top the custom taxonomy metabox (when hierarchical). I also see the taxonomy slug with it (“project_type” in the attached image).

How can I remove It? Is there an argument for that when registering the taxonomy?

enter image description here

Go to Source
Author: Marc

Opendkim running but not signing?

I have had a lot of fun with OpenDKIM – it is actively running on my Debian box and here is my code:

root@web1:~# tail -f /var/log/syslog | grep -i dkim
Sep  7 16:35:38 web1 sm-mta[1504]: 087FZbYw001504: Milter insert (1): header: DKIM-Signature:  v=1; a=rsa-sha256; c=simple/simple;ntd=web1.mydomain.com; s=web1; t=1599492938;ntbh=+j1V4TFBmUGM3frMlslpv/49yjR0n44tuVimZHHRn0Q=;nth=Date:To:From:Reply-To:Subject:From;ntb=Z1gNvmXGQZXdx3iXGDpAWsdROt8iBctCrf248LQWtpNq5D3803fEWgUWCo9Bi81Bxnt qpE3hKokZTfD3jHlmyuhV9kZMulxEVv+jcjBXaK5r2L4957mUYW4Ao+UgBycqM6jt9nt CuOE+YStbaWal5mNNtf0NplJCHbHYk25NTV1y2zs=

However when I test the signature using https://www.appmaildev.com/en/dkim I am getting DKIM-Result: permerror (no key)

From the result of the tail I believe Opendkim isn’t being passed the necessary to,from,reply-to etc but thats just my guess. Why would the email not be signed?

This is my /etc/opendkim.conf but I’m unclear where I would see any extra details such as the “LogWhy” should generate.

Syslog                  yes
UMask                   007
Socket                  inet:8891@localhost
PidFile               /var/run/opendkim/opendkim.pid
OversignHeaders         From
TrustAnchorFile       /usr/share/dns/root.key
UserID                opendkim
Domain                web1.mydomain.com
KeyFile               /etc/opendkim/web1.private
Selector              web1
LogWhy                  yes

So to be clear – my question is: Why is the email not being signed with DKIM?

Go to Source
Author: Antony

Error #2 when trying to install ECM (Extra Cmake Modules)

I am trying to install extra-cmake-modules from source, and then I get an error after executing make command:

Extension error:
Could not import extension ecm (exception: No module named 'sphinxcontrib')
make[2]: *** [docs/CMakeFiles/documentation.dir/build.make:62: docs/doc_format_html] Error 2
make[2]: Leaving directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make[1]: *** [CMakeFiles/Makefile2:217: docs/CMakeFiles/documentation.dir/all] Error 2
make[1]: Leaving directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make: *** [Makefile:163: all] Error 2

It seems that the problem is about module Sphinx, but I tried to uninstall and install it again via pip and the error still occurred. So what can I do to fix it?
Here are logs when I executed cmake -DCMAKE_INSTALL_PREFIX=/usr .. and make command:

$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
-- WARNING: skipping tests that require PyQt
-- The following features have been enabled:

 * BUILD_HTML_DOCS, Generate HTML documentation for installed modules.
 * BUILD_MAN_DOCS, Generate man page documentation for installed modules.
 * BUILD_TESTING, Build automated tests.

-- The following OPTIONAL packages have been found:

 * Sphinx (required version >= 1.2), Tool to generate documentation., <https://www.sphinx-doc.org/>
   Required to build documentation for Extra CMake Modules.
 * QCollectionGenerator, Qt help collection generator., <https://www.qt.io/>
   Required to build Extra CMake Modules documentation in Qt Help format.
 * Qt5LinguistTools, Qt5 linguist tools., <https://www.qt.io/>
   Required to run tests for the ECMPoQmTools module.
 * Qt5Core, Qt5 core library., <https://www.qt.io/>
   Required to run tests for the ECMQtDeclareLoggingCategory module, and for some tests of the KDEInstallDirs module.
 * Qt5Network (required version >= 5.14.2)
 * Qt5Qml (required version >= 5.14.2)
 * Qt5QmlModels (required version >= 5.14.2)
 * Qt5Gui (required version >= 5.14.2)
 * Qt5Quick, Qt5 Quick library., <https://www.qt.io/>
   Required to run tests for the ECMQMLModules module.

-- The following features have been disabled:

 * BUILD_QTHELP_DOCS, Generate QtHelp documentation for installed modules.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build
$ make
make[1]: Entering directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make[2]: Entering directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make[2]: Leaving directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make[2]: Entering directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
[ 50%] sphinx-build html: see /home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build/docs/build-html.log
/usr/lib/python3.8/importlib/__init__.py:127: RemovedInSphinx40Warning: The alias 'sphinx.util.pycompat.htmlescape' is deprecated, use 'html.escape' instead. Check CHANGES for Sphinx API modifications.
  return _bootstrap._gcd_import(name[level:], package, level)

Extension error:
Could not import extension ecm (exception: No module named 'sphinxcontrib')
make[2]: *** [docs/CMakeFiles/documentation.dir/build.make:62: docs/doc_format_html] Error 2
make[2]: Leaving directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make[1]: *** [CMakeFiles/Makefile2:217: docs/CMakeFiles/documentation.dir/all] Error 2
make[1]: Leaving directory '/home/masterpi/Documents/Extra-CMake-Modules/extra-cmake-modules/build'
make: *** [Makefile:163: all] Error 2

Go to Source
Author: Minh Nhật