(Angular 5/Typescript) @Input() not working

Question: I have two components parent & child, and i want to pass the category defined in parent to be used in child. But getting error undefined.
Parent Component:
export class MenuComponent implements OnInit {
  category: string;
  constructor() { }

  ngOnInit() {
    this.category = "Human";
  }

And the Child component is:
export class MenuListComponent implements OnInit{
 @Input() category: string;
 // category = 'Man';
 constructor() { }

  ngOnInit() {
  console.log(this.category);
}

Parent component template

    <app-menu-list></app-menu-list>

Output is undefined.
Comment: Can you add template code as well please so we can see how you're passing the input?
Comment: @user184994 Added the template
Answer: You actually need to pass your variable to the child:
<app-menu-list [category]="category"></app-menu-list>


trying to create a userinfo code for discord bot, everything runs fine, but when it loads, the field Joined Server is set as undefined any tips?

Question: I'm using node and visual studio code.
The script runs fine and the text gets embedded right below the title of the field. But instead of showing the joined server date, it shows 'undefined'.
switch(args[0]){
case 'userinfo':
     let usera = message.mentions.users.first()
     if(!usera) return message.channel.send("Must specify user")
     const joinDiscord = moment(user.createdAt).format('llll')

          let embed = new Discord.MessageEmbed()
          .setAuthor(usera.tag, usera.avatarURL)
          .addField("ID", usera.id, true)
          .addField("Username", usera.username, true)
          .addField("Status", usera.presence.status, true)
          .addField("Joined Server",usera.joinedAt, true)//its this part
          .addField("Created", usera.createdAt, true)
          .addField("Bot", usera.bot, true)
          .setTimestamp()
          .setColor(0x0f7fa6)
          .setThumbnail(usera.displayAvatarURL())
     message.channel.send({embed});

}
});

Answer: joinedAt is a varible for the guildMember object type, but what you have is a user object. You can get the member object from the user object by doing the following:
switch(args[0]){
case 'userinfo':
     let usera = message.mentions.users.first()
     if(!usera) return message.channel.send("Must specify user")
     const joinDiscord = moment(user.createdAt).format('llll')

          let embed = new Discord.MessageEmbed()
          .setAuthor(usera.tag, usera.avatarURL)
          .addField("ID", usera.id, true)
          .addField("Username", usera.username, true)
          .addField("Status", usera.presence.status, true)
          .addField("Joined Server",message.guild.members.cache.get(usera.id).joinedAt, true)//got the guild member from the users id
          .addField("Created", usera.createdAt, true)
          .addField("Bot", usera.bot, true)
          .setTimestamp()
          .setColor(0x0f7fa6)
          .setThumbnail(usera.displayAvatarURL())
     message.channel.send({embed});

}
});

Comment: Tip: You can make your code even shorter and use: `message.guild.members` instead of `message.channel.guild.members`.


What does Celes' Runic command do?

Question: I've never been able to figure out how to use Celes' Runic skill to any effect in battle.  Is it for a secret boss? What does it do?
Answer: Celes' Runic ability will absorb the first spell cast by anyone during the time that it is active, and use that to replenish her MP.  If no one casts a spell, then Celes effectively wastes her turn.
The advantage to this skill is that you can avoid extremely damaging magic attacks with it.  For instance, if you are worried that a Brachiosaur is going to use Ultima on you, using Runic will protect your party from taking damage, while giving Celes a MP boost.
There are certain restrictions, however.  Only certain weapons work with this skill.  For instance, all swords, spears, daggers and katanas are compatible with it.  Although it works with almost all magic spells (ie, those that your characters can learn via Espers), not all enemy skills are absorbed with it, although most are.
For a list of all the special cases and other info regarding this skill, consult the relevant Final Fantasy Wikia article.
Comment: Well, it is instrumental in getting some of the best gear in the game, and the toughest normal enemy...it's a pretty well known secret, at least if you actually know what brachiosaurs are and that they cast Ultima...
Comment: I think you can check the weapon to see if it says "Runic".
Comment: Brachisaur casts Ultima in a set pattern actually; you *know* it's going to cast it :P
Comment: @Ben Brocka: If you've bothered to look up and/or memorize the AI scripts, sure, but I hardly think most people do that. :)
Comment: Zounds - it's the weapon?  I never knew...

What does Celes' Runic command do?


Firebase insert data using Nodejs API

Question: I am trying write Hello world kind of basic application with Firebase and Nodejs.
Application code
#cat app.js

var express = require('express');
var Firebase = require('firebase');
var app = express();
app.get('/',function(req,res) {
  f();
  res.send("success");
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

  var onComplete = function(error) {
  if (error) {
    console.log('Synchronization failed');
  } else {
    console.log('Synchronization succeeded');
  }
};

function f() {
var ref = new Firebase("https://dazzling-torch-XXXXX.firebaseio.com");
ref.set({
  location: {
    city: "San Francisco",
    state: "California",
    zip: 94103
  }
},onComplete);
ref.child("location/zip").on("value", function(snapshot) {
console.log(snapshot.val());  // Alerts "San Francisco"
});
}

Library versions -
npm --version && node --version && firebase --version
1.3.6
v0.10.42
2.2.1

Node command -

node app.js
open browser http://localhost:3000/

Debugger Output
p:0: Making a connection attempt
c:0:17: Connection created
c:0:17:0 Websocket connecting to wss://dazzling-torch-XXXX.firebaseio.com/.ws?v=5
c:0:17:0 WebSocket error.  Closing connection.
c:0:17:0 Network error: wss://dazzling-torch-XXXX.firebaseio.com/.ws?v=5: getaddrinfo ESRCH
c:0:17:0 WebSocket is closing itself
c:0:17:0 Websocket connection was disconnected.
c:0:17: Realtime connection failed.
c:0:17: Closing realtime connection.
c:0:17: Shutting down all connections
p:0: data client disconnected
p:0: Trying to reconnect in 17797.816018858393ms

but it is not updating firebase data. I am using default security rules.
Thanks
Pari
Comment: Any error message? What do you get when you make a request to / route?
Comment: `ref.set()` takes an optional second callback function that will be called in case of any errors (see [the docs for info](https://www.firebase.com/docs/web/api/firebase/set.html)). Setting that and logging the errors might show a hint as to what is happening.
Comment: Thanks for reply. I have added debugger .

Debug output -
c:0:2: Connection created
c:0:2:0 Websocket connecting to wss://dazzling-torch-1380.firebaseio.com/.ws?v=5
c:0:2:0 WebSocket error.  Closing connection.
c:0:2:0 Network error: wss://dazzling-torch-1380.firebaseio.com/.ws?v=5: getaddrinfo ESRCH
c:0:2:0 WebSocket is closing itself
c:0:2:0 Websocket connection was disconnected.
c:0:2: Realtime connection failed.
c:0:2: Closing realtime connection.
c:0:2: Shutting down all connections
p:0: data client disconnected
Comment: Added onComplete callback function for set and debugger output in main post.

Thanks
Comment: Not really an answer, but the output of my steps is below.
Answer: I just ran on node v0.10.37 and firebase 2.4.2 (those are really the only versions that should matter) and it connected and wrote the data instantly.
node app.js
Example app listening on port 3000!
p:0: Browser went online.
0: set {"path":"/36518762","value":{"location":{"city":"San Francisco","state":"California","zip":94103}},"qh":null}
p:0: Buffering put: /36518762
p:0: Listen called for /36518762/location/zip default
event: /36518762/location/zip:value:94103
94103
p:0: Making a connection attempt
c:0:0: Connection created
c:0:0:0 Websocket connecting to wss://stackoverflow.firebaseio.com/.ws?v=5
c:0:0:0 Websocket connected.
c:0:0: Reset packet received.  New host: s-usc1c-nss-158.firebaseio.com
c:0:0: Shutting down all connections
c:0:0:0 WebSocket is being closed
c:0:0:0 Websocket connection was disconnected.
c:0:0:1 Websocket connecting to wss://s-usc1c-nss-158.firebaseio.com/.ws?v=5&ns=stackoverflow
c:0:0:1 Websocket connected.
c:0:0: Realtime connection established.
p:0: connection ready
p:0: reportStats {"c":{"sdk.js.2-4-2":1}}
p:0: {"r":1,"a":"s","b":{"c":{"sdk.js.2-4-2":1}}}
p:0: Listen on /36518762/location/zip for default
p:0: {"r":2,"a":"q","b":{"p":"/36518762/location/zip","h":""}}
p:0: {"r":3,"a":"p","b":{"p":"/36518762","d":{"location":{"city":"San Francisco","state":"California","zip":94103}}}}
p:0: from server: {"r":1,"b":{"s":"ok","d":""}}
c:0:0: Primary connection is healthy.
p:0: handleServerMessage d {"p":"36518762/location/zip","d":94103}
p:0: from server: {"r":2,"b":{"s":"ok","d":{}}}
p:0: listen response {"s":"ok","d":{}}
p:0: from server: {"r":3,"b":{"s":"ok","d":""}}
p:0: p response {"s":"ok","d":""}
Synchronization succeeded

It looks like your web socket is getting rejected way before that. You might want to check for proxies in between your client and the Firebase server. Try on a different network, that sort of thing.

Try the diagnostic page
ping INSTANCE.firebaseio.com
tracert INSTANCE.firebaseio.com
Run this curl command, substituting your Firebase URL at the end (don't forget .json!).
Try a different computer on a different network

Note that these are all just steps to help you troubleshoot connection problems.
Comment: Thanks Frank, your steps did help.
It was problem with my internet provider.
I have launched AWS instance with node.js installed. My program is working without any error on aws instance.
Comment: I tried to upvote your answer but as I don't have enough points, I could not do it. :(.

Firebase insert data using Nodejs API


Validate Map option not showing in Visual Studio

Question: I want to validate .btm map and want to generate xslt file but as mentioned in the following article: How to Configure Map Validation and Test Parameters
The "Validate Map" option not showing by doing a right click on .btm file as seen in the Screenshot below.
Any solution?
Comment: Do you have a BizTalk Server license?
Comment: No. It's a developer edition.
Answer: Install Visual studio tools from your BizTalk installer

After adding this option, make sure you restart your visual studio and build your project. You should able to validate your map.


Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources

Question: I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin
installed. When I try to do 'Run As---> Maven install', I am getting
the following error :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project mavencxf: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.5:resources: org/codehaus/plexus/util/Scanner
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-resources-plugin:2.5
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.jar
[ERROR] urls[1] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
[ERROR] urls[2] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
[ERROR] urls[3] = file:/C:/Users/Mindbowser-MB/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
[ERROR] urls[4] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[5] = file:/C:/Users/Mindbowser-MB/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[6] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
[ERROR] urls[7] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/apache/maven/shared/maven-filtering/1.0/maven-filtering-1.0.jar
[ERROR] urls[8] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/plexus-build-api-0.0.4.jar
[ERROR] urls[9] = file:/C:/Users/Mindbowser-MB/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.util.Scanner
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]

Comment: Sounds like a mismatch between your maven installations, perhaps. Check your maven settings in eclipse. Does mvn install work on command line. If not, what does mvn -e install provide.
Comment: Apart from the above check why are you using an older version of maven-resources-plugin.
Answer: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.5:resources: org/codehaus/plexus/util/Scanner
The resources plugin is missing a dependency; But it should download it automatically,... are you in offline mode? If you are go online once and execute it, it should download the missing dependencies automatically.
Answer: My problem was with the repositories defined in the POM.XML file.  I removed them so that it would use the default repo and it solved my issue.
Answer: This happened to me once when something went wrong with the repository, and then even if I ran maven again, it still failed.
Solution:

delete maven repo  ~/.m2/repository
and then re-build

It works for me.


Click image and be redirected to new page with clicked image added dynamically to new page?

Question: I'm creating a fictitious online guitar store. I have an image carousel on my main page and I want to be able to click on an image and be redirected to a product page with information about the item clicked, the clicked image and three additional images.
I know how to redirect to pages and I know how to dynamically load images (the gallery was gone this way) but I cannot seem to accomplish both when working between two files. Right now my product page images are hard coded.
This is the div where I want the new image src to be added. I can do it this way or create a new img tag dynamically, it doesn't matter

This is the code I've been playing around with. I left the lines comments out so you can see what I've been trying. Basically, when the clicked src matches one of the img1 srcs in the json file, I want the images from that object loaded. Right now I'm just concerned with img1
$(".more-info").on("click", function(e) {

    let moreSrc = $(e.target).attr('src')

    $.getJSON("../json/guitars.json", function(json) {
      var more_info = '';

      for(var i in json) {
        if (moreSrc === json[i].img1 ) {
          var image1 = json[i].img1
          var image2 = json[i].img2
          var image3 = json[i].img3
          var image4 = json[i].img4
          var alt = json[i].alt

          more_info += `<img id="clickImg" class="img-fluid" src="${image1}" alt="${alt}">`
          // console.log(moreSrc)
          // console.log(json[i].img1)
          // window.location.href = "./pages/html/product.html";
          // $('#clickImg').attr('src', moreSrc);
        }
      }
      $('.product-img-focus').html(more_info)
      window.location.href = "./pages/html/product.html"
    })
  })

Example of the json
{
    "category": "1",
    "condition": "used",
    "justIn": "true",
    "brand": "Gibson",
    "year": "1952",
    "code": "456def",
    "img1": "../img/sale/gibson/295-1.jpg",
    "img2": "../img/sale/gibson/295-2.jpg",
    "img3": "../img/sale/gibson/295-3.jpg",
    "img4": "../img/sale/gibson/295-4.jpg",
    "alt": "guitar1",
    "title": "Gibson ES-295 1952",
    "price": "$6,000.00",
    "description": "A beautiful ES-295 with wear you can't fake! The ES-295 was originally produced from 1952 to 1958 and is best known for being the model played by Scotty Moore with Elvis. This particular example plays well with a fantastic feeling neck! The guitar has heavy finish wear with the beautiful greening that you often see on '50s goldtops. Glaser has refretted the guitar and replaced the tailpiece crossbar. The pickguard is missing.",
    "specs": ["Body Wood - Laminated Maple",
              "Neck Wood - Mahogany",
              "Fingerboard Wood - Rosewood",
              "Scale Length - 24.75",
              "Nut Width - 1 11/16",
              "Pickup(s) - Original P-90s",
              "Case - Hard Case"
            ]
  },

JQuery or vanilla JS is fine. I searched everywhere before posting here. Thank you!
Comment: You need to send product ID to the next page, something like **window.location.href = "./pages/html/product.html?product=" + product_id;** in the new page you grab the ID from URL, look for it into JSON and show details.
Answer: You're going to need a way to tell the new page what image to display. I'd try passing that info with a URL parameter.
Maybe something like this:
window.location.href = "./pages/html/product.html?item=img1"

Then, on the product page, load the JSON and use the URL param as the object key.
function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}
var guitar = getUrlVars()["item"];

...

$('#clickImg').attr('src', '../' + guitar;


How can I get a loop to ignore non-letter elements in a list?

Question: I have a string that contains letters and punctuation. I'm trying to replace only the letters in this string with other letters. The function I have developed only works for strings that contain letters. If numbers are included it produces a logic error and if punctuation is included then it produces a run-time error. Is there anyway that I can get my function to ignore punctuation and leave it as is while only operating on the letters?
#Create a string variable, ABjumbler generates an alphabet shifted by x units to the right
#ABshifter converts a string using one type to another

textObject = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
smalltext = 'abcde'

alphabet = list(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])

def ABjumbler(alphabet, x):
    freshset = []
    i=0
    j=0
    while i<(len(alphabet)-x):
        freshset.extend(alphabet[i+x])
        i+=1
    while j<x:
    freshset.extend(alphabet[j]) #extend [0]
    j+=1 #change j = to 1, extends by [1], then by [2], and then terminates when it reaches x
    alphabet = freshset
    return alphabet

newAlphabet = ABjumbler(alphabet, 2)

def ABshifter(text, shiftedalphabet):
    freshset = []
    for letters in text:
        position = text.index(letters)
        freshset.extend(shiftedalphabet[position])
    final = ''.join(freshset)
    return final

print ABshifter(smalltext, newAlphabet)

Comment: Just curious - this looks remarkably familiar - one of the early pythonchallenge.com puzzles iirc ;)
Comment: `while j<x:` is not doing anything in your code because the block below it is not indented
Answer: For one, there are some faster/simpler ways of doing the shifting you want.
But to answer your question, you could simply add:
if not letter.isalpha():
    continue

str.isalpha() returns True if the string is composed only of alphabetic letters.
Comment: Thanks for the tip, it set me off on the right path anyway. I know there are simpler ways to do it, but I'm not as familiar with it. Once again, thanks for the help.
Comment: Yep, it turns out .isalpha() is all I needed to finish this.
Answer: Try this one:
textObject = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
smalltext = 'abcde'

alphabet = list(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])

def ABjumbler(alphabet, x):
    #for x greater then alphabet length
    if x>=len(alphabet):
        x = x % len(alphabet)
    #return a dictionary like 'a':'c', 'b':'d' etc
    return dict(zip(alphabet, alphabet[x:] + alphabet[:x]))

def ABshifter(letter, alph):
    if letter.isalpha():
        return alph[letter]
    return letter

print "".join(map(lambda x: ABshifter(x, ABjumbler(alphabet,2)), smalltext))

Comment: This is the most complete answer. I didn't mention that I wanted to try this without creating a dictionary, but now that I've got the code for it I can start figuring it out later. Thanks again.
Comment: You call len(alphabet) twice, and there's no reason to even do the if check there.
Answer: 1)
x = ['a', 'b', 'c']
print x

y = list(['a', 'b', 'c'])
print y

--output:--
['a', 'b', 'c']
['a', 'b', 'c']

Any difference?  Then don't call list() when it's unnecessary.
2)
x.append('d')
y.extend(['d'])

print x
print y

['a', 'b', 'c', 'd']
['a', 'b', 'c', 'd']

Any difference?  Then don't create a list with 'd' inside if it's unnecessary.
Your whole ABjumbler() function can be reduced to one line:
cypher = alphabet[x:] + alphabet[:x]

Examine this code:
import string

x = 23
letters = string.ascii_lowercase

print letters[x:]    #xyz
print letters[:x]    #abcdefghijklmnopqrstuvw
print "-" * 10

cypher = letters[x:] + letters[:x]
print cypher         #xyzabcdefghijklmnopqrstuvw

table = string.maketrans(letters, cypher)

The maketrans() function constructs a translation table like this:
letters:  abcdefghijklmnopqrstuvwxyz
 cypher:  xyzabcdefghijklmnopqrstuvw

If the letters on top are found in a string, they get translated to the letters directly beneath them:
x = "aaa"
print x.translate(table)   #xxx

x = 'abc'
print x.translate(table)   #xyz

x = 'a1bc!'
print x.translate(table)   #x1yz!

x = '123a-b-c!!!!a.b.c456'
print x
print x.translate(table)

--output:--
123a-b-c!!!!a.b.c456
123x-y-z!!!!x.y.z456

If x might be larger than the length of your alphabet, then write:
x = x % len(letters)

before constructing the cypher.
import string

def encode_it(str_, letters, offset):
    offset = offset % len(letters)
    cypher = letters[offset:] + letters[:offset]
    table = string.maketrans(letters, cypher)
    return str_.translate(table)

Answer: You can use the string.ascii_letters constant to check if your current character is a letter. Here's a snippet that replaces all letters in a string with 'x' (I know this isn't exactly what you want to do but it might get you started):

    import string

    s = "g fmnc, wma: bgblr?"
    sList = list(s)

    for i in range(0, len(sList)):
        if sList[i] in string.ascii_letters
            j[i] = 'x'
        s = ''.join(j)

    print(s) #'x xxxx, xxx: xxxxx?'


Unable to build C++ Class in JavaScript using Emscripten with generated Djinni Wrapper

Question: I'm trying to generate an extremely simple WebAssembly module from a C++ class with an add function. Here is the source c++ class and the respective djinni file
// ***src/MathUtils.cpp***
#include "MathUtils.hpp"

class MathUtils_ : public MathUtils {
public:
    double add_fff64(double a, double b) override {
        return a + b;
    }
};

// ***djinni/MathUtils.djinni***
MathUtils = interface +c {
    add_fff64(a: f64, b: f64): f64;
}

Using Snapchat/Djinni's wasm interface, I've generated the following files:
// ***src/MathUtils.hpp***
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file was generated by Djinni from MathUtils.djinni

#pragma once

class MathUtils {
public:
    virtual ~MathUtils() = default;

    virtual double add_fff64(double a, double b) = 0;
};

// ***wasm/MathUtils.hpp***
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file was generated by Djinni from MathUtils.djinni

#pragma once

#include "src/MathUtils.hpp"
#include "/Users/sam/snap.djinni/support-lib/wasm/djinni_wasm.hpp"

namespace djinni_generated {

struct MathUtils : ::djinni::JsInterface<::MathUtils, MathUtils> {
    using CppType = std::shared_ptr<::MathUtils>;
    using CppOptType = std::shared_ptr<::MathUtils>;
    using JsType = em::val;
    using Boxed = MathUtils;

    static CppType toCpp(JsType j) { return _fromJs(j); }
    static JsType fromCppOpt(const CppOptType& c) { return {_toJs(c)}; }
    static JsType fromCpp(const CppType& c) {
        ::djinni::checkForNull(c.get(), "MathUtils::fromCpp");
        return fromCppOpt(c);
    }

    static em::val cppProxyMethods();

    static double add_fff64(const CppType& self, double w_a,double w_b);

};

} // namespace djinni_generated

// ***wasm/MathUtils.cpp***
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file was generated by Djinni from MathUtils.djinni

#include "wasm/MathUtils.hpp"  // my header

namespace djinni_generated {

em::val MathUtils::cppProxyMethods() {
    static const em::val methods = em::val::array(std::vector<std::string> {
        "addFff64",
    });
    return methods;
}

double MathUtils::add_fff64(const CppType& self, double w_a,double w_b) {
    try {
        auto r = self->add_fff64(::djinni::F64::toCpp(w_a),
                  ::djinni::F64::toCpp(w_b));
        return ::djinni::F64::fromCpp(r);
    }
    catch(const std::exception& e) {
        return ::djinni::ExceptionHandlingTraits<::djinni::F64>::handleNativeException(e);
    }
}

EMSCRIPTEN_BINDINGS(_MathUtils) {
    em::class_<::MathUtils>("MathUtils")
        .smart_ptr<std::shared_ptr<::MathUtils>>("MathUtils")
        .function("nativeDestroy", &MathUtils::nativeDestroy)
        .function("addFff64", MathUtils::add_fff64)
        ;
}

} // namespace djinni_generated

From this, I've attempted to generate a simple native JavaScript module that allows me to call the add function in the class.
I've effectively tried run several versions of the following script with every conceivable relevant flag:
emcc wasm/MathUtils.cpp src/MathUtils.cpp /Users/sam/snap.djinni/support-lib/wasm/djinni_wasm.cpp -o out/MathUtils.js --bind

While this has indeed compiled into a JavaScript output, there is no semblance of the MathUtils class or any add_fff64 function in MathUtils.js. Indeed, when I attempt to call the add_fff64 function in a generic native html file, I get an error.
This is particularly strange to me because when debugging the generated WebAssembly file with tools such as wasm-objdump and wasm2wat, MathUtils class and addFff64 both appear.
 - 0010490: 7562 6c65 3e00 6164 6446 6666 3634 0048  uble>.addFff64.H

Online tutorials and examples make it seem so simple, but I have yet to find anyone encountering this issue. Not exactly sure what I'm doing wrong - I'm a novice with emscripten and djinni, so even any debugging advice would be great!
Answer: Managed to find a solution, described and highlighted in this repo here: github.com/SamKouteili/DjinniWasmDemo


Best practise with elasticsearch id

Question: With elasticsearch you can define your own id or let elasticsearch apply its own.
What is the best practise for storing ids?
My application is going to have users and each user can have an item, basically, think of this as a blog.
Would the following be acceptable
id = user23_post1

Or would you use the internal way to manage the ids and create your own id
item_id = user23_post1

Coming from a relation database background, I have my incremental id hat on, which isn't the way to think when approaching solr or elascticsearch. So I'm looking at what other people have already done and possibly learn from their mistakes.
Thanks
Answer: I am assuming that you are not using Elasticsearch as a datastore, but as a search engine.
This would mean, that ElasticSearch does not own any data, it is analogous to a cache layer that has a very fast lookup!
In which case, I wouldn't expect Elasticsearch to hold any IDs, at least not something that is exposed outside. Having ids in sync with the datastore will help trickling atomic and delta updates.
However, elasticsearch can also be used as a NOSQL datastore, in which case, I would have the IDs generated in Elasticsearch.
Comment: Ok, so that's what I meant, by using Elasticsearch as a search engine. I would recommend denormalizing the data, and use the same I'd, so that there is some level of data integrity. Note that, by not being a rdbms system, elasticsearch cannot offer unique constraint like features
Comment: Even though I have postgres database for the users, their content is to be stored in ElasticSearch.
Comment: to be indexed. It will need to be searchable.

Best practise with elasticsearch id


Why does the OpenCV loop not end

Question: i have a simple webcam opening using cv2 module:
cap=cv2.VideoCapture(0)
while True:
    ret, img = cap.read()
    cv2.imshow('webcam',img)
    k=cv2.waitKey(10)
    if k == 27:
        break
cap.release()
cv2.destroyWindows()

this program runs for ever, although i try to close it, the only way is closing vsCode
Comment: `k == 27`, that means Esc is the way to break out from OpenCV's loop. Go to the window displaying the webcam feed and press the Escape Key.
Comment: cv2 window doesn't stop your loop when you close window using button `[X]`. You have to use key `ESC` to stop loop and then it will close window too. I some question I saw some function to check if window is visible to stop loop when you use button `[X]` but this not popular so I don't remember code.
Comment: did you try to use `Ctrl+C` in terminal/console to stop code? Normally it works. `VS Code` should have also button to stop executing code - so it shouldn't need to close all `VS Code`
Comment: [OpenCV Python: How to detect if a window is closed? - Stack Overflow](https://stackoverflow.com/questions/35003476/opencv-python-how-to-detect-if-a-window-is-closed)
Answer: You can close the webcam window by clicking on your webcam window and press esc while if you want to close it with specific alphabet then you can use the below code to destroy the window by pressing q.
import cv2
cap=cv2.VideoCapture(0)
while True:
    ret, img = cap.read()
    cv2.imshow('webcam',img)
    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

Why does the OpenCV loop not end


Clarification of the meaning and functionality of private and public in java

Question: I have seen this question and I understand what theoretically the difference between public and private means. My understanding is as follows:

public means that it's "visible" / "accessible" everywhere. As in every class can see it.
  private is only "visible" / "accessible" in its declared class.

My first question is:
What does "visible" exactly mean? I'm not quite sure how to interpret the meaning of "this class can't "see" this method".
Second question is:
What is the functionality/use of these? In the second asnwer of the question, he explains that if we "encapsulate" our code, then we will make it "easier for ourselves to change the code later and not break anybody's else's code". What does this exactly mean?
Examples would help a lot
Comment: Please refer this : http://cs.gordon.edu/courses/cs112/kjrComplete/ch3/visibility.html

not only this you can  go through any java beginner tutorials, you will be able to get a good idea about the basics
Answer: With respect to the first question: What does "visible" exactly mean?
visibility translates to accessibility when talking of classes, whenever a class is declared public, that class is accessible to all the other classes of the project, and all the classes can access them as they like either by inheriting the class or instantiating a new object of the class. Similar concepts also transcend to public class members. However, one important point is that public class members such as methods and variables will only be visible/accessible to other classes if the containing class is not marked as private.
On the other hand, when the class is marked as private, it is hidden from all the classes in the codebase, you can think that the rest of the code won't even know that, that class exists.
Members of a private class are only accessible within the class and are hidden from the outside world.
A private member will remain inaccessible for the outside world even if its class is marked as public.
Now, for the second question: What is the functionality/use of these?
Access modifiers are especially useful when you want to restrict as to what part of your class should be accessible from outside and what part should not be accessible.
For example, in general, it is a good idea to make class variables as private and then expose functions that will allow you to fetch those variables, the major benefit you get with this approach is that at any point of time in future, you can change how those variables are calculated and the changes would propagate to all the classes without having the need to change them, had the classes directly accessed the variable, it would have been very difficult to make the change without impacting other classes. This is just one example demonstrating how useful access modifiers can prove to be even for the simplest of things.
Hope this gives you a brief idea.


about Synplify VHDL (code imported from Xilinx ISE)

Question: I'm start to work with Synopsys Synplify. Import my Xilinx ISE project (fully work).
Try to run and receive - "No matching overload for to_integer" for this line
rgb(7 downto 0) <= color_lut(result_reg(to_integer(unsigned(x(2 downto 0))-1 )));

What can I do to adopt this piece for Synplify?
Comment: Can you specify what libraries and packages you have referenced in your design? For example, library ieee; use ieee.std_logic_1164.all; etc...
Comment: Also specifying the version of Synplify could also be helpful.
Comment: Sure,library IEEE, ieee_proposed;  ----
    use IEEE.STD_LOGIC_1164.ALL;   ----
    use ieee.numeric_std.all;      ----
    use ieee_proposed.fixed_pkg.all; ----
Answer: You should be able to use the following libraries in synplify:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.fixed_pkg.all;

Under implementation options > VHDL Tab make sure you enable "VHDL 2008" checkbox. I don't think it is enabled by default. This could be your problem.


Can the Community user really suggest edits?

Question: For example, in How do I hide a field after login? you will notice that the Community user is shown as the user who edited the question.

The revision page shows an edit summary too specific to be made from an automated process, such as "edited title; improved grammar."

Does the Community user really propose the edit?
Comment: you might also want to see this : http://meta.drupal.stackexchange.com/q/977/6461
Answer: The "suggested" link shown in the revision page shows you the page for the proposed edit.

On that page is reported who made the edit: an anonymous user. Somebody without an account suggested an edit, which is then reported as proposed from the Community user.

There were edits that are effectively done from the Community users, but in those case the Community user doesn't appear as last editor. This includes edits where:

Links to the duplicated questions are inserted

Links to the duplicated questions are removed

Link to duplicate questions are not added anymore to the question body, but such edit can still be seen in old questions.


Uncaught error unexpected token (

Question: I'm getting an error Uncaught error unexpected token ( in script tag on string with for loop

I need an offer_photo variable which should contain arrays slide_offer_preview_1, slide_offer_preview_2, slide_offer_preview_3 etc.
Where did I make a mistake? Thanks!
Comment: you defined an object `offer_foto` with no properties, instead, you put an instruction, that's not permitted
Answer: Without seeing what your actual rendered code looks like, this will be difficult. But my guess is you should be using photo_array instead of @photos:

Comment: Thanks for helping, but I need a `offer_photo` variable. It should contain array like `slide_offer_preview_1`, `slide_offer_preview_2` etc.
Comment: I'm not quite sure I can use loop inside `var`
Comment: I think you need to rewrite your question. This isn't explained in your post.
Answer: Answer based on your comment: "...I need a offer_photo variable. It should contain array like slide_offer_preview_1, slide_offer_preview_2 etc."

Or if you need it to be in one array within "offer_foto" object:
var offer_foto = {};
offer_foto.slide_offer_preview_ = [];
for(var i = 0; i < <%= @photos.length %>; i++) {
  offer_photo.slide_offer_preview_[0] = photo_array[i];
}

Uncaught error unexpected token (


Unsupported architecture 'i386' when running `apt update` on Virtualbox bionic repo

Question: Encountered this today where there were no issues before, console logs follow:
Hit:3 https://download.virtualbox.org/virtualbox/debian bionic InRelease

N: Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository 'https://download.virtualbox.org/virtualbox/debian bionic InRelease' doesn't support architecture 'i386'

Is this a problem with the repository, or with my own config? The same operation had no issue as recently as 3 days ago.
Answer: Manual comparison of previous 16.04 LTS folder structure

with current 18.04 LTS folder structure

gives interesting result: it seems that Oracle dropped 32 bit for bionic repository.
See information on official Downloads page:

VirtualBox binaries
By downloading, you agree to the terms and conditions of the respective license.
If you're looking for the latest VirtualBox 5.2 packages, see VirtualBox 5.2 builds. >Please also use version 5.2 if you still need support for 32-bit hosts, as this has been discontinued in 6.0. Version 5.2 will remain supported until July 2020.

So you should change repository line in the /etc/apt/sources.list.d/virtualbox.list to
deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib

Comment: @weelillad *"I can now update the repository without errors."* It was already updating without errors; the message you got was prefixed with `N`, indicating that it was a **n**otice. **E**rrors are prefixed with `E`.
Comment: Thanks for the comprehensive explanation, it works and I can now update the repository without errors. By the way, the method to update `/etc/apt/sources.list` can be referenced from https://askubuntu.com/a/1029865/909537. In summary, run `sudo nano /etc/apt/sources.list.d/virtualbox.list` from the terminal.
Comment: Thanks, fixed the path. And marked question as duplicate.


Vue multiple questions, with each question having multiple options

Question: I have a list of properties in my database. I want the user to select the type of houses in the property.

Property
Selected property types

Property 1
['studio_apartment', 'one_bedroom', 'two_bedroom']

Property 2
['studio_apartment', 'one_bedroom']

To achieve this I am using the Vue v-for loop as follows:
<template>

    NAME: {{ name }}

    <input
      type="checkbox"
      value="studio_apartment"
      v-model="form.property_type"
    />Studio apartment

    <input
      type="checkbox"
      value="one_bedroom"
      v-model="form.property_type"
    />One bedroom

    <input
      type="checkbox"
      value="two_bedroom"
      v-model="form.property_type"
    />Two bedroom

    SELECTED: {{}}

</template>

The problem is when I select for example studio_apartment in property 1, then all the properties studio_apartment is checked. How do I only get the selected checkboxes for each property individually. Thanks.
Answer: This happens because there's only one form instance being shared in each loop iteration.
You could change form into an object array based on propertyNames, so that they have the same array length; then index into form with the iteration index of v-for:
<template>

      NAME: {{ name }}

      <input type="checkbox" value="studio_apartment" v-model="form[index].property_type">Studio apartment

      <input type="checkbox" value="one_bedroom" v-model="form[index].property_type">One bedroom

      <input type="checkbox" value="two_bedroom" v-model="form[index].property_type">Two bedroom

</template>

demo
Comment: Is there a way to replace const propertyNames = ['Property 1', 'Property 2'] with a computed property? I have the following computed property:  computed: {
     propertyNames() {
            const properties = this.property_form.property_name;
            const filtered = properties.filter(p => p != null)

            return filtered;
        }
}, and I want it to be: const propertyNames = this.propertyNames
Comment: If `propertyNames` is a computed prop, you'd have to use a watcher on it that updates `form` based on the new value.


Best Practices: Standalone Components vs. Modules in Angular 14

Question: I'm seeking clarification on the best practices regarding the usage of standalone components and modules in Angular 14. Given the introduction of standalone components as a new concept in Angular, I'm looking for factual guidance supported by citations or references.
I've created a new whole app only using standalone components with lazy loading routes, and everything works perfectly. Here the repo: https://github.com/Ismaestro/angular-example-app
However, I'm curious if this indicates a potential shift towards standalone components rendering NgModules obsolete.
Could someone provide evidence-based insights into the advantages and disadvantages of employing standalone components versus modules in Angular 14?
Thank you for your contributions.
Answer: Standalone components are not mandatory and will never be, there is no rule when to use them. However, Angular Architects recommend to always use Standalone components at least for new components you create. They are simply more treeshakeable and less boiler. You can mix standalone components and modules also.
For the mentioned recommendation of the Angular Architects, you can also watch the Webinar from last Monday: https://www.youtube.com/watch?v=9rj8kR0q0c8
Comment: I'm playing with standalone components right now and I agree that we should all use standalone components over modules (at least going forward). That said, I think a potentially valid reason to use a module would be if you _know for a fact_ that some number of components you are writing will _always_ be used _together_. Then I would still write them as standalone components, but you can easily create a module to import and export all of the components so they are easy to import as one unit. This is just and idea I'm playing with and would love to here other thoughts.
Comment: We have a big project with loads of services, which are often shared across components, so we currently put the services in a module and load that module in the components that need it, so that (in theory) the service only gets provided once but it's not in the root of the application. I can't really find a good way to do this with standalone components. Any thoughts on this?
Comment: currently i use modules for the sake of grouping components and services for a specific functionality.
for example i need something that is made up of 3 or more components and has some services that are suitable only for that single functionality , i group them in a single module .
but for simple functionalities or the sake of sharing code and preventing unnecessary repeated code, standalone components are amazing! and they have no limitations, for your new projects you can only use standalone components with no problems
Comment: Nice!, so I guess if I start a new application is better to use only standalone components? Thanks for the link
Comment: Yes, this approach is recommended. That is the way Angular is going forward.
Comment: I think thats a fair use of ng modules!. I've created a post on dev.to and an example app. Here the links: https://dev.to/ismaestro/implementing-standalone-components-in-angular-15-3c2p and https://github.com/Ismaestro/angular-example-app
Comment: So is there any, and I mean ANY reason to NOT to use standalone coponents, ever? Where would we declare root paths, or an NgRx root?
Comment: @PayamB.   Hi, is it possible to actually use a standalone component to do the grouping of components and services for a specific functionality, instead of using module.    If possible, wonder what is the advantage of using module over standalone in such case.
Comment: "Standalone components are not mandatory and will never be".   So does that mean module will NEVER be deprecated and removed in future? Cos if the day come when module is really removed, then standalone components will have to be mandatory.
Comment: That is what they said, there is no plan to remove modules.
Comment: I total agree with @PayamB. NgModule and StandaloneComponent should used flexibal case by case.
Answer: For practical upsides/downsides of using Standalone vs Modules check out this discussion on Reddit:
https://www.reddit.com/r/Angular2/comments/118i0pf/do_standalone_components_cause_duplicate_code_in/
The answer is not so easy and straightforward as some debaters suggest. I'm not going to repeat many advantages of standalone - they are stated everywhere, but the main omitted disadvantage of using only standalone components seems that you might end up loading the same code many times as described within the discussion. I will also borrow the conclusion from there:
"So I guess it becomes a balancing act of including too much in main.js vs having things duplicated in multiple lazy-loaded files? Like maybe if something's really needed everywhere, I would keep it in Shared but if it's only needed by some modules it might be better to make it standalone?" R00B0T


Finding all possible paths in graph

Question: I'm looking for some algorithm which will help me find all possible paths in a graph. Everything I found so far is not fully satisfying.
Let's imagine we have a graph (tree) like this one:

And let's use some algorithm like Breadth-First Search or Depth-First Search. In return we'll get something like
1, 2, 4, (2), 5, (2), 6, (2), (1), 3, 7, 8, (7), 9

Which is how we go through this tree and this is not what I'm looking for. I'd love to get all paths, like:
1
1, 2
1, 2, 4
1, 2, 5
1, 2, 6
1, 3
1, 3, 7
1, 3, 7, 8
1, 3, 7, 9

The thing is that I want just to specify root node and algorithm should be able to provide me with all possible paths of any length.

So far, the simple code I have looks like:
func dfs(_ graph: Graph, source: Node) -> [String] {
    var nodesExplored = [source.label]
    source.visited = true

    for edge in source.neighbors {
        if !edge.neighbor.visited {
            nodesExplored += dfs(graph, source: edge.neighbor)
        }
    }

    return nodesExplored
}

Comment: As you wrote BFS or DFS are the way to go, with a minor modification of updating the paths upon each step and making sure you're not adding the same path more than once (you can use a *Set* to accumulate the Path objects).
Comment: Well, all paths in an undirected or cyclic graph is an infinite set. And if you're actually searching for an algorithm for search in a tree you should probably ask explicitly for such algorithm in your question rather than generally for trees.
Comment: @Paul this thing is a tree, but it's possible in my case to have cycles. For example, we can have edge between nodes 2 and 3.
Answer: You can use this algorithm on a binary tree to print out all of its root-to-leaf paths. The function treePaths traverses the nodes depth-first (DFS), pre-order, recursively.
treePaths(root, path[1000], 0) // initial call, 1000 is a path length limit

// treePaths traverses nodes of tree DFS, pre-order, recursively
treePaths(node, path[], pathLen)
    1) If node is not NULL then
        a) push data to path array:
            path[pathLen] = node->data.
        b) increment pathLen
            pathLen++
    2) If node is a leaf node, then print the path array, from 0 to pathLen-1
    3) Else
        a) Call treePaths for left subtree
            treePaths(node->left, path, pathLen)
        b) Call treePaths for right subtree.
            treePaths(node->right, path, pathLen)

Answer: Just fold the result and count the new possibilities: Result = 9 (you forgott the path [1] )
n0  n1  n2  n3
1,   2,  4,       +3
    (2), 5,       +1
    (2), 6,       +1
    (2),          +0
(1), 3,  7,  8,   +3
        (7), 9    +1

Comment: I wonder how would you do it? I can see that my current return has everything I need, but I can't split it.

Finding all possible paths in graph


How do armors from equipment patches work?

Question: I've been getting tons of different equipment patches lately in the game, but I'm not sure how the ones giving armor does affect my defense in the battles. Does X armor means X or a certain percentage less HP damage you get in each turn? Does it give you extra shield? Or something completely different?
And after all should I get the patches giving armor or extra HP, which one is more efficient?
Answer: Armor in Stick of Truth functions as flat damage reduction, per hit.
Thus, if you have 100 Armor, and are hit by an attack that does 1000 damage, you'll only take 900 damage.
The thing that's great about Armor however, is that this applies to every hit, and tons of enemies have basic attacks that hit 2, 3, or even 4 times. So, if our hypothetical enemy, instead of hitting once for 1000, instead hits twice for 500, you'll only take 800 damage. What this means is that as you get hit more often, Armor becomes better and better, relative to just stacking HP; of course, the shorter any given fight is, or the less frequently your new kid gets hit, the more useful HP is instead of Armor. Armor also has the additional bonus that in conjunction with certain weapons, it also adds to your attack, as there are a number of weapons that add, 2, 3, or even 4 times your Armor to your damage.
All that said, I'd generally advise, that, unless you're using one of those weapons with an Armor multiplier effect (which is not a bad strategy! If you stack armor from items and patches, these can be the strongest weapons in the game, and you'll mitigate a ton of damage. It's especially good if you're bad at QTE blocking.), that you not use Armor or HP patches. In general, mitigating incoming damage with blocks is plenty, and patches are best used on either offensive boosts, or on bonuses to regeneration of HP, or PP. You'll generally get much better results.
Comment: Yes, exactly. However, you always take at least 1 damage from every attack. What is also not mentioned is that armour does not mitigate the damage from effects. Say you have 100 armour but you are bleeding. If you take 300 damage from the bleeding effect, you will take it in full without the armour reducing the damage. Hence, armour is also less effective against enemies who afflict status conditions as their main damage source. Those include Bleeding and Grossed Out but can include insta-death attacks as well such as Screwed.
Comment: Does that mean even if the opponent doesn't hit multiple times you'll get 100 less damage every time someone hits you? Then, it is more sensible to have 100 armor instead of just 100 hp, right?
Answer: The ones that give armor pad your defense, think of it like defense in pokemon, the higher the defense the less damage you will take from an attack. It will not give you a shield, I beat the game and collected almost all patches and have yet to see one that gives you a shield. What patch you use is entirely up to you, if you want more hp rather than more defense then go with the hp. It is all about your playing style. Though you should use what ever one will give you the highest boost, making your character as strong as it can be.


Forms authentication in Asp.Net 5

Question: I am trying to implement forms based authentication in Asp.Net 5 targeting .NetCore but I cannot find System.Web.Security.
What's the .netcore package I should use to implement Forms Authentication as in previous asp.net?
Thanks
Comment: If you will insall OWIN Forms Authentication it should install all the authentication you will need
Answer: Forms authentication is managed by the CookieAuthenticationMiddleware in ASP.NET 5: https://github.com/aspnet/Security/blob/dev/samples/SocialSample/Startup.cs#L42-L46

Forms authentication in Asp.Net 5


Solve $10x^4-7x^2(x^2+x+1)+(x^2+x+1)^2=0$

Question: How to solve the following equation?
$$10x^4-7x^2(x^2+x+1)+(x^2+x+1)^2=0$$

My attempt:
$$ 10x^4 - (7x^2+1)(x^2+x+1)=0$$
Thats all i can
Update
Tried to open brakets and simplify:
$$(7x^2+1)(x^2+x+1) = 7x^4+7x^3+7x^2+x^2+x+1=7x^4+7x^3+8x^2+1 $$
$$10x^4 - (7x^2+1)(x^2+x+1)= 3x^4-7x^3-8x^2-1=0 $$
Comment: I do not recommend that
Comment: I recommend you expand the brackets and simplify
Answer: Set $A=x^2,B=x^2+x+1$.
Then,
$$\begin{align}10x^4-7x^2(x^2+x+1)+(x^2+x+1)^2&=10A^2-7AB+B^2\\&=(2A-B)(5A-B)\\&=(2x^2-(x^2+x+1))(5x^2-(x^2+x+1))\\&=(x^2-x-1)(4x^2-x-1)\end{align}$$
Answer:
$$10x^4-7x^2(x^2+x+1)+(x^2+x+1)^2=0$$

Set $t=x^2,z=x^2+x+1$.
$\Longrightarrow$
$$\begin{align}10t^2-7tz+z^2&=(2t-z)(5t-z)\\&=(2x^2-(x^2+x+1))(5x^2-(x^2+x+1))\\&=(x^2-x-1)(4x^2-x-1)\end{align}$$
$$\boxed{\color{red}{x_{1,2}=\frac{1}{2}\pm\frac{\sqrt5}{2},\;x_{3,4}=\frac{1}{8}\pm \frac{\sqrt{17}}{8}}}$$
Comment: @Nehorai: You wrote first only $(x^2-x-1)(4x^2-x-1)=0$ without writing how you came up with this factorization. So, I wrote my answer with **how**. Then, you added how. What I'm saying is that "I wrote the final answer before mathlove" is a very misleading comment.
Comment: How did you come up with this factorization?
Comment: @mathlove has shown it
Answer: Divide by $(x^2 + x + 1)^2$, the equation becomes: $$10\frac{x^4}{(x^2 + x + 1)^2} - 7\frac{x^2}{x^2 + x + 1} + 1 = 0$$ Let $z = \frac{x^2}{x^2 + x + 1}$. The equation now is $$10z^2 - 7z + 1 = 0$$ Solving it like an ordinary quadratic equation on $z$ you get at most two roots $z_{1,2}$. Then let $\frac{x^2}{x^2 + x + 1} = z_1$, or, equivalently, $$x^2 = z_1 (x^2+x+1)$$ It is a quadratic equation in $x$. Similary for $z_2$. Solutions to this two equations are solutions to the initial problem.
Comment: You can also directly factor $10a^2-7ab+b^2=(-5a+b)(-2a+b)$.
Comment: @YvesDaoust yes, I can. mathlove has already shown this way of solution. I believe that such a factorization is not so obvious and involves either guesses or dividing and finding roots; the second way is exactly my answer.
Answer: $10x^4-7x^2(x^2+x+1)+(x^2+x+1)^2=0$
Divide by $x^4$ on both sides,
$10-\frac{7x^2(x^2+x+1)}{x^4}+\frac{(x^2+x+1)^2}{x^4}=0$
$10-7(1+\frac{1}{x}+\frac{1}{x^2})+(1+\frac{1}{x}+\frac{1}{x^2})^2=0$
Put $(1+\frac{1}{x}+\frac{1}{x^2})=t$
$10-7t+t^2=0$,solving we get $t=2,5$
when $t=2$
$1+\frac{1}{x}+\frac{1}{x^2}=2$
simplify we get,$x^2-x-1=0$.............(1)
when $t=5$
$1+\frac{1}{x}+\frac{1}{x^2}=5$
simplify we get,$4x^2-x-1=0...........(2)$
Solve (1) and (2) and get the answer.


SD Card reader stopped working: cannot even mount it

Question: On my HP 625 Laptop running Ubuntu 14.10 with kernel 3.16.0-28, the SD card reader stopped working after some time. The last actions related to this device were installing exfat-fuse and exfat-utils to mount SDXC cards. This was successful, but after copying some files from the card to hard drive, the device stopped working.
Now, there is nothing showing up in cat /proc/partitions (i.e. the output is identical before and after inserting a card (SD or SDXC, doesn't matter)).
The output of sudo lspci does not seem to have an SD card reader included:
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] RS880 Host Bridge
00:01.0 PCI bridge: Hewlett-Packard Company Device 9602
00:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to PCI bridge (PCIE port 0)
00:09.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to PCI bridge (PCIE port 4)
00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 SATA Controller [AHCI mode]
00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 SMBus Controller (rev 42)
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia (Intel HDA) (rev 40)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 LPC host controller (rev 40)
00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 PCI to PCI Bridge (rev 40)
00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI2 Controller
00:16.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
00:16.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor HyperTransport Configuration
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Address Map
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Miscellaneous Control
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Link Control
01:05.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RS880M [Mobility Radeon HD 4225/4250]
01:05.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] RS880 HDMI Audio [Radeon HD 4200 Series]
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller (rev 02)
03:00.0 Network controller: Broadcom Corporation BCM4313 802.11bgn Wireless Network Adapter (rev 01)

The output of lsusb doesn't look like it contains anything card reader related either:
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 04f2:b1ac Chicony Electronics Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

dmesg | grep -i "card" only outputs sound card related stuff.
Uninstalling exfat-fuse exfat-utils does not change anything, and neither does reinstalling the packages.
The device is enabled in BIOS.
It seems like the drivers for this device disappeared, doesn't it? How do I re-enable this?
Comment: That's the thing about hardware, though. It fails when least expected. I'm going to read through your question again, just to see if maybe it is software.
Comment: If you have Windows, go into that and see if the SD reader is detected. I think it may have broken.
Comment: Card readers are almost always attached via USB, so try `lsusb` instead of `lspci`.
Comment: @Cmdr I added the output, but I guess it's not helpful.
Comment: @Zacharee1 I don't have an alternative OS on this machine.
Comment: I didn't think you did, but I suggested it anyway. Do you have a hard drive with Windows on it?
Comment: @Zacharee1 Nothing that I can insert into this laptop, no. But thanks for your ideas.
Comment: Have you tried using a LiveCD?
Comment: @Zacharee1 I don't have one lying around and if possible, I'd like to fix this issue without external operating systems ;-)
Comment: Do you have a USB stick? This would be a good way to see if it's actually broken or if it's just your OS. This would be the first step I'd take. If it's broken, there's nothing we can do.
Comment: There's no point trying to fix something if it's a hardware problem.
Comment: @Zacharee1 I don't have any such tool available to me right now. I consider the likelyhood if a hardware problem to be very low, keeping in mind that there was no unusual action immediately prior to the failure.
Comment: So it does look like it's not being found at all. The only devices being found are controllers and your WiFi card.
Comment: Are you able to disable/enable it in BIOS?
Answer: Try this, your machine is now on, then:

Pop slowly out and then slowly in sd-card.
Type this into terminal
sudo apt-get install --reinstall udev*

Then when finish then repeat with 1. and then after this reboot your machine or shut completely down and boot up again without being online.
(the latter two lines are meant as in case sd-card would still not be recognized somehow you should not be sudo in the moment you are online).


How can I make my Realtek RTL8821CE wireless hardware work?

Question: I have been looking at several websites to try and set up wifi on Ubuntu with no success. OK, this website talks about the post 18.04 way. But how do you set it up after that version? I saw this website as well, and it talks about some of the differences but I still haven't been successful yet. Here are some things I have tried to do.
ip addr show

When I do this, I get this output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether f4:39:09:22:a6:60 brd ff:ff:ff:ff:ff:ff

Then I tried a similar command.
ip a

When I do this, I see this output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether f4:39:09:22:a6:60 brd ff:ff:ff:ff:ff:ff

With this command, I can see a little more information than the prior.
I have also just tried to connect using the mouse. This is what I see when I go to the WIFI in settings:
For the no adapter issue, this Youtube video looked promising.
I gave this command.
#apt-get remove --purge bcmwl-kernel-source

But unfortunately, it didn't work. This is the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bcmwl-kernel-source
root@brian-HP-Slim-Desktop-290-a0xxx:/home/brian#

Note: I tried to install it using a live cd just to see if I could and it tried.
Here are some more things that I have done to gather information for this question.
lspci

And this is the output.
01:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE
802.11ac PCIe Wireless Network Adapter
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd.
RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

rfkill list

This is the output
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no

Next I did this.
dmesg

A lot of information came up, but it was too much for this website.
I also did this.
lsmod

Same problem, too much information and I couldn't post it. In reading some of this information. It said something was blocked because I used secureboot when I downloaded the OS. I will be honest, I don't think I know what secureboot is.I hope this information helps.
I am using a Century Link router, model number C1000A. It is not connected directly to the computer.  I would be grateful to any and all who could render any kind of assistance, thank you.
Comment: Update your question by copying and pasting the command(s) you typed followed by the messages the commands produced.
Comment: Please check your added links they are unreachable!!!
Comment: Sorry about that, I check them and now I think they are working.
Comment: Please [edit] your question and convert the screenshots to text as that's searchable by google, whereas images are not...  Also, please go [here](https://askubuntu.com/questions/425155/my-wireless-wifi-connection-does-not-work-what-information-is-needed-to-diagnos) and add the additional info from there into your question.  Then leave a message @Fabby  **;-) 0:-)**
Comment: What's going on here is that your WiFi adapter is not recognized.  Please borrow/bribe/buy/steal  **;-)** an Ethernet cable, hook up your machine to the router that way and run [this script](https://askubuntu.com/questions/425155/my-wireless-wifi-connection-does-not-work-what-information-is-needed-to-diagnos) so we can give you the perfect answer!  **0:-)**  *And thanks for converting the screenshots to text...*
Comment: @Fabby, I am working on completing your requests. It tries to download from a live CD but there is a  wall on my actual OS.
Comment: @Fabby- I have done some trial and error to see different outputs on the commandline and it is posted. Per the comments in the question, a couple of the commands gave too much information. If you have a way for me to share this information with you, let me know.
Comment: The full output to the script is needed if you want the pros to work on your question. The personally identifiable information is already anonymised in the script so stuff like your MAC address is not communicated.  If you would deem any other output too invasive, leave the title in and add `# Removed due to privacy concerns` where the data was.  *Every time* the full script was invoked, we've been able to solve the issue... **¯\\_(ツ)_/¯**.  Use https://paste.ubuntu.com to paste the full edited output, don't try fitting it into your question; it's indeed too big.
Comment: In the meantime, I'll post an answer with the information we have.  Any additional question needs the full output of the script though.
Answer: You have Realtek RTL8821CE hardware, so use the following steps:
Open up a terminal by pressing Ctrl+Alt+T and type:
cd /tmp/
sudo apt install --reinstall git dkms build-essential linux-headers-$(uname -r)
git clone https://github.com/tomaspinho/rtl8821ce
cd rtl8821ce
chmod +x dkms-install.sh
chmod +x dkms-remove.sh
sudo ./dkms-install.sh

Which will download the Arch source and build the driver. After the above is completed, you can insmod the driver or simply reboot.
Warning: As you're downloading and building your own driver, ensure SecureBoot is disabled in the UEFI Firmware / BIOS if a simple reboot would not bring the desired result.
Comment: You're welcome @Fabby.  :-)
Comment: If you need any further help, edit your question and post a link to the output of the [Wireless information script](https://askubuntu.com/questions/425155/my-wireless-wifi-connection-does-not-work-what-information-is-needed-to-diagnos)
Comment: Hi Fabby, I tried to follow you instructions but this is the output that I got. Package build-essential is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source.
Comment: I will post to the script.
Comment: @BJsgoodlife For the missing package [follow this first](https://askubuntu.com/questions/316102/no-installation-candidate-when-trying-to-install-build-essential) and if that fails [do this one instead](https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt).
Comment: the title bar is missing on my OS. Could you please tell me how I can get it to appear so I can follow these instructions?
Comment: @Fabby- it is done, the script has been uploaded.
Comment: @BJsgoodlife "Title bar missing?"  Please elaborate...  Also which instructions? [this](https://askubuntu.com/questions/316102/no-installation-candidate-when-trying-to-install-build-essential) or [that](https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt) one?
Comment: @Fabby- The menu bar that is supposed to be on top of the Software Center where I can find the "Edit" menu. The first set of instructions is the one I am referring to. I cannot do the second one because it requires use of the internet to do it.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/86955/discussion-between-fabby-and-bjsgoodlife).
Answer: This is available as an apt package on 20.04 -
Run: sudo apt install rtl8821ce-dkms, restart and you're done :)
Answer: For the package bcmwl-kernel-source to be available, you need to enable the restricted repository.
You need to run software-properties-gtk and enable the restricted repository.

Then you will be able to install bcmwl-kernel-source
Comment: Hi solsTiCe- Thank you for your efforts to help me, however restricted drivers was already checked. I noticed something else, too. I tried to start with step one after it didn't work from where I left off, and my computer can't find the bcmwl-kernel-source driver to begin with. I will supply a screenshot of what I see.


Updated to Ubuntu 20.04 -now the Super key (win) is not working

Question: I just updated to 20.04 from 18.0.4 on my MSI CX62-7QL laptop, I'm using the Spanish (Win keys) layout and every single key is working but the Super or Win key. When I open the layout screen at Setting > Region & Language > Input Sources and I press the Win key to see if at least it's being recognized, it doesn't change to the grey tone that appears when you press the respective key. Oddly enough, if I press Super+a I can see the activities view.
The Win key does work when I'm using a different language layout and i'ts recognized on the layout scheme. The problem is, I can't stick to another layout because tildes the like get mangled up.
Thank you in advance for the help.
Answer: For me, the super key works only on the FIRST keyboard layout under Settings/Input sources. So I just dragged 'en' to be the first one.
Comment: Although this might be solution for OP the first step would be to post a comment asking them what their current settings are.
Comment: Thank you Tin, that solved the problem. But I'm left wondering... why? What's the logic behind it?
Comment: It's simply a bug I'd guess. :)
Answer: This is a known bug under Gnome, it only affects keyboard layouts in this order, so i know it isn't a permanent solution but you could switch your layouts into different order.

The super key will work
won't work
Won't Work
The super key will work again

Here is the Bug already reported


Show Home page as Category page

Question: I'm working on a custom Prestashop theme for my e-commerce, and I want to show the index homepage as the category pages.
I have a one big category (Home) that contains 4 subcategories ( Girl, boy, children, Babies)
I've setup the pages of the categories to show a 4 column list, and i want the same in the homepage ( to show all the products of my prestashop products with pagination, the home category ) but, I tried to copy the code, and of course, it doesn't work right the way....
How can i setup an specific Category ( Home in my case ) for re-use the code from category.tpl ?
Because i think, smarty doesn't see the home page as a category page: so can't use globals $category or $subcategories.
Thanks for your help,
Rodrigo
Answer: Normally in PS, on homepage the featured products are shown. Featured products are those products which are added in Home Category directly, but it has a limited number of products.
If you want the home page to be as category page, then you have to modify the homefeatured module or copy past that module to create a new module for that home page. Now in that module, copy past the code from the category controller  to fetch products count and fetch products. After assigning it to smarty variables, you can access them in your template file for that module, like in homefeatured.tpl.
For pagination, you have to add the pagination.tpl file in your module template file.
Hope this will give you the idea that how you can do it.
Thank you
Comment: It's a good idea, I'm going to try that and get back to you, thanks.

Show Home page as Category page


Help me find a way to get mold off my bathtub mat

Question: How do I get the mold off my bathtub mat? I have used vinager and bleach please help! Any ideas I don't want my kids sitting on mold.
Comment: Time for a new mat?
Comment: If bleach doesn't do it, then I agree it's time for a new mat. Though most mold is harmless.
Answer: Put it in direct sunlight for a day or two. (Also works great for removing tomato stains from plastic.)
Answer: Try making a paste out of baking soda and bleach and smearing it on the mat and letting it sit there that will hold the bleach in contact with the surface of the mat long enough for the bleach to work better. If this doesn't work it may be time just to replace the mat.


MS Access 2010 VBA Multiple Else If Issues

Question: I have an MS Access form where the user can select up to four criteria to filter the records returned by a report. In the VBA, I'm trying to build my filter string dynamically based on which fields, if any, the user chose to filter by. The below code is giving me a "Block If without End If" error. What am I doing wrong here?
If (IsNull(frm!employee) = False) Then
    strFilter = "Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
    If IsNull(frm!sop) = False Then
        strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
    End If
    If IsNull(frm!revision) = False Then
        strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
    End If
    If IsNull(frm!dept) = False Then
        strFilter = strFilter + " AND department = '" & frm!dept & "'"
    End If
Else
If (IsNull(frm!sop) = False) Then
    strFilter = "sop_number = '" & frm!sop & "'"
    If (IsNull(frm!employee) = False) Then
        strFilter = "Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
    End If
    If IsNull(frm!revision) = False Then
        strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
    End If
    If IsNull(frm!dept) = False Then
        strFilter = strFilter + " AND department = '" & frm!dept & "'"
    End If
Else
If (IsNull(frm!revision) = False) Then
    strFilter = "revision_number = '" & frm!revision & "'"
    If (IsNull(frm!employee) = False) Then
        strFilter = " AND Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
    End If
    If IsNull(frm!sop) = False Then
        strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
    End If
    If IsNull(frm!dept) = False Then
        strFilter = strFilter + " AND department = '" & frm!dept & "'"
    End If
Else
If IsNull(frm!dept) = False Then
    strFilter = "department = '" & frm!dept & "'"
    If (IsNull(frm!employee) = False) Then
        strFilter = " AND Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
    End If
    If IsNull(frm!sop) = False Then
        strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
    End If
    If IsNull(frm!revision) = False Then
        strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
    End If
End If

Any advice you could give me to improve this code would be appreciated.
Comment: http://www.oaltd.co.uk/Indenter/Default.htm - I'm using it on Office 2010 with no issues
Answer: That code avoids " AND " at the beginning of strFilter.  However the logic is challenging to follow and it uses multiple variations on the same basic themes.
Use a simpler approach. You're interested in the values contained in 4 form controls:

frm!employee
frm!sop
frm!Revision
frm!dept

Examine each of them in turn and, for any which contain a value, add a segment starting with " AND " to strFilter.  Afterwards, if strFilter contains any text, you know it starts with " AND " so you can simply discard the first 5 characters.
strFilter = vbNullString ' <- make it explicit
If Len(Trim(frm!employee) & vbNullString) > 0 Then
    strFilter = strFilter & _
        " AND Trainee_First_Name & ' ' &  Trainee_Last_Name = '" & _
        frm!employee & "'"
End If
If Len(Trim(frm!sop) & vbNullString) > 0 Then
    strFilter = strFilter & " AND sop_number = '" & frm!sop & "'"
End If
If Len(Trim(frm!Revision) & vbNullString) > 0 Then
    strFilter = strFilter & " AND revision_number = '" & _
        frm!Revision & "'"
End If
If Len(Trim(frm!dept) & vbNullString) > 0 Then
    strFilter = strFilter & " AND department = '" & frm!dept & "'"
End If
If Len(strFilter) > 0 Then
    ' discard " AND " from beginning of string
    strFilter = Mid(strFilter, 6)
End If
MsgBox "strFilter ->" & strFilter & "<-"

Comment: Thanks, Tim.  I upvoted your answer because you helped him understand the statement blocking in his question, and I think that's a good thing.  Both answers are useful IMO.
Answer: The issue is that your else... if clause aren't terminated with end if. You either need to use ElseIf or
Else
  If ...
  End If
Else...

I've modified your code below to use the latter syntax. Notice the End If lines below.
Note: You don't need **, that's just to call attention to it in your code block!
If (IsNull(frm!employee) = False) Then
        strFilter = "Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
        If IsNull(frm!sop) = False Then
            strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
        End If
        If IsNull(frm!revision) = False Then
            strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
        End If
        If IsNull(frm!dept) = False Then
            strFilter = strFilter + " AND department = '" & frm!dept & "'"
        End If
    Else
    If (IsNull(frm!sop) = False) Then
        strFilter = "sop_number = '" & frm!sop & "'"
        If (IsNull(frm!employee) = False) Then
            strFilter = "Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
        End If
        If IsNull(frm!revision) = False Then
            strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
        End If
        If IsNull(frm!dept) = False Then
            strFilter = strFilter + " AND department = '" & frm!dept & "'"
        End If

**End If**
    Else
    If (IsNull(frm!revision) = False) Then
        strFilter = "revision_number = '" & frm!revision & "'"
        If (IsNull(frm!employee) = False) Then
            strFilter = " AND Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
        End If
        If IsNull(frm!sop) = False Then
            strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
        End If
        If IsNull(frm!dept) = False Then
            strFilter = strFilter + " AND department = '" & frm!dept & "'"
        End If
    **End If**
    Else
    If IsNull(frm!dept) = False Then
        strFilter = "department = '" & frm!dept & "'"
        If (IsNull(frm!employee) = False) Then
            strFilter = " AND Trainee_First_Name + ' ' +  Trainee_Last_Name = '" & frm!employee & "'"
        End If
        If IsNull(frm!sop) = False Then
            strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
        End If
        If IsNull(frm!revision) = False Then
            strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
        End If
    **End If**
    End If


Cannot run Glumpy example app using GLFW as backend

Question: I've cloned glumpy from Github and am trying to run glumpy\examples\app-simple.py
I can run the example fine if I install pyglet using pip install pyglet, (or, I think I can? The window causes some weird warnings if I click on certain parts of it, like the bar to drag the window around) but it will not recognize GLFW.
I have tried installing GLFW using pip, and also by following the instructions here: https://glumpy.readthedocs.io/en/latest/installation.html where you copy the glfw3.dll.
Here is the error exactly:
[w] Backend (<module 'glumpy.app.window.backends.backend_glfw' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_glfw.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_pyglet' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_pyglet.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_sdl' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_sdl.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_sdl2' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_sdl2.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_osxglut' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_osxglut.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_freeglut' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_freeglut.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_qt5' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_qt5.py'>) not available
[w] Backend (<module 'glumpy.app.window.backends.backend_pyside' from 'C:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\glumpy\\app\\window\\backends\\backend_pyside.py'>) not available
[x] No suitable backend found
Traceback (most recent call last):
  File "c:\Users\Max\.vscode\extensions\ms-python.python-2019.8.29288\pythonFiles\ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "c:\Users\Max\.vscode\extensions\ms-python.python-2019.8.29288\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
    run()
  File "c:\Users\Max\.vscode\extensions\ms-python.python-2019.8.29288\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "C:\Users\Max\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "d:\VSCODEProjects\glumpy_escape_pyglet\glumpy\examples\app-simple.py", line 7, in <module>
    window = app.Window()
  File "C:\Users\Max\AppData\Local\Programs\Python\Python37\lib\site-packages\glumpy\app\__init__.py", line 157, in __new__
    raise NotImplementedError
NotImplementedError

Comment: error shows that it couldn't use `glfw` or any other backend. You could use `import glfw` to test if it has no problem to run this module. Maybe you will have to move .dll to different folder - to one of folder which is in variable `PATH` - `import os; print(os.environ['PATH'])`. I don't use Windows but as I remember there should be `C:\Windows\` on the list.
Comment: I just had to add the directory which contained the .dll file to my PATH.
Answer: for me
pip install pyglet

can slove my question.
Comment: In the question: `I can run the example fine if I install pyglet using pip install pyglet [...] but it will not recognize GLFW.`
Comment: I have same question.
Answer: In mac installing glfw3 solved this
brew install glfw3


Spring integration send List to MongoDB outbound channel

Question: I need to poll data from MongoDB, process the data, while it is being processed, I must update that status of the data in DB as "PROCESSED" using MongoDB outbound channel.
When I query the MongoDB using the inbound channel, I get a list of Objects.
I use a transformer which traverses this list and updates the status as "PROCESSING".
When I pass this updated list, wrapped as payload, to the outbound MongoDB channel, hoping it would update status if all the elements in the DB, I get an exception.

BasicDBObject can not be cast to BasicDBList

how to proceed here?
Answer: You know, sounds like a bug in the Spring Data MongoDB.
We have there a code like in the MongoTemplate.toDocument():
 if (!(objectToSave instanceof String)) {
        Document dbDoc = new Document();
        writer.write(objectToSave, dbDoc);

And after that we jump to the MappingMongoConverter.writeInternal():
    if (Collection.class.isAssignableFrom(entityType)) {
        writeCollectionInternal((Collection<?>) obj, ClassTypeInformation.LIST, (BasicDBList) bson);
        return;
    }

Where we indeed can't cast to the BasicDBList because our original bson is just that Document.
You can consider to use Splitter before modifying each entity and storing them into DB back individually, not as a list.
Comment: Thank you for your answer, using a Splitter is indeed what I am doing for now. But I think it would be a good feature to allow outbound channel to store a list of objects all at once rather than sending each object separately
Comment: Well, that is exactly what `MongoDbStoringMessageHandler` tries to do, but Spring Data MongoDB has that mentioned bug. I've notified SD team on the matter, so let's see what they will answer! Maybe already tomorrow...


How to show two list items result into one, for multiple results. Using java in selenium Webdriver

Question: Here need to print two list results in the particular format by combining two list data. For example: as show in image
Normal(5-7Days): Rs. 2,400.00
Fast(3-5Days): Rs. 3,000.00
Express(2-3Days): Rs. 3,600.00

Here is my code
<code> List<WebElement> ShippingLabel = driver.findElements(By.xpath(" //label[contains(@class,'radio__label')]"));
 List<WebElement> ShippingPrice = driver.findElements(By.xpath(" //label[contains(@class,'radio__label')]/following-sibling::span"));

 for (WebElement SLelement: ShippingLabel) {
       System.out.println("Testingl:"+SLelement.getText());
 }
 for (WebElement SPelement1: ShippingPrice) {
     System.out.println("Testinglp:"+SPelement1.getText());
    }
</code>
Comment: what does your code print?
Comment: Below is my Result those i get on console:

Testingl:Normal(5-7Days)
Testingl:Fast(3-5Days) ,
Testingl:Express(2-3Days) ,
Testinglp:Rs. 2,400.00 ,
Testinglp:Rs. 3,000.00 ,
Testinglp:Rs. 3,600.00
Answer: Why not this:
<code>List<WebElement> ShippingLabel = driver.findElements(By.xpath(" //label[contains(@class,'radio__label')]"));
 List<WebElement> ShippingPrice = driver.findElements(By.xpath(" //label[contains(@class,'radio__label')]/following-sibling::span"));

 for (int i = 0; i < ShippingLabel.size(); i++) {
     WebElement ele1 = ShippingLabel.get(i);
     WebElement ele2 = ShippingPrice.get(i);

     System.out.println(ele1.getText() + ":" + ele2.getText());
 }
</code>


How to show a Popup in a ListModel (QML,Qt)

Question: I am using QML to develope a GUI.
I have a ListModel as shown below in a file called List.qml:
List.qml
ListModel {
property string parentMenu

property variant sens: dids.sens //reading data

property string title: " LIST "
property bool showFunctions: true
property variant didsReadOnce: [
    "sens",
]

ListElement {
    type: "value"
    label: "sens"
    func1value: -128
    func1text: "DEFAULT"
    func3value: -1
    func3text: "!minus"
    func4value: 1
    func4text: "!plus"
    target: "dids.sens"
}

In this QML file, I want to popup a window when the sens value reaches 9 for example.
I tried to a put a Popup inside and outside the ListModel, but usually get Syntax Error.
My question is how can I show a popup in a ListModel using anyway, not necessarly Popup.
Thanks
Answer: First you need to detect the number of items of your listmodel. You can use the onCountChanged signal. It the number is your maximum value show the dialog.
ListModel {
    id: model
    onCountChanged: {
        console.log("onCountChanged count:" model.count)
        if (model.count > MAX ) {
           dialog.visible = true
        }
    }
 }

Dialog {
    id: dialog
    width: 400
    height: 200
    visible: false
}

Comment: Thnk you for your reply, my problem now is that anything I put outside ListModel, gives me a Syntax error. If I put Popup, Text, Item it does not recognize this object, but if I put it inside the ListModel it is recognized. I am not sure what is the problem.
Comment: @MahmoudHanafy could it be the `ListModel` is the root item? And the error is that a qml file cannot have more than one root item?
Comment: @Amfasis I am not sure, how can i know if ListModel is the root item? I am a bit new to QML, so I am not sure
Comment: It is basically the first item under the `import` statements (of course not comments ;-) ). Or in other words: the highest item in the hierarchy that you put in the file
Comment: Ahaa, maybe you are right, but how can i solve this and make it not a root item? should I put the ListModel in another object like Item or something?
Comment: @Amfasis I found also when I put Popup before the ListModel, Popup is recognized in this case but ListModel not (I mean by recognized is that it turns into green color and it is readable in the file) but if i put the Popup at the end, outside the list model, it is not readable, but ListModel is readable in theis case
Comment: @AdrianoCampos I tried to put Dialog after ListView in ItemView.qml file like this:

ListView{}
Dialog{}
but Dialog is not recognized in the qml file, should i import anything?
Comment: @MahmoudHanafy Are you loading a list model from a file like this                                                                                'ListView { model: MyModelFile {} }'  ? If yes, your dialog code and the handling of the signal "onCountChanged"should be at the main file (same as the listview). At your "MyModelFile.qml" file only put the ListElements.
Comment: @AdrianoCampos I have a qml file called ItemView.qml. in this file there is an object called ListView. In this LIstView something called onCountChanged.

So do you mean in my ListView object in ItemView.qml file I should put dialogue code
Comment: Yes. try import QtQuick.Controls 2.4 or import QtQuick.Dialogs 1.3.
Comment: @AdrianoCampos I have this problem when I import QtQuick.Controls 2.4 or  import QtQuick.Dialogs 1.3, the screen on the panal just shows white without any data on it. Whta may cause this problem
Comment: @AdrianoCampos I tried to just put
            console.log(listview.count)
under onCountChanged, but nothing even is printed in the console when i change the senstivity, why doe snot the console show any counts?
Comment: @AdrianoCampos sorry for my many comments, but now when i start the program it prents in the beginning like this:
OnCountChange is:  4
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0
OnCountChange is:  0

I dont know why 9 elements and what is 4?
Comment: @MahmoudHanafy What about share your source code by github or something else?


Does any interrupt occur when a usb device is connected?

Question: I am working on USB HIDs on linux platform. Keyboards, mouse etc., are examples of Human Interface Devices. Whenever a HID is inserted to a system, at first device enumeration occurs. Then an entry in the form of hidraw appears in the /dev directory.
In linux, "usbhid and hid" are the modules which are called when an HID device is inserted. When I disabled these modules (using rmmod and system restart), the devices were not enumerated and no hidraw entry appeared on /dev(as expected).
Now my question is there any way to know if any USB HID device is connected to a system with the above two modules being disabled i.e does any interrupt or signal generate upon hardware insertion.
I am planning to execute some code when such signal or interrupt occurs(in C). Any kind of help is appreciated.
Thanks,
Comment: I saw you tagged this as `kernel-module`. Are do doing it in kernel mode?
Answer: Insertion of the device is detected through the voltage level changes occuring on the D+ and the D- lines. I do not think that insertion of USB device generates any interrupt. The voltage level changes are read by the hub(root or any hub further down on the line) and according reported to the core.
The USB core driver would be notified about the same. So may be you can write a user-space driver which targets a specific device (using Vendor and Product ID) and through this you can carry out your functionality.
Comment: I wrote an user space program using libudev to continously look for hid devices. But it didn't work when the usbhid module was disabled. Again I don't want to rely on PID and VID as they can be modified. Can you provide me some link regarding how usb core driver handles voltage change.
Comment: http://www.lvr.com/usbcenum.htm This link explains Enumeration..... http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_113_Simplified%20Description%20of%20USB%20Device%20Enumeration.pdf

I will go through the USB HCI code and check how it handles this....My guess is the Host Controller must be having the required hardware to detect change on lines after which it must be generating an interrupt to the core....Need to confirm this....
Answer: If you are doing this in user mode, you get get a notification using udev (which use netlink internally).
You can match a device using the vendorId and productId field in the rulefile.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="abcd", ATTRS{idProduct}=="1234"


Can an access panel be installed inside a shower?

Question: I have a leak in a pipe behind my shower and yet I have PVC paneling on the wall so don't want the plumber to have to rip out the whole shower. There's an access panel at the side but the pipe is very difficult to reach from there due to other pipes in the way.  Can he cut a hole from inside the shower below the taps and then just cover with a large access panel? Are they waterproof enough for shower walls?
Comment: Usual approach is to simply put the access panel on the other side of the wall...
Comment: It might be easier to cut and repair the pipes that are in the way through the access panel than to cut and repair the shower wall.
Comment: Any plumber who would do that is suspect in my book. One does not simply modify shower surrounds for pipe access. [/boromir]
Comment: In fact many Victorians are built with an access panel directly behind the tub taps.  We just did a tap replacement in an hour.
Answer: If access cannot be made from the other side of the wall, then yes, a hole can be cut in the shower wall below the taps or where ever the plumber deems necessary. I wouldn't go with making an access panel there but would go with a more permanent repair to ensure no leaking.  The cutout could be carefully cut. A few supports glued to the back of the wall and then the cutout piece sealed and caulked back in place. A few pieces of tile trim from your home store could hide the seam and could be duplicated on the other walls for uniformity.
Plumbers are used to working in cramped,tight places so they might be able to fix this utilizing the existing access panel.
Comment: I would not put an access panel on the shower side because keeping that watertight would be a nightmare.
Comment: @Harper-ReinstateMonica  I agree as stated in my answer but  you might not have a choice if the wall behind the tub taps is an exterior wall or into a neighbor's  unit.
Comment: Most all plumbers have what they call "shark bite" fittings in their truck. That can make very easy repairs from what used to be nightmares.
Comment: Please don't duplicate your plastic trim faux paneling on the other walls.  Or if you do, OMG, inlay mirrors and put up a chandelier. :) :) :)


How to create a OS X native-looking modal dialog using Swing or AWT

Question: I tried using JOptionPane.showMessageDialog and an AWT Dialog but both just show a dialog window. I want the dialog to look like that of a cocoa app - sliding out from the top of the window.
Comment: See also [Mac Widgets for Java](http://code.google.com/p/macwidgets/)
Answer: Take a look at Look and Feel
Answer: Set the Look-And-Feel to the SystemDefault, for OSX it will look native.
<code>UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
</code>
There is also a nice LookAndFeel which looks like OSX for other Platforms: Quaqua Look and Feel
see JOptionPane
Comment: Well I already have set the system l&f but the dialogs still don't show up as in a native app.
Comment: What does `new JOptionPane().getUI()` says?
Comment: JOptionPane().getUI() says "com.apple.laf.AquaOptionPaneUI"