text:
Q: Can't open snap-store I am trying to open snap-store and it is not opening. This seems to be a problem for opening .deb packages as well.
I get this response when I try to open it on a terminal with sudo snap-store:
mkdir: cannot create directory '/run/user/0': Permission denied
Warning: Schema "org.gnome.system.locale" has path "/system/locale/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
Warning: Schema "org.gnome.system.proxy" has path "/system/proxy/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
Warning: Schema "org.gnome.system.proxy.http" has path "/system/proxy/http/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
Warning: Schema "org.gnome.system.proxy.https" has path "/system/proxy/https/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
Warning: Schema "org.gnome.system.proxy.ftp" has path "/system/proxy/ftp/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
Warning: Schema "org.gnome.system.proxy.socks" has path "/system/proxy/socks/".  Paths starting with "/apps/", "/desktop/" or "/system/" are deprecated.
/snap/snap-store/518/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0: symbol lookup error: /snap/snap-store/518/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: atk_plug_set_child
ERROR: /snap/snap-store/518/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 exited abnormally with status 127
/snap/snap-store/518/usr/bin/snap-store: symbol lookup error: /snap/snap-store/518/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: atk_plug_set_child

I've tried removing and reinstalling snap-store, but that didn't help. Snap version is 2.50.1 (if that helps). If you need any information I will provide it. I don't know how to solve this and nothing I've found online has been helpful.
I also saw a post where someone said they solved what looked like a similar error by looking at the output of ldd /usr/bin/gedit, but I have no idea what it's about. Here's the output for that though:
linux-vdso.so.1 (0x00007ffe043ec000)
libgedit-3.36.so => /usr/lib/x86_64-linux-gnu/gedit/libgedit-3.36.so (0x00007f1471f26000)
libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f1471ea4000)
libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f1471cc3000)
libtepl-4.so.0 => /lib/x86_64-linux-gnu/libtepl-4.so.0 (0x00007f1471c89000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1471a97000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f147196e000)
libgtk-3.so.0 => /lib/x86_64-linux-gnu/libgtk-3.so.0 (0x00007f14711bb000)
libgdk-3.so.0 => /lib/x86_64-linux-gnu/libgdk-3.so.0 (0x00007f14710b6000)
libpango-1.0.so.0 => /lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f1471067000)
libatk-1.0.so.0 => /lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f147103d000)
libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f1470f1a000)
libgdk_pixbuf-2.0.so.0 => /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f1470ef2000)
libgtksourceview-4.so.0 => /lib/x86_64-linux-gnu/libgtksourceview-4.so.0 (0x00007f1470e51000)
libamtk-5.so.0 => /lib/x86_64-linux-gnu/libamtk-5.so.0 (0x00007f1470e3f000)
libgirepository-1.0.so.1 => /lib/x86_64-linux-gnu/libgirepository-1.0.so.1 (0x00007f1470e07000)
libpeas-1.0.so.0 => /lib/x86_64-linux-gnu/libpeas-1.0.so.0 (0x00007f1470ded000)
libpeas-gtk-1.0.so.0 => /lib/x86_64-linux-gnu/libpeas-gtk-1.0.so.0 (0x00007f1470ddc000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f1470c9f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1470b4e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1470b2b000)
libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f1470b1f000)
libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f1470b19000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1470afd000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1470af7000)
libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f1470a95000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f1470a6a000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1470a4e000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f1470894000)
libuchardet.so.0 => /lib/x86_64-linux-gnu/libuchardet.so.0 (0x00007f147086f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1472019000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f14707fc000)
libpangocairo-1.0.so.0 => /lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f14707e8000)
libXi.so.6 => /lib/x86_64-linux-gnu/libXi.so.6 (0x00007f14707d6000)
libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f14707ce000)
libcairo-gobject.so.2 => /lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f14707c2000)
libatk-bridge-2.0.so.0 => /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0 (0x00007f147078b000)
libepoxy.so.0 => /lib/x86_64-linux-gnu/libepoxy.so.0 (0x00007f1470658000)
libfribidi.so.0 => /lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007f1470639000)
libpangoft2-1.0.so.0 => /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f1470620000)
libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f147051b000)
libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f14704d4000)
libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f1470415000)
libXinerama.so.1 => /lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f147040e000)
libXrandr.so.2 => /lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f1470401000)
libXcursor.so.1 => /lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f14703f4000)
libXcomposite.so.1 => /lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f14703ef000)
libXdamage.so.1 => /lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f14703ea000)
libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f14703a8000)
libwayland-cursor.so.0 => /lib/x86_64-linux-gnu/libwayland-cursor.so.0 (0x00007f147039d000)
libwayland-egl.so.1 => /lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f1470396000)
libwayland-client.so.0 => /lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f1470385000)
libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f1470370000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1470365000)
libthai.so.0 => /lib/x86_64-linux-gnu/libthai.so.0 (0x00007f147035a000)
libpixman-1.so.0 => /lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f14702b1000)
libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f1470279000)
libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f1470274000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f147024a000)
libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f147023b000)
libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f1470031000)
libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f146ffd8000)
libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f146ff48000)
libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f146fd62000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f146fd39000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f146fb58000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f146fb3b000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f146faea000)
libatspi.so.0 => /lib/x86_64-linux-gnu/libatspi.so.0 (0x00007f146fab3000)
libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f146fa86000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f146fa58000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f146fa4d000)
libdatrie.so.1 => /lib/x86_64-linux-gnu/libdatrie.so.1 (0x00007f146fa43000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f146fa3d000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f146fa35000)
libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f146df74000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f146dec3000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f146dea9000)
liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f146de88000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f146dd6a000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f146dd47000)

A: From the information in the bug report, a beta version with fix is already available. It can be installed with:
snap refresh snap-store --beta --ignore-running

Tried it, works.

A: The problem is in the internals of the latest snap-store version 3.38.0-59-g494f078     2021-04-20 (518) from default channel.
To fix it you can upgrade it to newer version by using command below
snap refresh snap-store --beta --ignore-running

Then you can use it as before.

Notes:

*

*this method is universal for all current Ubuntu releases - 18.04 LTS, 20.04 LTS, 20.10 and 21.04.

*we need to get official fix from Snap Store developers and switch then to default channel, bug 1931380 was reported to launchpad.

*if one is not happy with above solution, then one can use GNOME Software with snap plugin instead - sudo add-apt-repository universe; sudo apt-get update; sudo apt-get install gnome-software gnome-software-plugin-snap .

Update: The bug has been fixed. If you switched to the beta channel, you should switch back to stable with the following command:
snap refresh snap-store --stable


text:
Q: default coder for pojo object in apache beam As per apache beam documentation, I can find data type specific coders and also custom coders. It provides feasibility to create custom coders by registering with code registry. But I would like to know if there is any coder available for POJO/bean. For example,what is the coder for PCollection

A: If your POJO is defined within your project, then take a look at DefaultSchema. The example there does exactly what you want, registering a schema (which implicitly registers a coder) by inspecting JavaBean-compliant methods:
@DefaultSchema(JavaBeanSchema.class)
class MyClass {
  public String getFoo();
  void setFoo(String foo);
        ....
}

Note that coders are for elements of a collection, so there is no coder for PCollection. Rather, a PCollection can have a coder set, determining how individual elements are serialized and deserialized.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Use UIImagePickerController in qt application i am using qt 5.3 on mac to develop an iOS application. I want to use UIImagePickerController with objective-c to pick an image from ios gallery and show it in qt. I know how use objective-c code in qt. To use UIImagePickerController, i need to add <UIKit/UIKit.h> in objective-c file (.mm), but i get this error "UIKit/UIKit.h" file not found.
I've added this code in .pro : LIBS += framework UIKit.
Can someone tell me how can i use UIImagePickerController in qt?


text:
Q: Does "within 24 hours of leaving" mean 24 hour after leaving? Please help! If someone asks you to call them within 24 hours of leaving a place, does it mean 24 hours after leaving? For example, if you are still at home and call an hour before you leave home, does it still count as "within 24 hours of leaving home?"
My understanding is that "within 24 hours of leaving" includes at least some time before actually leaving (while you are getting ready to leave, for example). Or does "within 24 hours of leaving" only include the time AFTER leaving?

A: within x number of hours is the deadline.

*

*You leave at 6 p.m.

I say: Call me within 24 hours. [of that time]
That means: You have until the next day at the same time to call me.
It only includes the time after leaving.
Frankly, I see no ambiguity there at all.

A: Strictly speaking, 'within' could mean before or after the time indicated.  In the context you provided though, it seems likely the speaker meant to refer only to 24 hours or less after leaving.


text:
Q: Get local IP address in Qt Is there a cross-platform way to get the local IP address (i.e. something that looks like 192.168.1.49) of the computer using Qt?
I want to make an FTP server for a Symbian phone and I want to show the IP address the FTP client should connect to.

A: If you require more information than just IP addresses (like the subnet), you have to iterate over all the interfaces.
QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces();
QNetworkInterface eth;

foreach(eth, allInterfaces) {
    QList<QNetworkAddressEntry> allEntries = eth.addressEntries();
    QNetworkAddressEntry entry;
    foreach (entry, allEntries) {
        qDebug() << entry.ip().toString() << "/" << entry.netmask().toString();
    }
}

A: Use QNetworkInterface::allAddresses()
const QHostAddress &localhost = QHostAddress(QHostAddress::LocalHost);
for (const QHostAddress &address: QNetworkInterface::allAddresses()) {
    if (address.protocol() == QAbstractSocket::IPv4Protocol && address != localhost)
         qDebug() << address.toString();
}

A: QNetworkInterface returns lots of addresses. you must filter them, to get desirable result:
foreach (const QNetworkInterface &netInterface, QNetworkInterface::allInterfaces()) {
    QNetworkInterface::InterfaceFlags flags = netInterface.flags();
    if( (bool)(flags & QNetworkInterface::IsRunning) && !(bool)(flags & QNetworkInterface::IsLoopBack)){
        foreach (const QNetworkAddressEntry &address, netInterface.addressEntries()) {
            if(address.ip().protocol() == QAbstractSocket::IPv4Protocol)
                qDebug() << address.ip().toString();
        }
    }
}

A: Here is the code I implemented to get: name, IP, netmask and mac address of localhost.
   QString localhostname =  QHostInfo::localHostName();
   QString localhostIP;
   QList<QHostAddress> hostList = QHostInfo::fromName(localhostname).addresses();
   foreach (const QHostAddress& address, hostList) {
       if (address.protocol() == QAbstractSocket::IPv4Protocol && address.isLoopback() == false) {
            localhostIP = address.toString();
       }
   }
   QString localMacAddress;
   QString localNetmask;
   foreach (const QNetworkInterface& networkInterface, QNetworkInterface::allInterfaces()) {
       foreach (const QNetworkAddressEntry& entry, networkInterface.addressEntries()) {
           if (entry.ip().toString() == localhostIP) {
               localMacAddress = networkInterface.hardwareAddress();
               localNetmask = entry.netmask().toString();
               break;
           }
       }
   }
   qDebug() << "Localhost name: " << localhostname;
   qDebug() << "IP = " << localhostIP;
   qDebug() << "MAC = " << localMacAddress;
   qDebug() << "Netmask = " << localNetmask;

A: I wanted to get eth1 IP address of my target machine. Answers provided above helped me to get what I wanted: This is how I wrote my function to get me the IP address of the network interface name eth1.
QNetworkInterface eth1Ip = QNetworkInterface::interfaceFromName("eth1");
QList<QNetworkAddressEntry> entries = eth1Ip.addressEntries();
if (!entries.isEmpty()) {
    QNetworkAddressEntry entry = entries.first();
    qDebug() << entry.ip();
}

A: QNetworkInterface::allAddresses() will give you the network addresses.  You can then filter the results to IPv4 addresses that are not loopback addresses:
QList<QHostAddress> list = QNetworkInterface::allAddresses();

 for(int nIter=0; nIter<list.count(); nIter++)

  {
      if(!list[nIter].isLoopback())
          if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol )
        qDebug() << list[nIter].toString();

  }


text:
Q: Amount of homomorphisms from $V$ to $S_4$ I am trying to count the amount of homomorphisms from the klein four group to $S_n$, so the homommorphisms $f: V_4\to S_n$.
I think I am almost there, but just wanted to let you guys know my way of reasoning, and if that is correct: the elements of $V_4$ all have order 2 (except the identity). So they all need to go to an element of order 2 in $S_4$, right?
The elements of $S_4$, with order 2, are: (1 2), (1 3), (1 4), (2 3), (2 4), (3 4), (1 2)(3 4), (1 3)(2 4), (1 4)(2 3). So that is 9 elements.
Then I am a bit stuck. Am I at least going in the right direction?

A: Hint: $V \cong C_2 \times C_2$. Consider the possible homomorphisms $C_2 \to S_4$.


text:
Q: Filter out some input with GREP Echo "Hello everybody!"
I need to check whether the input argument of a linux script does comply with my security needs. It should contain only a-z characters, 0-9 digits, some spaces and the "+" sign. Eg.: "for 3 minutes do r51+r11"
This didn't worked for me:
if grep -v '[0123456789abcdefghijklmnopqrstuvwxyz+ ]' /tmp/input; then
  echo "THIS DOES NOT COMPLY!";
fi

Any clues?

A: You want to test the entire row (assuming there is only one row in /tmp/input), not just whether a single character anywhere matches, so you need to anchor it to the start end end of the row. Try this regexp:
^[0123456789abcdefghijklmnopqrstuvwxyz+ ]*$
Note that you can shorten this using ranges:
^[0-9a-z+ ]*$

A: You are telling grep:
Show me every line that does not contain [0123456789abcdefghijklmnopqrstuvwxyz+ ]

Which would only show you lines that contains neither of the characters above. So a line only containing other characters, like () would match, but asdf() would not match.
Try instead to have grep showing you every line that contains charachter not in the list above:
if grep '[^0-9A-Za-z+ ]' file; then

If you find something that's not a number or a letter or a plus, then.


text:
Q: Cannot find certain import on Java I am working with an example of a simple JSF and I am using NetBeans. With NetBeans, I can't seem to resolve these imports
import javax.inject.Named;

import javax.enterprise.context.SessionScoped;

but when I go to Eclipse to check, there seems to be no problem. They are found by the Java class created in Eclipse. I was wondering: what are the things that I need to import or configure with NetBeans so that I won't have this problem of my class not seeing packages?
Also, I just updated everything before posting this question

A: In the project view expand Libraries and add 'Java EE 6 API Library' this will add the required packages. The required file is javaee-api-6.0.jar.
Alternativly as maven dependency:
<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>6.0</version>
</dependency>

A: Check out that the correct reference library is added in netbeans in your applications build path.

A: they seem to work now after choosing the glassfish as the server. before, I chose tomcat which i guess don't have the imports that i want to use

A: A solution to continue developing with Tomcat are change the imports and annotations to:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="namebean")
@SessionScoped

It's an old question but someone can have the same problem ...

A: @ManagedBean is intended for use with legacy application servers and standalone servlet runners.
@Named is the best choice with a Java EE 6 compliant application server.
If you are using Maven, then you could use the above mentioned dependency in your pom file. Else you could just download the javaee 6 api jar file (javaee-api-6.0.jar) and add it to your class path. That should get it working.
It is readily available online. Here is one of those links:
http://www.java2s.com/Code/JarDownload/javaee-api/javaee-api-6.0.jar.zip


text:
Q: ASP.Net 1.1 Viewstate Security In ASP.Net 1.1 is it possible for the end user to change the viewdata before it's sent back to the server to for instance make it look like an item is selected in a dropdown that does not exist? I've tried manipulating the values in the dropdown using firebug but the server seems to ignore that, I'm presuming because the viewstate says that item does not exist, if however its possible to change the viewdata to achieve this then that could be more of a problem.
I'm asking because I've been asked to look over the security of one of our applications and if the above is possible there could be a big security gap.
Just to clarify I'm not asking how, I do not want to break someone elses software I just need to know if its something to be concerned about.
Hopefully this makes sense.
Thanks

A: Yes, View State can be hacked. In ASP.NET 2.0 a feature was introduced which allowed one to Encrypt the View State and thus prevent these types of attacks.
Hacking View State for Fun & Profit details how to hack the view state of an application.


text:
Q: Redirect to other page if login I have a home/static page with login button. Currently I've set the button url as "http://example.com/login"
How can I set the login button to redirect to a specific page IF/WHEN the user is logged in?
I do not know much about coding. I found some solution about add_action or something and added to theme's function.php. But I can't get it work.
Summary:
if non-login user: login button url ---> login page
if login user: login button url ---> specific page

A: Add below code in your functions.php file of active theme directory in order to restrict the login page to logged-in users and redirect them to core user page (user profile). You can replace "um_get_core_page( 'user' )" with any page URL where you want to redirect logged-in users.
/* Restrict Login page to logged-in users and redirect to core user page (user profile) */
add_action( 'template_redirect', 'um_restrict_login_page_logged_in' );
function um_restrict_login_page_logged_in() {
    if ( um_is_core_page('login') && is_user_logged_in() ) {
        wp_redirect( um_get_core_page( 'user' ) );
        exit;
    }
}

Hope this works!!

A: Okay so you are asking if user logged in then redirect to other pages or something like this. It's WordPress pre-built functionality. you can check it out here. You can copy and paste my code in your functions.php if you don't understand from reference code.
add_action( 'init', 'check_user_loggedin' );
function check_user_loggedin(){
    if ( is_user_logged_in() ) {
       wp_redirect( 'https://www.google.com' );
    } else {
        echo 'Welcome, visitor!';
    }
}

Description:
here is_user_logged_in() is checking user login status and if user login status is true then redirect to link or do whatever you like or if status is false then do something else.Here wp_redirect is WordPress default functionality for redirecting to specified link.


text:
Q: Is there a way to quietly run the "wevtutil" command DESCRIPTION: I have a script that is suppose to be collecting log system information however upon the end of shell script the error that is output by the following command wevtutil epl "$ALOG" "${SYSNAM}_${SAFNAM}.evtx", is Failed to export log.... The problem that I have is this last message that is out
ISSUE: I'm fine with the fact that the command is making the user aware that an error has occurred and (I will address that issue separately). The problem is that the output of this error message affects the printout of the taskbar displayed by the script. In fact at the end of the scripts run the message skews the printout
DESIRED OUTCOME: I would like to either run the wevtutil command above quietly whilst taking note of the errors (potentially by forwarding the error messages to a script_error.txt file, along with a conditional) OR if there is some sort of clever work around that I am not aware of I am willing to attempt that as well either way I would like for the output displayed to the user to be clean rather than skewed.
Here are some examples of the issue I am experiencing below


text:
Q: is it possible to get insert id without commit in postgresql Now I want to insert a article record into two PostgreSQL(version 13) table, one table contain the article base info, and the other table contains the article content(maybe move to another db in the future). Here is the problem that sometimes one save sql failed make the data lose.
now I want the two action both success or both failed, but the content table must get the base table's id to insert. is it possible to get the base table insert id before commit? so that I could commit at one places. This is my python 3 code:
   def save_single(self, guid, pub_time, title, author, content, feed_url):
        if content is not None and len(content) > 0:
            article = ArticleService()
            article = article.save(title, guid, author, pub_time)
            content = ArticleContentService()
            if article.id is not None:
                content.save(article.id, content)
        else:
            logger.error("article content is null,title:" + title)

what should I do to make data keep consistant? the database orm library is sqlalchemy.

A: No. Most likely your id is autoincrement and is generated when you commit to the database.
As for doing both things at once, yes. If you have a parent:child relationship set up, you can append the child to the parent and just commit the parent.


text:
Q: Extracting 1st level boundaries from GADM worldmap in QGIS? I need a world map, broken down to GADM 1st level. The obvious way would be to download all single country .shp files and merge them. But that is far too tedious of course.
I tried the dissolve function in QGIS on the 500mb GADM world map, but its not dissolving the entities properly. It fails in 1 out of 10 because for example there are some single points remaining which QGIS recognises as borders.
Is there any solution to the dissolve problem?
Or do you know another approach?
Or is there a 1st lvl administrative boundary .shp file out there on the internet to download?

A: The normal solution is to go to Natural Earth.
You didn't say what scale you need, but the 1:10m might be useful. You can download cultural features (including Level 0 and Level 1 boundaries) as vectors.
Note that Natural Earth uses defacto boundaries, and some political entities differ in opinion (or policy).


text:
Q: Python: Get max pair in a list of pairs with min y How i get max pair in a list of pairs with min y?
I got this list:
L =[[1,3],[2,5],[-4,0],[2,1],[0,9]]

With max(L) i get [2,5], but i want [2,1].

A: max(L, key=lambda item: (item[0], -item[1]))

Output:
[2, 1]

A: Your request is kind of cryptic, but I think this is what you want:
x, y = zip(*L)
maxPairs = [L[i] for i,a in enumerate(x) if a == max(x)]
returnPair = sorted(maxPairs)[0]

A: import operator

get_y= operator.itemgetter(1)
min(L, key=get_y)[0]

Finds the coordinate with minimum y, retrieves x.
If you dislike operator.itemgetter, do:
min(L, key=lambda c: c[1])[0]


text:
Q: XML parsing with PHP: how to use foreach <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<response docVer="1.0">
    <result code="0">OK</result>
    <engineVer value="2.0.8"/>
    <repInfo>
        <version value="2.0.6.25180"/>
        <expansion value="HotS"/>
        <gameLength gameTimeValue="840" unit="sec" value="606"/>
        <gameLength unit="frame" value="53760"/>
        <gameType value="AutoMM"/>
        <isCompetitive value="true"/>
        <gameSpeed value="Faster"/>
        <format value="2v2"/>
        <gateway value="Europe"/>
        <mapFile value="40/63/4063ce2135431de8ebea926f4263876e8e554d893262bf50718edd0556cf0920.s2ma"/>
        <clients count="2">
            <client index="0" value="[Angels]KoT"/>
            <client index="1" value="SCIIGears"/>
        </clients>

I am using $parsed = new SimpleXMLElement($result);.
How can I loop through all clients and extract their values for echo?
Player 1: nick-name
Player 2: nick-name
and so on. I am stuck with that foreach.

A: Is this what you are looking for?
foreach($parsed->repInfo->clients->client as $client)
{
     // do what you want, $client->attribute;
}

A: The simplest way to do it is with an XPath, like this (for example):
foreach ($parsed->xpath("//client") as $client) {
    echo $client->value;  // ... for example
}

The string "//client" picks any <client> element anywhere in the document.


text:
Q: How to access window.ApplePaySession in LWC? I am working on apple pay integration using LWC. So far, I am able to access the window.ApplePaySession in my safari browser console but in LWC it's showing undefined.
I have also tried with static renderMode = 'light';
Any Thoughts?


text:
Q: Kendo Ui Angular2 Grid Paging to first page I have grid with few pages,
When Im resfreshing data I want to go back to the first grid page by code.
my grid:

                        <kendo-grid [data]="gridView"
                                    [pageSize]="pageSize"
                                    [skip]="skip"
                                    [pageable]="{
                                                    buttonCount: buttonCount,
                                                    info: info,
                                                    type: type,
                                                    previousNext: previousNext
                                                  }"
                                    [scrollable]="'none'"
                                    [height]="260"
                                    [rowHeight]="36"
                                    (pageChange)="pageChange($event)"
                                     [selectable]="true"
                                    (selectionChange)="onSelectChange($event)" >
                            <kendo-grid-column field="CHAPTER_DESCRIPTION" title="mmm" width="10" headerClass="sectionTitle">
                            </kendo-grid-column>
                            <kendo-grid-column field="LineBasicSum" title="סכום" width="10" headerClass="sectionTitle">
                            </kendo-grid-column>
                            <kendo-grid-column field="WORK_TYPE_DESCRIPTION" title="mmm" headerClass="sectionTitle" width="10">
                            </kendo-grid-column>

                        </kendo-grid>

How can I return to the first grid page?
thanks,

A: It depends on how you have implemented the paging, generally speaking it should be something like this:
public onClick() {
    this.pageChange({skip: 0})
}

http://plnkr.co/edit/KlWJYRmvZ9hJMD00jNg8?p=preview


text:
Q: Trying to make a powerbi dynamic TOPN slicer to display the most repeated values I want to make a slicer that is able to manipulate a donut chart, that will display the most repeated values according to the number selected in the slicer.
Say I have this table

Customer

1
Doug

2
Andy

3
Doug

4
Kathy

5
Andy

6
Doug

7
Doug

I want to have a slicer that when on 1 will display Doug on the chart, on 2 will display Doug and Andy, and on 3 will display Doug, Andy, and Kathy.
I have a measurement
TopCustomer = Calculate(

TOPN(
'TOPN Selection'[Number of Customers'],
VALUES('Table'[Customers]),
RANKX( ALL ('Table'[Customers] ), COUNTROWS('Table'),,DESC)
)
)

In this case "TOPN Selection" is a table like this

TOPN Value

1

2

3

And 'TOPN Selection'[Number of Customers] is a measurement
Number of Customers = SELECTEDVALUE(
'TOPN Selection'[TOPN Value]
)

I have my measurement "TopCustomer" set as the value in my donut chart, but when I use the slicer, nothing changes.
I am not sure if my measurements are off, or the way things are connected are off, or what may be the case as dax is a little new to me.

A: Please test this code:
TopCustomer =
VAR PickFromSlicer = SELECTEDVALUE('TOPN Selection'[TOPN Value])
RETURN
SUMX(
TOPN(
PickFromSlicer,
FILTER(ADDCOLUMNS(
    VALUES(YourTable[Customer]),
    "Total",CALCULATE(COUNTROWS(YourTable)),
    "Rank", RANKX(ALL(YourTable[Customer]),CALCULATE(COUNT(YourTable[Customer])))
    ),[Rank] <= PickFromSlicer),[Total],DESC),[Total]
    )

If we test it on a visual just you described at the end of your question:
Rank_1:

Rank_2

Rank_3

I hope This solves your problem.


text:
Q: How to delete rows that contain certain numbers I'm working on a table that contains a lot of NAs and answers by numbering
and it looks like this
structure(list(ID = c(101, 102, 103, 104, 105, 106, 107, 108, 109, 110), a = c(NA, 9, NA, NA, NA, NA, NA, NA, NA, NA), b = c(NA, 10, 9, 9, NA, NA, 2, NA, NA,NA), c = c(NA, NA, NA, 9, 1, NA, NA, 4, 11, 9), d = c(NA, NA, NA, NA, 8, NA, NA, 7, 9, 9), e = c(NA, NA, NA, NA, 9, NA, NA, 8, NA, 9), f = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), g = c(NA, NA, NA, NA, NA, NA, NA, 9, NA, NA)), .Names = c("ID", "a", "b", "c", "d", "e", "f", "g"), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"))

And what I am trying to do is delete rows that only contains number 9.
In this case ID 103, 104, 110 would be the case. I want those 3 rows to be removed.
I tried the code below
df1[rowSums(df1[-1]==9)==0,]

But, with having NAs in the table, it only reproduces NA table.
Please help :( !

A: You can use apply to check for the whole row:
df1[apply(df1[,-1], 1, function(x) !all(na.omit(x) == 9) | all(is.na(x))), ]

#    ID  a  b  c  d  e  f  g
# 1 101 NA NA NA NA NA NA NA
# 2 102  9 10 NA NA NA NA NA
# 5 105 NA NA  1  8  9 NA NA
# 6 106 NA NA NA NA NA NA NA
# 7 107 NA  2 NA NA NA NA NA
# 8 108 NA NA  4  7  8 NA  9
# 9 109 NA NA 11  9 NA NA NA

I use na.omit to get rid of the NA-values in each row and then check if all the remaining values are equal to 9.

A: You can use the na.rm argument to ignore the NAs:
df1[rowSums(df1[-1]==9, na.rm = TRUE) == 0, ]

But also note that this code will only keep the rows that don't have any 9, which isn't exactly what you are asking for in the question.

edit after comment:
in that case simply flip:
df1[rowSums(df1[-1]!=9, na.rm = TRUE) > 0, ]

A: There's probably a much more efficient way, but the following works, I believe:
df1[!(apply(df1[-1] == 9, 1, prod, na.rm = TRUE) * !apply(is.na(df1[-1]), 1, prod)), ]


text:
Q: sending a 2d array jquery post to java servlet I have some data that I need to send that is in a 2D array. I found that you send an array through post here
here but i need to send a 2D array from my javascript using post to a java servlet. Is there a way to do this?

A: You can use exactly the same technique as the example you link to. This is because it uses JSON to serialise the data, so it can send entire JS data structures in one go. So, taking the example, but rebuilding it for a 2d array and tweaking it to send actual JSON:
var obj=[ [1.1, 1.2], [2.1, 2.2], [3.1, 3.2] ];
$.ajax({
        url:"myUrl",
        type:"POST",
        dataType:'json',
        success:function(data){
            // codes....
        },
        data:JSON.stringify(obj),
        contentType: 'application/json'
    });

Then this will send a string to your server, like:
"[[1.1,1.2],[2.1,2.2],[3.1,3.2]]"

Your Java servlet will then have to deserialise this and use it however you want. In this example, the JSON will be sent as RAW post data; if you want to get it via the request object, you can do something like:
var obj=[ [1.1, 1.2], [2.1, 2.2], [3.1, 3.2] ];
$.ajax({
        url:"myUrl",
        type:"POST",
        dataType:'json',
        success:function(data){
            // codes....
        },
        data: {json: JSON.stringify(obj)}
    });

Then you should be able to get the JSON string from:
request.getParameterValues("json");


text:
Q: React-js with JSX setup starter kit I just wanted to setup an react-js project with JSX, but I've searched on google for a good starter-kit but I really don't which is best to start with. I've tried to install this: react-starter-kit but I don't think thats an good one?
I know this is not the right place to ask this kind of questions but I really dont know it anymore..
I prefer with customisable bootstrap and scss or less compiler.

A: I'd go for create-react-app that'll get you up and running quickly.

A: This question is difficult to answer without knowing your level of experience with React, and I fear the Stack Overflow community may block this question but nonetheless, I recommend checking out this site:
http://andrewhfarmer.com/starter-project
There is no one best solution when it comes to a starter kit, it can heavily depend on what type of application you're building and how much boilerplate you actually need. The link above provides a number of good starters to get you up and running quickly.


text:
Q: org.apache.hadoop.yarn.exceptions.YarnException: Can't resolve the ip of ubuntu I have a new problem running the pytorch program in a pseudo-distributed Hadoop environment. The management page of yarn reports this error.
The error is reported as follows.
2022-05-26 13:55:01 INFO ApplicationMaster:448 - Preparing application master..
2022-05-26 13:55:01 INFO NMClientAsyncImpl:138 - Upper bound of the thread pool size is 500
2022-05-26 13:55:01 INFO DefaultNoHARMFailoverProxyProvider:64 - Connecting to ResourceManager at localhost/127.0.0.1:8030
2022-05-26 13:55:01 ERROR ApplicationMaster:496 - Exception while preparing AM
org.apache.hadoop.yarn.exceptions.YarnException: Can't resolve the ip of ubuntu
at com.linkedin.tony.util.Utils.getHostNameOrIpFromTokenConf(Utils.java:365)
at com.linkedin.tony.ApplicationMaster.prepare(ApplicationMaster.java:476)
at com.linkedin.tony.ApplicationMaster.run(ApplicationMaster.java:368)
at com.linkedin.tony.ApplicationMaster.main(ApplicationMaster.java:342)
2022-05-26 13:55:01 INFO ApplicationMaster:347 - Application Master failed. Exiting

I can access the management page of yarn when typing ubuntu:8042 into my browser.
My environment:
Ubuntu20.04
openjdk 1.8
Hadoop3.3.3


text:
Q: Uploaded images not saved and displayed in Django I'm working on user profiles, where the user can upload jpg images as their profile pictures. But the uploaded images are neither being stored in my media directory nor is it being displayed in the server. IT keeps displaying 'default photo' instead. I have set up the MEDIA_ROOT and MEDIA_URL in my settings file and have also added to the urls file, it's still not working. I'm new to Django, any help would be appreciated.
Here's my models.py:
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
image = models.ImageField(default='default.jpg', upload_to='profile_pics')

def __str__(self):
    return f'{self.user.username} Profile'

def save(self):
    super().save()

    image=Image.open(self.image.path)

    if image.height >300 or image.width  > 300:
        output_size=(300,300)
        image.thumbnail(output_size)
        image.save(self.image.path)

views.py:
def profile(request):
if request.method=='POST':
    update_form=UserUpdateForm(request.POST, instance=request.user)
    profile_form=ProfileUpdateForm(request.POST, request.FILES ,instance=request.user)
    if update_form .is_valid() and profile_form.is_valid():
        update_form.save()
        profile_form.save()
        messages.success(request, f'Your account has been updated!!')
        return redirect('profile')
else:
    update_form=UserUpdateForm(instance=request.user)
    profile_form=ProfileUpdateForm(instance=request.user)
context={
    'update_form': update_form,
    'profile_form':profile_form,
}
return render(request, 'users/profile.html', context)

profile.html:

{{ user.username }}

{{ user.email }}

    <form method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <fieldset class="form-group">
            <legend class="border-bottom mb-4">
Profile Info
</legend>
            {{ update_form|crispy }}
            {{ profile_form|crispy }}
        </fieldset>

            <button class="btn btn-oultline-info" type="submit"> Update </button>

    </form>

settings.py:
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

A: Create image filed in model
class Profile(models.Model):
    image = models.ImageField(upload_to='account_image/', blank=True, null=True)

'GET' data by request
def profile(request):
    data = Profile.objects.filter(user=request.user)
    return render(request, 'accounts/profile.html', locals())

load in html


text:
Q: Nodejs express listener must be a function I am using the following code to set up an express project, but I get an exception: TypeError: listener must be a function
var fs = require('fs');
var express = require('express');
var privateKey  = fs.readFileSync('C:/Node/cert/sn_com.key', 'utf8');
var certificate = fs.readFileSync('C:/Node/cert/sn_com.cer', 'utf8');
var credentials = {key: privateKey, cert: certificate};
var app = express();
var server = require('https').createServer(app, credentials);
server.listen(8001);

I don't understand why

A: The order of parameters to createServer should be reversed. First credentials and the express app.


text:
Q: Free objects ~50% of .NET heap. How to know what's causing OOM I am trying to determine what's contributing to my application high memory usage. So I took process dump file. EEHeap command is showing about 2.8 GB in .NET memory heap.
0:000> !EEHeap -gc
Number of GC Heaps: 2
------------------------------
Heap 0 (00000000001e3030)
generation 0 starts at 0x00000000a5f21360
generation 1 starts at 0x00000000a5c45a60
generation 2 starts at 0x000000007fff1000
ephemeral segment allocation context: none
 segment     begin allocated  size
000000007fff0000  000000007fff1000  00000000beeca248  0x3eed9248(1055756872)
Large object heap starts at 0x000000027fff1000
 segment     begin allocated  size
000000027fff0000  000000027fff1000  000000028f7d42f8  0xf7e32f8(259928824)
Heap Size:               Size: 0x4e6bc540 (1315685696) bytes.
------------------------------
Heap 1 (00000000001ed9e0)
generation 0 starts at 0x00000001a6c77908
generation 1 starts at 0x00000001a69a8370
generation 2 starts at 0x000000017fff1000
ephemeral segment allocation context: none
 segment     begin allocated  size
000000017fff0000  000000017fff1000  00000001cc127e58  0x4c136e58(1276341848)
Large object heap starts at 0x000000028fff1000
 segment     begin allocated  size
000000028fff0000  000000028fff1000  000000029b55d8f8  0xb56c8f8(190236920)
Heap Size:               Size: 0x576a3750 (1466578768) bytes.
------------------------------
GC Heap Size:            Size: 0xa5d5fc90 (2782264464) bytes.

Strange thing is that the biggest entry for !Dumpheap is the free which is consuming ~1.3 GB
00000000001ac980      388   1373069656      Free

Some of these are in LOH.
0:000> !dumpgen 3 -stat
       Count      Total Size      Type
-------------------------------------------------
           2        233,376   System.Collections.Hashtable+bucket[]
           1        262,168   System.Double[]
           6      1,804,496   System.Int64[]
           1      1,868,972   System.Int32[]
          57     18,707,978   System.Byte[]
          31     69,830,576   System.Object[]
         102    346,151,516   **** FREE ****

There are no objects ready for finalization which tells me that Finalize thread just finished its job.
0:000> !FinalizeQueue
SyncBlocks to be cleaned up: 0
Free-Threaded Interfaces to be released: 0
MTA Interfaces to be released: 0
STA Interfaces to be released: 0
----------------------------------
------------------------------
Heap 0
generation 0 has 2748 finalizable objects (00000000047b6518->00000000047bbaf8)
generation 1 has 55 finalizable objects (00000000047b6360->00000000047b6518)
generation 2 has 6878 finalizable objects (00000000047a8c70->00000000047b6360)
Ready for finalization 0 objects (00000000047bbaf8->00000000047bbaf8)
------------------------------
Heap 1
generation 0 has 69 finalizable objects (0000000004807160->0000000004807388)
generation 1 has 6 finalizable objects (0000000004807130->0000000004807160)
generation 2 has 7818 finalizable objects (00000000047f7ce0->0000000004807130)
Ready for finalization 0 objects (0000000004807388->0000000004807388)

LOH seem to be heavily fragmented.
0:000> !HeapStat
Heap             Gen0         Gen1         Gen2          LOH
Heap0       419073768      2996480    633686624    259928824
Heap1       625673552      2946456    647721840    190236920
Total      1044747320      5942936   1281408464    450165744

Free space:                                                 Percentage
Heap0       397468560           24      1545984    183287672SOH: 37% LOH: 70%
Heap1       611153984           24     16750104    162864048SOH: 49% LOH: 85%
Total      1008622544           48     18296088    346151720

I don't know if I am connecting all the dots here, but my thought is that in next GC, all the free object will be removed from memory and .NET heap memory should go down based on Free objects that are in Gen 0, 1, 2 (because those will be compressed). Is it a fair statement or do you see any other issues that I may be missing? Of course LOH fragmentation is a issue but I don't know how much that account for application utilization.
EDIT:
Applicaton has started failing with OOM now. Based on some comments below, memory reported against Free object doesn't go back to OS. How can I know what is causing OOM

A: The Large Object Heap does not do automatic defragmentation, so it is indeed possible to get an OOM while you have lots of free space on the LOH. There is no easy way out of this hole. There are three general approaches:
1) Reduce the amount of LOH (>85,000 bytes) allocations your application performs, pool large objects instead of letting them become collected, and try to perform a small number of very big allocations instead of a large number of medium ones.
2) Use .NET 4.5.1's LOH compaction. It's a stopgap, not a true solution, but if fragmentation is the only memory-related problem you have, it can help for now.
3) Move to a 64-bit process. You will still have a fragmentation problem, but you will not run out of memory so easily.


text:
Q: java.lang.IllegalArgumentException thrown at debug launch in Eclipse CDT I am using Eclipse CDT, with MinGW and under Windows XP, to developp a little C program exporting itself as a JNI-compliant DLL.
Debugging the program from the Java calls is not easy, and thus I added a "Debug" configuration to my project and a main method that tests some functions.
When I launch the debug, i get this weird Java error :
An internal error occurred during: "Launching NuanceWrapper.exe".
java.lang.IllegalArgumentException

It seems very much like it is an internal Eclipse problem. I got the stacktrace of the exception in the .log file of the .metadata folder :
!ENTRY org.eclipse.core.jobs 4 2 2011-02-04 14:08:31.531
!MESSAGE An internal error occurred during: "Launching Wrapper.exe".
!STACK 0
java.lang.IllegalArgumentException
    at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.getBundles(PackageAdminImpl.java:571)
    at org.eclipse.core.internal.runtime.InternalPlatform.getBundle(InternalPlatform.java:181)
    at org.eclipse.core.runtime.Platform.getBundle(Platform.java:1416)
    at org.springframework.ide.eclipse.core.BundleStateLocationVariableResolver.resolveValue(BundleStateLocationVariableResolver.java:32)
    at org.eclipse.core.internal.variables.DynamicVariable.getValue(DynamicVariable.java:54)
    at org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier$EclipseVarMacro.loadValue(EclipseVariablesVariableSupplier.java:103)
    at org.eclipse.cdt.internal.core.cdtvariables.EclipseVariablesVariableSupplier$EclipseVarMacro.getStringValue(EclipseVariablesVariableSupplier.java:90)
    at org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getLaunchEnvironment(LaunchUtils.java:385)
    at org.eclipse.cdt.dsf.gdb.launching.LaunchUtils.getGDBVersion(LaunchUtils.java:281)
    at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.getGDBVersion(GdbLaunchDelegate.java:243)
    at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launchDebugSession(GdbLaunchDelegate.java:129)
    at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launchDebugger(GdbLaunchDelegate.java:83)
    at org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate.launch(GdbLaunchDelegate.java:72)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Any idea what could be the problem ? I really need this debug functionality in order to understand what is wrong in my code.
Thank you for your answers.

A: I looked at the source code of the different files of your stack trace, and it seems to be a problem with your CDT project's configuration. You should check the settings here and try to change them.
One of the CDT build variables seems to be wrong. In LaunchUtils.java, line 390, var.getStringValue() is causing the issue because in this variable (var), which contains a name and an associated value, the value is null.
Hope this helps.

A: Had the same problem. the next string from the exception stack trace:
at org.springframework.ide.eclipse.core.BundleStateLocationVariableResolver.resolveValue(BundleStateLocationVariableResolver.java:32)
led me to the idea that SpringSource ToolSuite (or Spring IDE) could cause the issue. After uninstalling it and all its components the problem was gone.
Hope this helps.


text:
Q: How do I convert from int64 back to timestamp or datetime'? I am working on a project to look at how much a pitcher's different pitches break each game. I looked here for an earlier error which fixed my error but it gives me some weird numbers. What I mean is like when I print what I hope to be August 3rd,2020 I get 1.5964128e+18. Here's how I got there.
hughes2020=pd.read_csv(r"C:/Users/Stratus/Downloads/Hughes2020Test.csv",parse_dates=['game_date'])
game=hughes2020['game_date'].astype(np.int64)
#Skipping to next part to an example
elif name[i]=="Curveball":
   if (c<curve)
      xcurve[c]=totalx[i]
      ycurve[c]=totaly[i]
      cudate[c]=game[i]
      c+=1

and when I print the cudate it gives me the large number and I am wondering how I can change it back.
And if I run it as
game=hughes2020['game_date'] #.astype(np.int64)
    #Skipping to next part to an example
    elif name[i]=="Curveball":
       if (c<curve)
          xcurve[c]=totalx[i]
          ycurve[c]=totaly[i]
          cudate[c]=game[i]
          c+=1

It gives me an
TypeError: float() argument must be a string or a number, not 'Timestamp'

A: To convert int to datetime use pd.to_datetime():
df = pd.DataFrame(data=[1.5964128e+18], columns = ['t'])
df['t2'] = pd.to_datetime(df['t'])

              t         t2
0  1.596413e+18 2020-08-03

However a better solution would be to convert the dates at the time of csv reading (As @sinanspd correctly pointed out). Use parse_dates and other related options in pd.read_csv(). Function manual is here


text:
Q: Vertically center a title with fixed height in css I have a header

My Header

It has a height of 150px and a font-size of say 1.3em;
How can I make the header text vertically centered with CSS.
I would rather not wrap it in a container DIV (wrapping divs really defeat the whole CSS idea).

A: If the height of the title is 150px, could you also set the line-height to 150px?
h1
{
    font-size: 1.3em;
    line-height: 150px;
    height: 150px;
}

A: The best way is to add this rule:
h1 {
    line-height: 150px;
}

You don't need to set the height value, and the font size doesn't affect the vertical align.


text:
Q: Missing display of rounded corners in Android shape drawable (only on Samsung Galaxy Tab 7.0) I'm just trying to display a stroked rectangle (stroke width 1dp) with rounded corners (radius 3dp). Everything looks fine on most devices, but the corners are not displayed correctly on Samsung Galaxy Tab 7.0 plus N.
Here's the code:
<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"  >
    <solid android:color="#00000000"/>
    <stroke android:width="1dp" android:color="@color/borderGreen"/>
    <corners android:radius="3dp" />
</shape>

And here are the results. It's looking good on Kindle Fire HD (for example), but not so good on the Galaxy Tab:

The Kindle has a higher screen resolution, but it also looks ok on devices with resolutions lower than the Galaxy Tab's. Do you have any ideas on how to circumvent this problem or will I just have to live with it?

A: This issue happened to me when I was adding two rectangle shapes - one containing the other one (to achieve a double-border background in my case).
I was however only applying a corner radius to the outer rectangles and not the inner one. This was causing the effect of cut out or missing rounded corners.


text:
Q: Repair flawed experiment design I seem to have uncovered a methodological flaw in a published large study dataset that originally took about 30 years to collect and collate. The experiment had a sequence of stimuli in a globally unique randomized order — i.e. each interview was conducted in the same order, but the order was randomized once as part of the experiment design.
By analyzing the data, I have discovered that the first stimulus behaves differently from the rest: adjacent stimuli correlate pretty well (Absolute value of Pearson r between 0.3 and 0.85, with p-values far under 0.05); except for the first stimulus in the randomized order, which correlates with its neighbors far less (Pearson r at around -0.07, p ~ 1e-25).
Before writing these findings up and publishing them I would like to be able to suggest methods to still use the collected data for further analysis, which leads me to my question:
What strategies might be worth pursuing for extracting reliable conclusions from a dataset suffering from this type of sequential "burn-in" issues with the data collection method? Is there a good source I can read on handling data from flawed experimental design?


text:
Q: Matching rows in pandas based on values is different columns Input
Assume I have a dataframe with the following structure:
   transaction_code   transaction_time   amount reversed_transaction_code
0       TX051       2019-01-01 13:00:00   150
1       TX002       2019-01-01 14:00:00   250           TX004
2       TX113       2019-01-01 15:00:00   100
3       TX004       2019-01-01 16:00:00    80           TX002
4       TX805       2019-01-01 17:00:00    30

This can be reproduced using the following code:
eg = {'transaction_code': ['TX051','TX002','TX113','TX004','TX805'],
      'transaction_time': pd.to_datetime(['1 Jan 2019 1pm','1 Jan 2019 2pm','1 Jan 2019 3pm','1 Jan 2019 4pm','1 Jan 2019 5pm']),
      'amount': [150,250,100,80,30],
      'reversed_transaction_code': ['','TX004','','TX002','']}
df = pd.DataFrame(eg)

In df, each row corresponds to a transaction made at my shop. When items are returned, a new transaction is added and logged in the reversed_transaction_code column.
Problem
For example, $80 of items from TX002 were returned in TX004. How do I match these transactions, record the time and amount of returns and then remove the ROWS which are reversed transactions?
Expected output
The new columns should look like this:
   reversed_amount  reversed_transaction_time
0        NaN                   NaT
1        80            2019-01-01 16:00:00
2        NaN                   NaT
4        NaN                   NaT

This can be reproduced using the following code:
da = df[df.index!=3]
da['reversed_amount'] = [None, 80, None, None]
da['reversed_transaction_time'] =  pd.to_datetime([None, '1 Jan 2019 4pm', None, None])

A: I've modified your original data to make it little more complex.

Solution-
eg = {'transaction_code': ['TX051','TX002','TX113','TX004','TX805'],
          'transaction_time': pd.to_datetime(['1 Jan 2019 1pm','1 Jan 2019 2pm','1 Jan 2019 3pm','1 Jan 2019 4pm','1 Jan 2019 5pm']),
          'amount': [150,250,100,80,30],
          'reversed_transaction_code': ['','TX004','TX805','TX002','TX113']}
df = pd.DataFrame(eg)
df

+---+--------+---------------------------+------------------+---------------------+
|   | amount | reversed_transaction_code | transaction_code |  transaction_time   |
+---+--------+---------------------------+------------------+---------------------+
| 0 |    150 |                           | TX051            | 2019-01-01 13:00:00 |
| 1 |    250 | TX004                     | TX002            | 2019-01-01 14:00:00 |
| 2 |    100 | TX805                     | TX113            | 2019-01-01 15:00:00 |
| 3 |     80 | TX002                     | TX004            | 2019-01-01 16:00:00 |
| 4 |     30 | TX113                     | TX805            | 2019-01-01 17:00:00 |
+---+--------+---------------------------+------------------+---------------------+

# Fetching the index where there's an entry on reversed_transaction_code
idx_ = df[df.reversed_transaction_code.str.startswith('T')].index
idx_
# Int64Index([1, 2], dtype='int64')

# Creating blank columns
df['reversed_amount'] = np.NaN
df['reversed_transaction_time'] = None

# Reverse transaction index
idxR_ = df.iloc[idx_, :][df.loc[idx_, 'reversed_transaction_code'].str.split('TX', expand=True).iloc[:, 1] < df.loc[idx_, 'transaction_code'].str.split('TX', expand=True).iloc[:, 1]].index
idxR_
# Int64Index([3, 4], dtype='int64')

# Fetching valid reversed transaction code from reversed_transaction_code column
val = df.loc[idxR_, 'reversed_transaction_code']
val
# 3    TX002
# 4    TX113
# Name: reversed_transaction_code, dtype: object

# Fetching transaction code from transaction_code column
code_idx_ = df[np.where(df.transaction_code.isin(val), True , False)].index
code_idx_
# Int64Index([1, 2], dtype='int64')

# checking where does transaction code lies and adding corresponding results to new columns
# Below code can be made shorter or more efficient (say using merge/join, etc)
for i in range(len(val)):
    for j in range(len(code_idx_)):
        if val.iloc[i] == df.loc[code_idx_[j], 'transaction_code']:
            df.loc[code_idx_[j], 'reversed_transaction_time'] = df.loc[val.index[i], 'transaction_time']
            df.loc[code_idx_[j], 'reversed_amount'] = df.loc[val.index[i], 'amount']

# Removing the rows with reversed transactions
df.drop(val.index, inplace=True)
df

+---+--------+---------------------------+------------------+---------------------+-----------------+---------------------------+
|   | amount | reversed_transaction_code | transaction_code |  transaction_time   | reversed_amount | reversed_transaction_time |
+---+--------+---------------------------+------------------+---------------------+-----------------+---------------------------+
| 0 |    150 |                           | TX051            | 2019-01-01 13:00:00 | NaN             | None                      |
| 1 |    250 | TX004                     | TX002            | 2019-01-01 14:00:00 | 80.0            | 2019-01-01 16:00:00       |
| 2 |    100 | TX805                     | TX113            | 2019-01-01 15:00:00 | 30.0            | 2019-01-01 17:00:00       |
+---+--------+---------------------------+------------------+---------------------+-----------------+---------------------------+


text:
Q: Table messing up formatting of text I am using Anki (you don't have to be familiar with this) which is a flashcard app. When designing the cards, I cannot figure out what is going wrong.
The front of the card:

    {{#Title}}
{{Title}}
{{/Title}}

Details

        Origin
        {{cloze:Text1}}

        Insertion
        {{cloze:Text2}}

        Innervation
        {{cloze:Text3}}

        Action
        {{cloze:Text4}}

The back of the card:

    {{#Title}}
{{Title}}
{{/Title}}

Details

        Origin
        {{cloze:Text1}}

        Insertion
        {{cloze:Text2}}

        Innervation
        {{cloze:Text3}}

        Action
        {{cloze:Text4}}

The css styling of the card:
html {
  /* scrollbar always visible in order to prevent shift when revealing answer*/
  overflow-y: scroll;
}

.card {
  border: 1px solid #404040;
  padding: 8px;
  font-weight: normal;
  font-size: 16px;
  text-align: left;
  color: black;
  background-color: white;
}

/* general layout */

.text {
  /* center left-aligned text on card */
  column-count: 2;
  display: inline-block;
  align: center;
  text-align: left;
  margin: auto;
  max-width: 40em;
}

.hidden {
  /* guarantees a consistent width across front and back */
  font-weight: bold;
  display: block;
  line-height:0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.title {
  background-color: #edcac5;
  color: #000000;
  font-weight: bold;
  font-size: 20px;
  margin-bottom: 10px;
  text-align: center;
}

.subtitle {
  background-color: #3b3b3d;
  color: #FFFFFF;
  font-weight: bold;
  font-size: 16px;
  padding: 3px;
  margin-bottom: 5px;
  text-align: center;
}

.heading {
  color: #6395ff;
  font-weight: bold;
  text-align: left;
  width: 30%;
}

table {
  table-layout: fixed;
  width: 100%;
}

td {
  word-wrap: break-word;
}

/* clozes */

.cloze {
  /* regular cloze deletion */
  font-weight: bold;
  color: #FFFFFF;
}

.card21 #btn-reveal{
  /* no need to display reveal btn on last card */
  display:none;
}

/* additional fields */

.extra{
  margin-top: 0.5em;
  margin: auto;
  max-width: 40em;
}

.extra-entry{
  margin-top: 0.8em;
  font-size: 0.9em;
  text-align:left;
}

.extra-descr{
  margin-bottom: 0.2em;
  font-weight: bold;
  font-size: 1em;
}

#btn-reveal {
  font-size: 0.5em;
  display:none;
}

.mobile #btn-reveal {
  font-size: 0.8em;
  display:none;
}

This is how it is supposed to look:

But this is how it ends up looking:

I think the table has something to do with this, I greatly appreciate any help/feedback.

A: I went ahead and threw a section id and called it wrapper and give it a with. This way will minimize any format issues.

// Scroll to cloze
function scrollToCloze () {
    const cloze1 = document.getElementsByClassName("cloze")[0];
    const rect = cloze1.getBoundingClientRect();
    const absTop = rect.top + window.pageYOffset;
    const absBot = rect.bottom + window.pageYOffset;
    if (absBot >= window.innerHeight) {
        const height = rect.top - rect.bottom
        const middle = absTop - (window.innerHeight/2) - (height/2);
        window.scrollTo(0, middle);
    };
}
if ( document.readyState === 'complete' ) {
    setTimeout(scrollToCloze, 1);
} else {
    document.addEventListener('DOMContentLoaded', function() {
        setTimeout(scrollToCloze, 1);
    }, false);
}

// back of card

// Remove cloze syntax from revealed hint
var hint = document.getElementById("original");
if (hint) {
    var html = hint.innerHTML.replace(/\[\[oc(\d+)::(.*?)(::(.*?))?\]\]/mg,
                                      "$2");
    hint.innerHTML = html
};

// Scroll to cloze
function scrollToCloze () {
    const cloze1 = document.getElementsByClassName("cloze")[0];
    const rect = cloze1.getBoundingClientRect();
    const absTop = rect.top + window.pageYOffset;
    const absBot = rect.bottom + window.pageYOffset;
    if (absBot >= window.innerHeight) {
        const height = rect.top - rect.bottom
        const middle = absTop - (window.innerHeight/2) - (height/2);
        window.scrollTo(0, middle);
    };
}
if ( document.readyState === 'complete' ) {
    setTimeout(scrollToCloze, 1);
} else {
    document.addEventListener('DOMContentLoaded', function() {
        setTimeout(scrollToCloze, 1);
    }, false);
}

// Reveal full list
var olToggle = function() {
    var orig = document.getElementById('original');
    var clozed = document.getElementById('clozed');
    var origHtml = orig.innerHTML
    orig.innerHTML = clozed.innerHTML
    clozed.innerHTML = origHtml
}
html {
  /* scrollbar always visible in order to prevent shift when revealing answer*/
  overflow-y: scroll;
}

.card {
  border: 1px solid #404040;
  padding: 8px;
  font-weight: normal;
  font-size: 16px;
  text-align: left;
  color: black;
  background-color: white;
}

/* general layout */

.text {
  /* center left-aligned text on card */
  column-count: 2;
  display: inline-block;
  align-items: center;
  text-align: left;
  margin: auto;
  max-width: 40em;
}

.hidden {
  /* guarantees a consistent width across front and back */
  font-weight: bold;
  display: block;
  line-height:0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.title {
  background-color: #edcac5;
  color: #000000;
  font-weight: bold;
  font-size: 20px;
  margin-bottom: 10px;
  text-align: center;
}

.subtitle {
  background-color: #3b3b3d;
  color: #FFFFFF;
  font-weight: bold;
  font-size: 16px;
  padding: 3px;
  margin-bottom: 5px;
  text-align: center;
}

.heading {
  color: #6395ff;
  font-weight: bold;
  text-align: left;
  width: 30%;
}

table {
  table-layout: fixed;
  width: 100%;
}

td {
  word-wrap: break-word;
}

/* clozes */

.cloze {
  /* regular cloze deletion */
  font-weight: bold;
  color: #FFFFFF;
}

.card21 #btn-reveal{
  /* no need to display reveal btn on last card */
  display:none;
}

/* additional fields */

.extra{
  margin-top: 0.5em;
  margin: auto;
  max-width: 40em;
}

.extra-entry{
  margin-top: 0.8em;
  font-size: 0.9em;
  text-align:left;
}

.extra-descr{
  margin-bottom: 0.2em;
  font-weight: bold;
  font-size: 1em;
}

#btn-reveal {
  font-size: 0.5em;
  display:none;
}

.mobile #btn-reveal {
  font-size: 0.8em;
  display:none;
}

/* new css */
#wrapper {
  width: 309px;
  margin: auto;
}

Title

Details

        Origin
        cloze:Text1

        Insertion
        cloze:Text2

        Innervation
        cloze:Text3

        Action
        cloze:Text4

Title

Details

        Origin
        cloze:Text1

        Insertion
        cloze:Text2

        Innervation
        cloze:Text3

        Action
        cloze:Text4


text:
Q: Working on part(b) and the correct answer is 1/8. Don't know what is my error on R.H.D..

So, I worked part(a) which I already checked that it is right but stuck on part(b).
But I don't get the correct answer for R.H.D. Can anyone help me out with my error?
Thank you.

A: It looks like your L.H.S. is correct.  For the R.H.S. you should have this:
$$\int_{\frac{1}{2}}^{\frac{3}{4}} \frac{\frac{1}{2}-(1-y)}{1-y} \cdot 2(1-y)dy + \int_{\frac{3}{4}}^{1} 1 \cdot 2(1-y)dy$$
Looks like you had this second integral right, but the first one is slightly different.  You found $f_Y(y)$ correctly.
Consider $P(X \leq \frac{1}{2} | Y=y)$ when $\frac{1}{2}<y<\frac{3}{4}$.
$$P \bigg(X \leq \frac{1}{2} \bigg| Y=y \bigg) = \frac{\textrm{width of }x\textrm{'s less than }\frac{1}{2} \textrm{ when }Y=y}{\textrm{width of all possible }x\textrm{'s when }Y=y}$$
The $x$ values less than $\frac{1}{2}$ will always be between the line $x=1-y$ and $x=\frac{1}{2}$.
The entire domain that $x$ could be, given that $\frac{1}{2}<y<\frac{3}{4}$, would be anywhere between the lines $x=1-y$ and $x=2(1-y)$.
Therefore, $$P \bigg(X \leq \frac{1}{2} \bigg| Y=y \bigg) = \frac{\frac{1}{2}-(1-y)}{2(1-y)-(1-y)} = \frac{\frac{1}{2}-(1-y)}{1-y}$$
Going back to the full R.H.S.
$$\int_{\frac{1}{2}}^{\frac{3}{4}} \frac{\frac{1}{2}-(1-y)}{1-y} \cdot 2(1-y)dy + \int_{\frac{3}{4}}^{1} 1 \cdot 2(1-y)dy$$
$$=\int_{\frac{1}{2}}^{\frac{3}{4}} \bigg[ \frac{1}{2}-(1-y) \bigg] \cdot 2dy + \int_{\frac{3}{4}}^{1} 1 \cdot 2(1-y)dy$$
$$=\frac{1}{16} + \frac{1}{16} = \frac{1}{8}$$
I know I skipped a few steps at the end, but I think you can evaluate those integrals.


text:
Q: Powershell error trapping I've got a script that does some server maintenance.  Part of the job is to stop and restart services on the host server.  The easiest way to tell when the service is fully back online again is attempt to connect to the admin port.  Once you're able to connect to the admin port, than the service is up and ready for business.  Simple enough.  This bit of code will loop until it's back online:
function test-port {
$PortProbe = New-Object Net.Sockets.TcpClient
$ErrorActionPreference = "SilentlyContinue"

while ($PortProbe.Connected -eq 0){
$PortProbe.Connect("localhost",3041)
write-host "Server is off line... waiting for it to come online."
sleep 1

}
write-host "Server is back online!"
$ErrorActionPreference = "Continue"
 $PortProbe.Close()
}

test-port

So in my script I do my work, restart services and then call "test-port" to have the script to wait for the service to come back online before proceeding.
The problem I'm running into is if I have a generic trap in the script, it's trapping the connection error when the port isn't ready yet.
Exception calling "Connect" with "2" argument(s): "No connection could be made because the target machine actively refused it 127.0.0.1:3041"
At line:6 char:27
+         $PortProbe.Connect <<<< ("localhost",3041)
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

I've got a trap statement at the end in case some really bizarre error happens, it'll kick off an e-mail alert.  But it breaks the functionality of the test-port function.
In theory, I could trap this specific TCP/IP connection error and tell it to just continue on like nothing had happened, but I can't figure out how to tell what the class of the error message is.  I thought it would be something like this:
trap [Net.Sockets.TcpClient] { #Don't Panic
}

But that's not right.
Any suggestions?  Do I need to handle this completely differently?

A: Rather than dropping to sockets, why not use the Get-Service cmdlet in a loop to check the service's status e.g.:
do {
    $svc = Get-Service -ComputerName Localhost w3svc
    $connected = $false
    if ($svc -and $svc.Status -eq 'Running')     {
        $connected = $true
    }
    Start-Sleep -Milliseconds 500
} while (!$connected)


text:
Q: How can php not execute neither 'then' nor 'else' clauses of 'if'? Following this tutorial (which I adapted to PostgreSQL), I have a problem in register.inc.php:
if (empty($error_msg)) {
    // Create a random salt
    $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
    // Create salted password
    $pwd = hash('sha512', $pwd.$random_salt);
    // Insert the new user into the database
    $q = "insert into usr (username,email,pwd,salt) values ($1,$2,$3,$4);";
    $res = pg_query_params($conn,$q,[$username,$email,$pwd,$random_salt]);
    if ($res === false) {
        header("Location: ../html/coisas/error.php?err=Registration failure: INSERT");
    } else {
        header('Location: ./register_success.php?msg=1'.$random_salt);
    }
    header('Location: ./register_success.php?msg=2'.$random_salt);
}

The header sent is the 3rd one (?msg=2...). If I comment it out, there's no header sent. How can it be that it won't enter in the then clause, nor in the else clause? The data is not being stored in the database, but I'm getting a "sucess" response. How can I know for sure the value of $res?

A: A header() will only work if it is sent before any other output is sent to the browser. I would guess that you have already sent something to the browser, maybe a debugging message or something.
If this has happened you should see a self explanitory error message in the php error log
Also you should always do an exit; after any header() statement as the header() does not actually stop execution of the rest of the script.
i.e.
if ($res === false) {
    header("Location: ../html/coisas/error.php?err=Registration failure: INSERT");
    exit;
} else {
    header('Location: ./register_success.php?msg=1'.$random_salt);
    exit;
}
header('Location: ./register_success.php?msg=2'.$random_salt);
exit;


text:
Q: Bundle is waiting for namespace handlers [http://camel.apache.org/schema/blueprint] I have written a simple apache camel project which will eventually be deployed in a FUSE container.  For now, I'm simply trying to get a basic unit test working.  I'm using the example here as a starting point.
I have written unit tests which work, but when I include a blueprint file,  I get the following entry in the test output:
Bundle TestMainRoute is waiting for namespace handlers [http://camel.apache.org/schema/blueprint]

And the test fails with the following stack trace:
java.lang.RuntimeException: Gave up waiting for service (objectClass=org.apache.camel.CamelContext)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:240)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:202)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:352)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:247)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

My xml is very simple:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
  <routeContext id="validationRoute"  xmlns="http://camel.apache.org/schema/blueprint" >

    <route id="validation">
        <from uri="direct:validation" />
        <log message="validating..." />
    </route>
</routeContext>

As is the code:
public class RouteTest extends CamelBlueprintTestSupport  {

  @Test
  public void testValidationRoute() throws Exception    {
    DefaultExchange r1 = new DefaultExchange(context);
    r1.getIn().setBody("");
    Exchange response1 = template.send("direct:validation", r1);
  }

  protected String getBlueprintDescriptor() {
    return "OSGI-INF/blueprint/blueprint.xml";

*

*List item

}
    }
NB the validation route is referenced by my main camel context:
public class IntegrationFramework extends RouteBuilder {

public void configure() {

    from("netty-http:http://localhost:8457/broker/router.jsp").convertBodyTo(String.class)
    .log("http router "+simple("${body}").getText())
    .to("direct:validation");
}

I have other unit tests and logging which indicate that this part is working.

A: I had the same error but another setup then @mdarwin, so I want to share my solution with you, too.
I startet a project with the camel-archetype-blueprint, so my namespaces looked like the following:
blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
   xsi:schemaLocation="
     http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
     http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">

At the beginning it was a really simple blueprint with a timer and a file endpoint, so the implementation is not important here. I deployed my bundle to Karaf and for that I installed the aries-blueprint feature.
What I missed, and I feel really ashamed, was to install camel, too. For that I had to add the repo and than install it, as you can read here:
feature:repo-add camel
feature:install camel

Now the namespace handler is there.
I think that was obvious, but it still took some minutes to figure it out.

A: Turns out that a routeContext only exists in the context of xml dsl, and cannot be referenced from the Java DSL.  This in my opinion is a bug, since it restricts the flexibility of mixing xml and java configuration.
By changing the routeContext to a camelContext, this fixed the problem.
See also this question: Camel: importing routeContext into an external camelContext
Also related: https://issues.apache.org/jira/browse/CAMEL-5717


text:
Q: Fill missing value with specific condition satisfied I want to fill the ind==NA down with 1 until the first stat==sup following cunscative unsup value of var stat.
fdat <- data.frame(id=c(1,1,1,1,2,2,2,2,2,2,3,3,3, 4,4,4,4,4,4,5,5,5,5),
                   stat=c('sup','unsup','unsup', 'sup', 'unsup', 'unsup', 'unsup',
 'unsup', 'sup', 'sup','sup','unsup','unsup','sup', 'sup','unsup','unsup', 'unsup', 'sup', 'unsup','unsup','sup','unsup'), ind=c(NA,1,NA,NA,1,1,1,NA,NA,NA,NA,1,NA, NA,NA,1,1,NA,NA, 1,NA,NA,NA))

My expected output is
   id  stat ind
1   1   sup  NA
2   1 unsup   1
3   1 unsup   1
4   1   sup   1
5   2 unsup   1
6   2 unsup   1
7   2 unsup   1
8   2 unsup   1
9   2   sup   1
10  2   sup  NA
11  3   sup  NA
12  3 unsup   1
13  3 unsup   1
14  4   sup  NA
15  4   sup  NA
16  4 unsup   1
17  4 unsup   1
18  4 unsup   1
19  4   sup   1
20  5 unsup   1
21  5 unsup   1
22  5   sup   1
23  5 unsup  NA

I tried the following code
fdat %>%
  group_by(id) %>%
  mutate(
    ind = {
      ones = match(1, ind)
      nos  = match("no", tail(stat, -ones)) + ones
      replace(ind, seq(ones,nos), 1)
    })

and also tried with
fdat %>%
  group_by(key_no = cumsum((stat == "unsup" & !is.na(lag(stat)) & lag(stat) == "unsup") |
                             (stat == "sup" & row_number() > 2 & lag(stat) == "unsup"& lag(stat, n = 2) == "sup"))) %>% fill(ind, .direction = "down") %>% ungroup() #%>%
  select(-key_no)


text:
Q: MPMoviePlayerController and custom controls iOS8 - (UIView*)getContainerView
{
    UIView *playerControls = (self.videoPlayer.view ? self.videoPlayer.view : self.view);

    NSString* containerViewName = [self getContainerViewName]; **//@"MPSwipableView" gets returned**
    for(UIWindow* tempWindow in [[UIApplication sharedApplication]windows]){
        for(UIView* tempView in [tempWindow subviews]){
            if ([[tempView description] rangeOfString:containerViewName].location != NSNotFound){
                playerControls = tempView;
                break;
            }
        }
    }

    if(playerControls == nil){
        NSLog(@"player ERROR : movieDidEnterFullScreen , no view named %@ was found",containerViewName);
    }
    return playerControls;
}

- (void)addCustomControls
{
//...//

UIView *controlsPlaceholder = [self getContainerView];
    if (controlsPlaceholder) {
        if (![controlsPlaceholder.subviews containsObject:self.customControls.view]) {
            [controlsPlaceholder addSubview:self.customControls.view];
        }else{
            [controlsPlaceholder bringSubviewToFront:self.customControls.view];
        }
    }
//...//
    if (self.tapGestureRecognizer == nil) {
        self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
        self.tapGestureRecognizer.delegate = self;
    }
    if ([Device] is_iPad]) {
        [self.customControls.view addGestureRecognizer:self.tapGestureRecognizer];
    }
    else {
        [self.videoPlayer.view addGestureRecognizer:self.tapGestureRecognizer];
    }
}

===================
My problem is only with iOS8 while the player is in fullscreen. The handleTapGesture: is not called and also when I go in fullscreen the custom controls view disappears.
Any ideas?
Thanks in advance!

A: The "getContainerViewName" method has the following change:
- (NSString*)getContainerViewName
{
    if ([[PSDeviceInfo sharedInstance] is_iOS5]) {
        return @"UILayoutContainerView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS6]) {
        return @"MPSwipableView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS7]) {
        return @"MPSwipableView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS8]) {
        return@"MPSwipableView";
    }
    NSLog(@"player ERROR : getContainerViewName");
    return nil;
}

- (NSString*)getContainerViewName
{
    if ([[PSDeviceInfo sharedInstance] is_iOS5]) {
        return @"UILayoutContainerView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS6]) {
        return @"MPSwipableView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS7]) {
        return @"MPSwipableView";
    }
    if ([[PSDeviceInfo sharedInstance] is_iOS8]) {
        if (self.playerIsInfullScreen) {
            return @"UIInputSetContainerView";
        }else {
            return@"MPSwipableView";
        }
    }
    NSLog(@"player ERROR : getContainerViewName");
    return nil;
}

The custom controls view will respond to touch and it will also be visible. Hopefully this will help someone in need.


text:
Q: Why is this inequality true? $(a+b)^2\leq 2(a^2+b^2)$ Why is this inequality true? $a,b$ are real numbers.
$$
(a+b)^2=a^2+2ab+b^2\leq 2(a^2+b^2)
$$
I know $(a+b)^2=a^2+2ab+b^2 \geq 0$, but then?

A: Equivalently: $$a^2+2ab+b^2 \leq 2a^2+2b^2$$
Equivalently: $$0 \leq a^2-2ab+b^2$$
Equivalently: $$0 \leq (a-b)^2$$
This latter expression is true: squares are nonnegative.

A: $$(a-b)^2\geq0\\a^2-2ab+b^2\geq0\\a^2+b^2\geq2ab\\2a^2+2b^2\geq a^2+2ab+b^2\\2(a^2+b^2)\geq(a+b)^2$$

A: Because by C-S $$2(a^2+b^2)=(1^2+1^2)(a^2+b^2)\geq(1\cdot a+1\cdot b)^2=(a+b)^2$$


text:
Q: Magento 2 - Single instance, multiple websites with single store view each - How to configure Apache? I am trying to set Apache 2.4 to serve a new project on Magento 2 (EE).
The structure needs to be:
http://siteA.mydomain.com/     <-- (MAGE_RUN_CODE = aa_uk)
http://siteA.mydomain.com/de/  <-- (MAGE_RUN_CODE = aa_de)
http://siteA.mydomain.com/fr/  <-- (MAGE_RUN_CODE = aa_fr)

http://siteB.mydomain.com/     <-- (MAGE_RUN_CODE = bb_uk)
http://siteB.mydomain.com/de/  <-- (MAGE_RUN_CODE = bb_de)
http://siteB.mydomain.com/fr/  <-- (MAGE_RUN_CODE = bb_fr)

I am trying NOT to use .htaccess (Magento provides some for the various directories, root/, pub/, pub/static/)
The /de/ /fr/ and so on are real directories which only contain a symlink to ../index.php
When I tried using the .htaccess as follows, inside those subdirectories, the pages for each language were working correctly, so for example http://siteA.mydomain.com/de/contact/ was showing correctly with the MAGE_RUN_CODE being set:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteA.mydomain.com$
RewriteRule .* - [E=MAGE_RUN_CODE:aa_de]
RewriteCond %{HTTP_HOST} ^siteB.mydomain.com $
RewriteRule .* - [E=MAGE_RUN_CODE:bb_de]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]

The first problem I can't find a solution for is how to tell Apache to rewrite (?) the static assets: by default Magento will try to find all the css and such in http://siteA.mydomain.com/de/static/<subdirectories>/de_AT/mage/<etc>/something.js while they reside inside inside http://siteA.mydomain.com/static/<subdirectories>/de_AT/mage/<etc>/something.js (without /de/).
What complicate things is also that while some files do exist, others need to be handled by static.php as shown in the default Magento .htaccess section in /var/www/<magentoroot>/pub/static/.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* ../static.php?resource=$0 [L]

Now, trying without .htaccess (I moved them away), setting the following vhost in Apache does not work at all, other than the default store with UK language. I can see MAGE_RUN_CODE being set, I get a 404 even for /de/contact/
This is the relevant part of the vhost that I created using what's in the Magento provided .htaccess files:
    <VirtualHost *:80>

    DocumentRoot /var/www/html/pub

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^ siteA.mydomain.com $
    RewriteRule .* - [E=MAGE_RUN_CODE:aa_uk]
    RewriteCond %{REQUEST_URI} ^/de/
    RewriteRule .* - [E=MAGE_RUN_CODE:aa_de]
    RewriteCond %{ENV:REDIRECT_MAGE_RUN_CODE} (.+)
    RewriteRule .* - [E=MAGE_RUN_CODE:%1]

   <Directory /var/www/html/pub/de/>
    AllowOverride None
    Options +FollowSymLinks
    DirectoryIndex index.php

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php
    </Directory>

   <Directory /var/www/html/pub/>
        DirectoryIndex index.php
        AllowOverride None
        Options FollowSymLinks

        RewriteEngine on
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
        RewriteRule .* - [L,R=405]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-l
        RewriteRule .* index.php [L]

           [...]

    </Directory>

    <Directory /var/www/html/pub/static/>

        Options FollowSymLinks
        php_flag engine 0
        Options -MultiViews

        RewriteEngine On

        RewriteRule ^version.+?/(.+)$ $1 [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-l
        RewriteRule .* ../static.php?resource=$0 [L]

        [...]

    </Directory>

</VirtualHost>

The questions here being, first: can I not use .htaccess at all or is there some odd reason why it's necessary? I know not everything can be done inside it and not everything can be done inside the vhost configuration.
Second: is there anything wrong in my vhost that is preventing even the basic /de/contact/ page to be shown -let alone the /de/static/ resources not being passed?
Or is it even the whole strategy of sub-directories being wrong?
By the way, this works like a charm using Nginx, with a very simple and elegant configuration:
    location ~ /(ie|fr|de|us)/(static|media) {
         rewrite ie/(.*)$ /$1 last;
         rewrite fr/(.*)$ /$1 last;
         rewrite de/(.*)$ /$1 last;
         rewrite us/(.*)$ /$1 last;
    }

A:
The first problem I can't find a solution for is how to tell Apache to rewrite (?) the static assets

Actually, you don't need to do that. Instead of setting http://siteA.mydomain.com/de/ as Base URL, set it as Base Link URL, and keep the Base URL as http://siteA.mydomain.com/, configuring it in the website level. This will tell Magento to look for assets on your root path, so you don't even need to rewrite the static files, whilst the URLs for products and other links will be generated using /de/.
So you configuration for aa_de should look like this:

(Base URL is configured in the website level, while the Base Link URL is configured in the store level)


text:
Q: Spring Boot App. Вызов хранимых процедур. Модель данных Есть классический микросервис на Spring Boot.
Общение с БД в основном построено на вызове хранимых функций, возвращающих json.
На данном этапе, json, возвращенный базой, во многих операциях идентичен json-ну, который нужно отдать, к примеру, на фронтенд.
Вопрос касательно модели данных:

*

*нужен ли отдельный слой модели данных между БД и бэкендом (по типу слоя Entity) и тогда придется делать маппинг между этим слоем и DTO (во многих случаях один к одному)?

*Или json, возвращенный хранимой функцией, сразу маппить в DTO?


text:
Q: UnityEvent Loses Its Custom Inspector When Serialized in a class as a property so i have an array of Serializable classes, each with its own array of Serializable classes each of those has a UnityEvent.
class a : ScriptableObject
{
    entry[] entries
}

[Serializable]
class entry
{
    option[] Options
}

[Serializable]
class option
{
    string name;
    UnityEvent action;
}

the inspector of action
as opposed to the normal inspector view
(example of normal inspector)

A: You can't serialize a UnityEvent. You need to create a custom class for this, like this:
https://answers.unity.com/questions/1275147/can-you-force-unity-to-serialize-a-unityevent-in-t.html


text:
Q: Using non-const variable as index to constexpr array to pass to template parameter I have a constexpr size_t array whose members will be passed to the template parameters of a class that gets initialized, iterating over the array to construct and use several differently templated objects. Here's the general idea:
template <size_t N>
class Foo
{
    // magic
};

constexpr size_t c_arr[] = { 2, 5, 3, 2 };

for (int i = 0; i < 4; i++)
{
    Foo<c_arr[i]> foo;
    foo.bar();
}

However, this will raise the following error:
templ_arr.cpp: In function 'int main()':
templ_arr.cpp:56:21: error: the value of 'i' is not usable in a constant expression
         Foo<c_arr[i]> foo;
                     ^
templ_arr.cpp:51:14: note: 'int i' is not const
     for (int i = 0; i < 3; i++)
              ^
templ_arr.cpp:56:20: note: in template argument for type 'long unsigned int'
         Foo<c_arr[i]> foo;

I can't seem to find a way to use const_cast on i to allow it to be used inside the parameter, nor can I do something like this to get around it, as it gives me the same error:
for (int i = 0; i < 4; i++)
{
    const int j = i;
    Foo<c_arr[j]> f;
    foo.bar();
}

What am I doign wrong, and how can I get around this?

A: If you want values to be used as template parameter, use std::integer_sequence
template <size_t N>
class Foo
{
 public:
  void bar() {}
};

template<std::size_t ...I>
void foo_bar(std::index_sequence<I...>) {
  int dummy[] = { (Foo<I>{}.bar(), 0) ... };
  // ((Foo<I>{}.bar()), ...); if using C++17 or above
}

int main() {
  constexpr std::index_sequence<2, 5, 3, 2> id;

  foo_bar(id);
}


text:
Q: Trouble with Interfaces, Inheritance, and Polymorphism I have come to a point in my program where my polymorphism is broken. I realize that this is in my code, and I understand why; I'm just not sure how best to resolve it.
I have three model classes which have the same interface, but very significantly different implementations. I created an interface, and then three independent classes, which also derive from a ModelBase class:
public interface IMyModel
{ ... }

public class MyModelA : ModelBase, IMyModels
{ ... }

public class MyModelB : ModelBase, IMyModels
{ ... }

public class MyModelC : ModelBase, IMyModels
{ ... }

So far fine and dandy.
I have a ViewModel base class, which takes a model as a constructor:
public abstract class MyViewModelBase
{
    public MyViewModelBase(ModelBase Model)
    this.model = Model;
}

Now where I am caught; I want to have a concrete ViewModel class that can accept any of the three Model classes above:
public class MyViewModel : MyViewModelBase
{
    MyViewModel(IMyModel Model) : base (Model)   // <- Invalid Polymorphism!
    {
        // More here
    }
}

This doesn't work, because it is possible for an implementation of IMyModel to not be based on ModelBase.  The argument cannot be safely passed to the base constructor.
I can see one solution being to create an abstract base class derived from ModelBase for these models with exception-throwing content, and using that as the type in my ViewModel.  I had started with a base class, but found that almost every part had some difference!  However, that seems like a lot of work.  Also, it won't ensure that derived classes implement everything (like an interface does).  Finally, it seems to devalue the interface concept (indeed, I wouldn't need one anymore).
I don't see any way of marking the interface as saying that derived classes must have a specific base class.  It would be nice if I could do this, but it's not allowed:
public interface IMyModel : MyModelBase
{ ... }

Is there a better way to do this?
Clarification:
I probably oversimplified the names here.  I have other Models and ViewModels using the base classes, but not implementing the interface.
public class MyOtherModel : ModelBase  // But not IMyModel!
{ ... }

public class MyOtherViewModel : MyViewModelBase
{
    MyOtherViewModel(MyOtherModel Model) : base(Model)  // This works
    { ... }
}

A: you could use generic constraints:
public class MyViewModel<T> : MyViewModelBase where T : IMyModel , ModelBase
{
    MyViewModel(T model) : base (model)   // T inherits ModelBase and implements IMyModel , so it is legal
    {
        // More here
    }
}

A: You could make your base class implement the interface, then inherit your implementation classes from the base class, marking the base class and methods as abstract (MustInherit/MustOverride in VB parlance).  This would give you your polymorphism and guarantee the interface.

A: Often (not always) when you find yourself building an Abstract Base Class it means you are trying to share both an interface and some common logic. Perhaps you can split these two things?
Move the common interface into IMyModels, and extract the common functionality into a separate class. Then include an instance of that helper class in each model. Essentially use composition to share functionality instead of inheritance.

A: Make ModelBase implement IMyModel. If ModelBase does not implement all methods of the interface, implement them as abstract methods.

A: To my understanding

*

*Models are stupid Data containers

*Interfaces describe behaviour and Functionality, not data.

So why bother putting interfaces on the models at all?
@Yochai : Good point, using Generics - saves code, but you must first declare base classes (only one per class, there's no mixed inheritance in C#), then any amount of interfaces, thus your code should be:
public class MyViewModel<T> : MyViewModelBase where T : ModelBase, IMyModel


text:
Q: GridView page numbers appearing in separate columns far apart I am using a gridview as below. Somehow the page numbers appear in separate columns. I want them to appear together in the center. How do I bring the page numbers together in the center?
 <asp:GridView ID="GridView1" runat="server" Width="100%" OnRowCommand="GridView1_RowCommand" CssClass="GridStyle" AllowPaging="true" AllowSorting="True" AutoGenerateColumns="False" BorderColor="Black" OnPageIndexChanging="GridView1_PageIndexChanging">

 <PagerStyle Font-Underline="false" BorderColor="White" BorderStyle="None" BorderWidth="0"  />

CSS
.GridStyle {
table-layout: auto;
border: 1px solid black;
background-color: White;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
/*border-collapse: collapse;
margin-bottom: 0px;*/
}

.GridStyle tr {
    border: 1px solid black;
    color: black;
    background-color: #E5E4F2;
    height: 25px;
}

.GridStyle th {
    background-color: white;
    border: none;
    text-align: left;
    font-weight: bold;
    font-size: 15px;
    padding: 4px;
    color: black;
}

.GridStyle tr th a, .GridStyle tr th a:visited {
    color: red;
}

.GridStyle tr th, .GridStyle tr td table tr td {
    color: #484585;
    border: 1px solid black;
}

.GridStyle td {
    border-bottom: 1px solid black;
    padding: 2px;
}

Like this

A: Your CSS class of gridViewPager may be sizing the page number elements against the  table width.
Review gridViewPager, particularly in regards to any width: 100%;.

A: The pager in a GridView is a nested table. So it is probably inheriting a 100% width property from a parent element.
In HTML, the pager looks like this.

                1
                2
                3

You can either fix the inheriting or give the pager it's own class.
<PagerStyle CssClass="pagerCssClass" Font-Underline="false" BorderColor="White" BorderStyle="None" BorderWidth="0" />


text:
Q: Is ist possible to get a MemoryMXBean instance with a remote JVM? I found this nice article which explains how to query your current memory for your VM http://recursor.blogspot.com/2006/10/memory-notifications-in-java.html
My question is, is it possible to get an instance of the MemoryMXBean class from a remote VM easily (and how would I do that), or do I have to resort to query the MBeans manually?

A: as described on this page you can access it remotly, with the MBeanServerConnection:
   MBeanServerConnection mbs;

   // Connect to a running JVM (or itself) and get MBeanServerConnection
   // that has the JVM MXBeans registered in it
   ...

   try {
       // Assuming the RuntimeMXBean has been registered in mbs
       ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);

       // Get standard attribute "VmVendor"
       String vendor = (String) mbs.getAttribute(oname, "VmVendor");
   } catch (....) {
       // Catch the exceptions thrown by ObjectName constructor
       // and MBeanServer.getAttribute method
       ...
   }

however, as far as I understand, you won't be able to use the Java interface, you'll need to query the properties you want with
CompositeDataSupport mem = (CompositeDataSupport)serv.getAttribute(memory, "NonHeapMemoryUsage") ;

and
mem.get("committed")

which is quite awfull ('stringly-typed' interface, as they said in another question).
As Brian Agnew said, the JConsole view is very usefull to find out where the information you want is stored.

A: You can query JMX beans remotely. See the JMX Connectors section in the JMX tutorial.
The straightforward approach may be to use JConsole to determine what you want to query (in this case your MemoryMXBean) and then code around that.