问:
How to resolve conflicting declarations (CPU_SET_T) between ACE and Android?
Cross-Compile Target: Android 7

Host OS: Linux

NDK: Crystax 10.3.2 (b912)

OpenDDS: 3.11

Compiling OpenDDS fails and reports conflicting declarations of C++ macros. The ACE config-android.h file has this defined ...

```<code># define ACE_HAS_CPU_SET_T
</code>```

... which I've commented out, to no avail.

Anyone have thoughts on how to get past this? Here's the error message which I snipped just after some x86_64 building and where the arm build starts.

```<code>.... (snip)
make: Leaving directory '/home/dev/dds-test/OpenDDS-3.11/build/x86_64/dds/idl'
Searching /home/dev/dds-test/ACE_wrappers for files...
Found 25764 files and directories in 0 seconds.
Creating /home/dev/dds-test/ACE_wrappers/build/arm
Finished in /home/dev/dds-test/ACE_wrappers/build/arm
Total time: 1 seconds.
Searching /home/dev/dds-test/OpenDDS-3.11 for files...
Found 5220 files and directories in 0 seconds.
Creating /home/dev/dds-test/OpenDDS-3.11/build/arm
Finished in /home/dev/dds-test/OpenDDS-3.11/build/arm
Total time: 0 seconds.
MPC_ROOT was set to /home/dev/dds-test/ACE_wrappers/build/arm/MPC.
Using .../dds-test/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
CIAO_ROOT was used in the configuration file, but was not defined.
DANCE_ROOT was used in the configuration file, but was not defined.
Generating 'gnuace' output using TAO_ACE.mwc
Skipping SSL_FOR_TAO (ssl_for_tao.mpc); it requires ace_for_tao.
Skipping QoS (qos.mpc); it requires qos.
Skipping ACE_FOR_TAO (ace_for_tao.mpc); it requires ace_for_tao.
Skipping ACE_XML_Utils (XML.mpc); it requires xerces.
Skipping ACE_FoxReactor (ace_foxreactor.mpc); it requires fox.
Skipping ace_svcconf_gen (svcconfgen.mpc); it requires ace_svcconf_gen.
Skipping TAO_FoxResource (FoxResource.mpc); it requires fox.
Skipping Bzip2Compressor (Bzip2Compressor.mpc); it requires bzip2.
Skipping ZlibCompressor (ZlibCompressor.mpc); it requires zlib.
Skipping LzoCompressor (LzoCompressor.mpc); it requires lzo1.
Skipping TAO_IDL_GEN (tao_idl_fe.mpc); it requires tao_idl_fe_gen.
Skipping NamingViewer (NamingViewer.mpc); it requires mfc.
Skipping wxNamingViewer (wxNamingViewer.mpc); it requires wxWindows.
Generation Time: 49s
MPC_ROOT was set to /home/dev/dds-test/ACE_wrappers/build/arm/MPC.
Using .../dds-test/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
CIAO_ROOT was used in the configuration file, but was not defined.
DANCE_ROOT was used in the configuration file, but was not defined.
Generating 'gnuace' output using DDS.mwc
Skipping ishapes (ishapes.mpc); it requires boost.
Skipping DDS_Inconsistent_Qos_Inconsistent_Qos (Inconsistent_Qos.mpc); it requires xerces.
Skipping qos_dump (qos_dump.mpc); it requires xerces.
Skipping FaceUnitTests_SafetyProfilePool (FaceUnitTests.mpc); it avoids no_opendds_safety_profile.
Skipping OpenDDS_XML_QOS_XSC_Generation (qos_xml_handler.mpc); it requires xsc.
Skipping OpenDDS_QOS_XML_XSC_Handler (qos_xml_handler.mpc); it requires xerces.
Skipping OpenDDS_Corba (OpenDDS_Corba.mpc); it avoids no_opendds_safety_profile.
Skipping OpenDDS_CorbaSeq (CorbaSeq.mpc); it avoids no_opendds_safety_profile.
Skipping tao_java (tao_java.mpc); it requires java.
Skipping builtintopics_test (builtintopics_test.mpc); it requires java.
Skipping two_idl (two_idl.mpc); it requires java.
Skipping zerocopy_java_test (zerocopy.mpc); it requires java.
Skipping multirepo_test (multirepo_test.mpc); it requires java.
Skipping hello_java_client (hello_java_client.mpc); it requires java.
Skipping transport_config (transport_config.mpc); it requires java.
Skipping complex_idl_test (complex_idl_test.mpc); it requires java.
Skipping publisher_idl_test (publisher_idl_test.mpc); it requires java.
Skipping java_both_test (java_both_test.mpc); it requires java.
Skipping messenger_idl_test (messenger_idl_test.mpc); it requires java.
Skipping subscriber_idl_test (subscriber_idl_test.mpc); it requires java.
Skipping dcps_java (dcps_java.mpc); it requires java.
Skipping idl2jni_test_simple (idl2jni_test_simple.mpc); it requires java.
Skipping idl2jni_runtime (idl2jni_runtime.mpc); it requires java.
Skipping idl2jni_compact (idl2jni_compact.mpc); it requires java.
Skipping idl2jni_codegen (idl2jni_codegen.mpc); it requires java.
Skipping dissector (dissector.mpc); it requires wireshark.
Generation Time: 31s
calling make -C ace
make: Entering directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
make[1]: Entering directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
touch .depend.ACE
GNUmakefile: /home/dev/dds-test/ACE_wrappers/build/arm/ace/GNUmakefile.ACE MAKEFLAGS=w

arm-linux-androideabi-g++ -Wno-deprecated-declarations -W -Wall -Wpointer-arith -Wno-psabi -fno-strict-aliasing -Wall -W -Wpointer-arith -pipe  --sysroot=/opt/crystax-ndk/sysroot -I/opt/crystax-ndk/sysroot/usr/include -I/opt/crystax-ndk/include -D_REENTRANT  -D_GNU_SOURCE -DACE_HAS_CUSTOM_EXPORT_MACROS=0  -DNDEBUG  -I/home/dev/dds-test/ACE_wrappers/build/arm -DACE_NDEBUG -D__ACE_INLINE__ -I.. -DACE_AS_STATIC_LIBS  -c  -o .obj/Local_Name_Space.o Local_Name_Space.cpp
In file included from /home/dev/dds-test/ACE_wrappers/build/arm/ace/OS_NS_Thread.h:32:0,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Thread_Mutex.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Log_Category.h:20,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc.h:24,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc_T.h:18,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Local_Name_Space.h:20,
                 from Local_Name_Space.cpp::
/home/dev/dds-test/ACE_wrappers/build/arm/ace/os_include/os_sched.h:47:6: error: conflicting declaration 'typedef struct cpu_set_t cpu_set_t'
    } cpu_set_t;
      ^
In file included from /opt/crystax-ndk/sysroot/usr/include/sched.h:43:0,
                 from /opt/crystax-ndk/sysroot/usr/include/crystax/bionic/libc/include/mangled-pthread.h:33,
                 from /opt/crystax-ndk/sysroot/usr/include/pthread.h:43,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/os_include/os_pthread.h:54,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/OS_NS_Thread.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Thread_Mutex.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Log_Category.h:20,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc.h:24,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc_T.h:18,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Local_Name_Space.h:20,
                 from Local_Name_Space.cpp:3:
/opt/crystax-ndk/sysroot/usr/include/crystax/bionic/libc/include/mangled-sched.h:73:3:note: previous declaration as 'typedef struct cpu_set_t cpu_set_t'
 } cpu_set_t;
   ^
/home/dev/dds-test/ACE_wrappers/build/arm/include/makeinclude/rules.local.GNU:188: recipe for target '.obj/Local_Name_Space.o' failed
make[1]: *** [.obj/Local_Name_Space.o] Error 1
make[1]: Leaving directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
GNUmakefile:45: recipe for target 'ACE' failed
make: *** [ACE] Error 2
make: Leaving directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
calling TAO_ROOT make
... (snip)
</code>```

答: This can be solved by using TAO 6.4.3 and ACE 2.4.3 which you can download from Vanderbilt University. Look at the INSTALL for instructions how to set your own ACE/TAO version instead of downloading the OCI version as part of the configure script. I have made a pull request for OpenDDS to extend the configure script with a new option to let it download ACE/TAO from Vanderbilt University, hopefully that makes it into OpenDDS 3.12</p>

Body:
Cross-Compile Target: Android 7

Host OS: Linux

NDK: Crystax 10.3.2 (b912)

OpenDDS: 3.11

Compiling OpenDDS fails and reports conflicting declarations of C++ macros. The ACE config-android.h file has this defined ...

# define ACE_HAS_CPU_SET_T

... which I've commented out, to no avail.

Anyone have thoughts on how to get past this? Here's the error message which I snipped just after some x86_64 building and where the arm build starts.

.... (snip)
make: Leaving directory '/home/dev/dds-test/OpenDDS-3.11/build/x86_64/dds/idl'
Searching /home/dev/dds-test/ACE_wrappers for files...
Found 25764 files and directories in 0 seconds.
Creating /home/dev/dds-test/ACE_wrappers/build/arm
Finished in /home/dev/dds-test/ACE_wrappers/build/arm
Total time: 1 seconds.
Searching /home/dev/dds-test/OpenDDS-3.11 for files...
Found 5220 files and directories in 0 seconds.
Creating /home/dev/dds-test/OpenDDS-3.11/build/arm
Finished in /home/dev/dds-test/OpenDDS-3.11/build/arm
Total time: 0 seconds.
MPC_ROOT was set to /home/dev/dds-test/ACE_wrappers/build/arm/MPC.
Using .../dds-test/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
CIAO_ROOT was used in the configuration file, but was not defined.
DANCE_ROOT was used in the configuration file, but was not defined.
Generating 'gnuace' output using TAO_ACE.mwc
Skipping SSL_FOR_TAO (ssl_for_tao.mpc); it requires ace_for_tao.
Skipping QoS (qos.mpc); it requires qos.
Skipping ACE_FOR_TAO (ace_for_tao.mpc); it requires ace_for_tao.
Skipping ACE_XML_Utils (XML.mpc); it requires xerces.
Skipping ACE_FoxReactor (ace_foxreactor.mpc); it requires fox.
Skipping ace_svcconf_gen (svcconfgen.mpc); it requires ace_svcconf_gen.
Skipping TAO_FoxResource (FoxResource.mpc); it requires fox.
Skipping Bzip2Compressor (Bzip2Compressor.mpc); it requires bzip2.
Skipping ZlibCompressor (ZlibCompressor.mpc); it requires zlib.
Skipping LzoCompressor (LzoCompressor.mpc); it requires lzo1.
Skipping TAO_IDL_GEN (tao_idl_fe.mpc); it requires tao_idl_fe_gen.
Skipping NamingViewer (NamingViewer.mpc); it requires mfc.
Skipping wxNamingViewer (wxNamingViewer.mpc); it requires wxWindows.
Generation Time: 49s
MPC_ROOT was set to /home/dev/dds-test/ACE_wrappers/build/arm/MPC.
Using .../dds-test/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
CIAO_ROOT was used in the configuration file, but was not defined.
DANCE_ROOT was used in the configuration file, but was not defined.
Generating 'gnuace' output using DDS.mwc
Skipping ishapes (ishapes.mpc); it requires boost.
Skipping DDS_Inconsistent_Qos_Inconsistent_Qos (Inconsistent_Qos.mpc); it requires xerces.
Skipping qos_dump (qos_dump.mpc); it requires xerces.
Skipping FaceUnitTests_SafetyProfilePool (FaceUnitTests.mpc); it avoids no_opendds_safety_profile.
Skipping OpenDDS_XML_QOS_XSC_Generation (qos_xml_handler.mpc); it requires xsc.
Skipping OpenDDS_QOS_XML_XSC_Handler (qos_xml_handler.mpc); it requires xerces.
Skipping OpenDDS_Corba (OpenDDS_Corba.mpc); it avoids no_opendds_safety_profile.
Skipping OpenDDS_CorbaSeq (CorbaSeq.mpc); it avoids no_opendds_safety_profile.
Skipping tao_java (tao_java.mpc); it requires java.
Skipping builtintopics_test (builtintopics_test.mpc); it requires java.
Skipping two_idl (two_idl.mpc); it requires java.
Skipping zerocopy_java_test (zerocopy.mpc); it requires java.
Skipping multirepo_test (multirepo_test.mpc); it requires java.
Skipping hello_java_client (hello_java_client.mpc); it requires java.
Skipping transport_config (transport_config.mpc); it requires java.
Skipping complex_idl_test (complex_idl_test.mpc); it requires java.
Skipping publisher_idl_test (publisher_idl_test.mpc); it requires java.
Skipping java_both_test (java_both_test.mpc); it requires java.
Skipping messenger_idl_test (messenger_idl_test.mpc); it requires java.
Skipping subscriber_idl_test (subscriber_idl_test.mpc); it requires java.
Skipping dcps_java (dcps_java.mpc); it requires java.
Skipping idl2jni_test_simple (idl2jni_test_simple.mpc); it requires java.
Skipping idl2jni_runtime (idl2jni_runtime.mpc); it requires java.
Skipping idl2jni_compact (idl2jni_compact.mpc); it requires java.
Skipping idl2jni_codegen (idl2jni_codegen.mpc); it requires java.
Skipping dissector (dissector.mpc); it requires wireshark.
Generation Time: 31s
calling make -C ace
make: Entering directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
make[1]: Entering directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
touch .depend.ACE
GNUmakefile: /home/dev/dds-test/ACE_wrappers/build/arm/ace/GNUmakefile.ACE MAKEFLAGS=w

arm-linux-androideabi-g++ -Wno-deprecated-declarations -W -Wall -Wpointer-arith -Wno-psabi -fno-strict-aliasing -Wall -W -Wpointer-arith -pipe  --sysroot=/opt/crystax-ndk/sysroot -I/opt/crystax-ndk/sysroot/usr/include -I/opt/crystax-ndk/include -D_REENTRANT  -D_GNU_SOURCE -DACE_HAS_CUSTOM_EXPORT_MACROS=0  -DNDEBUG  -I/home/dev/dds-test/ACE_wrappers/build/arm -DACE_NDEBUG -D__ACE_INLINE__ -I.. -DACE_AS_STATIC_LIBS  -c  -o .obj/Local_Name_Space.o Local_Name_Space.cpp
In file included from /home/dev/dds-test/ACE_wrappers/build/arm/ace/OS_NS_Thread.h:32:0,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Thread_Mutex.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Log_Category.h:20,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc.h:24,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc_T.h:18,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Local_Name_Space.h:20,
                 from Local_Name_Space.cpp::
/home/dev/dds-test/ACE_wrappers/build/arm/ace/os_include/os_sched.h:47:6: error: conflicting declaration 'typedef struct cpu_set_t cpu_set_t'
    } cpu_set_t;
      ^
In file included from /opt/crystax-ndk/sysroot/usr/include/sched.h:43:0,
                 from /opt/crystax-ndk/sysroot/usr/include/crystax/bionic/libc/include/mangled-pthread.h:33,
                 from /opt/crystax-ndk/sysroot/usr/include/pthread.h:43,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/os_include/os_pthread.h:54,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/OS_NS_Thread.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Thread_Mutex.h:31,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Log_Category.h:20,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc.h:24,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Malloc_T.h:18,
                 from /home/dev/dds-test/ACE_wrappers/build/arm/ace/Local_Name_Space.h:20,
                 from Local_Name_Space.cpp:3:
/opt/crystax-ndk/sysroot/usr/include/crystax/bionic/libc/include/mangled-sched.h:73:3:note: previous declaration as 'typedef struct cpu_set_t cpu_set_t'
 } cpu_set_t;
   ^
/home/dev/dds-test/ACE_wrappers/build/arm/include/makeinclude/rules.local.GNU:188: recipe for target '.obj/Local_Name_Space.o' failed
make[1]: *** [.obj/Local_Name_Space.o] Error 1
make[1]: Leaving directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
GNUmakefile:45: recipe for target 'ACE' failed
make: *** [ACE] Error 2
make: Leaving directory '/home/dev/dds-test/ACE_wrappers/build/arm/ace'
calling TAO_ROOT make
... (snip)


来源: stackexchange

问:
JSP not Evaluating with Spring MVC
I am trying to render JSP in a Spring 3.2 using annotation driven configuration, but the JSP renders as a string and is not evaluated.

I am using the maven jetty plugin to run the webapp in development. So it seems as if everything should "just work".

The dependencies I am including to use JSP are

```<code><dependency>
  <groupId>javax.servlet.jsp</groupId>
  <artifactId>jsp-api</artifactId>
  <version>2.1</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>
</code>```

The bean to configure JSP is

```<code>@Configuration
public class WebAppConfiguration {
  @Bean
  public InternalResourceViewResolver internalResourceViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/views/");
    resolver.setSuffix(".jsp");
    return resolver;
  }
}
</code>```

The controller is pretty straight forward

```<code>@Controller
public class RootController {
  @RequestMapping(value = "/login")
  public String login() {
    return "login";
  }
</code>```

and the JSP is also pretty easy

```<code><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>

<html>
<head></head>
<body>
<%= "Hello World" %>
${ "Hello World" }
<form name="auth" action="<c:url value='j_spring_security_check' />" method="POST">
  <label>Username: <input type="text" name="j_username"></label>
  <label>Password: <input type="password" name="j_password"></label>
  <input type="submit" value="Submit"/>
</form>
</body>
</html>
</code>```

As you can see from the image the JSP is not being evaluated.  Is there anything I need to do to tell JSP to be evaluated when rendered.

Edit 1

So just for a little extra information I used the Resthub archetype resthub-mongodb-backbonejs-archetype to bootstrap this project, which uses a WebAppInitializer rather than the older web.xml, and it uses new annotation driven beans rather than the xml beans.

EDIT 2

I have been smashing my head on this for all to long so I put the project on github https://github.com/austinbv/calendar/. Since I do not know what is important and what is not.

Thanks for the help

答: Because JSP does not obey MVC pattern :P</p>

ContentLicense: CC BY-SA 3.0

Title: JSP not Evaluating with Spring MVC

Body:
I am trying to render JSP in a Spring 3.2 using annotation driven configuration, but the JSP renders as a string and is not evaluated.

I am using the maven jetty plugin to run the webapp in development. So it seems as if everything should "just work".

The dependencies I am including to use JSP are

<dependency>
  <groupId>javax.servlet.jsp</groupId>
  <artifactId>jsp-api</artifactId>
  <version>2.1</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>

The bean to configure JSP is

@Configuration
public class WebAppConfiguration {
  @Bean
  public InternalResourceViewResolver internalResourceViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/views/");
    resolver.setSuffix(".jsp");
    return resolver;
  }
}

The controller is pretty straight forward

@Controller
public class RootController {
  @RequestMapping(value = "/login")
  public String login() {
    return "login";
  }

and the JSP is also pretty easy

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>

<%= "Hello World" %>
${ "Hello World" }
<form name="auth" action="<c:url value='j_spring_security_check' />" method="POST">
  Username: <input type="text" name="j_username">
  Password: <input type="password" name="j_password">
  <input type="submit" value="Submit"/>
</form>

As you can see from the image the JSP is not being evaluated.  Is there anything I need to do to tell JSP to be evaluated when rendered.

Edit 1

So just for a little extra information I used the Resthub archetype resthub-mongodb-backbonejs-archetype to bootstrap this project, which uses a WebAppInitializer rather than the older web.xml, and it uses new annotation driven beans rather than the xml beans.

EDIT 2

I have been smashing my head on this for all to long so I put the project on github https://github.com/austinbv/calendar/. Since I do not know what is important and what is not.

Thanks for the help


问:
PHP array merge multiple indexed array
I am Having array Like this

```<code>Array
(
    [0] => Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
        )

[1] => Array
    (
        [title] => dsfg
        [lat] => sdsd
        [lng] => sd
        [description] => er
        [category] => sddsdsd
    )
 )
</code>```

I am struggling to merge the array

I am expecting my array to be like this

```<code>Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
            [title] => dsfg
            [lat] => sdsd
            [lng] => sd
            [description] => er
            [category] => sddsdsd
        )
</code>```

Any help regarding this Please

答:
Use a loop for lopping around your main/root array and use array_merge()

working code ....

```<code>    <?php
$root =array
(
    '0' => array
        (
            'title1' => 'SDSF',
            'lat2' => 'SDDS',
            'lng3' => 'SDSDSD',
            'description4' => 'SDSD',
            'category5' => 'SDSFFG'
        ) ,

'1' => array
    (
        'title' => 'dsfg',
        'lat' => 'sdsd',
        'lng' => 'sd',
        'description' => 'er',
        'category' => 'sddsdsd'
    )

);
$result = array();
foreach($root as $child_array)
{
    $result = array_merge($result,$child_array);
}
print_r($result);

    ?>
</code>```

else do...

```<code>print_r(array_merge($root[0],$root[1]));
</code>```

else do...

```<code>print_r($root[0]+$root[1]);
</code>```

Title: PHP array merge multiple indexed array

Body:
I am Having array Like this

Array
(
    [0] => Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
        )

[1] => Array
    (
        [title] => dsfg
        [lat] => sdsd
        [lng] => sd
        [description] => er
        [category] => sddsdsd
    )
 )

I am struggling to merge the array

I am expecting my array to be like this

Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
            [title] => dsfg
            [lat] => sdsd
            [lng] => sd
            [description] => er
            [category] => sddsdsd
        )

Any help regarding this Please

Body:
Use a loop for lopping around your main/root array and use array_merge()

working code ....

    <?php
$root =array
(
    '0' => array
        (
            'title1' => 'SDSF',
            'lat2' => 'SDDS',
            'lng3' => 'SDSDSD',
            'description4' => 'SDSD',
            'category5' => 'SDSFFG'
        ) ,

'1' => array
    (
        'title' => 'dsfg',
        'lat' => 'sdsd',
        'lng' => 'sd',
        'description' => 'er',
        'category' => 'sddsdsd'
    )

);
$result = array();
foreach($root as $child_array)
{
    $result = array_merge($result,$child_array);
}
print_r($result);

    ?>

else do...

print_r(array_merge($root[0],$root[1]));

else do...

print_r($root[0]+$root[1]);


问:
avoid latches in frequecny divider using fsm - Verilog
I am new to verilog and HDL.

I want to implement a N-frequency divider,

which count clock ticks (pos and neg) and start the counting mechanism from the first rising edge of the input clk.

In addition the clk divider has to support synchronous rst_n.

I am using Altera Quartus and the following code

module clk_divider_fsm
(
 in_clk,
 rst_n,
 out_clk
);

input in_clk, rst_n;
output out_clk;

parameter prescaler = 10;
parameter BIT_DEPTH = `CLOG2(prescaler);
parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10;
parameter CNT_RESET = {BIT_DEPTH{1'b0}};
//parameter CNT_FIRST = {BIT_DEPTH-1{1'b0}, 1'b1};
reg [1:0] ps, ns;
reg out_change;
reg out;
reg [BIT_DEPTH:0] cnt;

initial
begin
 ps = S0;
 ns = S0;
 cnt = CNT_RESET;
 out_change = 1'b0;
 out = 1'b0;
end

always @ (in_clk)
begin
 if(!rst_n)
  ps = S0;
 else
  ps =  ns;
// begin
//  if(ns != ps)
//   ps =  ns;
// end
end

always @ (in_clk)
begin
 case(ps)
  S0: begin
   if(in_clk === 1'b1)
   begin
    out_change <= 1'b1;
    ns <= S1;
    cnt <= CNT_RESET + 1'b1;
   end
   else
   begin
    out_change <= 1'b0;
    cnt <= CNT_RESET;
    ns <= S0;
   end
  end
  S1: begin
   if(in_clk === 1'b0)
   begin
    if(cnt == prescaler)
    begin
     cnt <= CNT_RESET + 1'b1;
     out_change <= 1'b1;
     ns <= S2;
    end
    else
    begin
     cnt <= cnt + 1'b1;
     out_change <= 1'b0;
     ns <= S2;
    end
   end
   else
   begin
    out_change = 1'b0;
    ns = S1;
    cnt <= cnt;
   end
  end

  S2: begin
   if(in_clk == 1'b1)
   begin
    if(cnt == prescaler)
    begin
     cnt <= CNT_RESET + 1'b1;
     out_change <= 1'b1;
     ns <= S1;
    end
    else
    begin
     cnt <= cnt + 1'b1;
     out_change <= 1'b0;
     ns <= S1;
    end
   end
   else
   begin
    out_change = 1'b0;
    ns = S2;
    cnt <= cnt;
   end
  end
  default: begin
   out_change <= 1'b0;
   cnt <= CNT_RESET;
   ns <= S0;
  end
 endcase

 if(!rst_n)
 begin
  ns <= S0;
  cnt <= CNT_RESET;
 end
end

always @ (posedge out_change or negedge rst_n)
begin
 if(!rst_n)
  out <= 1'b0;
 else
  out <= ~out;
end

assign out_clk = (prescaler == 1) ? (in_clk & rst_n) : out;

endmodule```

After synthesis I get warnings about latches used for cnt register.

What am I doing wrong?

Can you guide me with good practice tips to avoid such cases in the future or more elegant ways to implement those kind of RTL?

thanks

答:
```<code>always @ (in_clk)
...
always @ (posedge out_change or negedge rst_n)
</code>```

If you want to be synchronous you can't do that. You have to change values on the same posedge of in_clk.
But in general, we use PLL/DCM to divide clock. Clock follow special routing in FPGA using specials buffers.

[edit]

```<code>always @ (in_clk)
</code>```

This will synthesize latches. If you don't want latch (and be synchronous) you have to trigger all your process (always@) with the same posedge of clock. In your case with the same posedge of in_clk :

```<code>always @ (posedge in_clk)
</code>```

See Synthesizing Latches

Body:
I am new to verilog and HDL.

I want to implement a N-frequency divider,

which count clock ticks (pos and neg) and start the counting mechanism from the first rising edge of the input clk.

In addition the clk divider has to support synchronous rst_n.

I am using Altera Quartus and the following code

module clk_divider_fsm
(
 in_clk,
 rst_n,
 out_clk
);

input in_clk, rst_n;
output out_clk;

parameter prescaler = 10;
parameter BIT_DEPTH = `CLOG2(prescaler);
parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10;
parameter CNT_RESET = {BIT_DEPTH{1'b0}};
//parameter CNT_FIRST = {BIT_DEPTH-1{1'b0}, 1'b1};
reg [1:0] ps, ns;
reg out_change;
reg out;
reg [BIT_DEPTH:0] cnt;

initial
begin
 ps = S0;
 ns = S0;
 cnt = CNT_RESET;
 out_change = 1'b0;
 out = 1'b0;
end

always @ (in_clk)
begin
 if(!rst_n)
  ps = S0;
 else
  ps =  ns;
// begin
//  if(ns != ps)
//   ps =  ns;
// end
end

always @ (in_clk)
begin
 case(ps)
  S0: begin
   if(in_clk === 1'b1)
   begin
    out_change <= 1'b1;
    ns <= S1;
    cnt <= CNT_RESET + 1'b1;
   end
   else
   begin
    out_change <= 1'b0;
    cnt <= CNT_RESET;
    ns <= S0;
   end
  end
  S1: begin
   if(in_clk === 1'b0)
   begin
    if(cnt == prescaler)
    begin
     cnt <= CNT_RESET + 1'b1;
     out_change <= 1'b1;
     ns <= S2;
    end
    else
    begin
     cnt <= cnt + 1'b1;
     out_change <= 1'b0;
     ns <= S2;
    end
   end
   else
   begin
    out_change = 1'b0;
    ns = S1;
    cnt <= cnt;
   end
  end

  S2: begin
   if(in_clk == 1'b1)
   begin
    if(cnt == prescaler)
    begin
     cnt <= CNT_RESET + 1'b1;
     out_change <= 1'b1;
     ns <= S1;
    end
    else
    begin
     cnt <= cnt + 1'b1;
     out_change <= 1'b0;
     ns <= S1;
    end
   end
   else
   begin
    out_change = 1'b0;
    ns = S2;
    cnt <= cnt;
   end
  end
  default: begin
   out_change <= 1'b0;
   cnt <= CNT_RESET;
   ns <= S0;
  end
 endcase

 if(!rst_n)
 begin
  ns <= S0;
  cnt <= CNT_RESET;
 end
end

always @ (posedge out_change or negedge rst_n)
begin
 if(!rst_n)
  out <= 1'b0;
 else
  out <= ~out;
end

assign out_clk = (prescaler == 1) ? (in_clk & rst_n) : out;

endmodule

After synthesis I get warnings about latches used for cnt register.

What am I doing wrong?

Can you guide me with good practice tips to avoid such cases in the future or more elegant ways to implement those kind of RTL?

thanks

Body:
always @ (in_clk)
...
always @ (posedge out_change or negedge rst_n)

If you want to be synchronous you can't do that. You have to change values on the same posedge of in_clk.
But in general, we use PLL/DCM to divide clock. Clock follow special routing in FPGA using specials buffers.

[edit]

always @ (in_clk)

This will synthesize latches. If you don't want latch (and be synchronous) you have to trigger all your process (always@) with the same posedge of clock. In your case with the same posedge of in_clk :

always @ (posedge in_clk)

See Synthesizing Latches


问:
How to reset counter (global variable) when one of the conditions changes
How to reset counter (global variable) when one of the conditions changes. Basically, increase the counter by 1 until "type_name" is "Bar" if it changes to something else set the counter to 0. How can this be achieved for multiple type_names'. Thank you.</p>

```<code>type_name = "bar"
counter = 0

class Foo(object):
    """
    if type is different in the argument, reset counter to 0.
    Otherwise, increment the counter by 1.
    """

    def __init__(self, type_name):
        self.type_name = type_name
        self.counter = counter
        self.reset()

    def increament_counter(self):
        self.counter +=1

    def reset(self):
        if self.type_name != type_name:
            self.counter = 0

b = Foo("bar")
b.increament_counter()
b.increament_counter()
print b.counter

print "==============================="
c = Foo("taste")
c.reset()
print c.counter
c.increament_counter()
print c.counter

print "--------------------------"
d = Foo("bar")
d.increament_counter()
d.increament_counter()
print d.counter

print "--------------------------"
e = Foo("car")
e.increament_counter()
e.increament_counter()
print e.counter
</code>```

答:
Thank you. Due to space limitation I am adding updated code here with one more use case.                                                                                </p>

```<code>type_name = "bar"
counter = 1

class Foo(object):
    """
    if type is different in the argument, reset counter to 0.
    Otherwise increament counter by 1.
    """

    def __init__(self, type_name):
        self.type_name = type_name
        self.counter = counter
        self.reset()

    def reset(self):
        global counter
        if self.type_name != type_name:
            counter = 1
        else:
            counter += 1

c = Foo("taste")
print c.counter

print "--------------------------"
d = Foo("bar")
print d.counter

print "--------------------------"
e = Foo("taste")
print e.counter

print "--------------------------"
new_instances = []
for i in range(0, 10):
    new_instances.append(Foo("bar"))
print new_instances
print new_instances[0].counter
print new_instances[8].counter
</code>```

Body:
How to reset counter (global variable) when one of the conditions changes. Basically, increase the counter by 1 until "type_name" is "Bar" if it changes to something else set the counter to 0. How can this be achieved for multiple type_names'. Thank you.

type_name = "bar"
counter = 0

class Foo(object):
    """
    if type is different in the argument, reset counter to 0.
    Otherwise, increment the counter by 1.
    """

    def __init__(self, type_name):
        self.type_name = type_name
        self.counter = counter
        self.reset()

    def increament_counter(self):
        self.counter +=1

    def reset(self):
        if self.type_name != type_name:
            self.counter = 0

b = Foo("bar")
b.increament_counter()
b.increament_counter()
print b.counter

print "==============================="
c = Foo("taste")
c.reset()
print c.counter
c.increament_counter()
print c.counter

print "--------------------------"
d = Foo("bar")
d.increament_counter()
d.increament_counter()
print d.counter

print "--------------------------"
e = Foo("car")
e.increament_counter()
e.increament_counter()
print e.counter

Body:
Thank you. Due to space limitation I am adding updated code here with one more use case.

type_name = "bar"
counter = 1

class Foo(object):
    """
    if type is different in the argument, reset counter to 0.
    Otherwise increament counter by 1.
    """

    def __init__(self, type_name):
        self.type_name = type_name
        self.counter = counter
        self.reset()

    def reset(self):
        global counter
        if self.type_name != type_name:
            counter = 1
        else:
            counter += 1

c = Foo("taste")
print c.counter

print "--------------------------"
d = Foo("bar")
print d.counter

print "--------------------------"
e = Foo("taste")
print e.counter

print "--------------------------"
new_instances = []
for i in range(0, 10):
    new_instances.append(Foo("bar"))
print new_instances
print new_instances[0].counter
print new_instances[8].counter


问:
PL/SQL Trigger Mutating Table on compound trigger
writing a trigger on table that updates another table on oracle
trigger throws mutating table error.
I know the error is coming because i am updating the table that is reference in my row level block but i cannot figure out a work around

EDIT: This code throws a PL/SQL: numeric or value error: NULL index table key value but i seem to have gotten around the mutating table.

```<code>create or replace TRIGGER DSPLATE_WELL_VOLUME_V3
FOR UPDATE ON DSPLATE
COMPOUND TRIGGER

TYPE t_PLATE_ID IS TABLE OF DSPLATE.PLATE_ID%TYPE;
v_PLATE_ID  t_PLATE_ID;
TYPE t_NEW_AMOUNT IS TABLE OF DSPLATE.AMOUNT%TYPE;
v_NEW_AMOUNT  t_NEW_AMOUNT;

BEFORE STATEMENT IS
BEGIN
    v_PLATE_ID := t_PLATE_ID();
    v_NEW_AMOUNT := t_NEW_AMOUNT();
END BEFORE STATEMENT;

BEFORE EACH ROW IS
BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
      AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL THEN
           v_PLATE_ID(v_PLATE_ID.LAST) := :OLD.PLATE_ID;
           v_NEW_AMOUNT(v_NEW_AMOUNT.LAST) := :NEW.AMOUNT_INITIAL;
  END IF;
END BEFORE EACH ROW;

AFTER STATEMENT IS
BEGIN
    FOR p IN 1..v_PLATE_ID.LAST LOOP
                  UPDATE DSPLATE_WELL
            SET AMOUNT = AMOUNT - v_NEW_AMOUNT(p)
              WHERE WELL_ID IN (SELECT DSPLATE_WELL.WELL_ID
              FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
              WHERE DSPLATE_WELL.WELL_VALUE IN (SELECT DSPLATE_WELL.WELL_VALUE
              FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID WHERE DSPLATE.PLATE_ID = v_PLATE_ID(p))
              AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate' AND DSPLATE.LOCATION_ID = 1420);
        END LOOP;
END AFTER STATEMENT;

END;
</code>```

The original trigger i wrote that worked is this but I want it to be written as a compound trigger instead, when a plate_type is set to 'assay plate' the query looks up all well_values of that plate_id on table DSPLATE_WELL, the well_values correspond back to many different plate_ids on table DSPLATE with plate_type 'cherry pick' and specific WELL_IDs where the WELL_VALUES originally came from must have their volume amount updated.

```<code>create or replace TRIGGER INSERT_DSPLATE_WELL_VOLUME
AFTER UPDATE ON DSPLATE
FOR EACH ROW
DECLARE
pragma autonomous_transaction;

BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL
  THEN
      UPDATE DSPLATE_WELL
        SET AMOUNT = AMOUNT - :NEW.AMOUNT_INITIAL
          WHERE WELL_ID IN (SELECT DSPLATE_WELL.WELL_ID
          FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
          WHERE DSPLATE_WELL.WELL_VALUE IN (SELECT DSPLATE_WELL.WELL_VALUE
          FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID WHERE DSPLATE.PLATE_ID = :OLD.PLATE_ID)
          AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate' AND DSPLATE.LOCATION_ID = 1420);
          COMMIT;
  END IF;
END;
</code>```

答:
Your trigger should look like this one:

```<code>create or replace TRIGGER DSPLATE_WELL_VOLUME_V2
FOR UPDATE ON DSPLATE
COMPOUND TRIGGER

TYPE t_WELL_ID IS TABLE OF DSPLATE_WELL.WELL_ID%TYPE;
v_WELL_ID  t_WELL_ID := t_WELL_ID();
TYPE t_AMOUNT IS TABLE OF INT;
v_NEW_AMOUNT t_AMOUNT := t_AMOUNT();

TYPE t_PLATE_ID IS TABLE OF DSPLATE.PLATE_ID%TYPE;
v_PLATE_ID  t_PLATE_ID;

BEFORE STATEMENT IS
BEGIN
    v_PLATE_ID := t_PLATE_ID();
END BEFORE STATEMENT;

BEFORE EACH ROW IS
BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
      AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL THEN
           v_PLATE_ID.EXTEND;
           v_PLATE_ID(v_PLATE_ID.LAST) := :OLD.PLATE_ID;
  END IF;
END BEFORE EACH ROW;

AFTER STATEMENT IS
BEGIN

FOR p IN 1..v_PLATE_ID.LAST LOOP

    SELECT DSPLATE_WELL.WELL_ID, :NEW.AMOUNT
    BULK COLLECT INTO v_WELL_ID, v_NEW_AMOUNT
    FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
    WHERE DSPLATE_WELL.WELL_VALUE IN
          (SELECT DSPLATE_WELL.WELL_VALUE
          FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID
          WHERE DSPLATE.PLATE_ID = v_PLATE_ID(p))
       AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate'
       AND DSPLATE.LOCATION_ID = 1420;

    FOR i in 1..v_WELL_ID.count() LOOP
      UPDATE DSPLATE_WELL SET AMOUNT = (AMOUNT - v_NEW_AMOUNT(i))
      WHERE WELL_ID = v_WELL_ID(i);
    END LOOP;

END LOOP;

END AFTER STATEMENT;

END;
</code>```

Note, this code is not tested and most likely not optimal in terms of performance (I assume the second loop is not required and can be put in a single UPDATE statement). However, you should get an idea how compound triggers are working.

Body:
writing a trigger on table that updates another table on oracle
trigger throws mutating table error.
I know the error is coming because i am updating the table that is reference in my row level block but i cannot figure out a work around

EDIT: This code throws a PL/SQL: numeric or value error: NULL index table key value but i seem to have gotten around the mutating table.

create or replace TRIGGER DSPLATE_WELL_VOLUME_V3
FOR UPDATE ON DSPLATE
COMPOUND TRIGGER

TYPE t_PLATE_ID IS TABLE OF DSPLATE.PLATE_ID%TYPE;
v_PLATE_ID  t_PLATE_ID;
TYPE t_NEW_AMOUNT IS TABLE OF DSPLATE.AMOUNT%TYPE;
v_NEW_AMOUNT  t_NEW_AMOUNT;

BEFORE STATEMENT IS
BEGIN
    v_PLATE_ID := t_PLATE_ID();
    v_NEW_AMOUNT := t_NEW_AMOUNT();
END BEFORE STATEMENT;

BEFORE EACH ROW IS
BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
      AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL THEN
           v_PLATE_ID(v_PLATE_ID.LAST) := :OLD.PLATE_ID;
           v_NEW_AMOUNT(v_NEW_AMOUNT.LAST) := :NEW.AMOUNT_INITIAL;
  END IF;
END BEFORE EACH ROW;

AFTER STATEMENT IS
BEGIN
    FOR p IN 1..v_PLATE_ID.LAST LOOP
                  UPDATE DSPLATE_WELL
            SET AMOUNT = AMOUNT - v_NEW_AMOUNT(p)
              WHERE WELL_ID IN (SELECT DSPLATE_WELL.WELL_ID
              FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
              WHERE DSPLATE_WELL.WELL_VALUE IN (SELECT DSPLATE_WELL.WELL_VALUE
              FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID WHERE DSPLATE.PLATE_ID = v_PLATE_ID(p))
              AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate' AND DSPLATE.LOCATION_ID = 1420);
        END LOOP;
END AFTER STATEMENT;

END;

The original trigger i wrote that worked is this but I want it to be written as a compound trigger instead, when a plate_type is set to 'assay plate' the query looks up all well_values of that plate_id on table DSPLATE_WELL, the well_values correspond back to many different plate_ids on table DSPLATE with plate_type 'cherry pick' and specific WELL_IDs where the WELL_VALUES originally came from must have their volume amount updated.

create or replace TRIGGER INSERT_DSPLATE_WELL_VOLUME
AFTER UPDATE ON DSPLATE
FOR EACH ROW
DECLARE
pragma autonomous_transaction;

BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL
  THEN
      UPDATE DSPLATE_WELL
        SET AMOUNT = AMOUNT - :NEW.AMOUNT_INITIAL
          WHERE WELL_ID IN (SELECT DSPLATE_WELL.WELL_ID
          FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
          WHERE DSPLATE_WELL.WELL_VALUE IN (SELECT DSPLATE_WELL.WELL_VALUE
          FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID WHERE DSPLATE.PLATE_ID = :OLD.PLATE_ID)
          AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate' AND DSPLATE.LOCATION_ID = 1420);
          COMMIT;
  END IF;
END;

Body:
Your trigger should look like this one:

create or replace TRIGGER DSPLATE_WELL_VOLUME_V2
FOR UPDATE ON DSPLATE
COMPOUND TRIGGER

TYPE t_WELL_ID IS TABLE OF DSPLATE_WELL.WELL_ID%TYPE;
v_WELL_ID  t_WELL_ID := t_WELL_ID();
TYPE t_AMOUNT IS TABLE OF INT;
v_NEW_AMOUNT t_AMOUNT := t_AMOUNT();

TYPE t_PLATE_ID IS TABLE OF DSPLATE.PLATE_ID%TYPE;
v_PLATE_ID  t_PLATE_ID;

BEFORE STATEMENT IS
BEGIN
    v_PLATE_ID := t_PLATE_ID();
END BEFORE STATEMENT;

BEFORE EACH ROW IS
BEGIN
  IF :NEW.PLATE_TYPE != :OLD.PLATE_TYPE AND :NEW.PLATE_TYPE = 'Assay Plate'
      AND :NEW.AMOUNT_INITIAL IS NOT NULL AND :OLD.AMOUNT_INITIAL IS NULL THEN
           v_PLATE_ID.EXTEND;
           v_PLATE_ID(v_PLATE_ID.LAST) := :OLD.PLATE_ID;
  END IF;
END BEFORE EACH ROW;

AFTER STATEMENT IS
BEGIN

FOR p IN 1..v_PLATE_ID.LAST LOOP

    SELECT DSPLATE_WELL.WELL_ID, :NEW.AMOUNT
    BULK COLLECT INTO v_WELL_ID, v_NEW_AMOUNT
    FROM DSPLATE INNER JOIN DSPLATE_WELL ON DSPLATE_WELL.PLATE_ID = DSPLATE.PLATE_ID
    WHERE DSPLATE_WELL.WELL_VALUE IN
          (SELECT DSPLATE_WELL.WELL_VALUE
          FROM DSPLATE_WELL INNER JOIN DSPLATE ON DSPLATE.PLATE_ID = DSPLATE_WELL.PLATE_ID
          WHERE DSPLATE.PLATE_ID = v_PLATE_ID(p))
       AND DSPLATE.PLATE_TYPE = 'Cherry Pick Plate'
       AND DSPLATE.LOCATION_ID = 1420;

    FOR i in 1..v_WELL_ID.count() LOOP
      UPDATE DSPLATE_WELL SET AMOUNT = (AMOUNT - v_NEW_AMOUNT(i))
      WHERE WELL_ID = v_WELL_ID(i);
    END LOOP;

END LOOP;

END AFTER STATEMENT;

END;

Note, this code is not tested and most likely not optimal in terms of performance (I assume the second loop is not required and can be put in a single UPDATE statement). However, you should get an idea how compound triggers are working.


问:
developing custom android plugins using Cordova 6 and greater in eclipse ide
I'm making a native plugin for android in cordova using eclipse ide. I don't seem to be able to find the cordova jar. I don't really want to use android studio as i'm writing the app in angular 2 in eclipse and everything i need is there apart from the jar for cordova.

How can i get the cordova jar into the project to i can access the api while i'm writing my custom plugin?

答:
You can link the source files from the cordova project itself:

/cordova/platforms/android/CordovaLib/src/org/apache/cordova


问:
Will IE9 support WebGL and/or WebSockets?
Will IE9 support WebGL and/or WebSockets?</p>

答:
WebGL seems not to be include in IE's strategy because of DirectX.
Anyway google already worked on that with the ANGLE project.
http://code.google.com/p/angleproject/</p>

ContentLicense: CC BY-SA 2.5


问:
How to save uploaded file using IFormFile in ASP.NET 5 RC1 MVC
I'm using ASP.NET 5 RC with Visual Studio 2015.

I have a ViewModel defined:

```<code>public class TeamVM
{
    public IFormFile UploadedLogo { get; set; }
}
</code>```

and a controller:

```<code>[HttpPost]
public IActionResult Create(TeamVM vm)
{
     vm.UploadedLogo.SaveAs("filename.txt"); // Problem here - There is no SaveAs method
     return View();
}
</code>```

The problem is that intellisense shows that there is no SaveAs() method. I found out here that this interface actually does not have a SaveAs() method.

Also, I realized that if I change IFormFile to ICollection<IFormFile> and loop through, the collection the IFormFile instances will have the SaveAs() method defined.

In my case I want to use IFormFile instead of ICollection<IFormFile>.

How would be the correct way to save file to system using IFormFile?

答:
You can simply create your own file save extension for IFormFile.

Check out the code in this link

Body:
I'm using ASP.NET 5 RC with Visual Studio 2015.

I have a ViewModel defined:

public class TeamVM
{
    public IFormFile UploadedLogo { get; set; }
}

and a controller:

[HttpPost]
public IActionResult Create(TeamVM vm)
{
     vm.UploadedLogo.SaveAs("filename.txt"); // Problem here - There is no SaveAs method
     return View();
}

The problem is that intellisense shows that there is no SaveAs() method. I found out here that this interface actually does not have a SaveAs() method.

Also, I realized that if I change IFormFile to ICollection<IFormFile> and loop through, the collection the IFormFile instances will have the SaveAs() method defined.

In my case I want to use IFormFile instead of ICollection<IFormFile>.

How would be the correct way to save file to system using IFormFile?


问:
Eclipse Plugin Development: Adding items to a working set with the path of the item?
Hello,
I'm an eclipse plugin development newbie looking for pointers to get me started on a particular project.

I am trying to build an eclipse plugin that will automatically construct a working set from a text file that simply consists of a list of file path names. The files/items need not share any parent directories. The rough idea is represented in the following diagram:

I am not asking for the solution to this task. That's the over-arching goal. To achieve that goal, I want to conquer some smaller goals first.

With that in mind, here's the smaller goal I'm currently trying to tackle:

In Eclipse, how can I prompt the user for a single file's path, and then add that file to an existing working set?

I'm not sure where to start. Should I work directly off of the existing org.eclipse.ui.workingSets extension point? Or should I use a collection of other extension points? How do I convert strings into something that can be added to a working set? Do I write code that directly modifies the workingsets.xml file?

Even with a much simpler goal, I still feel quite overwhelmed with the vastness of eclipse extension options. There are probably many ways to go about implementing something like this, but I just need one to get started.

Thanks a bunch!

答:
To manipulate working sets you use the working set manager interface IWorkingSetManager. Get this with:

IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
```

<p>From this you can get a particular working by name with:</p>

<pre class="lang-java prettyprint-override"><code>IWorkingSet workingSet = manager.getWorkingSet("name");
</code>```

The contents of a working set is an array of IAdaptable objects:

IAdaptable [] contents = workingSet.getElements();
```

<p>You add to the contents by adding to this array and setting the contents:</p>

<pre class="lang-java prettyprint-override"><code>IAdaptable [] newContents

.... get new array with old contents + new contents

workingSet.setElements(newContents);
</code>```

A lot of Eclipse objects implement IAdaptable, for a file in the workspace you would use IFile. You can use dialogs such as ResourceSelectionDialog to select resources from the workspace.

Body:
To manipulate working sets you use the working set manager interface IWorkingSetManager. Get this with:

IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();

From this you can get a particular working by name with:

IWorkingSet workingSet = manager.getWorkingSet("name");

The contents of a working set is an array of IAdaptable objects:

IAdaptable [] contents = workingSet.getElements();

You add to the contents by adding to this array and setting the contents:

IAdaptable [] newContents

.... get new array with old contents + new contents

workingSet.setElements(newContents);

A lot of Eclipse objects implement IAdaptable, for a file in the workspace you would use IFile. You can use dialogs such as ResourceSelectionDialog to select resources from the workspace.


问:
PHP string convert encoding from utf8 to cp1251 with replace impossible characters via html-mnemonics
I convert string encoding from wide utf8 to limited encoding cp1251. I need to preserve some characters not included into cp1251.

In python 2.x there is a special function, which during encoding conversion replaces impossible characters with html-entities:

```<code># -*- coding: utf-8 -*-

s_in = "Ø 125 mm".decode('utf8')
s_out = s_in.encode('cp1251', 'xmlcharrefreplace')
print s_out # prints Ø 125 mm
</code>```

Live example on ideone

Is there any ready-to-use func/lib in PHP to do the task?

My code is:

```<code><?php
$in = 'Ø 125 mm';
$out = mb_convert_encoding($in, 'cp1251', 'utf8');
echo $out; // prints ? 125 mm
</code>```

Live example on sandbox.onlinephpfunctions

答:
Try json_encode with JSON_UNESCAPED_UNICODE

```<code>$in = 'Ø 125 mm';
$out = json_encode($in, JSON_UNESCAPED_UNICODE);
echo json_decode($out, true);
</code>```

http://sandbox.onlinephpfunctions.com/code/cfd9f38ed7ad8b668285be31004bfe2578da6436

Body:
I convert string encoding from wide utf8 to limited encoding cp1251. I need to preserve some characters not included into cp1251.

In python 2.x there is a special function, which during encoding conversion replaces impossible characters with html-entities:

# -*- coding: utf-8 -*-

s_in = "Ø 125 mm".decode('utf8')
s_out = s_in.encode('cp1251', 'xmlcharrefreplace')
print s_out # prints Ø 125 mm

Live example on ideone

Is there any ready-to-use func/lib in PHP to do the task?

My code is:

<?php
$in = 'Ø 125 mm';
$out = mb_convert_encoding($in, 'cp1251', 'utf8');
echo $out; // prints ? 125 mm

Live example on sandbox.onlinephpfunctions

Body:
Try json_encode with JSON_UNESCAPED_UNICODE

$in = 'Ø 125 mm';
$out = json_encode($in, JSON_UNESCAPED_UNICODE);
echo json_decode($out, true);

http://sandbox.onlinephpfunctions.com/code/cfd9f38ed7ad8b668285be31004bfe2578da6436


问:
Javascript Character Replacement
I'm trying to create a translation tool where somebody can enter text into a form and the translation automatically processes with each keystroke into a corresponding form.

The translation is per character in an array. Each Key will be replaced with its corresponding Value pair.

I don't know why the text won't output.

Here is the Code:

var array = {
  'a': 'z',
  'b': 'y',
  'c': 'x',
  'd': 'w',
  'e': 'v',
  'f': 'u',
  'g': 't',
  'h': 's',
  'i': 'r',
  'j': 'q',
  'k': 'p',
  'l': 'o',
  'm': 'n',
  'n': 'm',
  'o': 'l',
  'p': 'k',
  'q': 'j',
  'r': 'i',
  's': 'h',
  't': 'g',
  'u': 'f',
  'v': 'e',
  'w': 'd',
  'x': 'c',
  'y': 'b',
  'z': 'a'
};

var english = document.getElementById('englishform');
var backwards = document.getElementById('backwardsform');

var new_str = english;

for (var key in array) {
  if (!array.hasOwnProperty(key)) {
    continue;
  }

  new_str = new_str.replace(new RegExp(key, "g"), array[key]);
}

english.value = new_str;

english.onkeyup = function() {
  backwards.value = english.value;
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form action="home.html" method="post">
  <textarea class="form-control" id="englishform" placeholder="Enter English" rows="15">
    </textarea>
</form>
<form>
  <textarea class="form-control" id="backwardsform" placeholder="Enter Backwards English" rows="15">
    </textarea>
</form></code>```

答:
Here is a simpler implementation that doesn't use a map, but mathematically replaces based on each character's ASCII index:

(() => {
  const english = document.getElementById('englishform');
  const backwards = document.getElementById('backwardsform');
  const regexp = /([A-Z])|([a-z])/g;
  const upperBounds = [...'AZ'].map(c => c.charCodeAt(0));
  const lowerBounds = [...'az'].map(c => c.charCodeAt(0));

  function replacer(match, upper, lower) {
    let min, max;
    let value = (upper || lower).charCodeAt(0);

    if (upper) {
      [min, max] = upperBounds;
    } else {
      [min, max] = lowerBounds;
    }

    return String.fromCharCode(max - value + min);
  }

  english.addEventListener('input', () => {
    backwards.value = english.value.replace(regexp, replacer);
  });

  backwards.addEventListener('input', () => {
    english.value = backwards.value.replace(regexp, replacer);
  });
})();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>html, body {
  margin: 0;
  padding: 0;
}

body {
  padding: 60px;
}

form, textarea {
  position: relative;
  width: 100%;
}</code>```

<form action="home.html" method="post">
  <textarea class="form-control" id="englishform" placeholder="Enter English"></textarea>
</form>
<form>
  <textarea class="form-control" id="backwardsform" placeholder="Enter Backwards English"></textarea>
</form>```

Title: Javascript Character Replacement

Body:
I'm trying to create a translation tool where somebody can enter text into a form and the translation automatically processes with each keystroke into a corresponding form.

The translation is per character in an array. Each Key will be replaced with its corresponding Value pair.

I don't know why the text won't output.

Here is the Code:

var array = {
  'a': 'z',
  'b': 'y',
  'c': 'x',
  'd': 'w',
  'e': 'v',
  'f': 'u',
  'g': 't',
  'h': 's',
  'i': 'r',
  'j': 'q',
  'k': 'p',
  'l': 'o',
  'm': 'n',
  'n': 'm',
  'o': 'l',
  'p': 'k',
  'q': 'j',
  'r': 'i',
  's': 'h',
  't': 'g',
  'u': 'f',
  'v': 'e',
  'w': 'd',
  'x': 'c',
  'y': 'b',
  'z': 'a'
};

var english = document.getElementById('englishform');
var backwards = document.getElementById('backwardsform');

var new_str = english;

for (var key in array) {
  if (!array.hasOwnProperty(key)) {
    continue;
  }

  new_str = new_str.replace(new RegExp(key, "g"), array[key]);
}

english.value = new_str;

english.onkeyup = function() {
  backwards.value = english.value;
};

<form action="home.html" method="post">
  <textarea class="form-control" id="englishform" placeholder="Enter English" rows="15">
    </textarea>
</form>
<form>
  <textarea class="form-control" id="backwardsform" placeholder="Enter Backwards English" rows="15">
    </textarea>
</form>

Body:
Here is a simpler implementation that doesn't use a map, but mathematically replaces based on each character's ASCII index:

(() => {
  const english = document.getElementById('englishform');
  const backwards = document.getElementById('backwardsform');
  const regexp = /([A-Z])|([a-z])/g;
  const upperBounds = [...'AZ'].map(c => c.charCodeAt(0));
  const lowerBounds = [...'az'].map(c => c.charCodeAt(0));

  function replacer(match, upper, lower) {
    let min, max;
    let value = (upper || lower).charCodeAt(0);

    if (upper) {
      [min, max] = upperBounds;
    } else {
      [min, max] = lowerBounds;
    }

    return String.fromCharCode(max - value + min);
  }

  english.addEventListener('input', () => {
    backwards.value = english.value.replace(regexp, replacer);
  });

  backwards.addEventListener('input', () => {
    english.value = backwards.value.replace(regexp, replacer);
  });
})();

html, body {
  margin: 0;
  padding: 0;
}

body {
  padding: 60px;
}

form, textarea {
  position: relative;
  width: 100%;
}

<form action="home.html" method="post">
  <textarea class="form-control" id="englishform" placeholder="Enter English"></textarea>
</form>
<form>
  <textarea class="form-control" id="backwardsform" placeholder="Enter Backwards English"></textarea>
</form>


问:
Count min max length in numbers without space in jquery validate js
I am using jquery validate js to validate my number field.

```<code>phone: {
    required: true,
    minlength: 10,
    maxlength: 10,
    numero:true,
},
</code>```

numero is custom validator method that allows numbers with space. Now it is counting that space as well. How to avoid and make things work with min and max length of phone number only counting numbers?

答: i would say since its a phone number change input type text to input type number or tel   tel will be best ... then you dont need to worry about the white spaces </p>

Body:
I am using jquery validate js to validate my number field.

phone: {
    required: true,
    minlength: 10,
    maxlength: 10,
    numero:true,
},

numero is custom validator method that allows numbers with space. Now it is counting that space as well. How to avoid and make things work with min and max length of phone number only counting numbers?


问:
Xamarin Android Visual Studio layout not rendering when creating new blank app
I try to create new project using xamarin android blank app. When I try to open the main.axml layout, it give below error:

```<code>System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at Xamarin.AndroidDesigner.Java.JavaCommunicationContext.ReadMessageLoop() in C:\d\lanes\4699\1be4f0c9\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\Xamarin.AndroidDesigner\Xamarin.AndroidDesigner.Java\JavaCommunicationContext.cs:line 227
</code>```

答:
Same problem for me when I open the layout. It supposed to be a version problem of xamarin (check this post :

Unable to render xamarin android layout

I ckeck that version, it's the 4.5.0.476, the same as the post above.
I'll try to downgrade this version, I'll keep you informed

Body:
I try to create new project using xamarin android blank app. When I try to open the main.axml layout, it give below error:

System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at Xamarin.AndroidDesigner.Java.JavaCommunicationContext.ReadMessageLoop() in C:\d\lanes\4699\1be4f0c9\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\Xamarin.AndroidDesigner\Xamarin.AndroidDesigner.Java\JavaCommunicationContext.cs:line 227


问:
cakephp finding multiple images and displaying them (possibly outside webroot?)
I am currently trying to build a cakephp app that will list items from a database, and there is a field in the database named picture. This picture field contains a string which is the primary picture, so for example ABCD, and then in the images folder this is ABCD.jpg

However there is usually various extra pictures for this particular item, which may be named ABCD1 or ABCD_2 or some other such variating suffix. I had previously written some script in php which used a glob function and counted the files and outputted them.

I am seriously struggling to do this in cakephp, at the moment there is several thousand images stored in the webroot of the server in /images and I understand that cake will be looking in the webroot of the app like /app/webroot, so is it possible to view their original location? or must they be moved...

I have read a little about the file and folder classes but I am struggling to comprehend them, not sure if my brains failed me here or if this is actually a difficult concept..

my question is how would I find any files that begin with this prefix in the picture field after selecting by the id of the item, to then display all those that match for that particular item?

thanks for your help!

答:
Not a real answer to your question but you should start making a database relationship with your pics.

Check out hasMany to make a relationship between your Article (or whatever it is) and the Picture models. Now you will not have to look for each filename, as you'll have it in your database.


问:
removing print statements in python using eclipse or pycharm
I have looked on stackoverflow but didn't find the answer i was looking for.
 I have a bunch of python files and was using "print" liberally to debug. Now I want to get rid of every print statement since none of my python files is expected to print anything to stdout (It is a backend code for a web app). How do I get rid of my 'print's? I could have simply searched 'print' and replace it with "#print" but some of the print statements are multi-line.

Is there a way to do it using Elipse (preferrably) or PyCharm?

答:
Search for every occurrence of print and replace with:

```<code>if __debug__: print
</code>```

When run using Python's -o (optimize) command line flag, which you can easily do in your production environment, these statements will then be stripped entirely, as if they were never there. They remain in place to help you with debugging when running Python without -o.

Body:
Search for every occurrence of print and replace with:

if __debug__: print

When run using Python's -o (optimize) command line flag, which you can easily do in your production environment, these statements will then be stripped entirely, as if they were never there. They remain in place to help you with debugging when running Python without -o.


问:
not redeclaring variable in php
I`ve got problem, my variable $x is not redeclaring to "english". Where is the problem? Thanks a lot:

```<code><?php
// assign language or default english
$x = $lang_detected;
$language_table = '
<form id="lang_detected" method="post"
  action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '">
  <input type="button" value="' . $x . '" onclick = "displayLangList()" style="width:200px;display:block;margin:auto;" />
  <input type="submit" value="ok" />
</form>';

$possible_lang = mysqli_query($con,
'SELECT name2 FROM page WHERE name2 = "' . $lang_detected . '"');

if (mysqli_num_rows($possible_lang) > 0 ) {
  echo $language_table;
} else {
  $x = 'english';
  echo $language_table;
}
?>
</code>```

even if i do:

```<code>if (mysqli_num_rows($possible_lang) > 0 ) {
  $x = "bla bla";
  echo $language_table;
} else {
  $x = 'english';
  echo $language_table;
}
</code>```

$x still holds the value:

```<code>$x = $lang_detected;
</code>```

Thanks a lot!

答:
To solve your issue, you could use a function. </p>

```<code><?php
// assign language or default english
$x = $lang_detected;

$possible_lang = mysqli_query($con,
'SELECT name2 FROM page WHERE name2 = "' . $lang_detected . '"');

if (mysqli_num_rows($possible_lang) > 0 ) {
  echo getLanguageTable($x);
} else {
  $x = 'english';
  echo getLanguageTable($x);
}

function getLanguageTable($x) {
    return '
    <form id="lang_detected" method="post"
      action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '">
      <input type="button" value="' . $x . '" onclick = "displayLangList()" style="width:200px;display:block;margin:auto;" />
      <input type="submit" value="ok" />
    </form>';

}
</code>```

Title: not redeclaring variable in php

Body:
I`ve got problem, my variable $x is not redeclaring to "english". Where is the problem? Thanks a lot:

<?php
// assign language or default english
$x = $lang_detected;
$language_table = '
<form id="lang_detected" method="post"
  action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '">
  <input type="button" value="' . $x . '" onclick = "displayLangList()" style="width:200px;display:block;margin:auto;" />
  <input type="submit" value="ok" />
</form>';

$possible_lang = mysqli_query($con,
'SELECT name2 FROM page WHERE name2 = "' . $lang_detected . '"');

if (mysqli_num_rows($possible_lang) > 0 ) {
  echo $language_table;
} else {
  $x = 'english';
  echo $language_table;
}
?>

even if i do:

if (mysqli_num_rows($possible_lang) > 0 ) {
  $x = "bla bla";
  echo $language_table;
} else {
  $x = 'english';
  echo $language_table;
}

$x still holds the value:

$x = $lang_detected;

Thanks a lot!

Body:
To solve your issue, you could use a function.

<?php
// assign language or default english
$x = $lang_detected;

$possible_lang = mysqli_query($con,
'SELECT name2 FROM page WHERE name2 = "' . $lang_detected . '"');

if (mysqli_num_rows($possible_lang) > 0 ) {
  echo getLanguageTable($x);
} else {
  $x = 'english';
  echo getLanguageTable($x);
}

function getLanguageTable($x) {
    return '
    <form id="lang_detected" method="post"
      action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '">
      <input type="button" value="' . $x . '" onclick = "displayLangList()" style="width:200px;display:block;margin:auto;" />
      <input type="submit" value="ok" />
    </form>';

}


问:
Does anyone know where a parquet table stores the files?
I'm inserting some records into a Hive Parquet table and everything is flawlessly working, however I would like to check the files using the hue file browser, does anyone know where are those files located ? and is there a property I could use while creating the table to change the location ?

Here's my table definition:

```<code>CREATE EXTERNAL TABLE parquet_test_2 (
column1 int,
column2 int
)
STORED AS PARQUET
TBLPROPERTIES ('PARQUET.COMPRESS'='SNAPPY');
</code>```

答:
1.
The location of the table is under the location of the database you are using to store the table.

If you are not explicitly defining a database (create my_database.mytable ...) than it is your current active database (by default it is `default` and it can be changed using use mydatabase;)

The location of the database can be found using desc database my_database;

2.
I strongly recommend to treat Hive as a data warehouse and not as temp directory on one's personal computer.

The data should be organized using databases and not by determine each table's location separately.

Demo

```<code>create database prod;
desc database prod;
</code>```

```<code>+---------+---------+-------------------------------------------------------------+------------+------------+------------+
| db_name | comment |                          location                           | owner_name | owner_type | parameters |
+---------+---------+-------------------------------------------------------------+------------+------------+------------+
| prod    |         | hdfs://quickstart.cloudera:8020/user/hive/warehouse/prod.db | hive       | USER       |            |
+---------+---------+-------------------------------------------------------------+------------+------------+------------+
</code>```

```<code>use prod;
create table my_prod_table as select 'This is a PROD table';
show table extended in prod like my_prod_table;
</code>```

```<code>...
location:hdfs://quickstart.cloudera:8020/user/hive/warehouse/prod.db/my_prod_table
...
</code>```

```<code>create database playground location '/tmp/my_hive_playground';
desc database playground;
</code>```

```<code>+------------+---------+--------------------------------------------------------+------------+------------+------------+
|  db_name   | comment |                        location                        | owner_name | owner_type | parameters |
+------------+---------+--------------------------------------------------------+------------+------------+------------+
| playground |         | hdfs://quickstart.cloudera:8020/tmp/my_hive_playground | hive       | USER       |            |
+------------+---------+--------------------------------------------------------+------------+------------+------------+
</code>```

```<code>create table playground.my_playground_table as select 'This is a Playground table';
show table extended in playground like my_playground_table
</code>```

```<code>...
location:hdfs://quickstart.cloudera:8020/tmp/my_hive_playground/my_playground_table
...
</code>```

Body:
I'm inserting some records into a Hive Parquet table and everything is flawlessly working, however I would like to check the files using the hue file browser, does anyone know where are those files located ? and is there a property I could use while creating the table to change the location ?

Here's my table definition:

CREATE EXTERNAL TABLE parquet_test_2 (
column1 int,
column2 int
)
STORED AS PARQUET
TBLPROPERTIES ('PARQUET.COMPRESS'='SNAPPY');

Body:
1.
The location of the table is under the location of the database you are using to store the table.

If you are not explicitly defining a database (create my_database.mytable ...) than it is your current active database (by default it is `default` and it can be changed using use mydatabase;)

The location of the database can be found using desc database my_database;

2.
I strongly recommend to treat Hive as a data warehouse and not as temp directory on one's personal computer.

The data should be organized using databases and not by determine each table's location separately.

Demo

create database prod;
desc database prod;

+---------+---------+-------------------------------------------------------------+------------+------------+------------+
| db_name | comment |                          location                           | owner_name | owner_type | parameters |
+---------+---------+-------------------------------------------------------------+------------+------------+------------+
| prod    |         | hdfs://quickstart.cloudera:8020/user/hive/warehouse/prod.db | hive       | USER       |            |
+---------+---------+-------------------------------------------------------------+------------+------------+------------+

use prod;
create table my_prod_table as select 'This is a PROD table';
show table extended in prod like my_prod_table;

...
location:hdfs://quickstart.cloudera:8020/user/hive/warehouse/prod.db/my_prod_table
...

create database playground location '/tmp/my_hive_playground';
desc database playground;

+------------+---------+--------------------------------------------------------+------------+------------+------------+
|  db_name   | comment |                        location                        | owner_name | owner_type | parameters |
+------------+---------+--------------------------------------------------------+------------+------------+------------+
| playground |         | hdfs://quickstart.cloudera:8020/tmp/my_hive_playground | hive       | USER       |            |
+------------+---------+--------------------------------------------------------+------------+------------+------------+

create table playground.my_playground_table as select 'This is a Playground table';
show table extended in playground like my_playground_table

...
location:hdfs://quickstart.cloudera:8020/tmp/my_hive_playground/my_playground_table
...


问:
two way communication through channels in golang
I have several functions that I want them to be executed atomically since they deal with sensitive data structures. Suppose the following scenario:
There are two functions: lock(sth) and unlock(sth) that can be called anytime by a goroutine to lock or unlock sth in a global array. I was thinking about having a command channel so that goroutines send lock and unlock commands into the channel, and on the receive side of the channel, some kind of handler handles lock, unlock requests, sequentially, by grabbing commands from the channel. That's fine, but what if the handler wants to send the result back to the requester? Is it possible to do so use golang channels? I know that it is possible to use some kind of lock mechanism like mutex, but I was wondering if it's possible to use channels for such use-case? I saw somewhere that it is recommended to use channel instead of goland low-level lock structs.

In a single sentence:

In a channel with the capacity of 1, I want the receiver side to be able to reply back to the goroutine which sent the message.

or equivalently:

A goroutine sends something to a channel; the message is received by another goroutine and handled leading to some result; how does the sender become aware of the result?

答:
If you want to prevent race conditions then sync primitives should work just fine, as described in @Nevermore's answer. It leaves the code much more readable and easier to reason about.

However, if you want channels to perform syncing for you, you can always try something like below:

```<code>// A global, shared channel used as a lock. Capacity of 1 allows for only
// one thread to access the protected resource at a time.
var lock = make(chan struct{}, 1)

// Operate performs the access/modification on the protected resource.
func Operate(f func() error) error {
    lock <- struct{}{}
    defer func() { <- lock }()
    return f()
}
</code>```

To use this Operate, pass in a closure that accesses the protected resource.

```<code>// Some value that requires concurrent access.
var arr = []int{1, 2, 3, 4, 5}

// Used to sync up goroutines.
var wg sync.WaitGroup
wg.Add(len(arr))

for i := 0; i < len(arr); i++ {
    go func(j int) {
        defer wg.Done()

        // Access to arr remains protected.
        Operate(func () error {
            arr[j] *= 2
            return nil
        })

    }(i)
}
wg.Wait()
</code>```

Working example: https://play.golang.org/p/Drh-yJDVNh

Or you can entirely bypass Operate and use lock directly for more readability:

```<code>go func(j int) {
    defer wg.Done()

    lock <- struct{}{}
    defer func() { <- lock }()

    arr[j] *= 2
}(i)
</code>```

Working example: https://play.golang.org/p/me3K6aIoR7

As you can see, arr access is protected using a channel here.

Body:
If you want to prevent race conditions then sync primitives should work just fine, as described in @Nevermore's answer. It leaves the code much more readable and easier to reason about.

However, if you want channels to perform syncing for you, you can always try something like below:

// A global, shared channel used as a lock. Capacity of 1 allows for only
// one thread to access the protected resource at a time.
var lock = make(chan struct{}, 1)

// Operate performs the access/modification on the protected resource.
func Operate(f func() error) error {
    lock <- struct{}{}
    defer func() { <- lock }()
    return f()
}

To use this Operate, pass in a closure that accesses the protected resource.

// Some value that requires concurrent access.
var arr = []int{1, 2, 3, 4, 5}

// Used to sync up goroutines.
var wg sync.WaitGroup
wg.Add(len(arr))

for i := 0; i < len(arr); i++ {
    go func(j int) {
        defer wg.Done()

        // Access to arr remains protected.
        Operate(func () error {
            arr[j] *= 2
            return nil
        })

    }(i)
}
wg.Wait()

Working example: https://play.golang.org/p/Drh-yJDVNh

Or you can entirely bypass Operate and use lock directly for more readability:

go func(j int) {
    defer wg.Done()

    lock <- struct{}{}
    defer func() { <- lock }()

    arr[j] *= 2
}(i)

Working example: https://play.golang.org/p/me3K6aIoR7

As you can see, arr access is protected using a channel here.


问:
Michael Hartl ch9 : how to sign up
I’ve completed Michael Hartl ch 9 and have no error in testing.
But I could not  sign up...

It returns error as below even so previously I be able to sign up..login works fine.

How to fix it and be able to sign up?

Should I  merge  sign up branch? But doing that I could loose all changes..  Could something be done about sign up form this more advance branch?

Error:

No route matches [POST] "/signup"

routes.rb:

```<code>Rails.application.routes.draw do
  root   'static_pages#home'

  get    '/help',    to: 'static_pages#help'
  get    '/about',   to: 'static_pages#about'
  get    '/contact', to: 'static_pages#contact'
  get    '/signup',  to: 'users#new'
  get    '/login',   to: 'sessions#new'
  post   '/login',   to: 'sessions#create'
  delete '/logout',  to: 'sessions#destroy'

  resources :users
end
</code>```

thanks.

Thanks everybody for answers.
It works now.
One more question related.
When users sign up - they could directly participate in website. It is no good since they need to get confirmation by email and only that they could participate.

How it could be implemented?

I think it is in the solutions Michael Hartl and I even implemented it for Rails 4, but could not remember what need to change..
What files need to be changed to allow users participate in website only after getting confirmation by email.
thanks.

答:
The error is very clear and crisp, you don't have a route for users#create, you need to implement that action and it should work.

Go through this section in the book..

Title: Michael Hartl ch9 : how to sign up

Body:
I’ve completed Michael Hartl ch 9 and have no error in testing.
But I could not  sign up...

It returns error as below even so previously I be able to sign up..login works fine.

How to fix it and be able to sign up?

Should I  merge  sign up branch? But doing that I could loose all changes..  Could something be done about sign up form this more advance branch?

Error:

No route matches [POST] "/signup"

routes.rb:

Rails.application.routes.draw do
  root   'static_pages#home'

  get    '/help',    to: 'static_pages#help'
  get    '/about',   to: 'static_pages#about'
  get    '/contact', to: 'static_pages#contact'
  get    '/signup',  to: 'users#new'
  get    '/login',   to: 'sessions#new'
  post   '/login',   to: 'sessions#create'
  delete '/logout',  to: 'sessions#destroy'

  resources :users
end

thanks.

Thanks everybody for answers.
It works now.
One more question related.
When users sign up - they could directly participate in website. It is no good since they need to get confirmation by email and only that they could participate.

How it could be implemented?

I think it is in the solutions Michael Hartl and I even implemented it for Rails 4, but could not remember what need to change..
What files need to be changed to allow users participate in website only after getting confirmation by email.
thanks.


问:
Unable to take username and password in Twitter account using Selenium
I am using below code to login in twitter</p>

```<code>    driver.get("https://twitter.com/login/");
    driver.findElement(By.xpath("//*[@id='page-container']/div/div[1]/form/fieldset/div[1]/input")).sendKeys("viaxpath");
    driver.findElement(By.xpath("//*[@id='page-container']/div/div[1]/form/fieldset/div[2]/input")).sendKeys("viaxpath");
</code>```

答: The code which you have mentioned is already working. You should be able to enter username and password for twitter account.</p>

Body:
I am using below code to login in twitter

    driver.get("https://twitter.com/login/");
    driver.findElement(By.xpath("//*[@id='page-container']/div/div[1]/form/fieldset/div[1]/input")).sendKeys("viaxpath");
    driver.findElement(By.xpath("//*[@id='page-container']/div/div[1]/form/fieldset/div[2]/input")).sendKeys("viaxpath");


问:
PHP array merge multiple indexed array
I am Having array Like this

```<code>Array
(
    [0] => Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
        )

[1] => Array
    (
        [title] => dsfg
        [lat] => sdsd
        [lng] => sd
        [description] => er
        [category] => sddsdsd
    )
 )
</code>```

I am struggling to merge the array

I am expecting my array to be like this

```<code>Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
            [title] => dsfg
            [lat] => sdsd
            [lng] => sd
            [description] => er
            [category] => sddsdsd
        )
</code>```

Any help regarding this Please

答:
I have a solution for you.

```<code>$a = array(
    'title1' => 'SDSF',
    'lat2' => 'SDDS',
    'lng3' => 'SDSDSD',
    'description4' => 'SDSD',
    'category5' => 'SDSFFG'
    );
$b = array(
    'title' => 'dsfg',
    'lat' => 'sdsd',
    'lng' => 'sd',
    'description' => 'er',
    'category' => 'sddsdsd'
    );
$c = $a + $b;
print_r($c);
</code>```

You will get exact output what you want.

Title: PHP array merge multiple indexed array

Body:
I am Having array Like this

Array
(
    [0] => Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
        )

[1] => Array
    (
        [title] => dsfg
        [lat] => sdsd
        [lng] => sd
        [description] => er
        [category] => sddsdsd
    )
 )

I am struggling to merge the array

I am expecting my array to be like this

Array
        (
            [title1] => SDSF
            [lat2] => SDDS
            [lng3] => SDSDSD
            [description4] => SDSD
            [category5] => SDSFFG
            [title] => dsfg
            [lat] => sdsd
            [lng] => sd
            [description] => er
            [category] => sddsdsd
        )

Any help regarding this Please

Body:
I have a solution for you.

$a = array(
    'title1' => 'SDSF',
    'lat2' => 'SDDS',
    'lng3' => 'SDSDSD',
    'description4' => 'SDSD',
    'category5' => 'SDSFFG'
    );
$b = array(
    'title' => 'dsfg',
    'lat' => 'sdsd',
    'lng' => 'sd',
    'description' => 'er',
    'category' => 'sddsdsd'
    );
$c = $a + $b;
print_r($c);

You will get exact output what you want.


问:
Rails: losing quotes in post parameters
I'm adding full-text search to my Rails site and allowing users to enter double quotes in the search input box. The problem is that the double quotes seem to get filtered out by Mongrel and so I never receive those quotes in the values of the params hash. How do I prevent this from happening? I'm running Rails 2.3.8.

[Edit: added analysis data]

In Firebug I see the post parameter being posted correctly with quotes:

```<code>search_criteria "great post"
</code>```

In the development log, however, the quotes are gone:

Processing PostsController#search (for
  127.0.0.1 at 2010-06-18 17:28:45) [POST]   Parameters:
  {"search_criteria"=>"great post",
  "action"=>"search", "authenticity_token"=>"xUaOc1IAyjQmKn1NGqBpPVaTBmD4ayPq/lUJsqJGCxY=",
  "controller"=>"posts"}

And when I log the contents and size of params[:search_criteria] in the controller, I get:

```<code>search criteria = great post
search criteria size = 10
</code>```

[Edit: new discovery]
This problem described above does not occur when the quoted string is trailed or preceded by another character, e.g. a space.

答:
Apparently this is a bug in rack 1.1.0.  The fix [patch here] was made for rack 1.2.0.  However, actionpack (and thus, rails) 2.3.6 through 2.3.10 depend on rack ~> 1.1.0, so they all have this problem.

Potential solutions with most likely actually happening ordered first...

Patch your copy of rack based on above fix

Upgrade to Rails 3

This question has tips on how to patch rack.

Title: Rails: losing quotes in post parameters

Body:
I'm adding full-text search to my Rails site and allowing users to enter double quotes in the search input box. The problem is that the double quotes seem to get filtered out by Mongrel and so I never receive those quotes in the values of the params hash. How do I prevent this from happening? I'm running Rails 2.3.8.

[Edit: added analysis data]

In Firebug I see the post parameter being posted correctly with quotes:

search_criteria "great post"

In the development log, however, the quotes are gone:

Processing PostsController#search (for
  127.0.0.1 at 2010-06-18 17:28:45) [POST]   Parameters:
  {"search_criteria"=>"great post",
  "action"=>"search", "authenticity_token"=>"xUaOc1IAyjQmKn1NGqBpPVaTBmD4ayPq/lUJsqJGCxY=",
  "controller"=>"posts"}

And when I log the contents and size of params[:search_criteria] in the controller, I get:

search criteria = great post
search criteria size = 10

[Edit: new discovery]
This problem described above does not occur when the quoted string is trailed or preceded by another character, e.g. a space.


问:
childViewController.view.frame in UIView present different value
I use childViewController to separate view in project, but some strange issue happened, here is my code.

```<code>class ViewController: UIViewController {

    var container = UIView()
    var childVC = ChildViewController()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white

        addChildViewController(childVC)
        childVC.didMove(toParentViewController: self)

        addChildView()

        setContainerFrame()
    }

    func setContainerFrame() {
        container.frame = CGRect(x: 0, y: 100, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - 100)
        container.backgroundColor = .red
        view.addSubview(container)
    }

    func addChildView() {
        let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
        childVC.view.frame = frame
        childVC.view.backgroundColor = .green
        container.addSubview(childVC.view)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        print("childVC.view.frame: \(childVC.view.frame)")
    }
}

class ChildViewController: UIViewController {
}
</code>```

when I exchange the order invoking func addChildView() and func setContainerFrame() in ViewController's viewDidLoad(), xcode'console prints different frame log.

答: The strange behavior occurs because in addChildView() function you are adding the child view controller's view as subview to container view but container view's frame is setting in the function setContainerFrame() which is not yet called. That means you are adding a subview to a view whose frame hasn't set already.

Body:
I use childViewController to separate view in project, but some strange issue happened, here is my code.

class ViewController: UIViewController {

    var container = UIView()
    var childVC = ChildViewController()

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white

        addChildViewController(childVC)
        childVC.didMove(toParentViewController: self)

        addChildView()

        setContainerFrame()
    }

    func setContainerFrame() {
        container.frame = CGRect(x: 0, y: 100, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - 100)
        container.backgroundColor = .red
        view.addSubview(container)
    }

    func addChildView() {
        let frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
        childVC.view.frame = frame
        childVC.view.backgroundColor = .green
        container.addSubview(childVC.view)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        print("childVC.view.frame: \(childVC.view.frame)")
    }
}

class ChildViewController: UIViewController {
}

when I exchange the order invoking func addChildView() and func setContainerFrame() in ViewController's viewDidLoad(), xcode'console prints different frame log.


问:
How to export view to the excel ASP.NET MVC
I'm not an ASP.NET MVC expert but I need to handle a small project and need some help.

Basically what I'm doing is an MVC project for submitting or listing some text reports and I used database first approach on the model. So I have this model of the tables I've created before, without doing a good plan. After starting the project, I happened to be obliged to add some images to it which wasn't a case while I was designing the data model and I solved this issue in a very poor way, via going out of the MVC philosophy but it worked.

So I added an "img" folder to the project and put the .jpeg files inside.

..and I showed the images in view like that among the data coming from the model:

```<code>...@foreach (var item in Model) {
<tr>
    <td>
       <img src="~/img/@string.Format("{0}.jpeg",item.emailid)"/>
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.emailid)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.date)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.task1)
    </td>.......
</code>```

And then I exported that view to the excel file using this code:

```<code>public ActionResult ExportData()
    {
        GridView gv = new GridView();
        gv.DataSource = db.web_weeklyreports.Include(w => w.web_kategori).Include(w => w.web_kategori1).Include(w => w.web_kategori2).Include(w => w.web_kategori3).Include(w => w.web_kategori4).ToList();
        gv.DataBind();
        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment; filename=WeeklyReports.xls");
        Response.ContentType = "application/ms-excel";
        Response.Charset = "";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gv.RenderControl(htw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();

        return RedirectToAction("adminreports");
    }
</code>```

This code worked well except the image because on DataSource there is only model information and my images are not located in Model, they are in a folder inside the solution as shown above.

So I'm able to export my view except for images and I need to get those images to excel report too.

So this is my view with images

Any help?

答:
I solved it with this class

```<code>        public ActionResult ExportData()
    {
        GridView gv = new GridView();
        var data = db.web_weeklyreports.Include(w => w.web_kategori).Include(w => w.web_kategori1).Include(w => w.web_kategori2).Include(w => w.web_kategori3).Include(w => w.web_kategori4).ToList();

        gv.AutoGenerateColumns = false;
        gv.Columns.Add(new ImageField { HeaderText="IMG",  DataImageUrlField = "Imagepath", DataImageUrlFormatString = "https://localhost:44353/img/{0}.jpeg",  });
        gv.Columns.Add(new BoundField { HeaderText="ID", DataField = "ID" });
        gv.Columns.Add(new BoundField { HeaderText="Email", DataField = "emailid" });
        gv.Columns.Add(new BoundField { HeaderText="Date", DataField = "date" });
        gv.Columns.Add(new BoundField { HeaderText="Task 1", DataField = "task1" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t1kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task2" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t2kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task3" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t3kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task4" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t4kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task5" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t5kategoriid" });

        DataTable dt = new DataTable();
        dt.Columns.Add("Imagepath");
        dt.Columns.Add("ID");
        dt.Columns.Add("emailid");
        dt.Columns.Add("date");
        dt.Columns.Add("task1");
        dt.Columns.Add("t1kategoriid");
        dt.Columns.Add("task2");
        dt.Columns.Add("t2kategoriid");
        dt.Columns.Add("task3");
        dt.Columns.Add("t3kategoriid");
        dt.Columns.Add("task4");
        dt.Columns.Add("t4kategoriid");
        dt.Columns.Add("task5");
        dt.Columns.Add("t5kategoriid");

        foreach (var item in data)
        {
            dt.Rows.Add(item.emailid, item.ID, item.emailid, item.date, item.task1, item.t1kategoriid, item.task2, item.t2kategoriid, item.task3, item.t3kategoriid, item.task4, item.t4kategoriid, item.task5, item.t5kategoriid);
        }

        gv.DataSource = dt;
        gv.DataBind();

        for (int i = 0; i < data.Count; i++)
        {
            gv.Rows[i].Height = 40;
        }

        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment; filename=WeeklyReports.xls");
        Response.ContentType = "application/ms-excel";
        Response.Charset = "";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gv.RenderControl(htw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();

        return RedirectToAction("adminreports");
    }
</code>```

Now I can export images like this:

Body:
I'm not an ASP.NET MVC expert but I need to handle a small project and need some help.

Basically what I'm doing is an MVC project for submitting or listing some text reports and I used database first approach on the model. So I have this model of the tables I've created before, without doing a good plan. After starting the project, I happened to be obliged to add some images to it which wasn't a case while I was designing the data model and I solved this issue in a very poor way, via going out of the MVC philosophy but it worked.

So I added an "img" folder to the project and put the .jpeg files inside.

..and I showed the images in view like that among the data coming from the model:

...@foreach (var item in Model) {

        @Html.DisplayFor(modelItem => item.emailid)

        @Html.DisplayFor(modelItem => item.date)

        @Html.DisplayFor(modelItem => item.task1)
    	.......

And then I exported that view to the excel file using this code:

public ActionResult ExportData()
    {
        GridView gv = new GridView();
        gv.DataSource = db.web_weeklyreports.Include(w => w.web_kategori).Include(w => w.web_kategori1).Include(w => w.web_kategori2).Include(w => w.web_kategori3).Include(w => w.web_kategori4).ToList();
        gv.DataBind();
        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment; filename=WeeklyReports.xls");
        Response.ContentType = "application/ms-excel";
        Response.Charset = "";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gv.RenderControl(htw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();

        return RedirectToAction("adminreports");
    }

This code worked well except the image because on DataSource there is only model information and my images are not located in Model, they are in a folder inside the solution as shown above.

So I'm able to export my view except for images and I need to get those images to excel report too.

So this is my view with images

Any help?

Body:
I solved it with this class

        public ActionResult ExportData()
    {
        GridView gv = new GridView();
        var data = db.web_weeklyreports.Include(w => w.web_kategori).Include(w => w.web_kategori1).Include(w => w.web_kategori2).Include(w => w.web_kategori3).Include(w => w.web_kategori4).ToList();

        gv.AutoGenerateColumns = false;
        gv.Columns.Add(new ImageField { HeaderText="IMG",  DataImageUrlField = "Imagepath", DataImageUrlFormatString = "https://localhost:44353/img/{0}.jpeg",  });
        gv.Columns.Add(new BoundField { HeaderText="ID", DataField = "ID" });
        gv.Columns.Add(new BoundField { HeaderText="Email", DataField = "emailid" });
        gv.Columns.Add(new BoundField { HeaderText="Date", DataField = "date" });
        gv.Columns.Add(new BoundField { HeaderText="Task 1", DataField = "task1" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t1kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task2" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t2kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task3" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t3kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task4" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t4kategoriid" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "task5" });
        gv.Columns.Add(new BoundField { HeaderText="", DataField = "t5kategoriid" });

        DataTable dt = new DataTable();
        dt.Columns.Add("Imagepath");
        dt.Columns.Add("ID");
        dt.Columns.Add("emailid");
        dt.Columns.Add("date");
        dt.Columns.Add("task1");
        dt.Columns.Add("t1kategoriid");
        dt.Columns.Add("task2");
        dt.Columns.Add("t2kategoriid");
        dt.Columns.Add("task3");
        dt.Columns.Add("t3kategoriid");
        dt.Columns.Add("task4");
        dt.Columns.Add("t4kategoriid");
        dt.Columns.Add("task5");
        dt.Columns.Add("t5kategoriid");

        foreach (var item in data)
        {
            dt.Rows.Add(item.emailid, item.ID, item.emailid, item.date, item.task1, item.t1kategoriid, item.task2, item.t2kategoriid, item.task3, item.t3kategoriid, item.task4, item.t4kategoriid, item.task5, item.t5kategoriid);
        }

        gv.DataSource = dt;
        gv.DataBind();

        for (int i = 0; i < data.Count; i++)
        {
            gv.Rows[i].Height = 40;
        }

        Response.ClearContent();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment; filename=WeeklyReports.xls");
        Response.ContentType = "application/ms-excel";
        Response.Charset = "";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gv.RenderControl(htw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();

        return RedirectToAction("adminreports");
    }

Now I can export images like this: