text:
Q: How to force a route in React I am trying to follow this SO Answer to "go home" after I close my Modal...
import React, { Suspense, useState } from 'react';
import { BrowserRouter, Route, Switch, useHistory } from "react-router-dom";
import './App.css';
import { Button } from 'reactstrap';
import Slideshow from './components/Slideshow.js';
import LogoHeader from './components/LogoHeader';
import Login from "./components/Login/Login.js";
import ChangePassword from "./components/Login/ChangePassword.js";
import useToken from "./components/useToken";
import NewFooter from "./components/NewFooter";
import GetCategories from "./components/GetCategories";
import { formatter } from './components/common.js'
import { GetCart, Increment, Decrement } from './components/ShoppingCart/CartHandler.js'
import CheckoutModal from './components/ShoppingCart/CheckoutModal.js'

const FeaturedCards = React.lazy(() => import('./components/featuredCards'));
const ProdCard = React.lazy(() => import('./components/productCards'));
const Portal = React.lazy(() => import('./components/Portal/portal'));

function App() {
    const { token, setToken } = useToken();
    const [cart, setCart] = useState(GetCart());
    const [isOpen, setIsOpen] = useState(false);
    const history = useHistory();

    if (!token) {
        return <Login setToken={setToken} />
    }

    if (token.forcePasswordChange === true) {
        return <ChangePassword setToken={setToken} />
    }

    function handleIncrementClick(item) {
        Increment(item.ItemNumber, cart);
        setCart(GetCart);
    }

    function handleDecrementClick(item) {
        Decrement(item.ItemNumber, cart);
        setCart(GetCart);
    }

    let onRequestClose = () => {
        setIsOpen(false);
        setCart(GetCart);
        history.push('/')
    }

    let handleClick = () => {
        setIsOpen(true)
    }

    return (

            <BrowserRouter>

Hello, {token.firstName}

                <LogoHeader />
                <GetCategories />
                <Switch>
                    <Route path="/cart">
                        <Suspense fallback={
Loading...
}>

                                            Item Number
                                            Price
                                            Quantity

                                        {cart.map(item =>

                                                {item.ItemNumber}
                                                {formatter.format(item.Price)}
                                                {item.Quantity}
                                                <Button className="BtnIncrement" onClick={() => handleIncrementClick(item)}>{'+'}</Button>
                                                <Button className="BtnDecrement" onClick={() => handleDecrementClick(item)}>{'-'}</Button>

                                        )}

                                <Button onClick={() => handleClick()}>Checkout</Button>
                                {isOpen ? <CheckoutModal onRequestClose={onRequestClose} /> : null}

                        </Suspense>
                    </Route>
                    <Route path="/portal">
                        <Suspense fallback={
Loading...
}>
                            <Portal />
                        </Suspense>
                    </Route>
                    <Route path="/">
                        <Slideshow id="slideshow" />

Featured Products

                            <Suspense fallback={
Loading...
}>

                                <FeaturedCards setCartFunc={setCart} />

                            </Suspense>

Most Popular

                            <Suspense fallback={
Loading...
}>
                                <ProdCard />
                            </Suspense>

New Products

                            <Suspense fallback={
Loading...
}>
                                <ProdCard />
                            </Suspense>

                    </Route>
                </Switch>
                <NewFooter />
            </BrowserRouter>

    );
}
export default App;

UPDATE
As requested, my CheckoutModal:
import React from 'react';
import "./Checkout.scss"
import AddressBlock from './AddressBlock';
import PaymentBlock from './PaymentBlock';
import ShippingBlock from './ShippingBlock';
import TotalsBlock from './TotalsBlock';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';

class CheckoutModal extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            name: 'React',
            shippingMethod: null
        };
    }

    setShippingMethod(method) {
        this.setState(state => ({ ...state, shippingMethod: method }));
    }

    render() {
        const buttonStyles = {
            position: "absolute",
            top: "-35px",
            right: "10px",
            border: "0",
            background: "none"
        };

        return (
            <Modal id="checkout"
                isOpen
                size='xl'>
                <button onClick={this.props.onRequestClose} style={buttonStyles}>x</button>
                <ModalHeader className="header">
                    Checkout
                </ModalHeader>
                <ModalBody>

                        <AddressBlock />
                        <ShippingBlock setShippingMethod={this.setShippingMethod.bind(this)} shippingMethod={this.state.shippingMethod}/>

                        <PaymentBlock onRequestClose={this.props.onRequestClose} />
                        <TotalsBlock />

                </ModalBody>
            </Modal>
        );
    }
}
export default CheckoutModal;

I am getting history is undefined from my function onRequestClose. I tried prepending this but that didn't work. Is this because App.js is not a class component or rather just a function? Any tips or suggestions would be greatly appreciated.
nodejs 16.13.0
react-router-dom 8.1.2

A: Issue
You are using/calling the useHistory hook from App but App is the very component rendering the BrowserRouter that provides the routing context to the app, including a valid history object reference.
Solution
Move the BrowserRouter out of App, likely into the index.js where you are rendering App. This is to provide a valid routing context for App and all other components in the App's subtree to access.
Example index.js
...
import { BrowserRouter } from "react-router-dom";
...

const rootElement = document.getElementById("root");
ReactDOM.render(
  <StrictMode>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </StrictMode>,
  rootElement
);

App
function App() {
  const { token, setToken } = useToken();
  const [cart, setCart] = useState(GetCart());
  const [isOpen, setIsOpen] = useState(false);
  const history = useHistory(); // <-- will now be defined

  ...

  const onRequestClose = () => {
    setIsOpen(false);
    setCart(GetCart);
    history.push('/'); // <-- should navigate now
  }

  ...

  return (

Hello, {token.firstName}

      <LogoHeader />
      <GetCategories />
      <Switch>
        <Route path="/cart">
          <Suspense fallback={
Loading...
}>
            <>

                ...

              <Button onClick={handleClick}>Checkout</Button>
              {isOpen && <CheckoutModal onRequestClose={onRequestClose} />}
            </>
          </Suspense>
        </Route>
        ...
      </Switch>
      <NewFooter />

  );
}

A: Using useRouter in App.js will not work. Becourse its outside the browser router. BrowserRouter wrapped components can only able to use useRouter. Hope this is helpfull.


text:
Q: How to convert string int JSON into real int with json.loads I'm trying to convert a string which represents a JSON object to a real JSON object using json.loads but it doesn't convert the integers:
(in the initial string, integers are always strings)
$> python
Python 2.7.9 (default, Aug 29 2016, 16:00:38)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> c = '{"value": "42"}'
>>> json_object = json.loads(c, parse_int=int)
>>> json_object
{u'value': u'42'}
>>> json_object['value']
u'42'
>>>

Instead of {u'value': u'42'} I'd like it becomes {u'value': 42}. I know I can run through the whole object, but I don't want to do that, it's not really efficient to do it manually, since this parse_int argument exists (https://docs.python.org/2/library/json.html#json.loads).
Thanks to Pierce's proposition:
Python 2.7.9 (default, Aug 29 2016, 16:00:38)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>>
>>> class Decoder(json.JSONDecoder):
...     def decode(self, s):
...         result = super(Decoder, self).decode(s)
...         return self._decode(result)
...     def _decode(self, o):
...         if isinstance(o, str) or isinstance(o, unicode):
...             try:
...                 return int(o)
...             except ValueError:
...                 try:
...                     return float(o)
...                 except ValueError:
...                     return o
...         elif isinstance(o, dict):
...             return {k: self._decode(v) for k, v in o.items()}
...         elif isinstance(o, list):
...             return [self._decode(v) for v in o]
...         else:
...             return o
...
>>>
>>> c = '{"value": "42", "test": "lolol", "abc": "43.4",  "dcf": 12, "xdf": 12.4}'
>>> json.loads(c, cls=Decoder)
{u'test': u'lolol', u'dcf': 12, u'abc': 43.4, u'value': 42, u'xdf': 12.4}

A: As we established in the comments, there is no existing functionality to do this for you. And I read through the documentation and some examples on the JSONDecoder and it also appears to not do what you want without processing the data twice.
The best option, then, is something like this:
class Decoder(json.JSONDecoder):
    def decode(self, s):
        result = super().decode(s)  # result = super(Decoder, self).decode(s) for Python 2.x
        return self._decode(result)

    def _decode(self, o):
        if isinstance(o, str) or isinstance(o, unicode):
            try:
                return int(o)
            except ValueError:
                return o
        elif isinstance(o, dict):
            return {k: self._decode(v) for k, v in o.items()}
        elif isinstance(o, list):
            return [self._decode(v) for v in o]
        else:
            return o

This has the downside of processing the JSON object twice — once in the super().decode(s) call, and again to recurse through the entire structure to fix things. Also note that this will convert anything which looks like an integer into an int. Be sure to account for this appropriately.
To use it, you do e.g.:
>>> c = '{"value": "42"}'
>>> json.loads(c, cls=Decoder)
{'value': 42}

A: In addition to the Pierce response, I think you can use the json.loads object_hook parameter instead of cls one, so you don't need to walk the json object twice.
For example:
def _decode(o):
    # Note the "unicode" part is only for python2
    if isinstance(o, str) or isinstance(o, unicode):
        try:
            return int(o)
        except ValueError:
            return o
    elif isinstance(o, dict):
        return {k: _decode(v) for k, v in o.items()}
    elif isinstance(o, list):
        return [_decode(v) for v in o]
    else:
        return o

# Then you can do:
json.loads(c, object_hook=_decode)

As @ZhanwenChen pointed out in a comment, the code above is for python2. For python3 you'll need to remove the or isinstance(o, unicode) part in the first if condition.

A: For my solution I used object_hook, which is useful when you have nested json
>>> import json
>>> json_data = '{"1": "one", "2": {"-3": "minus three", "4": "four"}}'
>>> py_dict = json.loads(json_data, object_hook=lambda d: {int(k) if k.lstrip('-').isdigit() else k: v for k, v in d.items()})

>>> py_dict
{1: 'one', 2: {-3: 'minus three', 4: 'four'}}

There is a filter only for parsing a json key to int. You can use int(v) if v.lstrip('-').isdigit() else v to filter for json values too.

A: In addition to @juanra and therefore @Pierce Darragh I added a conversion for boolean values from string. My example is a dict converted from XML that contains 'true' and 'false' that won't be loaded as JSON-boolean True and False automatically with the suggested answers.
def _decode(o):
    if isinstance(o, str):
        if o.lower() == 'true':
            return True
        elif o.lower() == 'false':
            return False
        else:
            try:
                return int(o)
            except ValueError:
                return o
    elif isinstance(o, dict):
        return {k: _decode(v) for k, v in o.items()}
    elif isinstance(o, list):
        return [_decode(v) for v in o]
    else:
        return o

According what you need you can also include other strings for boolean conversion with Converting from a string to boolean in Python?

A: def convert_to_int(params):
    for key in params.keys():
        if isinstance(params[key], dict):
            convert_to_int(params[key])
        elif isinstance(params[key], list):
            for item in params[key]:
                if not isinstance(item, (dict, list)):
                    item = int(item)
                else:
                    convert_to_int(item)
        else:
            params[key] = int(params[key])
    return params

print convert_to_int({'a': '3', 'b': {'c': '4', 'd': {'e': 5}, 'f': [{'g': '6'}]}})

redpajama_set_name: RedPajamaStackExchange


text:
Q: IBM MQ : Connection to host 'localhost/127.0.0.1:1414' rejected My spring-boot application runs in openshift and connects to IBM MQ.
The JMS configuration is defined in application.yaml. But when the spring-boot application starts, the below exception occurs.  What could be the cause of this exception ?
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
         at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         ... 96 common frames omitted
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'localhost(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9204: Connection to host 'localhost/127.0.0.1:1414' rejected. [1=java.net.ConnectException[Connection refused (Connection refused)],3=localhost/127.0.0.1:1414,4=TCP,5=Socket.connect]],3=localhost(1414),4=,5=RemoteTCPConnection.bindAndConnectSocket]
         at com.ibm.mq.jmqi.remote.api.RemoteFAP$Connector.jmqiConnect(RemoteFAP.java:13610) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.api.RemoteFAP$Connector.access$100(RemoteFAP.java:13150) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1449) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1390) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:377) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:562) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:391) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         ... 95 common frames omitted
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'localhost/127.0.0.1:1414' rejected. [1=java.net.ConnectException[Connection refused (Connection refused)],3=localhost/127.0.0.1:1414,4=TCP,5=Socket.connect]
         at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.bindAndConnectSocket(RemoteTCPConnection.java:932) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:1419) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:1012) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getNewConnection(RemoteConnectionSpecification.java:688) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:282) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:181) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:127) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         at com.ibm.mq.jmqi.remote.api.RemoteFAP$Connector.jmqiConnect(RemoteFAP.java:13350) ~[com.ibm.mq.allclient-9.2.4.0.jar:9.2.4.0 - p924-L211104]
         ... 101 common frames omitted

spring:
  environment: DEV
  jms:
    wmq:
      host: mq.cloud-mq.svc.cluster.local
      port: 1414
      queue-manager:
      channel: DEV.APP.SVRCONN

A: Connection to host 'localhost/127.0.0.1:1414' rejected

Your MQ server is deployed on hostlocalhost, ie in the same pod as you app ???
Check where you define the IBM MQ server host in your config, it is probably the source of the error

A: That Spring is trying to connect to localhost(1414) implies that the configuration in application.yaml isn't quite correct.
It is not clear if you are you making use of mq-jms-spring-boot-starter ( https://github.com/ibm-messaging/mq-jms-spring ). If you are then you may be falling into a default trap, where default attributes are:

The default attributes are
ibm.mq.queueManager=QM1
ibm.mq.channel=DEV.ADMIN.SVRCONN
ibm.mq.connName=localhost(1414)
ibm.mq.user=admin
ibm.mq.password=passw0rd

At least the last three will need to be set to valid values in line with your configuration.
You can find some more samples here - https://github.com/ibm-messaging/mq-dev-patterns/tree/master/Spring-JMS


text:
Q: NoClassDefFoundError thrown when trying to use get() methods from OSHI I'm using OSHI (Operating System Hardware Information), a java project, intended to obtain system information.
I'm using NetBeans IDE and have added the individual jar files for each of the dependencies to the project library. But whenever I try to use any of the get() methods, a NoClassDefFoundError is thrown. For example, this is my code where I try to get the OS information (I've added all the necessary import statements);
SystemInfo si=new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
Sensors sense=hal.getSensors();
System.out.println("Cpu Temperature" + sense.getCpuTemperature());

When I run this code, it shows the following error;
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Variant$VARIANT
at oshi.hardware.platform.windows.WindowsSensors.getCpuTemperature(WindowsSensors.java:54)
at pandorastress.PandoraUI.b1ActionPerformed(PandoraUI.java:168)
at pandorastress.PandoraUI.access$000(PandoraUI.java:55)
at pandorastress.PandoraUI$1.actionPerformed(PandoraUI.java:83)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException:
com.sun.jna.platform.win32.Variant$VARIANT
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 40 more

is there any way to rectify this?

A: Based on some previous answers, you need Java Native Access (JNA) library and a logging system that implements slf4j.
To add the JNA support you can download the appropriate (based on your system) bundle from this link.
Also, you can try to add the JNA-bundle directly by downloading the jar and adding it to your project.
Otherwise, you can change your project to a maven project and then use the maven to build your project. This will download all the dependencies.


text:
Q: Can JavaScript save values without PHP? I am begginer in programming. I have made these stopwatch for speedsolves using HTML and JavaScript.
Is there any way of saving my average solve time using Javascript only?
For instance i have some variable with loop:
var time=0;
if (true){
  time++;
}

and after I close the HTML site, close the browser and turn off the computer, after opening the site again I want to get  var time=value before closing the site
I'm familiar with PHP and databases, but I dont really want to use it, since I have to start a server.

A: Little more information will help, but, as you are talking of storage, you can use localstorage or sessionstorage within javascript to store the values.

A: For saving files on the local device, you can use FileSaver. But in your situation, an easier solution would be to take advantage of localstorage.
Note: From what I've found, LocalStorage won't work without a server. So if you want to store data and aren't using a server, FileSaver may work better. Then again, I don't know if it's possible to load the data in a file saved in FileSaver into javascript in a browser, especially if you don't have a server

A: If you just want to save data for your program to read later, you can use localStorage or sessionStorage. That is, localStorage.setItem('name', 'value') and localStorage.getItem('name') to read it. (They're the same, except sessionStorage gets cleared once the browser is closed, while localStorage doesn't.)
To actually save a file, you can do that only by triggering it to be downloaded. First you create a Blob with the content you want for the file, then you get an object URL for that Blob. Assign the URL to the href of a link with a "download" attribute and click it.
function saveFile(contents, name) {
  const blob = new Blob([contents], {type: 'text/plain'});
  const url = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.download = name;
  link.href = url;
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}


text:
Q: How to Use @NotNull Annotation Correctly? I have used @NotNull annotation on Java bean class for JSF in register page. But it is not working as expceted.
Here is my xhtml page part :
User Name : <h:inputText value="#{user.userName}" />

And here is my Java bean part :
@NotNull(message = "User name cannot be null")
private String userName;

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

But it still save userName to database(PostgreSQL) as ''. So technically it is not null.
I know may be I must also make not null that column on database. But what for we use @NotNull annotation then?

A: I believe what you want to use is @NotBlank. Here is some reference between @NotNull,@NotEmpty, and @NotBlank.
public class UserNotBlank {

    @NotBlank(message = "Name may not be blank")
    private String name;

    // standard constructors / getters / toString

}

@NotNull: a constrained CharSequence, Collection, Map, or Array is valid as long as it's not null, but it can be empty
@NotEmpty: a constrained CharSequence, Collection, Map, or Array is valid as long as it's not null and its size/length is greater than zero
@NotBlank: a constrained String is valid as long as it's not null and the trimmed length is greater than zero


text:
Q: wired dmesg output and high cpu load I have like 50 Linux servers with the same hardware and kernel,
but recently found that some of them suffers from high CPU load, runs very slowly, top and ps show TIME column with impossible large numbers;
ps aux output with many 99% CPU.
the kernel is Linux 3.0.13, it's tailored:
    Linux  3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
ps with high cpu :
#ps u |grep 99\.9
root      1604 99.9  0.0 13760 2132 pts/1    Ss+  Oct29 38443218:17 -bash
root     13011 99.9  0.0  1532  588 tty1     Ss+  Oct28 20833538:06 /sbin/mingetty --noclear tty1
root     13014 99.9  0.0  1532  572 tty4     Ss+  Oct28 600517:28 /sbin/mingetty tty4
root     13016 99.9  0.0  1532  576 tty6     Ss+  Oct28 20833538:06 /sbin/mingetty tty6
root     14501 99.9  0.0 13760 2124 pts/2    Ss   18:30 1501293:42 -bash

and top with very large TIME:
#top
top - 18:34:20 up 2 days,  7:39,  2 users,  load average: 7.08, 7.36, 7.96
Tasks: 158 total,  11 running, 111 sleeping,   2 stopped,  34 zombie
Cpu0 : 71.2% us, 17.2% sy,  0.7% ni, 10.9% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu1 :  0.6% us,  1.3% sy,  0.0% ni, 98.1% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu2 : 15.2% us,  8.9% sy,  0.0% ni, 65.2% id,  0.0% wa,  0.3% hi, 10.3% si
Cpu3 : 16.3% us, 10.0% sy,  0.0% ni, 64.8% id,  0.0% wa,  0.0% hi,  9.0% si
Cpu4 : 25.9% us, 12.3% sy,  0.0% ni, 56.1% id,  0.0% wa,  0.0% hi,  5.6% si
Cpu5 :  1.0% us,  3.6% sy,  0.0% ni, 86.9% id,  0.0% wa,  0.0% hi,  8.5% si
Cpu6 :  0.3% us,  0.0% sy,  0.0% ni, 99.7% id,  0.0% wa,  0.0% hi,  0.0% si
Cpu7 : 10.6% us,  7.9% sy,  0.0% ni, 81.5% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:  16444164k total, 15097904k used,  1346260k free,   107516k buffers
Swap:        0k total,        0k used,        0k free,  5322840k cached

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
337 root      20   0 11392  732  400 S 99.9  0.0 324224:12 keepalive.sh
14499 root      20   0  7564 1836 1476 S 99.9  0.0 369896:40 sshd
13624 root      20   0  1348  212  172 S 99.9  0.0 486338:00 sleep.out
32713 root      20   0  1908  956  696 R  0.3  0.0  74529:31 top
1   root      20   0   720  224  188 S  0.0  0.0 436089:26 init
2   root      20   0     0    0    0 S  0.0  0.0 369896:40 kthreadd
3   root      20   0     0    0    0 S  0.0  0.0 385563:56 ksoftirqd/0
6   root      RT   0     0    0    0 S  0.0  0.0 303560:22 migration/0
7   root      RT   0     0    0    0 R  0.0  0.0 300258:44 watchdog/0
8   root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1
9   root      20   0     0    0    0 S  0.0  0.0 300258:44 kworker/1:0
10  root      20   0     0    0    0 S  0.0  0.0  23965:30 ksoftirqd/1
12  root      RT   0     0    0    0 R  0.0  0.0 600517:28 watchdog/1
13  root      RT   0     0    0    0 S  0.0  0.0 303408:44 migration/2
15  root      20   0     0    0    0 S  0.0  0.0 700896:24 ksoftirqd/2
16  root      RT   0     0    0    0 R  0.0  0.0 600517:28 watchdog/2

defunct processes:
root      5381 32001 99 11:42 ?        208-12:18:44 [sh] <defunct>
root      5383 32001 99 11:42 ?        208-12:18:44 [sh] <defunct>
root      5385 32001  0 11:42 ?        00:00:00 [sh] <defunct>
root      5387 32001  0 11:42 ?        00:00:00 [sh] <defunct>
root     32162 31998 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32164 32000 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32166 32000  0 11:42 ?        00:00:00 [sh] <defunct>
root     32168 31999 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32170 31999  0 11:42 ?        00:00:00 [sh] <defunct>
root     32172 31999 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32174 32004  0 11:42 ?        00:00:00 [sh] <defunct>
root     32175 31997 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32177 32004 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32179 31997 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32181 32004  0 11:42 ?        00:00:00 [sh] <defunct>
root     32183 32004 99 11:42 ?        208-12:18:44 [sh] <defunct>
root     32185 31997  0 11:42 ?        00:00:00 [sh] <defunct>

eight cpus alike:
#cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 45
model name      : Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz
stepping        : 7
cpu MHz         : 2400.236
cache size      : 10240 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
bogomips        : 4800.47
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

the abnormal dmesg(half past the benning,the first column):
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.0.13-0.27-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b)
[    0.000000] Command line: root=/dev/sda1 splash=0 crashkernel=256M-:128M@16M vga=0x31a
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 0000000000093400 (usable)
[    0.000000]  BIOS-e820: 0000000000093400 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000007e69b000 (usable)
[    0.000000]  BIOS-e820: 000000007e69b000 - 000000007e7a9000 (ACPI NVS)
[    0.000000]  BIOS-e820: 000000007e7a9000 - 000000007f3a9000 (reserved)
[    0.000000]  BIOS-e820: 000000007f3a9000 - 000000007f423000 (ACPI data)
[    0.000000]  BIOS-e820: 000000007f423000 - 000000007f4af000 (reserved)
[    0.000000]  BIOS-e820: 000000007f4af000 - 000000007f4b1000 (usable)
[    0.000000]  BIOS-e820: 000000007f4b1000 - 000000007f4b2000 (ACPI NVS)
[    0.000000]  BIOS-e820: 000000007f4b2000 - 000000007f4bb000 (reserved)
[    0.000000]  BIOS-e820: 000000007f4bb000 - 000000007f4c2000 (ACPI NVS)
[    0.000000]  BIOS-e820: 000000007f4c2000 - 000000007f4e4000 (reserved)
[    0.000000]  BIOS-e820: 000000007f4e4000 - 000000007f56a000 (ACPI NVS)
[    0.000000]  BIOS-e820: 000000007f56a000 - 000000007f7e0000 (usable)
[    0.000000]  BIOS-e820: 000000007f7e0000 - 000000007f7e1000 (ACPI NVS)
[    0.000000]  BIOS-e820: 000000007f7e1000 - 000000007f7e6000 (reserved)
[    0.000000]  BIOS-e820: 000000007f7e6000 - 000000007f800000 (usable)
[    0.000000]  BIOS-e820: 0000000080000000 - 0000000090000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fed1c000 - 00000000fed20000 (reserved)
[    0.000000]  BIOS-e820: 00000000ff000000 - 0000000100000000 (reserved)
[    0.000000]  BIOS-e820: 0000000100000000 - 0000000480000000 (usable)
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] DMI 2.7 present.
[    0.000000] DMI: empty empty/ S7057 , BIOS V1.01B 06/23/2014
[    0.000000] e820 update range: 0000000000000000 - 0000000000010000 (usable) ==> (reserved)
[    0.000000] e820 remove range: 00000000000a0000 - 0000000000100000 (usable)
[    0.000000] No AGP bridge found
[    0.000000] last_pfn = 0x480000 max_arch_pfn = 0x400000000
[    0.000000] MTRR default type: uncachable
[    0.000000] MTRR fixed ranges enabled:
[    0.000000]   00000-9FFFF write-back
[    0.000000]   A0000-BFFFF uncachable
[    0.000000]   C0000-FFFFF write-protect
[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 000000000000 mask 3FFC00000000 write-back
[    0.000000]   1 base 000400000000 mask 3FFF80000000 write-back
[    0.000000]   2 base 000080000000 mask 3FFF80000000 uncachable
[    0.000000]   3 disabled
[    0.000000]   4 disabled
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000]   8 disabled
[    0.000000]   9 disabled
[    0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
[    0.000000] e820 update range: 0000000080000000 - 0000000100000000 (usable) ==> (reserved)
[    0.000000] last_pfn = 0x7f800 max_arch_pfn = 0x400000000
[    0.000000] found SMP MP-table at [ffff8800000fd930] fd930
[    0.000000] initial memory mapped : 0 - 20000000
[    0.000000] Base memory trampoline at [ffff88000008e000] 8e000 size 20480
[    0.000000] Using GB pages for direct mapping
[    0.000000] init_memory_mapping: 0000000000000000-000000007f800000
[    0.000000]  0000000000 - 0040000000 page 1G
[    0.000000]  0040000000 - 007f800000 page 2M
[    0.000000] kernel direct mapping tables up to 7f800000 @ 1fffe000-20000000
[    0.000000] init_memory_mapping: 0000000100000000-0000000480000000
[    0.000000]  0100000000 - 0480000000 page 1G
[    0.000000] kernel direct mapping tables up to 480000000 @ 7f7ff000-7f800000
[    0.000000] RAMDISK: 37653000 - 37ff0000
[    0.000000] crashkernel reservation failed - memory is in use.
[    0.000000] ACPI: RSDP 00000000000f0490 00024 (v02 ALASKA)
[    0.000000] ACPI: XSDT 000000007f3a9080 00084 (v01 ALASKA    A M I 01072009 AMI  00010013)
[    0.000000] ACPI: FACP 000000007f3b21a8 000F4 (v04 ALASKA    A M I 01072009 AMI  00010013)
[    0.000000] ACPI: DSDT 000000007f3a9198 0900C (v02 ALASKA    A M I 00000001 INTL 20051117)
[    0.000000] ACPI: FACS 000000007f4c0f80 00040
[    0.000000] ACPI: APIC 000000007f3b22a0 000AA (v03 ALASKA    A M I 01072009 AMI  00010013)
[    0.000000] ACPI: MCFG 000000007f3b2350 0003C (v01 ALASKA OEMMCFG. 01072009 MSFT 00000097)
[    0.000000] ACPI: SRAT 000000007f3b2390 00330 (v01 A M I  AMI SRAT 00000001 AMI. 00000000)
[    0.000000] ACPI: SLIT 000000007f3b26c0 00030 (v01 A M I  AMI SLIT 00000000 AMI. 00000000)
[    0.000000] ACPI: HPET 000000007f3b26f0 00038 (v01 ALASKA    A M I 01072009 AMI. 00000004)
[    0.000000] ACPI: SSDT 000000007f3b2728 70104 (v02  INTEL    CpuPm 00004000 INTL 20051117)
[    0.000000] ACPI: EINJ 000000007f422830 00130 (v01    AMI AMI EINJ 00000000      00000000)
[    0.000000] ACPI: ERST 000000007f422960 00230 (v01  AMIER AMI ERST 00000000      00000000)
[    0.000000] ACPI: HEST 000000007f422b90 000A8 (v01    AMI AMI HEST 00000000      00000000)
[    0.000000] ACPI: BERT 000000007f422c38 00030 (v01    AMI AMI BERT 00000000      00000000)
[    0.000000] ACPI: BGRT 000000007f422c68 00038 (v00 ALASKA    A M I 01072009 AMI  00010013)
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] SRAT: PXM 0 -> APIC 0x00 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x02 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x04 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x06 -> Node 0
[    0.000000] SRAT: PXM 1 -> APIC 0x20 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x22 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x24 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x26 -> Node 1
[    0.000000] SRAT: Node 0 PXM 0 0-80000000
[    0.000000] SRAT: Node 0 PXM 0 100000000-280000000
[    0.000000] SRAT: Node 1 PXM 1 280000000-480000000
[    0.000000] NUMA: Initialized distance table, cnt=2
[    0.000000] NUMA: Node 0 [0,80000000) + [100000000,280000000) -> [0,280000000)
[    0.000000] Initmem setup node 0 0000000000000000-0000000280000000
[    0.000000]   NODE_DATA [000000027ffd9000 - 000000027fffffff]
[    0.000000] Initmem setup node 1 0000000280000000-0000000480000000
[    0.000000]   NODE_DATA [000000047ffd8080 - 000000047ffff07f]
[    0.000000]  [ffffea0000000000-ffffea0008bfffff] PMD -> [ffff880277e00000-ffff88027edfffff] on node 0
[    0.000000]  [ffffea0008c00000-ffffea000fbfffff] PMD -> [ffff880477600000-ffff88047e5fffff] on node 1
[    0.000000] Zone PFN ranges:
[    0.000000]   DMA      0x00000010 -> 0x00001000
[    0.000000]   DMA32    0x00001000 -> 0x00100000
[    0.000000]   Normal   0x00100000 -> 0x00480000
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[7] active PFN ranges
[    0.000000]     0: 0x00000010 -> 0x00000093
[    0.000000]     0: 0x00000100 -> 0x0007e69b
[    0.000000]     0: 0x0007f4af -> 0x0007f4b1
[    0.000000]     0: 0x0007f56a -> 0x0007f7e0
[    0.000000]     0: 0x0007f7e6 -> 0x0007f800
[    0.000000]     0: 0x00100000 -> 0x00280000
[    0.000000]     1: 0x00280000 -> 0x00480000
[    0.000000] On node 0 totalpages: 2091184
[    0.000000]   DMA zone: 56 pages used for memmap
[    0.000000]   DMA zone: 5 pages reserved
[    0.000000]   DMA zone: 3910 pages, LIFO batch:0
[    0.000000]   DMA32 zone: 14280 pages used for memmap
[    0.000000]   DMA32 zone: 500069 pages, LIFO batch:31
[    0.000000]   Normal zone: 21504 pages used for memmap
[    0.000000]   Normal zone: 1551360 pages, LIFO batch:31
[    0.000000] On node 1 totalpages: 2097152
[    0.000000]   Normal zone: 28672 pages used for memmap
[    0.000000]   Normal zone: 2068480 pages, LIFO batch:31
[    0.000000] ACPI: PM-Timer IO Port: 0x408
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x02] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x02] lapic_id[0x04] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x03] lapic_id[0x06] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x04] lapic_id[0x20] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x05] lapic_id[0x22] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x06] lapic_id[0x24] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x07] lapic_id[0x26] enabled)
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] high edge lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 32, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: IOAPIC (id[0x02] address[0xfec01000] gsi_base[24])
[    0.000000] IOAPIC[1]: apic_id 2, version 32, address 0xfec01000, GSI 24-47
[    0.000000] ACPI: IOAPIC (id[0x03] address[0xfec40000] gsi_base[48])
[    0.000000] IOAPIC[2]: apic_id 3, version 32, address 0xfec40000, GSI 48-71
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: IRQ0 used by override.
[    0.000000] ACPI: IRQ2 used by override.
[    0.000000] ACPI: IRQ9 used by override.
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x8086a701 base: 0xfed00000
[    0.000000] SMP: Allowing 8 CPUs, 0 hotplug CPUs
[    0.000000] nr_irqs_gsi: 88
[    0.000000] PM: Registered nosave memory: 0000000000093000 - 0000000000094000
[    0.000000] PM: Registered nosave memory: 0000000000094000 - 00000000000a0000
[    0.000000] PM: Registered nosave memory: 00000000000a0000 - 00000000000e0000
[    0.000000] PM: Registered nosave memory: 00000000000e0000 - 0000000000100000
[    0.000000] PM: Registered nosave memory: 000000007e69b000 - 000000007e7a9000
[    0.000000] PM: Registered nosave memory: 000000007e7a9000 - 000000007f3a9000
[    0.000000] PM: Registered nosave memory: 000000007f3a9000 - 000000007f423000
[    0.000000] PM: Registered nosave memory: 000000007f423000 - 000000007f4af000
[    0.000000] PM: Registered nosave memory: 000000007f4b1000 - 000000007f4b2000
[    0.000000] PM: Registered nosave memory: 000000007f4b2000 - 000000007f4bb000
[    0.000000] PM: Registered nosave memory: 000000007f4bb000 - 000000007f4c2000
[    0.000000] PM: Registered nosave memory: 000000007f4c2000 - 000000007f4e4000
[    0.000000] PM: Registered nosave memory: 000000007f4e4000 - 000000007f56a000
[    0.000000] PM: Registered nosave memory: 000000007f7e0000 - 000000007f7e1000
[    0.000000] PM: Registered nosave memory: 000000007f7e1000 - 000000007f7e6000
[    0.000000] PM: Registered nosave memory: 000000007f800000 - 0000000080000000
[    0.000000] PM: Registered nosave memory: 0000000080000000 - 0000000090000000
[    0.000000] PM: Registered nosave memory: 0000000090000000 - 00000000fed1c000
[    0.000000] PM: Registered nosave memory: 00000000fed1c000 - 00000000fed20000
[    0.000000] PM: Registered nosave memory: 00000000fed20000 - 00000000ff000000
[    0.000000] PM: Registered nosave memory: 00000000ff000000 - 0000000100000000
[    0.000000] Allocating PCI resources starting at 90000000 (gap: 90000000:6ed1c000)
[    0.000000] Booting paravirtualized kernel on bare hardware
[    0.000000] setup_percpu: NR_CPUS:4096 nr_cpumask_bits:8 nr_cpu_ids:8 nr_node_ids:2
[    0.000000] PERCPU: Embedded 26 pages/cpu @ffff88027fc00000 s74880 r8192 d23424 u524288
[    0.000000] pcpu-alloc: s74880 r8192 d23424 u524288 alloc=1*2097152
[    0.000000] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7
[    0.000000] Built 2 zonelists in Zone order, mobility grouping on.  Total pages: 4123819
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: root=/dev/sda1 splash=0 crashkernel=256M-:128M@16M vga=0x31a
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] xsave/xrstor: enabled xstate_bv 0x7, cntxt size 0x340
[    0.000000] Checking aperture...
[    0.000000] No AGP bridge found
[    0.000000] Memory: 16430212k/18874368k available (4405k kernel code, 2121024k absent, 323132k reserved, 7781k data, 1356k init)
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU dyntick-idle grace-period acceleration is enabled.
[    0.000000] NR_IRQS:262400 nr_irqs:1560 16
[    0.000000] Extended CMOS year: 2000
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [tty0] enabled
[    0.000000] allocated 134217728 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] hpet clockevent registered
[    0.000000] Fast TSC calibration using PIT
[    0.004000] Detected 2400.236 MHz processor.
[18014398.509486] Calibrating delay loop (skipped), value calculated using timer frequency.. 4800.47 BogoMIPS (lpj=9600944)
[18014398.509491] pid_max: default: 32768 minimum: 301
[18014398.696649] kdb version 4.4 by Keith Owens, Scott Lurndal. Copyright SGI, All Rights Reserved
[18014398.696878] Security Framework initialized
[18014398.696895] AppArmor: AppArmor initialized
[18014398.698294] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes)
[18014398.701889] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[18014398.703370] Mount-cache hash table entries: 256
[18014398.703558] Initializing cgroup subsys cpuacct
[18014398.703564] Initializing cgroup subsys memory
[18014398.703580] Initializing cgroup subsys devices
[18014398.703583] Initializing cgroup subsys freezer
[18014398.703585] Initializing cgroup subsys net_cls
[18014398.703588] Initializing cgroup subsys blkio
[18014398.703595] Initializing cgroup subsys perf_event
[18014398.703668] CPU: Physical Processor ID: 0
[18014398.703670] CPU: Processor Core ID: 0
[18014398.703677] mce: CPU supports 16 MCE banks
[18014398.703704] CPU0: Thermal monitoring enabled (TM1)
[18014398.703722] using mwait in idle threads.
[18014398.704892] ACPI: Core revision 20110413
[18014398.729594] x2apic not enabled, IRQ remapping init failed
[18014398.730201] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[18014398.769828] CPU0: Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz stepping 07
[18014398.877280] Performance Events: PEBS fmt1+, SandyBridge events, Intel PMU driver.
[18014398.877288] ... version:                3
[18014398.877289] ... bit width:              48
[18014398.877291] ... generic registers:      8
[18014398.877293] ... value mask:             0000ffffffffffff
[18014398.877296] ... max period:             000000007fffffff
[18014398.877298] ... fixed-purpose events:   3
[18014398.877300] ... event mask:             00000007000000ff
[18014398.877514] NMI watchdog enabled, takes one hw-pmu counter.
[18014398.877651] Booting Node   0, Processors  #1
[18014398.877654] smpboot cpu 1: start_ip = 8e000
[18014398.909186] NMI watchdog enabled, takes one hw-pmu counter.
[18014398.909344]  #2
[18014398.909346] smpboot cpu 2: start_ip = 8e000
[18014398.940474] NMI watchdog enabled, takes one hw-pmu counter.
[18014398.940625]  #3
[18014398.940627] smpboot cpu 3: start_ip = 8e000
[18014398.971752] NMI watchdog enabled, takes one hw-pmu counter.
[18014398.971970]  Ok.
[18014398.971972] Booting Node   1, Processors  #4
[18014398.971975] smpboot cpu 4: start_ip = 8e000
[18014399.081093] NMI watchdog enabled, takes one hw-pmu counter.
[18014399.081258]  #5
[18014399.081259] smpboot cpu 5: start_ip = 8e000
[18014399.112362] NMI watchdog enabled, takes one hw-pmu counter.
[18014399.112528]  #6
[18014399.112530] smpboot cpu 6: start_ip = 8e000
[18014399.143633] NMI watchdog enabled, takes one hw-pmu counter.
[18014399.143795]  #7 Ok.
[18014399.143797] smpboot cpu 7: start_ip = 8e000
[18014399.174900] NMI watchdog enabled, takes one hw-pmu counter.
[18014399.174924] Brought up 8 CPUs
[18014399.174927] Total of 8 processors activated (38401.60 BogoMIPS).
[18014399.555854] devtmpfs: initialized
[18014399.559405] PM: Registering ACPI NVS region at 7e69b000 (1105920 bytes)
[18014399.559459] PM: Registering ACPI NVS region at 7f4b1000 (4096 bytes)
[18014399.559462] PM: Registering ACPI NVS region at 7f4bb000 (28672 bytes)
[18014399.559465] PM: Registering ACPI NVS region at 7f4e4000 (548864 bytes)
[18014399.559498] PM: Registering ACPI NVS region at 7f7e0000 (4096 bytes)
[18014399.559645] print_constraints: dummy:
[18014399.559675] Time: 10:55:14  Date: 10/28/15
[18014399.559772] NET: Registered protocol family 16
[18014399.559933] ACPI FADT declares the system doesn't support PCIe ASPM, so disable it
[18014399.559938] ACPI: bus type pci registered
[18014399.560001] PCI: MMCONFIG for domain 0000 [bus 00-ff] at [mem 0x80000000-0x8fffffff] (base 0x80000000)
[18014399.560006] PCI: MMCONFIG at [mem 0x80000000-0x8fffffff] reserved in E820
[18014399.605298] PCI: Using configuration type 1 for base access
[18014399.606398] bio: create slab <bio-0> at 0
[18014399.612428] ACPI: EC: Look up EC in DSDT
[18014399.618314] ACPI: Executed 1 blocks of module-level executable AML code
[18014399.758896] ACPI: Interpreter enabled
[18014399.758903] ACPI: (supports S0 S1 S4 S5)
[18014399.758926] ACPI: Using IOAPIC for interrupt routing
[18014399.759318] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored
[18014399.837279] ACPI: No dock devices found.
[18014399.837285] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[18014399.837640] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-7e])
[18014399.837989] pci_root PNP0A08:00: host bridge window [io  0x0000-0x03af]
[18014399.837993] pci_root PNP0A08:00: host bridge window [io  0x03e0-0x0cf7]
[18014399.837996] pci_root PNP0A08:00: host bridge window [io  0x03b0-0x03df]
[18014399.837998] pci_root PNP0A08:00: host bridge window [io  0x0d00-0x9fff]
[18014399.838001] pci_root PNP0A08:00: host bridge window [mem 0x000a0000-0x000bffff]
[18014399.838005] pci_root PNP0A08:00: host bridge window [mem 0x000c0000-0x000dffff]
[18014399.838008] pci_root PNP0A08:00: host bridge window [mem 0x80000000-0xdfffffff]
[18014399.838026] pci 0000:00:00.0: [8086:3c00] type 0 class 0x000600
[18014399.838072] pci 0000:00:00.0: PME# supported from D0 D3hot D3cold
[18014399.838075] pci 0000:00:00.0: PME# disabled
[18014399.838099] pci 0000:00:01.0: [8086:3c02] type 1 class 0x000604
[18014399.838148] pci 0000:00:01.0: PME# supported from D0 D3hot D3cold
[18014399.838151] pci 0000:00:01.0: PME# disabled
[18014399.838177] pci 0000:00:01.1: [8086:3c03] type 1 class 0x000604
[18014399.838225] pci 0000:00:01.1: PME# supported from D0 D3hot D3cold

the other normal-like server's dmesg snippet:
[    0.000000] Allocating PCI resources starting at 90000000 (gap: 90000000:6ed1c000)
[    0.000000] Booting paravirtualized kernel on bare hardware
[    0.000000] setup_percpu: NR_CPUS:4096 nr_cpumask_bits:8 nr_cpu_ids:8 nr_node_ids:2
[    0.000000] PERCPU: Embedded 26 pages/cpu @ffff88027fc00000 s74880 r8192 d23424 u524288
[    0.000000] pcpu-alloc: s74880 r8192 d23424 u524288 alloc=1*2097152
[    0.000000] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7
[    0.000000] Built 2 zonelists in Zone order, mobility grouping on.  Total pages: 4123819
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: root=/dev/sda1 splash=0 crashkernel=256M-:128M@16M vga=0x31a
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] xsave/xrstor: enabled xstate_bv 0x7, cntxt size 0x340
[    0.000000] Checking aperture...
[    0.000000] No AGP bridge found
[    0.000000] Memory: 16430212k/18874368k available (4405k kernel code, 2121024k absent, 323132k reserved, 7781k data, 1356k init)
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU dyntick-idle grace-period acceleration is enabled.
[    0.000000] NR_IRQS:262400 nr_irqs:1560 16
[    0.000000] Extended CMOS year: 2000
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [tty0] enabled
[    0.000000] allocated 134217728 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] hpet clockevent registered
[    0.000000] Fast TSC calibration using PIT
[    0.004000] Detected 2399.963 MHz processor.
[    0.000004] Calibrating delay loop (skipped), value calculated using timer frequency.. 4799.92 BogoMIPS (lpj=9599852)
[    0.000009] pid_max: default: 32768 minimum: 301
[    0.000384] kdb version 4.4 by Keith Owens, Scott Lurndal. Copyright SGI, All Rights Reserved
[    0.000616] Security Framework initialized
[    0.000632] AppArmor: AppArmor initialized
[    0.002018] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes)

in case it is relavent:
#cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
#

my manager said that even reboot does not solve the problem,(high CPU load,runs slowly.etc). shutdown the server, and restart half an hour later may solve it.
only a few of the serves act like this ,the others seems normal.
and it is hard to reproduce the problem.
Is it likely to be software problem or hardware problem? what should I do to debug? (I don't have the kernel src code).
If you need more information, please let me know!


text:
Q: Is it possible to run scatter matmul in pytorch? Edit: apparently DGL is working on it already: https://github.com/dmlc/dgl/pull/3641
I have several types of embeddings and each one needs its own linear projection. I can solve the problem with a for loop of type:
emb_out = dict()
for ntype in ntypes:
    emb_out[ntype] = self.lin_layer[ntype](emb[ntype])

But ideally, I wanted to do some sort of scatter operation to run it in parallel. Something like:
pytorch_scatter(lin_layers, embeddings, layer_map, reduce='matmul'), where the layer map tells which embedding should go through which layer. If I have 2 types of linear layers and batch_size = 5, then layer_map would be something like [1,0,1,1,0].
Would it be possible to vectorize the for loop in a efficient way, like in pytorch_scatter? Please check below minimal examples.
import torch
import random
import numpy as np

seed = 42
torch.manual_seed(seed)
random.seed(seed)

def matmul_single_embtype(lin_layers, embeddings, layer_map):
   #run single linear layer over all embeddings, irrespective of type
   output_embeddings = torch.matmul(lin_layers[0], embeddings.T).T
   return output_embeddings

def matmul_for_loop(lin_layers, embeddings, layer_map):
   #let each embedding type have its own projection, looping over emb types
   output_embeddings = dict()
   for emb_type in np.unique(layer_map):
       output_embeddings[emb_type] = torch.matmul(lin_layers[emb_type], embeddings[layer_map == emb_type].T).T
   return output_embeddings

def matmul_scatter(lin_layers, embeddings, layer_map):
   #parallelize the for loop by creating a diagonal matrix of lin layers
   #this is very innefficient, because creates a copy of the layer for each embedding, instead of broadcasting
   mapped_lin_layers = [lin_layers[i] for i in layer_map]
   mapped_lin_layers = torch.block_diag(*mapped_lin_layers) #batch_size*inp_size x batch_size*output_size
   embeddings_stacked = embeddings.view(-1,1) #stack all embeddings to multiply the linear block
   output_embeddings = torch.matmul(mapped_lin_layers, embeddings_stacked).view(embeddings.shape)
   return output_embeddings

"""
GENERATE DATA
lin_layers:
   List of matrices of size n_layer x inp_size x output_size
embeddings:
   Matrix of size batch_size x inp_size
layer_map:
   Vector os size batch_size stating which embedding should go thorugh each layer
"""

emb_size = 32
batch_size = 500
emb_types = 20
layer_map = [random.choice(list(range(emb_types))) for i in range(batch_size)]

lin_layers = [torch.arange(emb_size*emb_size, dtype=torch.float32).view(emb_size,emb_size) for i in range(emb_types)]
embeddings = torch.arange(batch_size*emb_size, dtype=torch.float32).view(batch_size,emb_size)
grouped_emb = {i: embeddings[layer_map==i] for i in np.unique(layer_map)} #separate embeddings by embedding type

#Run experiments
%timeit matmul_scatter(lin_layers, embeddings, layer_map)
%timeit matmul_for_loop(lin_layers, embeddings, layer_map)
%timeit matmul_single_embtype(lin_layers, embeddings, layer_map)

>>>>>133 ms ± 2.47 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
>>>>>1.64 ms ± 14 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>>>>31.4 µs ± 805 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

Related stackoverflow question: how to vectorize the scatter-matmul operation
Related issue in pytorch: https://github.com/pytorch/pytorch/issues/31942

A: Just found out that DGL is working on this feature already: https://github.com/dmlc/dgl/pull/3641


text:
Q: how to start or call a function from a different class in python? hey guys need to know as of how to start a method in a classA from class B
have
 classA(object):
      def __init__(self):
 #this is where the ClassB method'' def multiplyPeople() ''should be called or started.

 classB(object):
     def  multiplyPeople(self):

its giving an error
  TypeError: unbound method multiplyPeople() must be called
with classB instance as first argument (got nothing instead)

know this is something basic, but am trying to figure out what exactly is supposed to be done and where am I getting lost.
I have called it as
 classA(object):

 def__init__(self):
 self.PeopleVariable=classB.multiplyPeople()

A: It depends on how you want the function to work. Do you just want to use the class as a placeholder? Then you can use a so called static method for which you do not need to instantiate an object.
Or you can use a regular method and use it on a created object (notice that there you have access to self)
class A():
    def __init__(self):
        b = B()
        b.non_static()

        B.multiplyPeople()

class B():
    @staticmethod
    def multiplyPeople():
        print "this was called"

    def non_static(self):
        print self, " was called"

if __name__ == "__main__":
    a = A()

output:
<__main__.B instance at 0x7f3d2ab5d710>  was called
this was called


text:
Q: Possible to have AngularJs and Angular (v7) in the same application? We have a AngularJs site and we are planning to upgrade to Angular.
I understand that there is ngUpgrade but I am thinking to have Angular in the same application but only use it for the new pages so that the existing/current pages work the same until we updated them.
Is this possible to have two Angular (AngularJs and Angular) and how can it be done?


text:
Q: TextField overlaid on ScrollView "Adjust to Fit" TextField not working I have a scroll view overlaid by two text fields, one near the top and one near the bottom. When text in the text field reaches the side constraints the app freezes up and does not adjust the size to fit the width.  Initially, I had a image view overlaid by two text fields and it was working properly. I think this has some relation to the scroll view.
In the interface builder, Adjust to Fit is checked and min font size set. I also have used the following statements and no avail.
    topTextField.adjustsFontSizeToFitWidth = true
    bottomTextField.adjustsFontSizeToFitWidth = true

Below is a screen shot of the app when it freezes up and screen shot of the layout in Xcode.

A: Looks like something to todo with Auto layout constraints. Double check constraints for scrollview .Follow this tutorial very well explained step by step how to handle constraints with scrollview.


text:
Q: adding a WCF to existing website or have a new service? I am a total newbie to the WCF world. I have an ASP.net (v4) website running on our dedicated windows 2008 server box. I'll refer to the website as, webisteA.com
I'm creating a new website, websiteB.com.au and I'd like to expose the functionality in WebsiteA.com to the new site. Things like logging in, registering in the database etc.
I think the best way to do this is to create a WCF service which sits in WebsiteA.com - but I am struggling to find any tutorials on how to do this. There are lots about creating a new project, but not that many about adding a WCF service to existing websites.
Is this the best way to do it? In the future I'd also like to use the service for mobile apps in the future too - not sure if that will make a difference.
OR - do I create a new service in a new app which is totally seperate to websiteA.com and websiteB.com and host this as website0.com and expose the database via that?
The questions I don't have answers for are...
is it restful? Do I use XML or JSON?
Baiscally, I want to be able to use it like an API - for example, saying "show me all the members who meet criteria X".
Thanks for any information.
ps) I have visual studio express 2010 c# (and a trial of studio pro)

A: You can certainly include WCF within the website A project - but have you considered the ASP.NET Web API? I haven't used it yet - but did use the earlier WCF Web API which spawned it.
Neat features include Content Negotiation (if the client asks for XML the API sends XML. If it asks for JSON is gets JSON) and a lot less config cruft (WCF web.configs are dreadful and completely overcomplicated IMO)
It's probably a lot easier to make a RESTy API with the ASP.NET Web API than with standard WCF.
A great open-source .NET solution is NancyFX which is really worth a look too.


text:
Q: .Net MVC add text box dynamically and bind to model I want to dynamically add textboxes and bind it to my model, so when I post all data should be in HttpPost. Here is my model
 public class JobViewModel
    {
        public JobViewModel()
        {
            JobDescriptions = new List<JobDescription>();
        }
        public int Id { get; set; }
        [Required]
        public string JobTitle { get; set; }
        public List<JobDescription> JobDescriptions { get; set; }
}

Here is my Razor view
@using (Html.BeginForm("CreateJob", "Jobs", FormMethod.Post, new { @id = "jobFrm" }))
{
    @Html.AntiForgeryToken()

Job

    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        @Html.LabelFor(model => model.JobTitle, htmlAttributes: new { @class = "control-label col-md-2" })

            @Html.EditorFor(model => model.JobTitle, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.JobTitle, "", new { @class = "text-danger" })

        @Html.Label("Add Description", htmlAttributes: new { @class = "control-label col-md-2" })

            <input id="btnAdd" type="button" class="btn btn-success" value="Add"  />

 ............. more fields and submit button ............

I searched and tried different codes, they add textboxes while clicking ADD button, but that filled textboxes value are not binded to my model. Sometimes it add empty model, or none at all.
Need help to bind values to my model

A: You can choose one of two solutions as per need:

*

*If you are add dynamic control from Razor at time of rendering then use conditional add of control.

*If you want to do this at run time, therefore in browser through javascript then use proper name and id fields to create and map back.

A: I referenced this when trying to create a form with dynamic add/delete functionality for a one to many relationship.  One major thing to keep in mind is to ensure the index of the newly added item.  Also as stated above, there will be some client side calls to add a new editor for each specific item.  This post also provided me with some great reference when setting up my editor templates with the client side call to "AddNewItem" to the form and ensuring that the index of the newly added item was available for deleting if necessary.


text:
Q: Using a BAT file as service with NSSM I am writing a .BAT script which goes as follows:
cd "C:\Program Files\WinRAR"

winrar.exe

Double clicking this batch file works fine and openes winrar for me....now i try installing it as service with NSSM
i place nssm.exe in the same directory as my batch file and proceed to install it like following:

All other tabs are left unchanged. when I open services.msc and manually click start on this service it shows running but nothing happens. Can anyone tell me what I did wrong?

A: Sorry for asking this dumb question....it actually runs in baground like all services.


text:
Q: What should I use for hosting videos for streaming in my mobile app I have an app for Android and iOS, and I want to integrate video. However, if I put the video in the app, it will make the app very big. So I want to stream the video from the web. What are some good services I can use to host the videos? They are a total of about 25-30 MB. I would like to use a service with a free plan that I can start out with until I have a lot of users.
Thank you in advance.

A: I would look at HTTP or RTMP (Real Time Messaging Protocol) streaming via Amazon Cloudfront.  They have cheap $per/GB pricing and support secured and/or authenticated access to resources.


text:
Q: C# windows (WinForms) child application locks sockets I have two windows C# WinForms applications that behave the same way related to this issue. The behavior exhibits if the applications are ran in this order:
Main application starts up and part of its normal working process opens some sockets; mixture of tcp udp and multicast.
At some time pressing a button it starts another application using C# process related libraries. The second app starts ok and all is ok.
It is known and acceptable that if I start a second instance of my main app the second instance won't be able to use the sockets the first one owns.
The issue that I have is that if I shutdown the first app and restart, it won't be able to acquire the sockets anymore... until the child app is also shutdown.
Note that the second app doesn't use ANY sockets whatsoever, but somehow windows keeps the sockets locked until the second app shuts down.
I HAVE THIS QUESTION RELATED TO PROGRAMMING IN C# WIN FORMS WHICH IS ON THE TOPIC NOW WITH CAPITAL LETTERS FOR PEOPLE WHO CAN NOT DISTINGUISH ON/OFF TOPIC:
how do I solve this so that I don't need to shutdown the second app for the first one to be able to acquire its sockets (WHICH -i know - ARE FREE).

A: This is normal handle inheritance behavior. Unfortunately the .Net Process.Start is passing true as bInheritHandles to CreateProcess (NB. an open request to allow control of this behavior exists: Make Process.Start have a option to change handle inheritance). As a work around, use the native CreateProcess instead, see When System.Diagnostics.Process creates a process, it inherits inheritable handles from the parent process.


text:
Q: DynamicJAXBContextFactory.createContextFromXSD fails to load SchemaMetadata I'm using the DynamicJAXBContextFactory.createContextFromXSD method to create a jaxbcontextfrom an xsd.
It works fine when I instantiate all classes from a junit test, but when I call the same classes deployed on a glassfish 4 server, the class org.eclipse.persistence.jaxb.dynamic.metadata.SchemaMetadata can't be found!
Running GlassFish Server Open Source Edition 4.0 (build 89) with Eclipselink 2.5.0
I have tested with nightly build glassfish-4.0.1-b04-02_04_2014-ml with Eclipselink 2.5.1, it's the same fault there.
I downloaded the source code and during debug I could set a log.debugflag to 4 and got a detailed description of the cause:

java.lang.ClassNotFoundException: *** Class 'org.eclipse.persistence.jaxb.dynamic.metadata.SchemaMetadata' was not found because bundle org.eclipse.persistence.core [211] does not import 'org.eclipse.persistence.jaxb.dynamic.metadata' even though bundle org.eclipse.persistence.moxy [216] does export it. Additionally, the class is also available from the system class loader. There are two fixes: 1) Add an import for 'org.eclipse.persistence.jaxb.dynamic.metadata' to bundle org.eclipse.persistence.core [211]; imports are necessary for each class directly touched by bundle code or indirectly touched, such as super classes if their methods are used. 2) Add package 'org.eclipse.persistence.jaxb.dynamic.metadata' to the 'org.osgi.framework.bootdelegation' property; a library or VM bug can cause classes to be loaded by the wrong class loader. The first approach is preferable for preserving modularity. ***

I added org.eclipse.persistence.jaxb.dynamic.metadata to the org.osgi.framework.bootdelegation property. Then the class loaded, but now it't can't find the constructor!
I debug the org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getConstructorFor method, (see code below), but it can't find the constructor even if they look the same to me!
The parameterType is class org.eclipse.persistence.dynamic.DynamicClassLoader,
the argType is class org.eclipse.persistence.dynamic.DynamicClassLoader,
but somehow the methods parameterType.isAssignableFrom(argType)) && (!argType.isAssignableFrom(parameterType) fail if the code runs in glassfish 4 but works if run from a junit-test.
I don't know why it won't work, can someone help me please?
And the detailed message suggest that the number 1) solution should be used, i.e

1) Add an import for 'org.eclipse.persistence.jaxb.dynamic.metadata' to bundle org.eclipse.persistence.core [211];

Is this a bug in eclipselink, if so can someone fix it?
Here is the code for the method:
public static Constructor getConstructorFor(final Class javaClass, final Class[] args, final boolean shouldSetAccessible) throws NoSuchMethodException {
    Constructor result = null;
    try {
        result = javaClass.getConstructor(args);
    } catch (NoSuchMethodException missing) {
        // Search for any constructor with the same number of arguments and assignable types.
        for (Constructor constructor : javaClass.getConstructors()) {
            if (constructor.getParameterTypes().length == args.length) {
                boolean found = true;
                for (int index = 0; index < args.length; index++) {
                    Class parameterType = Helper.getObjectClass(constructor.getParameterTypes()[index]);
                    Class argType = Helper.getObjectClass(args[index]);
                    if ((!parameterType.isAssignableFrom(argType))
                        && (!argType.isAssignableFrom(parameterType))) {
                        found = false;
                        break;
                    }
                }
                if (found) {
                    result = constructor;
                    break;
                }
            }
        }
        if (result == null) {
            throw missing;
        }
    }
    if (shouldSetAccessible) {
        result.setAccessible(true);
    }
    return result;
}

A: MOXy's support for bootstrapping a dynamic JAXB model from an XML Schema does not currently work in an OSGi environment.
For this feature MOXy leverages code from the JAXB reference implementation.  Part of the code that is responsible for generating Java classes from an XML Schema.  This code gave us problems when we tried to OSFi-ify it, therefore we couldn't expose the code that depended on it though OSGi.


text:
Q: Wordpress admin: Get current open post (order) edit page meta value We have a website running on woocommerce and we run a custom tax solution there. On frontend everything works perfect atleast in admin as we have set, that tax is calculated by store address, we get the basic store country into all of the orders. What we are trying to achieve is to replace this country in admin from current open order post meta. But we are unlucky and we are not getting any data. Is there any possiblity to get current open post meta value?
function custom_base_country($base_country ){
if (is_admin()){
    global $woocommerce;
    $order = $_GET['post'];
    $country = get_post_meta($order->id, 'country_code', true);
    $base_country = $country;
}
    return $base_country;
}
add_filter('woocommerce_countries_base_country', 'custom_base_country', 10, 1);

A: Found out the answer by changing the code to $country = get_post_meta($order, 'country_code', true);


text:
Q: Problems with egit connecting to a git repository on a godaddy shared account Our shared server account at godaddy comes preinstalled with git version 1.7.1. I've set up a bare repository following this strategy,
http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
When I attempt to push via ssh in egit in eclipse I get this error,

Can't connect to any URI: ssh://url:22/git-test/test.git
  (ssh://url:22/git-test/test.git: connection failed)

And yet using the same authentication in Putty I have no problem.
What I eventually want to do is to set up a git repository on the godaddy account that will permit development of the website from a few remote locations and then permit a push to production-live.
There is no git-daemon available, but apparently it isn't needed according to the above link.
This could be a problem with server configuration or remote setup on the egit side.

A: Make sure you are suing the full path of your repo
git remote set-url origin ssh://username@domain.com/home/username/path/git-test/test.git

(with test.git being a bare repo, with a post-receive hook to update the live site)
Try it from the command line first (no need for putty), then change your remote url on Eclipse/EGit.
You don't need to specify the port number (22 being the default one for ssh).

A: For me the problem was firewall by the VPN i used. By disabling the VPN Eclipse could push.


text:
Q: Can't retrieve data from database (Firebase) I would like to retrieve my data from my database but I do not know how to do this (I am new to the Android studio). After some research
I got to this code below
but it's not working
I want to retrieve the information from "Documeto" by
looking for the attribute "cpf".
basiclly I want the user to get the 'Documeto' info by  searching it's "cpf" on the app.
  public void BuscarDoc(){

        String Cpf = txtBusc.getText().toString().trim();
        Toast.makeText(this, Cpf, Toast.LENGTH_LONG).show();
        //databaseDoc = FirebaseDatabase.getInstance().getReference("duscadi");
        //DatabaseReference ref = databaseDoc.child("Documento");
        databaseDoc = FirebaseDatabase.getInstance().getReference();
        Query query =databaseDoc.child("Documento").child("cpf").equalTo(Cpf);
        query.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

                for (DataSnapshot childSnapshot: dataSnapshot.getChildren()) {
                    Documento doc = dataSnapshot.getValue(Documento.class);

                    System.out.println("ta normal");
                    if (doc != null){
                        System.out.println("o objetyo ta salvo");
                    }else{
                        System.out.println("tA NUZAÇO");
                    }
                }
                //Documento doc = dataSnapshot.getValue(Documento.class);
                //System.out.println(doc);
                //System.out.println("cupameupaui");
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });
}

inactivity disconnecting from the service


text:
Q: NTFS partition got merged and contents not showing I had a 750GB NTFS partition, 100GB NTFS partition and 100GB ext4 partition.
Recently I formatted my 100GB NTFS partition to ext4 partition with live ubuntu cd.
After that, the partitions were changed to 850GB ext4 and 100 GB ext4.
All my data of 750GB NTFS is also not showing now. Please help!

A: Stop using the computer immediately!
It sounds like you did more than just create an ext4 filesystem on the 100 GB partition. You don't say how you did this, so I can't say what your (presumed) mistake was, but chances are you accidentally operated on the wrong partition or even accidentally did much more extensive partitioning operations.
I can't really be more specific without more specific information, such as a screen shot of GParted or the output of sudo parted -l. (You can do this from a boot of a live USB disk to minimize the risk of doing further damage.)
If I'm right, though, your best hope for full recovery is to restore files from a backup. If you don't have a backup, your best hope for partial recovery is to use a tool like PhotoRec to extract files from the disk onto a separate recovery medium. Some Windows-specific tools are said to do a better job recovering filenames than PhotoRec, but I don't have pointers to specific tools. If I'm right, the odds of your getting your system back to the state it was in before the accident are pretty slim, unless of course you have a recent backup, in which case you can use it.


text:
Q: Return to shell output from last run shell command I run my tests file like such:
:!bundle exec rspec my_file_spec.rb

When I run that command it displays my test results in another window and I get "Press ENTER or type command to continue" to return back to vim.  That's all working.
What I'd like to do though is get back to that previous output once I've left it.  Is that at all possible?
I don't see it in my list of buffers and I really don't need to keep the output in a separate window/split.

A: The output from the :! command is printed directly to the terminal (or GVIM's built-in emulator); it is not saved. To do that, you could redirect into an external file with tee:
:!bundle exec rspec my_file_spec.rb | tee a.out
:split a.out

Or, you directly open a scratch buffer and :read in the command's output:
:new +setl\ buftype=nofile | 0read !bundle exec rspec my_file_spec.rb

The downside of this is that you only see the output once the external command concludes.


text:
Q: How to run test gradle project with docker file It's an automation framework with the stack [gradle, java, etc...] it's a separate module
Structure in the repository
1)Frontend side -> dockerfile
2)Backend side -> dockerfile
3)Automation -> need here a docker file
the command for gradle is [gradle clean test -DtestEnv='ci']
what I should add in this docker file for run the application and how i can test if it works fine locally


text:
Q: MDX filter one dimension by multiple criteria using "like" I'm new on MDX, and please help me with an example of how can I build an MDX query that will have a filter equivalent with the following SQL:
select *
from [dbo].[FactPurchase]
where Artikelnummer like 'E75%'
or Artikelnummer like 'S241%%NA'
or Artikelnummer like 'S241%%SW'
or Artikelnummer like 'S241%%PL'
Thanks.

A: I find an answer that works for my needs here:
http://sqljason.com/2010/04/searching-substrings-in-mdx.html


text:
Q: Why was the cyborg Darth Vader wheezy? The cyborg General Grievous was wheezy because he was trying to maintain the last remnants of his biological self in his mostly mechanical body. With the high level hi-tech cloning technology and the artificial limbs available in the medical field in Star Wars, I have to wonder why Darth Vader was dependent on his respiration suit in order to survive. I know he burned his lungs and that's why he wears the iconic self contained breathing suit. Is there a canon reason as to why they didn't just "fix him up"?  Why was Darth Vader wheezy?

A: From Wookieepedia:

Vader's helmet was the center of the life-support system. It was fitted with an air pump, which was connected to a flat filter system worn on Vader's back. Together, the backpack and the air pump continuously cycled purified air through Vader's ravaged lungs. A small, back-up air-processing filter was located in his distinctive mouth grill, which also doubled as a respiratory intake system. Vader's life-support system also included a chest-worn, computerized control panel unit that regulated his respiratory functions.  From this chest panel, a thick cable entered his torso, linking to a breathing apparatus and heartbeat regulator. The ventilator was implanted in his terribly scarred chest, along with tubes that ran directly into his damaged lungs, and others that entered his burned throat, so that should the chest plate or belt control panels develop a glitch, he could breathe unassisted air for a limited time out of his mouth, which had not been burned to the extent of his throat.
A belt-mounted function box housed the respiratory sensor matrix responsible for controlling Vader's breathing. Using it, Vader could easily adjust the controls on his armor to increase or decrease his supply of oxygen.
Vader's breathing was machine-regulated, but his pace of breathing quickened during physical exertion and could be overridden by involuntary emotional reactions. In addition, his respirator would also let out a strained rasp if undergoing extreme exertion rendering him exhausted or if part of his armor is significantly damaged. This is especially evident when Vader ended up having his right arm cut off by Luke Skywalker in their final duel. The respirator slowed down or sped up in response to changes in his remaining body's functions, but Vader was unable to stop it or hold his breath, nor could he slow it. Vader's breather functioned even while Vader was speaking.
However, it is apparent that a dampener or similar device had been installed into his suit by 3 ABY, as he was able to surprise Luke Skywalker in a dark passage near the carbon-freezing chamber on Bespin. Vader's ambush was only possible because he could temporarily quiet his loud breathing.
Lord Vader's breather was seriously damaged by Force lightning during his struggle with the Emperor. Although it continued to operate to some extent, the sound of the mechanism was reduced to a strained rasp, implying that the respirator was broken. The labored breathing sound persisted until his final unmasking.
His signature, labored mechanical breathing was the sound of the iron lung Vader was forced to wear. The med droids that had made the suit had inserted the redundant breathing tubes low enough so that, with the aid of an enunciator, his scorched vocal cords could still form sounds and words through a voice synthesizer in the mask. Absent from the enunciator in Vader's mouth grill, which imparted a synthetic bass tone, his own voice was little more than a whisper. Though limited by what the respirator could do, Vader could still make his respirator approximate a laugh or a sigh.

A: Because George Lucas said so:

...he falls into a volcanic pit and gets fried and is one destroyed being. That's why he has to wear the suit with a mask, because it's a breathing mask. It's like a walking iron lung.

What does an iron lung sound like?

A: Breathing inside a fully-concealed plastic suit would somehow affect the flow of sound he makes when he breathes, etc.


text:
Q: Why v[i] = i++ is undefined behavior in C? Reading an interesting article on ACCU's overload #115: "Demons May Fly Out Of Your Nose" I found the author saying:

between sequence points you are not allowed to make any assumptions about the state of involved variables. This also means that in C, unlike most other languages, the following expression leads to undefined behaviour
v[i] = i++;
because the assignment operator does not represent a sequence point in C

Can someone explain what's the detailed reasoning that implies UB here?
I thought it would be a matter of having more than one write to the same variable between two sequence point, which I cannot see here except for the possibility of v[i] aliasing i...

A: It is not just about writes. Reads also play a role in situations when you don't know whether you are reading the old value of the variable or the new value. In this case there's no way to say whether v[i] refers to the old value of i or to the new value of i.
For example, the expression v[i] = i++ can be interpreted as

*

*Perform assignment: v[i] = i

*Increment i
Or, alternatively, it can be interpreted as

*

*Get the old value of i: i_old = i

*Increment i

*Perform assignment: v[i] = i_old
As you can easily see, the behavior of the code changes depending on how it is interpreted. These are just examples of two possible inconsistent scenarios.
But the language does not restrict the behavior to such limited variety of scenarios. Instead the language says that the behavior is undefined, which means, among other things, that the compiler is free to refuse to interpret this code in any "predictable" way.

A: There is a read and a write of i within the same sequence point.  That is, i++ could mutate i before OR after computing the address of v[i].  In fact, because this behaviour is undefined, it could very well do neither of those things -- the compiler could, for example, assume the statement to be unreachable and remove it.  (Or make demons fly out your nose, etc.)

A: You're correct that modifying a variable more than once without an intervening sequence point leads to undefined behavior. But there is an additional requirement that the variable's value be only accessed to determine the value to be modified. It's the second requirement that disallows
v[i] = i++;

Here the access of i's value for array indexing has nothing to do with the modification being made to i (i++). Since there is no intervening sequence point between the two accesses, this is undefined behavior.


text:
Q: Android Studio Não roda o script ( KVM MISSING ) Bom dia, tenho o Android Studio rodando no meu Windows normal , o emulador também funciona.
Instalei na VMBOX da oracle o debian, no processador habilitei a opção de VT-X/AMD-V
instalei o andorid studio mais o emulador com nexus 5 mas na hora de executar ele diz que não tenho suporte ao KVM
ja tentei instalar os pacotes do KVM na mão , e dei uma "googada" sobre o assunto mas todas saídas que achei foram para ubuntu e não debian 8
Alguém sabe como proceder?
no meu terminal rodei
egrep -c '(vmx|svm)' /proc/cpuinfo

e o retorno foi 0

A: Se você rodou o comando egrep -c '(vmx|svm)' /proc/cpuinfo e retornou "0" é porque seu processador não tem suporte para executar o kvm.


text:
Q: VueJS + Nuxtjs Unexpected Token 'export' So i have this code as my index page and It was working, but a couple minutes later it just stopped.
the error is:
SyntaxError
Unexpected token export

Within the script section, If i remove my import then the error will go away, but I need to import it and use it. It was working with the package being imported, but I have looked this code up and down I have no idea what the heck is going on.
Anyone have any suggestions? Am I dumb and have missed something so simple?
<template>

            <button> Send a card </button>

 Or

            <button class='btn-blue'> Open a card </button>

</template>

A: In your build property in nuxt.config.js you'll need to add a transpile block that targets this library:
build: {
  transpile: [
    'qrcode-generator-es6'
  ]
}

This is due to the fact that nuxt expects libraries to export as CJS modules and not ES6 modules.

A: In nuxt.config.js replace export default { on module.exports = {


text:
Q: Passage of a vector of structures to a function My program is working with graph, and I'm trying to create a vector of edges. The edge type in my program is this one :
typedef struct arco{
    TipoNodo p, s;
    int peso;
    }arco;

where p and s are the vertex, and peso is how much is long the edge.
I'm trying to create a vector of the edges made from the adjacency matrix, but when I pass the vector of type arco to my function, my program raises a run time error. How should I pass the vector of arcos to my function, and modify his elements?
main code:
case 'f':
      printf("Algoritmo di Dijkstra. Scrivere Nodo i di partenza: ");
      scanf("%d", &i);
      arco vet[MaxArchi];

          int dimensione;
          printf("fuck\n");
//I'm debugging just the matrix part, becouse I think that the error with adjacency list is the same.
          if(matlist=='m') dimensione = CodaMinPrioritaMatrice(grafoMat, vet); else dimensione = CodaMinPrioritaLista(grafoList, vet);
//printing the array, the program doesn't arrive here.
          for(peso = 0; peso <dimensione; peso++) printf("%d->%d, (%d)\n", vet[peso].p, vet[peso].s, vet[peso].peso);
          break;

function:
int CodaMinPrioritaMatrice(GrafoMatrice *grafo, arco *vet[]){
      int dimensione;
      TipoNodo i, j;
      for(i=0; i<NumNodi; i++)
          for(j = 0; j<NumNodi; j++)
              if(grafo->matr_adiacenza[i][j] != 0){
                                             //the program stops here
                     //*vet[dimensione] = malloc(sizeof(arco));
                     vet[dimensione].p = i;
                     vet[dimensione].s = j;
                     vet[dimensione].peso = grafo->matr_adiacenza[i][j];

                     dimensione++;
              }
      return dimensione;
}

I don't post my whole program because I wrote more or less 600 lines of code, all I know about graph
Thank you every body
Giacomo.

A: I think you need to make one more change in your code...
int dimensione=0;

you are using a variable without initialization.
This may help you.

A: This should fix your code -
Change the function definition from:
int CodaMinPrioritaMatrice(GrafoMatrice *grafo, arco *vet[]){

To:
int CodaMinPrioritaMatrice(GrafoMatrice *grafo, arco *vet){


text:
Q: RegEx: How to find instance of new class in Eclipse? I am working on old large pieces of code that directly create struts 1 actions, because it places logic in there.
I wish to find instances where the action classes are created directly in the code. For instance, say I have MoveAction, UpAction, DownAction. How would I find these using regular expressions, where instances of those classes are created? I need something similar to
new *Action()

That will not match new ActionMessages()

A: you can select the constructor of Action in the eclipse IDE and press ctrl+h to find all occurrences within your project
public Action()/*select the constructor in the class file */{
}

A: new .*Action( should match "new " followed by anything up to "Action("


text:
Q: Can writes to a datagram socket ever raise SIGPIPE? I'm working with some code that needs to be safe against killing the caller due to SIGPIPE, but the only socket writes it's performing are going to datagram sockets (both UDP and Unix domain datagram sockets). Do I need to worry about SIGPIPE? I'm using connect on the socket, but preliminary testing (on Linux) showed that I just get ECONNREFUSED on send if there's nobody listening on the Unix domain socket. Not sure what happens with UDP.
I can wrap the whole thing in hacks to get rid of SIGPIPE, but if it's a non-issue I'd rather save the overhead and keep the code complexity down.

A: The open group is one thing, and Apple is another.
It is definitely possible to get a SIGPIPE on iOS when writing to a dead UDP socket, as some of my crash logs revealed lately.
iOS tends to close UDP sockets while the app is in the background, writing to these sockets can pop a SIGPIPE.
From my crash log (courtesy of testflightapp):

Exception Latest Victim   Occurrences
  SIGPIPE
  2 libsystem_c.dylib 0x32df47ec _sigtramp + 48
  3 instant talk 0x0005b10e -[IPRSNetDatagramSocket send:size:to:] (iprs_iphone_net.m:671)...

Don't recall this happening on Linux, Solaris or Windows - though I never tried to close a socket and then write to it.

A: The answer is in the specification for send:

[EPIPE] The socket is shut down for writing, or the socket is connection-mode and is no longer connected. In the latter case, and if the socket is of type SOCK_STREAM or SOCK_SEQPACKET and the MSG_NOSIGNAL flag is not set, the SIGPIPE signal is generated to the calling thread.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html
Thus, no, writes to datagram sockets do not generate SIGPIPE or an EPIPE error.

A: According to man 2 write on my Debian box,
EPIPE: fd is connected to a pipe or socket whose reading end is closed.  When this happens the writing process will also receive a SIGPIPE signal.   (Thus,  the  write
              return value is seen only if the program catches, blocks or ignores this signal.)
It appears that it is possible to get SIGPIPE when writing to a socket, but it's not clear whether it can happen for UDP sockets specifically.


text:
Q: Reusable ContentView Binding for an ActivityIndicator I have an ActivityIndicator which I have in a number of different pages like this:
<ActivityIndicator HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"
                    Color="DarkBlue" IsVisible="{Binding IsLoading}" IsRunning="{Binding IsLoading}">
</ActivityIndicator>-

I'm trying to make this component more easily reusable by creating a 'ContentView', which looks like this:
Loading.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="Framework.Controls.Loading" x.Name="Loading">
  <ContentView.Content>
      <ActivityIndicator HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Color="DarkBlue"
                         IsVisible="{Binding Source={x:Reference Name=Loading},Path=IsLoading}"
                         IsRunning="{Binding Source={x:Reference Name=Loading},Path=IsLoading}">
      </ActivityIndicator>
    </ContentView.Content>
</ContentView>

Which I am trying to consume with code like this:
<controls:Loading IsLoading="{Binding IsLoading}"></controls:Loading>

The problem I'm having is that I am not sure how to create a binding so that I can set the IsVisible and IsRunning properties on the ActivityIndicator.
My code-behind for the component looks like this:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Loading : ContentView
{
    public static readonly BindableProperty LoadingIndicatorProperty =
        BindableProperty.Create(
            propertyName: nameof(IsLoading), typeof(bool),
            typeof(Loading), default(string), BindingMode.OneWayToSource);

    public bool IsLoading
    {
        get => (bool)GetValue(LoadingIndicatorProperty);
        set => SetValue(LoadingIndicatorProperty, value);
    }

    public Loading()
    {
        InitializeComponent();
    }
}

With the current code, I get build errors, so something obviously isn't right here.
The errors are as follows:

*

*In the Loading.xaml file, I get a message that says for x.Name=Loading that the 'Type x not found in xmls http://xamarin.com/schemas/2014/forms and also that The attachable property 'Name' was not found in type 'x'.

*On the page where I am trying to consume the control I get an error: No property, bindable property or event found for 'IsLoading', or mismatching type between value and property.

How do I correctly create a binding that will apply to the IsVisible and IsRunning properties on my Activity Indicator? And why doesn't the compiler like the ContentView 'x.Name' property?

A: First, you have a typo:
It is x:Name and you have x.Name
So, in your View:
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="Framework.Controls.Loading"
             x:Name="Loading">
  <ContentView.Content>
      <ActivityIndicator HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Color="DarkBlue"
                         IsVisible="{Binding IsLoading"
                         IsRunning="{Binding IsLoading">
      </ActivityIndicator>
    </ContentView.Content>
</ContentView>

then, in code-behind you can just:
XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Loading : ContentView
{
    public static readonly BindableProperty LoadingIndicatorProperty =
        BindableProperty.Create(
            propertyName: nameof(IsLoading), typeof(bool),
            typeof(Loading), default(string));

    public bool IsLoading
    {
        get => (bool)GetValue(LoadingIndicatorProperty);
        set => SetValue(LoadingIndicatorProperty, value);
    }

    public Loading()
    {
        InitializeComponent();
        BindingContext=this;
    }
}

A: I created a Xamarin.Forms control that does exactly that, and more (handle errors and empty state as well).
You can find it here:
https://github.com/roubachof/Sharpnado.Presentation.Forms#taskloaderview
The blog post explaining it in details is here:
https://www.sharpnado.com/taskloaderview-async-init-made-easy/