问:
Qt Creator can't find library
I'm using ubuntu(32 bit) on virtualbox. I am trying to add a the rtlsdr library but Qt creator can't find the rtlsdr library.
The library is located in /usr/local/lib/librtlsdr.so and I have tried adding the following to my .pro file

```<code>LIBS += -L/usr/local/lib -lrtlsdr

INCLUDEPATH +=usr/local/lib
</code>```

But I get the following error:

```<code>/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link=/home/luis/qt-bbb/tslib/lib -Wl,-rpath,/opt/qt-arm/lib -o qt-test main.o mainwindow.o moc_mainwindow.o -L/home/luis/qt-bbb/tslib/lib -L/opt/qt-arm/lib -L/home/luis/qt-arm/rtl-sdr/build/src/ -lrtlsdr -lQtGui -L/opt/qt-arm/lib -L/home/luis/qt-bbb/tslib/lib -lQtNetwork -lQtCore -lpthread

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: *skipping incompatible /home/luis/qt-arm/rtl-sdr/build/src//librtlsdr.so when searching for -lrtlsdr*

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: *skipping incompatible /home/luis/qt-arm/rtl-sdr/build/src//librtlsdr.a when searching for -lrtlsdr*

Makefile:105: recipe for target 'qt-test' failed

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lrtlsdr

collect2: error: ld returned 1 exit status

make: *** [qt-test] Error 1
</code>```

I'm using ubuntu 32bit to cross compile for my beaglebone running debian. Deploying on my beaglebone works ok and I verified the libraries are 32 bit so I don't know why it can't find them or why it's giving me “skipping incompatible” message. I also tried adding them by right clicking on the .pro->add library but still can't find them.

答:
skipping incompatible tells you the library cannot be linked. Probably compiled with the wrong compiler?
                    – Sebastian Lange

Ok i figured out my problem, the library was built for x86 and not arm. Thanks for the hints! – luismbedder

Title: Qt Creator can't find library

Body:
I'm using ubuntu(32 bit) on virtualbox. I am trying to add a the rtlsdr library but Qt creator can't find the rtlsdr library.
The library is located in /usr/local/lib/librtlsdr.so and I have tried adding the following to my .pro file

LIBS += -L/usr/local/lib -lrtlsdr

INCLUDEPATH +=usr/local/lib

But I get the following error:

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link=/home/luis/qt-bbb/tslib/lib -Wl,-rpath,/opt/qt-arm/lib -o qt-test main.o mainwindow.o moc_mainwindow.o -L/home/luis/qt-bbb/tslib/lib -L/opt/qt-arm/lib -L/home/luis/qt-arm/rtl-sdr/build/src/ -lrtlsdr -lQtGui -L/opt/qt-arm/lib -L/home/luis/qt-bbb/tslib/lib -lQtNetwork -lQtCore -lpthread

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: *skipping incompatible /home/luis/qt-arm/rtl-sdr/build/src//librtlsdr.so when searching for -lrtlsdr*

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: *skipping incompatible /home/luis/qt-arm/rtl-sdr/build/src//librtlsdr.a when searching for -lrtlsdr*

Makefile:105: recipe for target 'qt-test' failed

/home/luis/qt-bbb/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lrtlsdr

collect2: error: ld returned 1 exit status

make: *** [qt-test] Error 1

I'm using ubuntu 32bit to cross compile for my beaglebone running debian. Deploying on my beaglebone works ok and I verified the libraries are 32 bit so I don't know why it can't find them or why it's giving me “skipping incompatible” message. I also tried adding them by right clicking on the .pro->add library but still can't find them.


来源: stackexchange

问:
How to connect a Docker container to a local network
I'm running Docker on a Raspberry Pi 3 using Raspbian (Jessie). I want to access my containers from other PCs on the same network. Can someone explain how can I make containers to show under my router list as an independent machine?

Port forwarding is useless because we are using few ports and if we need to add some new function to it, we must commit the container, delete the container, create a new container under the image created and add the new ports to forward.

答:
Maybe you can try docker ps -a to check the container's states and available ports.

This is the result on my Linux (IP address is 135.251.247.21):

```<code>sdn@sdn-KVM:~$ docker ps -a

CONTAINER ID   IMAGE                             COMMAND                  CREATED             STATUS      PORTS                                                                       NAMES
be8c8289fe20   135.249.45.113:9005/onos:1.7.004  "./bin/onos-service"     3 weeks ago         Up 7 hours  0.0.0.0:6633->6633/tcp, 6653/tcp, 0.0.0.0:8101->8101/tcp, 9876/tcp, 0.0.0.0:9191->8181/tcp   onos-docker
</code>```

I can access this container from a remote machine via SSH:
ssh -p 8101 karaf@135.251.247.21.

If you cannot access your container from a remote machine, you can try to access it on your local machine by running docker exec -it xxx bash, where xxx is the container name.

ContentLicense: CC BY-SA 4.0

Body:
Maybe you can try docker ps -a to check the container's states and available ports.

This is the result on my Linux (IP address is 135.251.247.21):

sdn@sdn-KVM:~$ docker ps -a

CONTAINER ID   IMAGE                             COMMAND                  CREATED             STATUS      PORTS                                                                       NAMES
be8c8289fe20   135.249.45.113:9005/onos:1.7.004  "./bin/onos-service"     3 weeks ago         Up 7 hours  0.0.0.0:6633->6633/tcp, 6653/tcp, 0.0.0.0:8101->8101/tcp, 9876/tcp, 0.0.0.0:9191->8181/tcp   onos-docker

I can access this container from a remote machine via SSH:
ssh -p 8101 karaf@135.251.247.21.

If you cannot access your container from a remote machine, you can try to access it on your local machine by running docker exec -it xxx bash, where xxx is the container name.


问:
Errors after installing lodash in Angular 2
I'm getting a MASSIVE stack of errors after installing lodash in my Angular 2 project. To test, I started a new project with the CLI: ng new tester, then I installed lodash with npm install --save @types/lodash. Then I ran ng serve, and I got the following:

```<code>ERROR in /Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,21): ']' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,22): ';' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,23): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,33): ']' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,34): ')' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,35): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,37): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19499,1): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (244,13): Duplicate identifier '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (248,19): Duplicate identifier '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (244,16): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (246,25): Cannot find name 'Partial'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (366,39): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (2083,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5636,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5643,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5650,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5657,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5690,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5699,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5706,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5713,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5722,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5729,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5736,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5745,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5752,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5759,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5768,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5775,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5782,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,9): A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,10): Cannot find name 'P'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,15): Cannot find name 'keyof'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,21): Cannot find name 'T'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,26): A parameter initializer is only allowed in a function or constructor implementation.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,31): Cannot find name 'T'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,40): Cannot find name 'boolean'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11511,29): Cannot find name 'ConformsPredicateObject'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11522,42): Cannot find name 'ConformsPredicateObject'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (12762,29): Cannot find name 'object'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15452,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15461,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15494,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15503,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15538,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15547,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15580,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15589,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15622,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15629,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15662,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15669,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15685,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15694,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15704,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15714,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15724,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15734,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15744,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15754,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15789,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15797,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15804,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15836,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15844,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15851,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15914,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15914,37): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15930,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16591,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16601,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16611,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16680,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16689,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16698,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16758,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16767,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16777,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16787,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16797,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16807,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16817,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16827,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16846,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16855,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16864,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16874,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16882,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16892,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16900,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16922,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16932,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16942,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16953,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16962,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16973,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16982,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17139,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17147,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17154,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17170,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17179,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17188,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17197,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17207,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17215,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17225,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17233,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17984,39): Cannot find name 'TemplateSettings'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18604,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18612,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18734,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18742,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18751,47): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18760,47): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18876,31): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18913,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18920,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18927,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18934,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18941,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18953,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18960,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18967,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18974,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18981,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18993,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19000,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19007,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19014,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19021,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19032,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19072,53): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19079,58): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19086,58): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19246,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19270,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19293,23): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19316,23): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19339,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19507,15): All declarations of 'WeakMap' must have identical type parameters.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19507,33): Cannot find name 'object'.
</code>```

Please me know what I am missing here.

答:
I recently encountered this error. Either downgrade the @types/lodash dependency to ts2.0,

```<code>"dependencies": {
    "lodash": "^4.17.0",
    "@types/lodash": "ts2.0",
}
</code>```

or upgrade your typescript version to 2.2:

```<code>{
  "dependencies": {
    "lodash": "^4.17.0",
    "@types/lodash": "^4.14.58",
    "typescript": "^2.2.0",
  }
}
</code>```

The further usage is import * as _ from 'lodash';

ContentLicense: CC BY-SA 3.0

Body:
I'm getting a MASSIVE stack of errors after installing lodash in my Angular 2 project. To test, I started a new project with the CLI: ng new tester, then I installed lodash with npm install --save @types/lodash. Then I ran ng serve, and I got the following:

ERROR in /Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,21): ']' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,22): ';' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,23): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,33): ']' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,34): ')' expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,35): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,37): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19499,1): Declaration or statement expected.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (244,13): Duplicate identifier '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (248,19): Duplicate identifier '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (244,16): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (246,25): Cannot find name 'Partial'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (366,39): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (2083,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5636,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5643,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5650,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5657,44): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5690,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5699,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5706,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5713,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5722,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5729,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5736,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5745,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5752,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5759,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5768,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5775,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (5782,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,9): A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,10): Cannot find name 'P'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,15): Cannot find name 'keyof'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,21): Cannot find name 'T'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,26): A parameter initializer is only allowed in a function or constructor implementation.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,31): Cannot find name 'T'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11502,40): Cannot find name 'boolean'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11511,29): Cannot find name 'ConformsPredicateObject'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (11522,42): Cannot find name 'ConformsPredicateObject'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (12762,29): Cannot find name 'object'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15452,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15461,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15494,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15503,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15538,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15547,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15580,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15589,12): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15622,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15629,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15662,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15669,24): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15685,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15694,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15704,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15714,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15724,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15734,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15744,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15754,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15789,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15797,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15804,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15836,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15844,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15851,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15914,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15914,37): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (15930,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16591,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16601,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16611,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16680,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16689,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16698,33): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16758,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16767,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16777,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16787,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16797,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16807,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16817,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16827,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16846,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16855,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16864,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16874,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16882,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16892,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16900,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16922,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16932,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16942,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16953,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16962,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16973,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (16982,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17139,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17147,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17154,21): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17170,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17179,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17188,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17197,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17207,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17215,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17225,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17233,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (17984,39): Cannot find name 'TemplateSettings'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18604,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18612,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18734,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18742,19): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18751,47): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18760,47): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18876,31): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18913,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18920,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18927,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18934,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18941,43): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18953,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18960,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18967,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18974,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18981,40): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (18993,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19000,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19007,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19014,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19021,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19032,39): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19072,53): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19079,58): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19086,58): Cannot find name 'Many'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19246,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19270,22): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19293,23): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19316,23): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19339,21): Cannot find namespace '_'.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19507,15): All declarations of 'WeakMap' must have identical type parameters.
/Users/bradley/Work/test/tester2/node_modules/@types/lodash/index.d.ts (19507,33): Cannot find name 'object'.

Please me know what I am missing here.

Body:
I recently encountered this error. Either downgrade the @types/lodash dependency to ts2.0,

"dependencies": {
    "lodash": "^4.17.0",
    "@types/lodash": "ts2.0",
}

or upgrade your typescript version to 2.2:

{
  "dependencies": {
    "lodash": "^4.17.0",
    "@types/lodash": "^4.14.58",
    "typescript": "^2.2.0",
  }
}

The further usage is import * as _ from 'lodash';


问:
Workbooks.open on a specific USB drive
I wanted to know how to test a drive before openning it.
For example if the USB is on the E: or F:
Something like this :

```<code>if (?DriveExist?)
   Workbooks.Open Filename:="E:"
else
   Workbooks.Open Filename:="F:"
</code>```

Thanks for the help

答:
This would do it:

```<code>Function driveexists(DriveName As String)
    Dim objDrv      As Object
    driveexists = False

    For Each objDrv In CreateObject("Scripting.FileSystemObject").Drives
       If DriveName = objDrv.DriveLetter Then driveexists = True
    Next

    Set objDrv = Nothing
End Function
</code>```

So you'd use it as

```<code>IF driveexists("F") then...
</code>```

Title: Workbooks.open on a specific USB drive

Body:
I wanted to know how to test a drive before openning it.
For example if the USB is on the E: or F:
Something like this :

if (?DriveExist?)
   Workbooks.Open Filename:="E:"
else
   Workbooks.Open Filename:="F:"

Thanks for the help

Body:
This would do it:

Function driveexists(DriveName As String)
    Dim objDrv      As Object
    driveexists = False

    For Each objDrv In CreateObject("Scripting.FileSystemObject").Drives
       If DriveName = objDrv.DriveLetter Then driveexists = True
    Next

    Set objDrv = Nothing
End Function

So you'd use it as

IF driveexists("F") then...


问:
HIbernate - @Where equivalent in XML configuration for Restricting Collections
I would like to use the functionality that is provided by @Where to restrict collections only to the items that have status ACTIVE.
However, I cannot use annotations only xml. Therefore I look for @Where equivalent in xml but I cannot found anything.

Example ( I need something like  element "where")

```<code><hibernate-mapping>
<class name="Teacher" table="teacher" >
    ...

    <bag name="subjects" inverse="true" cascade="save-update">
        <key>
            <column name="id_policy" />
        </key>
        <one-to-many class="Subject" />
        <where>status = 'a'</where>
    </bag>

    ....
</class>
</hibernate-mapping>
</code>```

Of course, I can use the custom collection loader, but this is quite ugly for such simple task.
The filter is a more suitable option but it must be enabled explicitly for Hibernate session and I simply need this "where" clause to be applied always.

Any ideas?

答:
you can easily add the where clause in the tag, like this example:</p>

```<code><bag name="subjects" inverse="true" cascade="save-update" where="flag_visible='S'" >
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I would like to use the functionality that is provided by @Where to restrict collections only to the items that have status ACTIVE.
However, I cannot use annotations only xml. Therefore I look for @Where equivalent in xml but I cannot found anything.

Example ( I need something like  element "where")

<hibernate-mapping>
<class name="Teacher" table="teacher" >
    ...

    <bag name="subjects" inverse="true" cascade="save-update">
        <key>
            <column name="id_policy" />
        </key>
        <one-to-many class="Subject" />
        <where>status = 'a'</where>
    </bag>

    ....
</class>
</hibernate-mapping>

Of course, I can use the custom collection loader, but this is quite ugly for such simple task.
The filter is a more suitable option but it must be enabled explicitly for Hibernate session and I simply need this "where" clause to be applied always.

Any ideas?

Body:
you can easily add the where clause in the tag, like this example:

<bag name="subjects" inverse="true" cascade="save-update" where="flag_visible='S'" >


问:
Off heap not working when query parallelism is set
We are trying 1.9 query parallelism in the cache config but It doesn't  work with off heap.If we comment out parallelism everything works fine.  Paralellism works fine with on heap . </p>

<p>Are we missing anything ? </p>

答:
There is a known bug [1] that already fixed and merged to master branch. You can apply it to 1.9 and build ignite from sources.

[1] https://issues.apache.org/jira/browse/IGNITE-4826

Body:
We are trying 1.9 query parallelism in the cache config but It doesn't  work with off heap.If we comment out parallelism everything works fine.  Paralellism works fine with on heap .

Are we missing anything ?


问:
Which is the best method to perform string concatenation in PHP?
In php we can append strings in many ways.

```<code>            Method 1
            ----------------------------
            $sql  = "SELECT field1, ";
            $sql .= "       field2, ";
            $sql .= "       field3, ";
            $sql .= "       field4, ";
            $sql .= "FROM   table1 ";
            $sql .= "WHERE  condition1 = '".$value."' " ;

            Method 2
            ----------------------------
            $sql  = 'SELECT field1, ';
            $sql .= '       field2, ';
            $sql .= '       field3, ';
            $sql .= '       field4, ';
            $sql .= 'FROM   table1 ';
            $sql .= 'WHERE  condition1 = "'.$value.'" ' ;

            Method 3
            ----------------------------
            $sql  = 'SELECT field1,
                           field2,
                           field3,
                           field4,
                    FROM   table1
                    WHERE  condition1 = "'.$value.'" ' ;

            Method 4
            ----------------------------
            $str = <<<HEREDOC
                    SELECT field1,
                           field2,
                           field3,
                           field4,
                    FROM   table1
                    WHERE  condition1 = "$value"
            HEREDOC;
</code>```

Which of the above is the best approach? Are there any other methods which will result in better performance?

答: creating the query itself doesn't take the smallest amount of memory or cpu(it does but in such small nr that it doesnt matter) from your computer but running it, is what you should be concerned about, make sure you have a proper index and so on</p>

Body:
In php we can append strings in many ways.

            Method 1
            ----------------------------
            $sql  = "SELECT field1, ";
            $sql .= "       field2, ";
            $sql .= "       field3, ";
            $sql .= "       field4, ";
            $sql .= "FROM   table1 ";
            $sql .= "WHERE  condition1 = '".$value."' " ;

            Method 2
            ----------------------------
            $sql  = 'SELECT field1, ';
            $sql .= '       field2, ';
            $sql .= '       field3, ';
            $sql .= '       field4, ';
            $sql .= 'FROM   table1 ';
            $sql .= 'WHERE  condition1 = "'.$value.'" ' ;

            Method 3
            ----------------------------
            $sql  = 'SELECT field1,
                           field2,
                           field3,
                           field4,
                    FROM   table1
                    WHERE  condition1 = "'.$value.'" ' ;

            Method 4
            ----------------------------
            $str = <<<HEREDOC
                    SELECT field1,
                           field2,
                           field3,
                           field4,
                    FROM   table1
                    WHERE  condition1 = "$value"
            HEREDOC;

Which of the above is the best approach? Are there any other methods which will result in better performance?


问:
Android: Elevation missing on button when setting a gradient drawable as background
I have a Button and I am setting as background a gradient drawable.
The buttons with the gradient drawable are missing the elevation whereas all other buttons have the elevation.

Why is the elevation missing on the buttons with the gradient drawable? And is there any easy way to fix this?

My code looks like this:

gradient.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>

        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">

            <gradient
                android:type="radial"
                android:gradientRadius="250dp"
                android:startColor="@color/blue"
                android:endColor="@color/red"/>

            <corners android:radius="@dimen/round_corner_radius"/>

            <stroke
                android:width="5dp"
                android:color="@android:color/transparent"/>

        </shape>

    </item>

    <item android:top="7dp"
        android:left="7dp"
        android:right="7dp"
        android:bottom="7dp">

        <shape android:shape="rectangle" >

            <solid android:color="#88ffffff"/>
            <corners android:radius="@dimen/round_corner_radius"/>

        </shape>

    </item>

</layer-list>
</code>```

activity.xml

```<code>...
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button"
        android:background="@drawable/gradient"/>
...
</code>```

答:
I solved my problem. I had to remove the

```<code><stroke
    android:width="5dp"
    android:color="@android:color/transparent"/>
</code>```

The problem was probably the color that was set. Without the stroke the button behaves like a normal raised button.

Body:
I have a Button and I am setting as background a gradient drawable.
The buttons with the gradient drawable are missing the elevation whereas all other buttons have the elevation.

Why is the elevation missing on the buttons with the gradient drawable? And is there any easy way to fix this?

My code looks like this:

gradient.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>

        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">

            <gradient
                android:type="radial"
                android:gradientRadius="250dp"
                android:startColor="@color/blue"
                android:endColor="@color/red"/>

            <corners android:radius="@dimen/round_corner_radius"/>

            <stroke
                android:width="5dp"
                android:color="@android:color/transparent"/>

        </shape>

    </item>

    <item android:top="7dp"
        android:left="7dp"
        android:right="7dp"
        android:bottom="7dp">

        <shape android:shape="rectangle" >

            <solid android:color="#88ffffff"/>
            <corners android:radius="@dimen/round_corner_radius"/>

        </shape>

    </item>

</layer-list>

activity.xml

...
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button"
        android:background="@drawable/gradient"/>
...

Body:
I solved my problem. I had to remove the

<stroke
    android:width="5dp"
    android:color="@android:color/transparent"/>

The problem was probably the color that was set. Without the stroke the button behaves like a normal raised button.


问:
Set filename of the Pdf that is streamed back to the browser
I have a Java webapp creating a pdf and streaming it back to the browser.

```<code> byte[] pdf = report.exportPdfToArray(user);
response.setContentType("application/pdf");
response.setHeader("content-disposition", "inline; filename=\"My.pdf\"");
outStream = response.getOutputStream();
outStream.write(pdf);
outStream.flush();
outStream.close();
</code>```

The report is executed and it is sent back to the browser, but I can not control the name of the file even though I set the content-disposition.
I am using Jboss 4.2.1. Do you know what am I missing?

EDIT: So is there any way to set the filename when the content-disposition is inline?

答:
It's weird but it can be useful for someone(maybe someone can tell what is wrong with it):

When I set two headers like:

```<code>response.addHeader("content-length", String.valueOf(((FileInputStream) is).getChannel().size()));
response.addHeader("Content-disposition", "attachment; filename=\"MyFileName.doc\"");
</code>```

It doesn't work. But when I change the order it works as expected:

```<code>response.addHeader("Content-disposition", "attachment; filename=\"MyFileName.doc\"");
response.addHeader("content-length", String.valueOf(((FileInputStream) is).getChannel().size()));
</code>```

Body:
I have a Java webapp creating a pdf and streaming it back to the browser.

 byte[] pdf = report.exportPdfToArray(user);
response.setContentType("application/pdf");
response.setHeader("content-disposition", "inline; filename=\"My.pdf\"");
outStream = response.getOutputStream();
outStream.write(pdf);
outStream.flush();
outStream.close();

The report is executed and it is sent back to the browser, but I can not control the name of the file even though I set the content-disposition.
I am using Jboss 4.2.1. Do you know what am I missing?

EDIT: So is there any way to set the filename when the content-disposition is inline?

Body:
It's weird but it can be useful for someone(maybe someone can tell what is wrong with it):

When I set two headers like:

response.addHeader("content-length", String.valueOf(((FileInputStream) is).getChannel().size()));
response.addHeader("Content-disposition", "attachment; filename=\"MyFileName.doc\"");

It doesn't work. But when I change the order it works as expected:

response.addHeader("Content-disposition", "attachment; filename=\"MyFileName.doc\"");
response.addHeader("content-length", String.valueOf(((FileInputStream) is).getChannel().size()));


问:
Server error when trying to report Achievement to GameCenter
When using the code from Apple,

```<code>- (void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent
{
    GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
    if (achievement)
    {
  achievement.percentComplete = percent;
  [achievement reportAchievementWithCompletionHandler:^(NSError *error)
   {
    if (error != nil)
    {
     NSLog(@"problem with reporting");
     NSLog(@"%@",[error localizedDescription]);
     // Retain the achievement object and try again later (not shown).
    }
   }];
    }
}
</code>```

I  get the error:

The requested operation could not be completed due to an error communicating with the server.

I have verified the user and it seems to register that i have played the game, but it cannot record the achievement.  Any ideas?

答: Try using the reachability sample application from Apple to find out if the iPhone is connected to the internet via wifi or 3G. http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html </p>

Body:
When using the code from Apple,

- (void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent
{
    GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
    if (achievement)
    {
  achievement.percentComplete = percent;
  [achievement reportAchievementWithCompletionHandler:^(NSError *error)
   {
    if (error != nil)
    {
     NSLog(@"problem with reporting");
     NSLog(@"%@",[error localizedDescription]);
     // Retain the achievement object and try again later (not shown).
    }
   }];
    }
}

I  get the error:

The requested operation could not be completed due to an error communicating with the server.

I have verified the user and it seems to register that i have played the game, but it cannot record the achievement.  Any ideas?


问:
Android library project debugging quickly
I am developing a library project. Right now my debugging process is something like this :

Make some changes in library code

build it into an aar file

use the aar file in main app project as new library module

then debug the code changes in lib code.

As you can see it's a long process and takes a lot of time to debug library. What is the proper way for library development using android studio?

答:
You can do this way:

Add library module in same project directory like app folder : File-> new-> new module -> Android Library.

Add your library module name in setting.gradle (eg. include ':app',':xyz') : should be added automatically

Right click on your main app folder-> open module settings -> add your library as dependency to "app" (it's under module dependency).

Go to build.gradle file of your main project, add module like compile project (':xyz')

No need to create aar , just make changes in lib module and Run your main project and debug it .

Hope this will help you !


问:
PHP Google_Client insert youtube playlistItem (2-leg-oauth)
My web using the PHP Google_Client to insert the youtube playlistItem in my playlist (2-leg-oauth),
and get the error
Client is unauthorized to retrieve access tokens using this method.
Where can I setting the server using my-account@gmail.com to have the same permission to access google api
such like insert playlistItem,
or is there having another way without using my-account@gmail.com to get same permission?

PHP Code:

```<code>putenv('GOOGLE_APPLICATION_CREDENTIALS=client_secret.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/youtube');
$client->setSubject('my-account@gmail.com');
</code>```

答:
You're hitting a common problem. Many developers think that a Service Account is the correct way for server apps to communicate to Google's API services for a given Google account. It isn't! A Service Account, as its name implies, is a brand new account (actually a kind of half-account since you can't actually log in to it) that is dedicated to your app.

What you need to do is a one-time procedure to generate a Refresh Token, which you will store securely. Thereafter, whenever you need to access a Google API such as YouTube, you will use that Refresh Token to generate an Access Token, which you will include in each API request. The steps are enumerated How do I authorise an app (web or installed) without user intervention? (canonical ?) and https://www.youtube.com/watch?v=hfWe1gPCnzc

Body:
My web using the PHP Google_Client to insert the youtube playlistItem in my playlist (2-leg-oauth),
and get the error
Client is unauthorized to retrieve access tokens using this method.
Where can I setting the server using my-account@gmail.com to have the same permission to access google api
such like insert playlistItem,
or is there having another way without using my-account@gmail.com to get same permission?

PHP Code:

putenv('GOOGLE_APPLICATION_CREDENTIALS=client_secret.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/youtube');
$client->setSubject('my-account@gmail.com');


问:
Typescript : require statement not part of an import statement
Typescript version 2.2.2

I wrote this require in my UserRoutzr.ts

```<code>const users = <IUser[]> require(path.join(process.cwd() + "/data"));
</code>```

TSLint is raising the following warning:

```<code>require statement not part of an import statement
</code>```

if I changed it to :

```<code>import users = <IUser[]> require(path.join(process.cwd() + "/data"));
</code>```

Then it's raising an error :

```<code>TS1003 Identifier expected
</code>```

How should I rewrite this require ?
thanks for feedback

答:
TypeScript modules are an implementation of ES6 modules. ES6 modules are static. Your issue comes from the dynamic path: path.join(process.cwd() + "/data"). The compiler can't determine which module it is at compile time, and the linter doesn't like the causes that lead to any.

You should use a static path to the module. At compile time, TypeScript resolves it. And it affects the right exported type (IUser[]) to users.

```<code>import users = require("./yourModuleThatExportsUsers");
</code>```

Notice: If your module data contains just data, you could consider to change it to a JSON file, which could be loaded (Node.js) or bundled (Webpack).

UPDATE (from May 2019) — It is also possible to use dynamic import, with which TypeScript accepts static and dynamic paths:

```<code>const users = await import("./yourModuleThatExportsUsers");
</code>```

See also: TypeScript 2.4 Release Notes

Body:
Typescript version 2.2.2

I wrote this require in my UserRoutzr.ts

const users = <IUser[]> require(path.join(process.cwd() + "/data"));

TSLint is raising the following warning:

require statement not part of an import statement

if I changed it to :

import users = <IUser[]> require(path.join(process.cwd() + "/data"));

Then it's raising an error :

TS1003 Identifier expected

How should I rewrite this require ?
thanks for feedback

Body:
TypeScript modules are an implementation of ES6 modules. ES6 modules are static. Your issue comes from the dynamic path: path.join(process.cwd() + "/data"). The compiler can't determine which module it is at compile time, and the linter doesn't like the causes that lead to any.

You should use a static path to the module. At compile time, TypeScript resolves it. And it affects the right exported type (IUser[]) to users.

import users = require("./yourModuleThatExportsUsers");

Notice: If your module data contains just data, you could consider to change it to a JSON file, which could be loaded (Node.js) or bundled (Webpack).

UPDATE (from May 2019) — It is also possible to use dynamic import, with which TypeScript accepts static and dynamic paths:

const users = await import("./yourModuleThatExportsUsers");

See also: TypeScript 2.4 Release Notes


问:
How to import external libraries in jshell java 9?
I was trying to understand jshell and fumbled to import external library. As of date I couldn't see any suggestion/solution for this.

Can someone please let me know if already figured this out.

答:
I tried with 9 Build 162 Linux 64-bit with preparation:

Downloaded guava-19.0.jar and commons-lang3-3.4.jar to
/opt/libs

The following options are available:

Specify CLASSPATH environment variable:

$> CLASSPATH="/opt/libs/commons-lang3-3.4.jar:/opt/libs/guava-19.0.jar" bin/jshell

Specify classpath with jshell option:

$> bin/jshell --class-path /opt/libs/guava-19.0.jar:/opt/libs/commons-lang3-3.4.jar

Configure evaluation context within jshell session with command /env, /reset or /reload(these commands are different, you can check out with its help info), take /env as example:

jshell> /env -class-path /opt/libs/commons-lang3-3.4.jar:/opt/libs/guava-19.0.jar

And then you're able to either import org.apache.commons.lang3.StringUtils or import com.google.common.base.Optional;.


问:
Nougat 7.1.2 debug issue
I recently enrolled my Pixel XL for Android Beta program. After the update to Nougat 7.1.2 my device is not detected properly in Android Studio Linux.

I get something like this in AVD monitor

```<code>HT6A70201284 [null]
</code>```

But it was working on my windows desktop, I tried it on other linux devices and got the same issue. I came across a post mentioning about the driver support, so I updated my SDK to Android O preview, but it had no use.

Another strange behavior is when I turn of the debug mode in phone, it gets detected by my linux system, other posts state the same driver issues, but I am not able to figure out exactly which driver and from where I am supposed to install.

答:
I am not sure if anyone else faced this issue, but after trying several stuffs, the problem seems to be solved temporarily.

Generally I use my device in charging mode while developing the apps, but after the update Android studio detects the device in Data Transfer Mode only, somehow, USB mode charging has some bugs in preview release and couldn't be detected by Android Studio.

Title: Nougat 7.1.2 debug issue

Body:
I recently enrolled my Pixel XL for Android Beta program. After the update to Nougat 7.1.2 my device is not detected properly in Android Studio Linux.

I get something like this in AVD monitor

HT6A70201284 [null]

But it was working on my windows desktop, I tried it on other linux devices and got the same issue. I came across a post mentioning about the driver support, so I updated my SDK to Android O preview, but it had no use.

Another strange behavior is when I turn of the debug mode in phone, it gets detected by my linux system, other posts state the same driver issues, but I am not able to figure out exactly which driver and from where I am supposed to install.


问:
SKErrorDomain Code=0 in In-App Purchase
Today, when testing IAP in sandbox mode, we suddenly got SKPaymentTransactionStateFailed with Error message:

Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}

Then the alert comes

It works before, we did not change any IAP related Code.

I have searched stackoverflow and google and tried these:

Test with device, not simulator,

Make sure product id is right.

Make sure the build number in XCode General Settings is right

Create new sandbox test account in iTunes connect, and logout all other account, then test with sandbox test account.

Reboot/Reset the device

Make sure apple developer account is not renewed recently

None of these works for me. Any suggestions？

Update: I think it is the iTunes Connect Server problem, it is solved now.

答:
There seems to be a bug going on just now. Our logs show increased errors in both production and sandbox. So far we haven't seen any solution yet.

--Edit--

This has been fixed.

Voting to close this issue to prevent confusing future similar problems.

Title: SKErrorDomain Code=0 in In-App Purchase


答:
As far as I'm concerned there is no 'best method'.

Rule of thumb is choose one you prefer and stick to it and be consistent across the project.

Title: Which is the best method to perform string concatenation in PHP?


问:
is it better to use Html js DOM or Use CSS for responsive design?
So i am trying to build mobile version of a Website and using CSS to change the styles when window's width is smaller than 400. basically website has 3 main sections upper, middle and bottom.i'have somehow made upper div adjust and displays on all devices very well but the middle and bottom div has to be completely removed and reconstructed. i have two options: get two pre-designed divs for each section(One for desktop and one for mobile).and hide one for mobile when page is loaded on desktop and vise versa. another option is creating all elements using javascript when page loads in mobile. which one is better and faster?</p>

答: I Suggest you go with CSS. If you wanna make mobile suitable application then CSS is great. We cant rely on JavaScript for the sake of design. You can use CSS+JS for any transformation thing like slides, any action or any event.</p>


问:
Create structures in loop without naming them
Let's say I want to create structures in a loop. I don't want to change the values of the structure variables in each loop, I want to create new ones. However, from what I've learnt until know I have to name every new structure I make. Is there a way to do it without naming the structures?

And more specifically, can I have a pointer in each structure that will point to the next one?

What I wanna make is a BST and my struct is for every new node I add to the tree.That's how I've seen people do it, with struct. How can I add nodes if I don't name them? I definitely have some blanks there.

答:
You can use a struct variable many times in the loop by using malloc() to allocate memory for each iteration

```<code>#include<stdio.h>
#include<stdlib.h>
struct structname
{
int a;
struct structname* b;  //points to next struct
};
int main()
{
struct structname* ptr[10]; //
for(int i=0; i<10; i++)
    {
     ptr[i] = (struct structname*)malloc(sizeof(struct structname));
     ptr[i]->a=1;
     ptr[i]->b=NULL; //point to next struct instead of NULL
    }
}
</code>```

However if you know the number of struct s before hand you can create an array to hold the struct s

```<code>#include<stdio.h>
#include<stdlib.h>
struct structname
{
int a;
};
int main()
{
 struct structname array[10];
for(int i=0; i<10; i++)
    {
     array[i].a = 1; //input number here
    //no need of pointing to next struct as its already in an array
     }
}
</code>```

Body:
You can use a struct variable many times in the loop by using malloc() to allocate memory for each iteration

#include<stdio.h>
#include<stdlib.h>
struct structname
{
int a;
struct structname* b;  //points to next struct
};
int main()
{
struct structname* ptr[10]; //
for(int i=0; i<10; i++)
    {
     ptr[i] = (struct structname*)malloc(sizeof(struct structname));
     ptr[i]->a=1;
     ptr[i]->b=NULL; //point to next struct instead of NULL
    }
}

However if you know the number of struct s before hand you can create an array to hold the struct s

#include<stdio.h>
#include<stdlib.h>
struct structname
{
int a;
};
int main()
{
 struct structname array[10];
for(int i=0; i<10; i++)
    {
     array[i].a = 1; //input number here
    //no need of pointing to next struct as its already in an array
     }
}


问:
Incrementing certain values in "Tuples" in Python
Is there a way to increment a value for each distinct collision?

For example, I have a hash table [(1234, 1), (5678, 5), (2145, 7)] and I had a collision with 1234 and I want to update the entire tuple to (1234, 2). I found a way to do so, which is to initialise a variable called val = 0 but the problem is, it'll increment from where it left off.

```<code>def __init__(self, size):
    self.val = 0

def __setitem__(self, key, value):

    position = self.hash(key)
    j = 1

    for _ in range(self.table_size):
        #if there is nothing there, self.array[position] = (position, value)
        if self.array[position] is None:
            self.array[position] = (position, value)
            self.count += 1
            return

        elif self.array[position][0] == self.hash(key):
            #if there is an exisiting key and key == position, increment self.val
            self.val += 1
            self.array[position] = (position, self.val)
            self.collisions += 1
            return

        else:
            #if there's an existing key and key != position, find next available slot
            position = (position + j**2) % self.table_size
            j += 1
            self.collisions += 1
            self.count += 1
</code>```

Basically I want the self.val to go back to where it left off for it's own key but I do not know how to do that without resetting it and making every key start from 0 again.

答:
Tuples are not mutable in python, that's why you can't update the value. But also, that's not a hash table. Hashes are implemented as dictionaries in python. You can replace your structure by this:

```<code>d = {1234: 1, 5678: 5, 2145: 7}
</code>```

Then you can do things like d[1234] += 1 to increment the value.

Edit:

to conform with the restrictions of not using builtin types, you actually need to create a new tuple, since they are not mutable. But you should use the previous value you had in the tuple. It should look something like this:

```<code> self.array[position] = (position, self.array[position][1]+1)
</code>```

Body:
Is there a way to increment a value for each distinct collision?

For example, I have a hash table [(1234, 1), (5678, 5), (2145, 7)] and I had a collision with 1234 and I want to update the entire tuple to (1234, 2). I found a way to do so, which is to initialise a variable called val = 0 but the problem is, it'll increment from where it left off.

def __init__(self, size):
    self.val = 0

def __setitem__(self, key, value):

    position = self.hash(key)
    j = 1

    for _ in range(self.table_size):
        #if there is nothing there, self.array[position] = (position, value)
        if self.array[position] is None:
            self.array[position] = (position, value)
            self.count += 1
            return

        elif self.array[position][0] == self.hash(key):
            #if there is an exisiting key and key == position, increment self.val
            self.val += 1
            self.array[position] = (position, self.val)
            self.collisions += 1
            return

        else:
            #if there's an existing key and key != position, find next available slot
            position = (position + j**2) % self.table_size
            j += 1
            self.collisions += 1
            self.count += 1

Basically I want the self.val to go back to where it left off for it's own key but I do not know how to do that without resetting it and making every key start from 0 again.

Body:
Tuples are not mutable in python, that's why you can't update the value. But also, that's not a hash table. Hashes are implemented as dictionaries in python. You can replace your structure by this:

d = {1234: 1, 5678: 5, 2145: 7}

Then you can do things like d[1234] += 1 to increment the value.

Edit:

to conform with the restrictions of not using builtin types, you actually need to create a new tuple, since they are not mutable. But you should use the previous value you had in the tuple. It should look something like this:

 self.array[position] = (position, self.array[position][1]+1)


问:
Adding Model field from django views
I am using django-rest-framework with pandas to make an api and my models.py file looks like this

```<code>class Health(models.Model):
    Name = models.CharField(max_length=30,null=True,blank=True)
    Age = models.IntegerField(null=True,blank=True)
    Weight = models.FloatField(null=True,blank=True)
    Height = models.FloatField(null=True,blank=True)
    Sugar = models.FloatField(null=True,blank=True)
    def __str__(self):
        return self.Name
</code>```

and my views.py file looks like this

```<code>@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    df = read_frame(qs)
    df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
    df['1.96*std'] = 1.96*df['Age'].std()
    df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
    df['BMI'] = df['Weight']/(df['Height']/100)**2
    a = df.fillna(0)
    a = a.to_dict(orient = 'records')
    return Response(a)
</code>```

As you can see that i have no model field named BMI as I am creating it in my views using pandas dataframe and I want to save the field and it's corresponding data in my django database from django views. can anyone help me to achieve this task or suggest an appropriate way to do this.

答:
As said by AKS you need to create field for BMI in django models then updat e that field in your views using save.
Here is how you do it:

```<code>class Health(models.Model):
    Name = models.CharField(max_length=30,null=True,blank=True)
    Age = models.IntegerField(null=True,blank=True)
    Weight = models.FloatField(null=True,blank=True)
    Height = models.FloatField(null=True,blank=True)
    Sugar = models.FloatField(null=True,blank=True)
    BMI =  models.FloatField(null=True,blank=True)
    def __str__(self):
        return self.Name
</code>```

In your views do this:

```<code>@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    df = read_frame(qs)
    df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
    df['1.96*std'] = 1.96*df['Age'].std()
    df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
    df['BMI'] = df['Weight']/(df['Height']/100)**2

    # once the BMI is caluculated update the DB row with the value
    qs.BMI = df['BMI']
    qs.save()

    a = df.fillna(0)
    a = a.to_dict(orient = 'records')

    return Response(a)
</code>```

Try this:

view function:

```<code>@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    l = len(qs)

    if l>0:
        for x in qs:
            df = read_frame(x)
            df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
            df['1.96*std'] = 1.96*df['Age'].std()
            df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
            df['BMI'] = df['Weight']/(df['Height']/100)**2

            # once the BMI is caluculated update the DB row with the value
            x.BMI = df['BMI']
            x.save()

            a = df.fillna(0)
            a = a.to_dict(orient = 'records')

    else:
        print "no rows exists for the query "
</code>```

Hope this was useful.

Title: Adding Model field from django views

Body:
I am using django-rest-framework with pandas to make an api and my models.py file looks like this

class Health(models.Model):
    Name = models.CharField(max_length=30,null=True,blank=True)
    Age = models.IntegerField(null=True,blank=True)
    Weight = models.FloatField(null=True,blank=True)
    Height = models.FloatField(null=True,blank=True)
    Sugar = models.FloatField(null=True,blank=True)
    def __str__(self):
        return self.Name

and my views.py file looks like this

@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    df = read_frame(qs)
    df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
    df['1.96*std'] = 1.96*df['Age'].std()
    df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
    df['BMI'] = df['Weight']/(df['Height']/100)**2
    a = df.fillna(0)
    a = a.to_dict(orient = 'records')
    return Response(a)

As you can see that i have no model field named BMI as I am creating it in my views using pandas dataframe and I want to save the field and it's corresponding data in my django database from django views. can anyone help me to achieve this task or suggest an appropriate way to do this.

Body:
As said by AKS you need to create field for BMI in django models then updat e that field in your views using save.
Here is how you do it:

class Health(models.Model):
    Name = models.CharField(max_length=30,null=True,blank=True)
    Age = models.IntegerField(null=True,blank=True)
    Weight = models.FloatField(null=True,blank=True)
    Height = models.FloatField(null=True,blank=True)
    Sugar = models.FloatField(null=True,blank=True)
    BMI =  models.FloatField(null=True,blank=True)
    def __str__(self):
        return self.Name

In your views do this:

@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    df = read_frame(qs)
    df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
    df['1.96*std'] = 1.96*df['Age'].std()
    df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
    df['BMI'] = df['Weight']/(df['Height']/100)**2

    # once the BMI is caluculated update the DB row with the value
    qs.BMI = df['BMI']
    qs.save()

    a = df.fillna(0)
    a = a.to_dict(orient = 'records')

    return Response(a)

Try this:

view function:

@api_view(['GET'])
def my_view(request,id):
    qs = Health.objects.filter(id = id)
    l = len(qs)

    if l>0:
        for x in qs:
            df = read_frame(x)
            df['x-Mean'] = abs(df['Age'] - df['Age'].mean())
            df['1.96*std'] = 1.96*df['Age'].std()
            df['Outlier'] = abs(df['Age'] - df['Age'].mean()) > 1.96*df['Age'].std()
            df['BMI'] = df['Weight']/(df['Height']/100)**2

            # once the BMI is caluculated update the DB row with the value
            x.BMI = df['BMI']
            x.save()

            a = df.fillna(0)
            a = a.to_dict(orient = 'records')

    else:
        print "no rows exists for the query "

Hope this was useful.


问:
Extract Substring from String java
I want to extract specific substrings from a string:

```<code>String source = "info1 info1ContentA info1ContentB info3 info3ContentA info3ContentB"+
"info2 info2ContentA";
</code>```

The result should be:

```<code>String info1 ="info1ContentA info1ContentB";
String info2 ="info2ContentA";
String info3 ="info3ContentA info3ContentB";
</code>```

For me it's very difficult to extract the informations, because sometimes after "info" their are one, two or more content informations. Another problem that occurs is, that the order of info1, info2 etc. is not sorted and the "real data" doesn't contain a ascending number.

My first idea was to add info1, info2, info3 etc to an ArrayList.

```<code>private ArrayList<String> arr = new ArrayList<String>();
arr.add("info1");
arr.add("info2");
arr.add("info3");
</code>```

Now I want to extract the substring with the method StringUtils.substringBetween() from Apache Commons (https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.4):

```<code>String result = StringUtils.substringBetween(source, arr.get(0), arr.get(1));
</code>```

This works, if info1 is in the string before info2, but like I said the "real data" is not sorted.

Any idea how I can fix this?

答:
Split those string by space  and then use String's method startsWith to add the part to proper result string

```<code>Map<String, String> resultMap = new HashMap<String, String>();
String[] prefixes = new String[]{"info1", "info2", "info3"};
String source = "info1 info1ContentA info1ContentB info3 info3ContentA info3ContentB"+" info2 info2ContentA";
String[] parts = source.split(" ");

for(String part : parts) {
    for(String prefix : prefixes) {
        if(part.startsWith(prefix) {
            String currentResult = (resultMap.containsKey(prefix) ? resultMap.get(prefix) + part + " " : part);
            resultMap.put(prefix, currentResult);
        }
    }
}
</code>```

Also consider using StringBuilder instead of adding string parts

If you cannot be sure that parts will be embraces with spaces you can change at the beginning all part to <SPACE>part in your source string using String replace method

Title: Extract Substring from String java

Body:
I want to extract specific substrings from a string:

String source = "info1 info1ContentA info1ContentB info3 info3ContentA info3ContentB"+
"info2 info2ContentA";

The result should be:

String info1 ="info1ContentA info1ContentB";
String info2 ="info2ContentA";
String info3 ="info3ContentA info3ContentB";

For me it's very difficult to extract the informations, because sometimes after "info" their are one, two or more content informations. Another problem that occurs is, that the order of info1, info2 etc. is not sorted and the "real data" doesn't contain a ascending number.

My first idea was to add info1, info2, info3 etc to an ArrayList.

private ArrayList<String> arr = new ArrayList<String>();
arr.add("info1");
arr.add("info2");
arr.add("info3");

Now I want to extract the substring with the method StringUtils.substringBetween() from Apache Commons (https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.4):

String result = StringUtils.substringBetween(source, arr.get(0), arr.get(1));

This works, if info1 is in the string before info2, but like I said the "real data" is not sorted.

Any idea how I can fix this?

Body:
Split those string by space  and then use String's method startsWith to add the part to proper result string

Map<String, String> resultMap = new HashMap<String, String>();
String[] prefixes = new String[]{"info1", "info2", "info3"};
String source = "info1 info1ContentA info1ContentB info3 info3ContentA info3ContentB"+" info2 info2ContentA";
String[] parts = source.split(" ");

for(String part : parts) {
    for(String prefix : prefixes) {
        if(part.startsWith(prefix) {
            String currentResult = (resultMap.containsKey(prefix) ? resultMap.get(prefix) + part + " " : part);
            resultMap.put(prefix, currentResult);
        }
    }
}

Also consider using StringBuilder instead of adding string parts

If you cannot be sure that parts will be embraces with spaces you can change at the beginning all part to <SPACE>part in your source string using String replace method


问:
Cassandra vs HDFS to store analytics data
we have an Apache Spark cluster that analyse data stored in HDFS (.parquet).
The solution is optimal in terms of performance but it's not disaster safe as we would like, indeed, HDFS architecture has a single point of failure (the namenode) even using two namenode (you just have 2 point of failure but it's not enough).
To improve our cluster fault tolerance we would like to move to another data store solution like Cassandra.
Questions are:

With Cassandra as datastore is Spark able to leverage on DataLocality as it do with HDFS?

How this change can affect the performance?

Thanks

Matteo

答:
There's article about data locality, spark and Cassandra, so yes, it is possible:

https://www.slideshare.net/SparkSummit/cassandra-and-spark-optimizing-russell-spitzer-1

I didn't done any performance checks with Spark on HDFS vs Cassandra, and i believe it will vary depending on different workflows, but since Netflix and Microsoft using Cassandra with Spark, i believe performance is acceptable in most cases, and probably is a trade-off between data ingestion speed, existence/nonexistence of ETL and speed of the analytical process.

About hadoop single point of failure - If you will run Cassandra with replication factor 3 and consistency level quorum, you will get same 2 nodes down that will make data unavailable :) , keep it in mind.

And maybe consider MapR hadoop distribution, they've tried to solve namenode problem.


问:
Swipe between fragments in android bottom bar
I'm using BottomNavigationView and I'm trying to swipe between fragments, in tapLayout we use setupWithViewPager() is there any way to implement swipe in BottomNavigationView like this ?

thanks in advance.

答:
is there any way to implement swipe in BottomNavigationView like this ?

According to Material design guidelines, BottomNavigationView is not supposed to support swipe behavior. But i doubt why you stick with BottomNavigationView?  You can always use TabLayout in the bottom of your parent Layout. TabLayout also supports custom views, so there is not limits to implement any behavior. cheers :)


问:
RewriteRule : replace hyphens with plus signs
I just moved my website to a new permalink structure and need to do the following for some URLs.

I'd like to take the final "slug" after the number in
/Annuaire-Artisan-106-creation-complete-de-salle-de-bains.htm

Replace hyphens to plus signs, and redirect to /travaux/new+slug+with+plus+signs without the final .htm.

...So

```<code>/Annuaire-Artisan-106-creation-complete-de-salle-de-bains.htm
</code>```

becomes

```<code>/travaux/creation+complete+de+salle+de+bains
</code>```

I currently have :

```<code>RewriteRule ^Annuaire-Artisan-([0-9]+)-(.*)-(.*).htm$ /Annuaire-Artisan-$1-$2+$3.htm [L,R,NE]
</code>```

... that correctly transform the hyphens in the last part to plus signs :

```<code>/Annuaire-Artisan-106-creation+complete+de+salle+de+bains.htm
</code>```

But I can't find the second RewriteRule to ignore the initial Annuaire-Artisan-106-and final .htm and rewrite to /travaux/creation+complete+de+salle+de+bains

Any help would be greatly appreciated :)

答:
First of all, don't use the R|redirect flag at this stage, because the client will issue a new request for each hyphen replaced. This is also true for search engines, which might be bad for ranking. Rather use the L flag alone, or maybe N|next giving

```<code>RewriteRule ^(Annuaire-Artisan-[0-9]+)-(.*)-(.*)\.htm$ /$1-$2+$3.htm [N=100,NE]
</code>```

N=100 restricts the loop to at most 100 hyphens. You may adjust this to less, if you like.

The following rule would then remove .htm and replace the leading part. It takes a similar pattern and now, it will redirect the client to the new URL

```<code>RewriteRule ^Annuaire-Artisan-[0-9]+-(.*)\.htm$ /travaux/$1 [R,L,NE]
</code>```

When everything works as it should, you may replace R with R=301 (permanent redirect). Never test with R=301.

Body:
I just moved my website to a new permalink structure and need to do the following for some URLs.

I'd like to take the final "slug" after the number in
/Annuaire-Artisan-106-creation-complete-de-salle-de-bains.htm

Replace hyphens to plus signs, and redirect to /travaux/new+slug+with+plus+signs without the final .htm.

...So

/Annuaire-Artisan-106-creation-complete-de-salle-de-bains.htm

becomes

/travaux/creation+complete+de+salle+de+bains

I currently have :

RewriteRule ^Annuaire-Artisan-([0-9]+)-(.*)-(.*).htm$ /Annuaire-Artisan-$1-$2+$3.htm [L,R,NE]

... that correctly transform the hyphens in the last part to plus signs :

/Annuaire-Artisan-106-creation+complete+de+salle+de+bains.htm

But I can't find the second RewriteRule to ignore the initial Annuaire-Artisan-106-and final .htm and rewrite to /travaux/creation+complete+de+salle+de+bains

Any help would be greatly appreciated :)

Body:
First of all, don't use the R|redirect flag at this stage, because the client will issue a new request for each hyphen replaced. This is also true for search engines, which might be bad for ranking. Rather use the L flag alone, or maybe N|next giving

RewriteRule ^(Annuaire-Artisan-[0-9]+)-(.*)-(.*)\.htm$ /$1-$2+$3.htm [N=100,NE]

N=100 restricts the loop to at most 100 hyphens. You may adjust this to less, if you like.

The following rule would then remove .htm and replace the leading part. It takes a similar pattern and now, it will redirect the client to the new URL

RewriteRule ^Annuaire-Artisan-[0-9]+-(.*)\.htm$ /travaux/$1 [R,L,NE]

When everything works as it should, you may replace R with R=301 (permanent redirect). Never test with R=301.


问:
How to group factors by product and display if a product has more than one factor-pair?
Using a predefined array of numbers, how can I use PHP to generate a multi-dimensional array which groups all factor-pairs by their product?

Input array:

```<code>$array = array(1,2,3,4,5,6,7,8);
</code>```

I want to display all factor-pairs for each product group that have more than one factor-pair.

In a case where there are no product groups that have more than one factor-pair, No pairs Found should be displayed.

Given the above input, this is my expected result:

```<code>1 6 and 2 3  // product group = 6
1 8 and 2 4  // product group = 8
2 6 and 3 4  // product group = 12
3 8 and 4 6  // product group = 24
</code>```

*note as the input array increases in size, the output will display more than two factor-pairs per group.

This is my code from C++:

```<code> void findPairs(int arr[], int n)
{
    bool found = false;
    unordered_map<int, pair < int, int > > H;
    for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            // If product of pair is not in hash table,
            // then store it
            int prod = arr[i]*arr[j];
            if (H.find(prod) == H.end())
                H[prod] = make_pair(i,j);

            // If product of pair is also available in
            // then print current and previous pair
            else
            {
                pair<int,int> pp = H[prod];
                cout << arr[pp.first] << " " << arr[pp.second]
                     << " and " << arr[i]<<" "<<arr[j]<<endl;
                found = true;
            }
        }
    }
    // If no pair find then print not found
    if (found == false)
        cout << "No pairs Found" << endl;
}
</code>```

答:
This is your C++ code "translated" to PHP (mostly by search & replace).

90% of the translation was achieved by removing the variable types and prepending the variable names with $. The array PHP type is a mixture of array, list and map (aka hash, dictionary) and can be used for both $H and the values it contains (pairs of values).

```<code>function findPairs(array $arr, $n)
{
    $found = false;
    $H = array();
    for ($i=0; $i<$n; $i++)
    {
        for ($j=$i+1; $j<$n; $j++)
        {
            // If product of pair is not in hash table,
            // then store it
            $prod = $arr[$i]*$arr[$j];
            if (! array_key_exists($prod, $H))
                $H[$prod] = array($i,$j);

            // If product of pair is also available in
            // then print current and previous pair
            else
            {
                $pp = $H[$prod];
                echo $arr[$pp[0]], " ", $arr[$pp[1]]
                     , " and ", $arr[$i], " ", $arr[$j], "\n";
                $found = true;
            }
        }
    }
    // If no pair find then print not found
    if ($found == false)
        echo "No pairs Found\n";
}

$array = array(1,2,3,4,5,6,7,8);
findPairs($array, count($array));
</code>```

And this is its output:

```<code>1 6 and 2 3
1 8 and 2 4
2 6 and 3 4
3 8 and 4 6
</code>```

Body:
Using a predefined array of numbers, how can I use PHP to generate a multi-dimensional array which groups all factor-pairs by their product?

Input array:

$array = array(1,2,3,4,5,6,7,8);

I want to display all factor-pairs for each product group that have more than one factor-pair.

In a case where there are no product groups that have more than one factor-pair, No pairs Found should be displayed.

Given the above input, this is my expected result:

1 6 and 2 3  // product group = 6
1 8 and 2 4  // product group = 8
2 6 and 3 4  // product group = 12
3 8 and 4 6  // product group = 24

*note as the input array increases in size, the output will display more than two factor-pairs per group.

This is my code from C++:

 void findPairs(int arr[], int n)
{
    bool found = false;
    unordered_map<int, pair < int, int > > H;
    for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            // If product of pair is not in hash table,
            // then store it
            int prod = arr[i]*arr[j];
            if (H.find(prod) == H.end())
                H[prod] = make_pair(i,j);

            // If product of pair is also available in
            // then print current and previous pair
            else
            {
                pair<int,int> pp = H[prod];
                cout << arr[pp.first] << " " << arr[pp.second]
                     << " and " << arr[i]<<" "<<arr[j]<<endl;
                found = true;
            }
        }
    }
    // If no pair find then print not found
    if (found == false)
        cout << "No pairs Found" << endl;
}

Body:
This is your C++ code "translated" to PHP (mostly by search & replace).

90% of the translation was achieved by removing the variable types and prepending the variable names with $. The array PHP type is a mixture of array, list and map (aka hash, dictionary) and can be used for both $H and the values it contains (pairs of values).

function findPairs(array $arr, $n)
{
    $found = false;
    $H = array();
    for ($i=0; $i<$n; $i++)
    {
        for ($j=$i+1; $j<$n; $j++)
        {
            // If product of pair is not in hash table,
            // then store it
            $prod = $arr[$i]*$arr[$j];
            if (! array_key_exists($prod, $H))
                $H[$prod] = array($i,$j);

            // If product of pair is also available in
            // then print current and previous pair
            else
            {
                $pp = $H[$prod];
                echo $arr[$pp[0]], " ", $arr[$pp[1]]
                     , " and ", $arr[$i], " ", $arr[$j], "\n";
                $found = true;
            }
        }
    }
    // If no pair find then print not found
    if ($found == false)
        echo "No pairs Found\n";
}

$array = array(1,2,3,4,5,6,7,8);
findPairs($array, count($array));

And this is its output:

1 6 and 2 3
1 8 and 2 4
2 6 and 3 4
3 8 and 4 6


问:
Inequalities as python parameters
Firstly, Sry fo the bad title of this question I simply don't know a better one.
If you have a better one => Tell me!

So my problem is that I would like to write a simplex solver in Python by myself to deeply understand how they work.

Therefore, I would like to have something like this in my program:

```<code> m.addConstr(x[0] <= 7)
</code>```

Which basically should add a constraint to my model m.
This works in Gurobi which is just wonderful cause it's so easy to read.
The problem is that x[0] has to be an object where I itself can define what should happen when there is an inequality or equality or whatever, right?

I am happy to figure out most of the stuff by myself would just like to get an idea how this works.

答:
I don't think it should be your first concern to come up with an elegant input syntax. You should rather implement the simplex algorithm first.

I suggest, you handle the input by writing a parser for the two standard formats for linear programming problems: .lp and .mps

If you still want to know how to implement proper expression handling in Python I recommend you have a look at PySCIPOpt since this is exactly doing what you want and you can inspect the entire source code.

Title: Inequalities as python parameters

Body:
Firstly, Sry fo the bad title of this question I simply don't know a better one.
If you have a better one => Tell me!

So my problem is that I would like to write a simplex solver in Python by myself to deeply understand how they work.

Therefore, I would like to have something like this in my program:

 m.addConstr(x[0] <= 7)

Which basically should add a constraint to my model m.
This works in Gurobi which is just wonderful cause it's so easy to read.
The problem is that x[0] has to be an object where I itself can define what should happen when there is an inequality or equality or whatever, right?

I am happy to figure out most of the stuff by myself would just like to get an idea how this works.