问:
ActionController::RoutingError (No route matches [POST] "/users")
I've tested my project with development env and everything works fine but after I upload my project to the host I got this error.

```<code># log
[2020-02-17T14:54:55.319109 #2097106]  INFO -- : [2ac848c8-15f3-47fd-ad77-ede940b1502e] Started POST "/admin/users" for my_server_ip at 2020-02-17 14:54:55 -0500
[2020-02-17T14:54:55.320555 #2097106] FATAL -- : [2ac848c8-15f3-47fd-ad77-ede940b1502e]
[2ac848c8-15f3-47fd-ad77-ede940b1502e] ActionController::RoutingError (No route matches [POST] "/users"):
[2ac848c8-15f3-47fd-ad77-ede940b1502e]
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/method_override.rb:24:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/runtime.rb:24:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/sendfile.rb:113:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:157:in `accept_and_process_next_request'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
</code>```

here are my routes

```<code># config/routes.rb
namespace :admin do
  resources :users
end
</code>```

and here is my form

```<code># app/views/admin/users/index.html.erb
<%= form_with(model: admin_user, local: true) do |form| %>

  # my form inputs

  <%= form.submit class: 'btn btn-dark' %>

<% end %>
</code>```

答:
The route you created is under namespace admin, but you are making a pos request to/users.

Try the same request with /admin/users.

Body:
I've tested my project with development env and everything works fine but after I upload my project to the host I got this error.

# log
[2020-02-17T14:54:55.319109 #2097106]  INFO -- : [2ac848c8-15f3-47fd-ad77-ede940b1502e] Started POST "/admin/users" for my_server_ip at 2020-02-17 14:54:55 -0500
[2020-02-17T14:54:55.320555 #2097106] FATAL -- : [2ac848c8-15f3-47fd-ad77-ede940b1502e]
[2ac848c8-15f3-47fd-ad77-ede940b1502e] ActionController::RoutingError (No route matches [POST] "/users"):
[2ac848c8-15f3-47fd-ad77-ede940b1502e]
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/method_override.rb:24:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/runtime.rb:24:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] rack (2.1.2) lib/rack/sendfile.rb:113:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:157:in `accept_and_process_next_request'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
[2ac848c8-15f3-47fd-ad77-ede940b1502e] /opt/passenger-5.3.7-2.el7.cloudlinux/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'

here are my routes

# config/routes.rb
namespace :admin do
  resources :users
end

and here is my form

# app/views/admin/users/index.html.erb
<%= form_with(model: admin_user, local: true) do |form| %>

  # my form inputs

  <%= form.submit class: 'btn btn-dark' %>

<% end %>


来源: stackexchange

问:
Run Hello World on Android Phone
as the problem I have above mentioned
(during this tenure my phone is connected to the system and I prefer my phone instead of emulator) the installation of the app on my phone get complete but the app that had installed when I try to open the app my phone's screen blink that means the app open but very soon it disappers so why it happens and for java programming language I use android studio....
and their my code is

package com.example.filename.java;

class A
{
    public static void main(String []args)
    {
        System.out.println("Hello World");
    }
}
```

that was my code
and another thing is that when I run the pre-written code of android studio the app opens and runs completely and the hello world appears.
so is there problem in my code or anything else.

答:
Android doesn't run on a JVM and System.out is only shown in logs.

For a Hello World application in android, you need to edit one xml file assuming you started a blank project in android and your main activity(MainActivity.java) is set as launcher activity in Android Manifest and setContentView is called on the xml file(activity_main.xml).

Go to the activity_main.xml file and it should come with a template having a Constraint Layout and a TextView in it(As of Android Studio Version 3.5.3). The text view has a property "text" to which you can assign "Hello World". When you run this on your emulator or android device it should show Hello World.

activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</code>```

MainActivity.java

```<code>@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Run Hello World on Android Phone

Body:
as the problem I have above mentioned
(during this tenure my phone is connected to the system and I prefer my phone instead of emulator) the installation of the app on my phone get complete but the app that had installed when I try to open the app my phone's screen blink that means the app open but very soon it disappers so why it happens and for java programming language I use android studio....
and their my code is

package com.example.filename.java;

class A
{
    public static void main(String []args)
    {
        System.out.println("Hello World");
    }
}

that was my code
and another thing is that when I run the pre-written code of android studio the app opens and runs completely and the hello world appears.
so is there problem in my code or anything else.

Body:
Android doesn't run on a JVM and System.out is only shown in logs.

For a Hello World application in android, you need to edit one xml file assuming you started a blank project in android and your main activity(MainActivity.java) is set as launcher activity in Android Manifest and setContentView is called on the xml file(activity_main.xml).

Go to the activity_main.xml file and it should come with a template having a Constraint Layout and a TextView in it(As of Android Studio Version 3.5.3). The text view has a property "text" to which you can assign "Hello World". When you run this on your emulator or android device it should show Hello World.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}


问:
jQuery cycle - can the transition cycle through all slides
I need to tweak a jQuery carousel I have made using the excellent cycle plugin
http://jquery.malsup.com/cycle/

Basiaclly, as you can see from this demo (
http://jquery.malsup.com/cycle/pager11.html), if you click '3' on the pager from '1' or vice-versa, that slide will slide in without seeing slide 2

Is there a quick way to tweak the settings so the scrollHorz will cycle from 3 to 2 to 1 rather then just 3 to 1.

It would be good if its possible as it kind of retains the order.

Ta in advance as always,
A.

答:
I had the same problem recently and couldn't find a way to get jQuery.Cycle to do what you're describing. I ended up using jQuery.jCarousel instead.

Here's an example: http://sorgalla.com/projects/jcarousel/examples/static_controls.html

Make sure to set the scroll and visible options to 1 so that only one element is shown at a time.

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
Why can templates only be implemented in the header file?
Quote from The C++ standard library: a tutorial and handbook:

The only portable way of using templates at the moment is to implement them in header files by using inline functions.

Why is this?

(Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)

答:
I suggest looking at this gcc page which discusses the tradeoffs between the "cfront" and "borland" model for template instantiations.

https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Template-Instantiation.html

The "borland" model corresponds to what the author suggests, providing the full template definition, and having things compiled multiple times.

It contains explicit recommendations concerning using manual and automatic template instantiation.  For example, the "-repo" option can be used to collect templates which need to be instantiated.  Or another option is to disable automatic template instantiations using "-fno-implicit-templates" to force manual template instantiation.

In my experience, I rely on the C++ Standard Library and Boost templates being instantiated for each compilation unit (using a template library).  For my large template classes, I do manual template instantiation, once, for the types I need.

This is my approach because I am providing a working program, not a template library for use in other programs.  The author of the book, Josuttis, works a lot on template libraries.

If I was really worried about speed, I suppose I would explore using Precompiled Headers
https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

which is gaining support in many compilers.  However, I think precompiled headers would be difficult with template header files.

OwnerDisplayName: Jinx

Body:
Quote from <a href="http://books.google.com/books?id=n9VEG2Gp5pkC&pg=PA10&lpg=PA10&dq=%22The%20only%20portable%20way%20of%20using%20templates%20at%20the%20moment%20is%20to%20implement%20them%20in%20header%20files%20by%20using%20inline%20functions.%22&source=bl&ots=Ref8pl8dPX&sig=t4K5gvxtBblpcujNxodpwMfei8I&hl=en&ei=qkR6TvbiGojE0AHq4IzqAg&sa=X&oi=book_result&ct=result&resnum=3&ved=0CC8Q6AEwAg#v=onepage&q=%22The%20only%20portable%20way%20of%20using%20templates%20at%20the%20moment%20is%20to%20implement%20them%20in%20header%20files%20by%20using%20inline%20functions.%22&f=false" rel="noreferrer">The C++ standard library: a tutorial and handbook:

The only portable way of using templates at the moment is to implement them in header files by using inline functions.

Why is this?

(Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)

LastEditorDisplayName: Jinx


问:
Allow only the author of the post to edit in class based views- Django?
views.py

```<code>class EditPost(UserPassesTestMixin, LoginRequiredMixin, UpdateView):
    model = Posts
    form_class = PostForm
    template_name="posts/add_post.html"

    def test_func(self):
        x = self.request.user.pk
        print (x)
        y = Posts.objects.get(user='user')
        print (y)
        if x == y:
            return True
        else:
            if self.request.user.is_authenticated():
                raise Http404("You are not allowed to edit this Post")
</code>```

models.py

```<code>class Posts(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
    post = models.CharField(max_length=1200, blank=False)
</code>```

How do i match the loggedin user and the user object of the Post

i could not find any solution since i am using class based views.

答:
To add to the previous posts, try this:

Add to your class EditPost:

```<code>login_url = 'your url name or path to login page'
def test_func(self):
    obj = self.get_object()
    return obj.author == self.request.user
</code>```

The test_func method is used by UserPassesTestMixin for this particular logic. To override it we set variable obj to the current object returned by the view using get.object().
After that, if the author on the current object (obj.author) matches the current user (self.request.user) we allow editing. If not (i.e. false) we throw an error.

login_url is from LoginRequiredMixin and the default location is /accounts/login. To override it, set your own path or name of the login template. This will take those people who are not logged in to the login page.

Body:
views.py

class EditPost(UserPassesTestMixin, LoginRequiredMixin, UpdateView):
    model = Posts
    form_class = PostForm
    template_name="posts/add_post.html"

    def test_func(self):
        x = self.request.user.pk
        print (x)
        y = Posts.objects.get(user='user')
        print (y)
        if x == y:
            return True
        else:
            if self.request.user.is_authenticated():
                raise Http404("You are not allowed to edit this Post")

models.py

class Posts(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
    post = models.CharField(max_length=1200, blank=False)

How do i match the loggedin user and the user object of the Post

i could not find any solution since i am using class based views.

Body:
To add to the previous posts, try this:

Add to your class EditPost:

login_url = 'your url name or path to login page'
def test_func(self):
    obj = self.get_object()
    return obj.author == self.request.user

The test_func method is used by UserPassesTestMixin for this particular logic. To override it we set variable obj to the current object returned by the view using get.object().
After that, if the author on the current object (obj.author) matches the current user (self.request.user) we allow editing. If not (i.e. false) we throw an error.

login_url is from LoginRequiredMixin and the default location is /accounts/login. To override it, set your own path or name of the login template. This will take those people who are not logged in to the login page.


问:
Cannot find the object "XXX" because it does not exist or you do not have permission
I'm getting the following error when calling a stored procedure:

Cannot find the object "XXX" because it does not exist or you do not have permission.

I've checked the database and the SP is there with the correct permissions yet I'm still getting the error.

Any suggestions?

答: The scheme may be different. If there is a different scheme, add it in front of it.

OwnerDisplayName: Twiggz


问:
List all X coordinates by given a Y coordinate in a line profiles by DM scripting
For a line profile (curve), I want to reach that list all X coordinates that corresponding a Y coordinate by given this Y coordinate. And I could get the minimum and maximum values of these x coordinates.  Here supposed I want to list all the X coordinates corresponding y=8, is this correct or any other better way? Thx</p>

```<code> Number minx, maxx
    Image front=:getfrontimage()

    GetSize( front, xsize, ysize )

    for (i=0; i<xsize; i++)

                {
                    x= getpixel(front, i, 8)
                 minx=min(x)
          maxx=max(x)

                }
</code>```

答:
You script becomes wrong when you use the min and max, because you can not get a minimum/maximum of a single value (or rather, it is always that value). What you want to do is likely:

```<code>image spec := RealImage("Test",4,100)
spec = trunc(Random()*10)
number v = 8

ClearResults()
number nCh = spec.ImageGetDimensionSize(0)
for( number i=0; i<nCh; i++)
{
    if( v == sum(spec[i,0]) )
        Result("\n Value "+ v +" @ " + i )
}
</code>```

(The sum() is needed here a a trick to convert an image-expression to a single value.)

However, going pixel-by-pixel in script can be slow. Whenever possible, try to code with image-expressions, because they are much faster (for big images).
I therefore often utilize a trick: I threshold an image for the value I search for, and then iterate over that mask as long as it is not all-zero. The max(img,x,y) command will return the first maximum if there are multiple, so I get an ordered list.

```<code>image spec := RealImage("Test",4,100)
spec = trunc(Random()*10)
spec.ShowImage()

number v = 8
image mask = (spec==v)?1:0

ClearResults()
while( 0<sum(mask) )
{
    number x,y
    max(mask,x,y)
    Result("\n Value " + v +" @ " + x )
    mask[x,0]=0
}
</code>```

Edit: Answering the question of the comment below.

This is how one gets the ZLP maximum (position and value) from a line-profile in calibrated values.

Precursor: DM contains all data as simple arrays and values (real or integer). These are the real data and unrelated to any calibrations. You see these values if you toggle the "calibration" checkbox off in the Image Status palette:

These are the values all script commands etc. will use, i.e. positions are always indices (starting from 0) and values are the raw numeric values stored.

These images or spectra are calibrated by defining an origin and scale (and unit) for each dimensional axis as well as the intensity (=value). These triplets of values can be found in the image display info of data:

Only when the "Show calibrated values" checkbox is checked, is the data displayed in calibrated values. However, the real values remain unchanged. Just the scale/origin values are used to convert the numbers.

If you want to use a script to use calibrated values, then you have to perform the same conversions in you script yourself.
Here is the example:

```<code>image spectrum := GetFrontImage()

number xScale = spectrum.ImageGetDimensionScale(0)  // 0 for X dimension
number xOrigin = spectrum.ImageGetDimensionOrigin(0)
string xUnit = spectrum.ImageGetDimensionUnitString(0)

number iScale = spectrum.ImageGetIntensityScale()
number iOrigin = spectrum.ImageGetIntensityOrigin()
string iUnit = spectrum.ImageGetIntensityUnitString()

string info = "\n"
info += "Image ["+spectrum.ImageGetLabel()+"]:"
info += "\n\t Dimension calibration: nCh * " + xScale + " + " + xOrigin + " [" + xUnit + "]"
info += "\n\t Intensity calibration: (value - " + iOrigin + ") * " + iScale +" [" + iUnit + "]"
Result(info)

// Find ZLP maximum (uncalibrated values)
number maxP_ch, dummy, maxV_raw
maxV_raw = max(spectrum,maxP_ch,dummy)
info = "\n"
info += "\n\t The maximum position is at channel index: " + maxP_ch
info += "\n\t The maximum Value at maximum position is: " + maxV_raw
Result(info)

number maxP_cal = xOrigin + xScale * maxP_ch
number maxV_cal = (maxV_raw - iOrigin) * iScale
info = "\n"
info += "\n\t The maximum position is at : " + maxP_cal
info += "\n\t The maximum Value is       : " + maxV_cal
Result(info)
</code>```

Note the different calibration formulas between dimensional calibration and intensity calibration!

Body:
For a line profile (curve), I want to reach that list all X coordinates that corresponding a Y coordinate by given this Y coordinate. And I could get the minimum and maximum values of these x coordinates.  Here supposed I want to list all the X coordinates corresponding y=8, is this correct or any other better way? Thx

 Number minx, maxx
    Image front=:getfrontimage()

    GetSize( front, xsize, ysize )

    for (i=0; i<xsize; i++)

                {
                    x= getpixel(front, i, 8)
                 minx=min(x)
          maxx=max(x)

                }

Body:
You script becomes wrong when you use the min and max, because you can not get a minimum/maximum of a single value (or rather, it is always that value). What you want to do is likely:

image spec := RealImage("Test",4,100)
spec = trunc(Random()*10)
number v = 8

ClearResults()
number nCh = spec.ImageGetDimensionSize(0)
for( number i=0; i<nCh; i++)
{
    if( v == sum(spec[i,0]) )
        Result("\n Value "+ v +" @ " + i )
}

(The sum() is needed here a a trick to convert an image-expression to a single value.)

However, going pixel-by-pixel in script can be slow. Whenever possible, try to code with image-expressions, because they are much faster (for big images).
I therefore often utilize a trick: I threshold an image for the value I search for, and then iterate over that mask as long as it is not all-zero. The max(img,x,y) command will return the first maximum if there are multiple, so I get an ordered list.

image spec := RealImage("Test",4,100)
spec = trunc(Random()*10)
spec.ShowImage()

number v = 8
image mask = (spec==v)?1:0

ClearResults()
while( 0<sum(mask) )
{
    number x,y
    max(mask,x,y)
    Result("\n Value " + v +" @ " + x )
    mask[x,0]=0
}

Edit: Answering the question of the comment below.

This is how one gets the ZLP maximum (position and value) from a line-profile in calibrated values.

Precursor: DM contains all data as simple arrays and values (real or integer). These are the real data and unrelated to any calibrations. You see these values if you toggle the "calibration" checkbox off in the Image Status palette:

These are the values all script commands etc. will use, i.e. positions are always indices (starting from 0) and values are the raw numeric values stored.

These images or spectra are calibrated by defining an origin and scale (and unit) for each dimensional axis as well as the intensity (=value). These triplets of values can be found in the image display info of data:

Only when the "Show calibrated values" checkbox is checked, is the data displayed in calibrated values. However, the real values remain unchanged. Just the scale/origin values are used to convert the numbers.

If you want to use a script to use calibrated values, then you have to perform the same conversions in you script yourself.
Here is the example:

image spectrum := GetFrontImage()

number xScale = spectrum.ImageGetDimensionScale(0)  // 0 for X dimension
number xOrigin = spectrum.ImageGetDimensionOrigin(0)
string xUnit = spectrum.ImageGetDimensionUnitString(0)

number iScale = spectrum.ImageGetIntensityScale()
number iOrigin = spectrum.ImageGetIntensityOrigin()
string iUnit = spectrum.ImageGetIntensityUnitString()

string info = "\n"
info += "Image ["+spectrum.ImageGetLabel()+"]:"
info += "\n\t Dimension calibration: nCh * " + xScale + " + " + xOrigin + " [" + xUnit + "]"
info += "\n\t Intensity calibration: (value - " + iOrigin + ") * " + iScale +" [" + iUnit + "]"
Result(info)

// Find ZLP maximum (uncalibrated values)
number maxP_ch, dummy, maxV_raw
maxV_raw = max(spectrum,maxP_ch,dummy)
info = "\n"
info += "\n\t The maximum position is at channel index: " + maxP_ch
info += "\n\t The maximum Value at maximum position is: " + maxV_raw
Result(info)

number maxP_cal = xOrigin + xScale * maxP_ch
number maxV_cal = (maxV_raw - iOrigin) * iScale
info = "\n"
info += "\n\t The maximum position is at : " + maxP_cal
info += "\n\t The maximum Value is       : " + maxV_cal
Result(info)

Note the different calibration formulas between dimensional calibration and intensity calibration!


问:
VueJS + Electron, building issue with API
I have an issue:

I'm working on an app in Electron-Vue, and to test if it works outside of the "npm run dev", I build it, and launched. The app runs well but as soon as I try to connect on the ui end with a random session (doing an API call), the app does nothing.
When I click to get a random page which does'nt need API call, it works well and redirects me to the correct page, but when it needs to make an API call, it suddenly fail and doesn't do anything at all.
Do you know how I can track errors in build mode or do you have an idea of what's going on ?

NB : I use electron-vue builder

Thanks a lot ^^

答:
Actually, after a quick lookup, I've found an answer to this.

https://github.com/SimulatedGREG/electron-vue/issues/214

Here, in the case of electron-vue, this can be used to easily get a console while just entering a manual command on your keyboard !


问:
Moving rectangle to location using deltatime
I'm trying to have a simple rectangle move from current location to the clicked location on the canvas. When I provide a constant speed, the rectangle appears and moves fine. But when I multiply it by deltatime the rectangle doesn't appear anymore. I'm using requestAnimationFrame as the draw loop.

canvas.js

```<code>window.addEventListener('DOMContentLoaded', (event) => {
    let canvas = document.getElementById("gamecanvas");
    let ctx = canvas.getContext('2d');
    var oldframetime = 0;
    var x = 0;
    var y = 0;
    var dstx = 0;
    var dsty = 0;
    var deltatime = 0;
    var speed = 5;
    function getmousepos(evt){
        var rect = canvas.getBoundingClientRect();
        return {
          x: evt.clientX - rect.left,
          y: evt.clientY - rect.top
        };
    }
    canvas.addEventListener("mousedown",e=>{
        let coord = getmousepos(e);
        dstx = coord.x;
        dsty = coord.y;
    });
    function movetowards(current,target,maxdistancedelta){
        if(Math.abs(target - current)<=maxdistancedelta){
            return target;
        }
        return current+Math.sign(target - current) * maxdistancedelta;
    }
    function tick(timestamp){
        deltatime = (timestamp - oldframetime)/1000;

        var step = deltatime*speed;
        var newlocx = movetowards(x,dstx-50,5);
        var newlocy = movetowards(y,dsty-50,5);

        ctx.clearRect(0,0,canvas.clientWidth,canvas.clientHeight);
        ctx.fillStyle = 'green';
        ctx.fillRect(newlocx,newlocy,100,100);

        x = newlocx;
        y = newlocy;
        console.log(newlocx+":"+newlocy);
        oldframetime = timestamp;
        requestAnimationFrame(tick);
    }
    requestAnimationFrame(function(){
        tick();
    });
});
</code>```

In that example, newlocx and newlocy both print NaN:NaN
But if I choose not to use step and give it a constant speed of like 5, then it works fine.

```<code>    function tick(timestamp){
        deltatime = (timestamp - oldframetime)/1000;

        var step = deltatime*speed;
        var newlocx = movetowards(x,dstx-50,5);
        var newlocy = movetowards(y,dsty-50,5);

        ctx.clearRect(0,0,canvas.clientWidth,canvas.clientHeight);
        ctx.fillStyle = 'green';
        ctx.fillRect(newlocx,newlocy,100,100);

        x = newlocx;
        y = newlocy;
        console.log(newlocx+":"+newlocy);
        oldframetime = timestamp;
        requestAnimationFrame(tick);
    }
</code>```

The print is also accurate now. Why does multiplyng step by deltatime prevent the rectangle from moving? Or even appearing?

Here's the HTML if anyone's interested.

index.html

```<code><html>
    <head>
        <script src="canvas.js"></script>
    </head>
    <body>
        <canvas id="gamecanvas" width="2000" height="1000"></canvas>
    </body>
</html>
</code>```

答:
You should be starting the animation with requestAnimationFrame rather than indirectly as you have done.

Replace

requestAnimationFrame(function(){
         tick();
     });

with

```<code>requestAnimationFrame(tick)
</code>```

Then in the function tick you check if oldframetime has been set, if not set  deltaTime to 0, as no time has passed, and thus starts the animation at the start. If you set the value of deltaTime to any other value you end up not rendering the animation from the start.

```<code>function tick(timestamp){
    if (!oldframetime) {
       deltaTime = 0;
    } else {
       deltatime = (timestamp - oldframetime)/1000;
    }

    // .. animation code

    oldframetime = timestamp;
    requestAnimationFrame(tick);
}
</code>```

Body:
I'm trying to have a simple rectangle move from current location to the clicked location on the canvas. When I provide a constant speed, the rectangle appears and moves fine. But when I multiply it by deltatime the rectangle doesn't appear anymore. I'm using requestAnimationFrame as the draw loop.

canvas.js

window.addEventListener('DOMContentLoaded', (event) => {
    let canvas = document.getElementById("gamecanvas");
    let ctx = canvas.getContext('2d');
    var oldframetime = 0;
    var x = 0;
    var y = 0;
    var dstx = 0;
    var dsty = 0;
    var deltatime = 0;
    var speed = 5;
    function getmousepos(evt){
        var rect = canvas.getBoundingClientRect();
        return {
          x: evt.clientX - rect.left,
          y: evt.clientY - rect.top
        };
    }
    canvas.addEventListener("mousedown",e=>{
        let coord = getmousepos(e);
        dstx = coord.x;
        dsty = coord.y;
    });
    function movetowards(current,target,maxdistancedelta){
        if(Math.abs(target - current)<=maxdistancedelta){
            return target;
        }
        return current+Math.sign(target - current) * maxdistancedelta;
    }
    function tick(timestamp){
        deltatime = (timestamp - oldframetime)/1000;

        var step = deltatime*speed;
        var newlocx = movetowards(x,dstx-50,5);
        var newlocy = movetowards(y,dsty-50,5);

        ctx.clearRect(0,0,canvas.clientWidth,canvas.clientHeight);
        ctx.fillStyle = 'green';
        ctx.fillRect(newlocx,newlocy,100,100);

        x = newlocx;
        y = newlocy;
        console.log(newlocx+":"+newlocy);
        oldframetime = timestamp;
        requestAnimationFrame(tick);
    }
    requestAnimationFrame(function(){
        tick();
    });
});

In that example, newlocx and newlocy both print NaN:NaN
But if I choose not to use step and give it a constant speed of like 5, then it works fine.

    function tick(timestamp){
        deltatime = (timestamp - oldframetime)/1000;

        var step = deltatime*speed;
        var newlocx = movetowards(x,dstx-50,5);
        var newlocy = movetowards(y,dsty-50,5);

        ctx.clearRect(0,0,canvas.clientWidth,canvas.clientHeight);
        ctx.fillStyle = 'green';
        ctx.fillRect(newlocx,newlocy,100,100);

        x = newlocx;
        y = newlocy;
        console.log(newlocx+":"+newlocy);
        oldframetime = timestamp;
        requestAnimationFrame(tick);
    }

The print is also accurate now. Why does multiplyng step by deltatime prevent the rectangle from moving? Or even appearing?

Here's the HTML if anyone's interested.

index.html

        <canvas id="gamecanvas" width="2000" height="1000"></canvas>

Body:
You should be starting the animation with requestAnimationFrame rather than indirectly as you have done.

Replace

requestAnimationFrame(function(){
         tick();
     });

with

requestAnimationFrame(tick)

Then in the function tick you check if oldframetime has been set, if not set  deltaTime to 0, as no time has passed, and thus starts the animation at the start. If you set the value of deltaTime to any other value you end up not rendering the animation from the start.

function tick(timestamp){
    if (!oldframetime) {
       deltaTime = 0;
    } else {
       deltatime = (timestamp - oldframetime)/1000;
    }

    // .. animation code

    oldframetime = timestamp;
    requestAnimationFrame(tick);
}


问:
Best Practises for developing a TCP Communicator
We are developing a Vehicle Tracking System. In this system, we fix a GPS device into the vehicle which sends the location data to our server using TCP communication. There can be more than 1000's of devices sending data at any given time. Please suggest me the best practices I should follow to build the TCP communicator. We are using java as programming language and MySQL as database server.

I need your suggestions on best practices I should follow along with the reasons. e.g. I should follow Thread-per-connection model or Thread-on-event model of multi-threading? Why that model? How should I implement connection pooling? Shall I implement messaging queue?,etc..

Thanks,
Saurabh

答: Use NIO and make full use of multi-threading. If possible use some exisitng libraries like MINA


问:
docker error in windows container read tcp : wsarecv: An existing connection was forcibly closed by the remote host
i am using the latest version of docker for windows. the linux container goes smoothly but i am  getting below problem

wsarecv: An existing connection was forcibly closed by the remote host.

it occurs for fetching some specific image  from repos. In my case i am fetching microsoft/aspnet. i have created a docker file and trying to built my custom image.I have followed the repository instruction for creating a docker file.
the picture is given below

after this state i am getting this forcibly closed by remote host error.

my dockerfile content is

```<code>FROM microsoft/aspnet:4.7
ARG site_root=.
ADD ${site_root} /inetpub/wwwroot
</code>```

答: I had been consistently encountering this error from inside a corporate network. We added mcr.microsoft.com to a firewall white-list, and everything worked as intended.

Body:
i am using the latest version of docker for windows. the linux container goes smoothly but i am  getting below problem

wsarecv: An existing connection was forcibly closed by the remote host.

it occurs for fetching some specific image  from repos. In my case i am fetching microsoft/aspnet. i have created a docker file and trying to built my custom image.I have followed the repository instruction for creating a docker file.
the picture is given below

after this state i am getting this forcibly closed by remote host error.

my dockerfile content is

FROM microsoft/aspnet:4.7
ARG site_root=.
ADD ${site_root} /inetpub/wwwroot


问:
Same file in different branches
There is the same file in my master and in my welcome branch. My master has nothing in the file but in my welcome there is a lot of things. What is going to happen when I put it all together?

答:
When you merge two branches, Git considers three locations: the two heads (in this case, the master and welcome branches) and the merge base, which is usually the point at which the branches forked.

When the merge happens, Git essentially looks at each side independently and compares it to the merge base, and determines what has changed.  Git then applies both sets of changes in the result.

If one side is changed, and the other is not, Git incorporates the changes.  So if at the point your branches were forked, the file was empty, then the result of the merge will have the contents of the file.  If both sides are changes in the same area, a merge conflict will occur, and you'll need to resolve it.  There isn't a way to avoid this, since Git doesn't know what you want done in this case.

If you want to test this out and see what will happen in your case, you can create a temporary branch off of master and merge welcome into it, and see what the result is like:

```<code>$ git checkout master
$ git checkout -b temp
$ git merge welcome
</code>```

If you get into a conflicted state and don't want to continue, you can run git merge --abort to return to where you were.

Title: Same file in different branches

Body:
When you merge two branches, Git considers three locations: the two heads (in this case, the master and welcome branches) and the merge base, which is usually the point at which the branches forked.

When the merge happens, Git essentially looks at each side independently and compares it to the merge base, and determines what has changed.  Git then applies both sets of changes in the result.

If one side is changed, and the other is not, Git incorporates the changes.  So if at the point your branches were forked, the file was empty, then the result of the merge will have the contents of the file.  If both sides are changes in the same area, a merge conflict will occur, and you'll need to resolve it.  There isn't a way to avoid this, since Git doesn't know what you want done in this case.

If you want to test this out and see what will happen in your case, you can create a temporary branch off of master and merge welcome into it, and see what the result is like:

$ git checkout master
$ git checkout -b temp
$ git merge welcome

If you get into a conflicted state and don't want to continue, you can run git merge --abort to return to where you were.


问:
Create conda environment: "Found conflicts!" when solving environment and "Finding shortest conflict path" running forever
I was provided with an environment.ubuntu.yml file to be able to create a conda environment. However, running conda create env --file environment.ubuntu.yml I get the following output:

```<code>conda env create --file environment.ubuntu.yml
Collecting package metadata (repodata.json): done
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining fontconfig:   5%|▉                 | 10/202 [00:00<00:00, 5393.91it/ ]
Comparing specs that have this dependency:   0%|         | 0/12 [00:00<?, ?it/s]
Finding shortest confli|  path for fontconfig==2.13.1=he4413a7_1000:  12%|▏| 1/8
Finding shortest conflict path for fontconfig==2.13.1=he4413a7_1000:  25%|▎| 2/8
Finding shortest conflict pa/  for fontconfig[version='>=2.13.0,<3.0a0']:  25%|
Finding shortest conflict path for fontconfig[version='>=2.13.0,<3.0a0']:  38%|
Finding shortest conf- ct path for fontconfig[version='>=2.11.1']:  38%|▍| 3/8 [
Finding shortest conflict path for fontconfig[version='>=2.11.1']:  50%|▌| 4/8 [
Finding shortest conflict pa|  for fontconfig[version='>=2.12.4,<3.0a0']:  50%|
...
</code>```

The Finding shortest conflict path goes on for a long time - apparently it is trying to resolve some dependency issues. Running for 2 hours it is not clear if it will ever stop.

My question is: what is happening here and can I somehow manually speed up this process, e.g. by removing unnecessary dependencies? Since I did not create the environment I don't know which are actually necessary.

The reason why I'm curious is because it is checking conflict paths like fontconfig[version='>=2.12.6,<3.0a0'] when the one in dependencies is 2.13.1 and I have installed it through 2.13.1

Please find below the .yml file for reference.

```<code>name: cea
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - dlr-sc
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - conda-forge
  - conda-forge/label/gcc7
  - defaults
dependencies:
  - attrs=19.1.0=py_0
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.5=py_1
  - backports_abc=0.5=py_1
  - boost-cpp=1.68.0=h11c811c_1000
  - bzip2=1.0.6=h14c3975_1002
  - ca-certificates=2019.3.9=hecc5488_0
  - cairo=1.14.12=h80bd089_1005
  - certifi=2019.3.9=py27_0
  - click=7.0=py_0
  - click-plugins=1.0.4=py_0
  - cligj=0.5.0=py_0
  - curl=7.64.1=hf8cf82a_0
  - cycler=0.10.0=py_1
  - descartes=1.1.0=py_2
  - enum34=1.1.6=py27_1001
  - expat=2.2.5=hf484d3e_1002
  - fiona=1.8.6=py27hf242f0b_2
  - fontconfig=2.13.1=he4413a7_1000
  - freetype=2.10.0=he983fc9_0
  - freexl=1.0.5=h14c3975_1002
  - functools32=3.2.3.2=py_3
  - futures=3.2.0=py27_1000
  - gdal=2.4.1=py27h5f563d9_8
  - geopandas=0.4.1=py_1
  - geos=3.7.1=hf484d3e_1000
  - geotiff=1.4.3=h1105359_1000
  - gettext=0.19.8.1=hc5be6a0_1002
  - giflib=5.1.7=h516909a_1
  - glib=2.56.2=had28632_1001
  - hdf4=4.2.13=h9a582f1_1002
  - hdf5=1.10.4=nompi_h3c11f04_1106
  - icu=58.2=hf484d3e_1000
  - jpeg=9c=h14c3975_1001
  - json-c=0.13.1=h14c3975_1001
  - kealib=1.4.10=h1978553_1003
  - kiwisolver=1.0.1=py27h6bb024c_1002
  - krb5=1.16.3=h05b26f9_1001
  - libblas=3.8.0=4_openblas
  - libcblas=3.8.0=4_openblas
  - libcurl=7.64.1=hda55be3_0
  - libdap4=3.19.1=hd48c02d_1000
  - libedit=3.1.20170329=hf8c457e_1001
  - libffi=3.2.1=he1b5a44_1006
  - libgdal=2.4.1=heae24aa_8
  - libiconv=1.15=h516909a_1005
  - libkml=1.3.0=h328b03d_1009
  - liblapack=3.8.0=4_openblas
  - libnetcdf=4.6.2=hbdf4f91_1001
  - libpng=1.6.36=h84994c4_1000
  - libpq=11.2=h4770945_0
  - libspatialindex=1.9.0=he1b5a44_0
  - libspatialite=4.3.0a=hb5ec416_1026
  - libssh2=1.8.2=h22169c7_2
  - libtiff=4.0.10=h648cc4a_1001
  - libuuid=2.32.1=h14c3975_1000
  - libxcb=1.13=h14c3975_1002
  - libxml2=2.9.8=h143f9aa_1005
  - mapclassify=1.0.1=py27_1
  - matplotlib=2.2.3=py27h8a2030e_1
  - matplotlib-base=2.2.3=py27h60b886d_1
  - munch=2.3.2=py_0
  - ncurses=6.1=hf484d3e_1002
  - numpy=1.16.2=py27h8b7e671_1
  - openblas=0.3.5=h9ac9557_1001
  - openjpeg=2.3.0=hf38bd82_1003
  - openssl=1.1.1b=h14c3975_1
  - pandas=0.24.2=py27hf484d3e_0
  - pip=19.0.3=py27_0
  - pixman=0.34.0=h14c3975_1003
  - poppler=0.67.0=h2fc8fa2_1002
  - poppler-data=0.4.9=1
  - postgresql=11.2=h61314c7_0
  - proj4=5.2.0=h14c3975_1001
  - pthread-stubs=0.4=h14c3975_1001
  - pyparsing=2.3.1=py_0
  - pyproj=1.9.6=py27hc0953d3_1000
  - pyqt=5.6.0=py27h13b7fb3_1008
  - python=2.7.15=h721da81_1008
  - python-dateutil=2.8.0=py_0
  - pytz=2018.9=py_0
  - readline=7.0=hf8c457e_1001
  - rtree=0.8.3=py27h666c49c_1002
  - scipy=1.2.1=py27h09a28d5_1
  - setuptools=40.8.0=py27_0
  - shapely=1.6.4=py27h2afed24_1003
  - singledispatch=3.4.0.3=py27_1000
  - sip=4.18.1=py27hf484d3e_1000
  - six=1.12.0=py27_1000
  - sqlite=3.26.0=h67949de_1001
  - subprocess32=3.5.3=py27h14c3975_0
  - tbb=2019.5=hc9558a2_0
  - tk=8.6.9=h84994c4_1001
  - tornado=5.1.1=py27h14c3975_1000
  - tzcode=2018g=h14c3975_1001
  - wheel=0.33.1=py27_0
  - xerces-c=3.2.2=hac72e42_1001
  - xorg-kbproto=1.0.7=h14c3975_1002
  - xorg-libice=1.0.9=h516909a_1004
  - xorg-libsm=1.2.3=h84519dc_1000
  - xorg-libx11=1.6.7=h14c3975_1000
  - xorg-libxau=1.0.9=h14c3975_0
  - xorg-libxdmcp=1.1.3=h516909a_0
  - xorg-libxext=1.3.4=h516909a_0
  - xorg-libxrender=0.9.10=h516909a_1002
  - xorg-renderproto=0.11.1=h14c3975_1002
  - xorg-xextproto=7.3.0=h14c3975_1002
  - xorg-xproto=7.0.31=h14c3975_1007
  - xz=5.2.4=h14c3975_1001
  - zlib=1.2.11=h14c3975_1004
  - freeimageplus=3.18.0=hf484d3e_2
  - gl2ps=1.3.8=h14c3975_4
  - oce=0.17.2=h6bb024c_10
  - pythonocc-core=0.17=py27_1
  - mkl=2017.0.3=0
  - mkl-service=1.1.2=py27_3
  - dbus=1.13.2=h714fa37_1
  - gst-plugins-base=1.14.0=hbbd80ab_1
  - gstreamer=1.14.0=hb453b48_1
  - libgcc-ng=8.2.0=hdf63c60_1
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libstdcxx-ng=8.2.0=hdf63c60_1
  - pcre=8.43=he6710b0_0
  - qt=5.6.3=h8bf5577_3
  - pip:
    - alabaster==0.7.12
    - babel==2.6.0
    - backports.shutil-get-terminal-size==1.0.0
    - bleach==3.1.0
    - chardet==3.0.4
    - cloudpickle==0.8.1
    - configparser==3.7.4
    - cvxopt==1.2.3
    - decorator==4.4.0
    - defusedxml==0.5.0
    - docutils==0.14
    - doit==0.29.0
    - entrypoints==0.3
    - ephem==3.7.6.0
    - funcsigs==1.0.2
    - h5py==2.9.0
    - idna==2.8
    - imagesize==1.1.0
    - importlib-resources==1.0.2
    - ipaddress==1.0.22
    - ipykernel==4.10.0
    - ipython==5.8.0
    - ipython-genutils==0.2.0
    - ipywidgets==7.4.2
    - jinja2==2.10
    - joblib==0.12.5
    - jsonschema==3.0.1
    - jupyter==1.0.0
    - jupyter-client==5.2.4
    - jupyter-console==5.2.0
    - jupyter-core==4.4.0
    - llvmlite==0.28.0
    - lxml==4.3.3
    - markupsafe==1.1.1
    - mistune==0.8.4
    - mock==2.0.0
    - nbconvert==5.4.1
    - nbformat==4.4.0
    - networkx==2.2
    - notebook==5.7.8
    - numba==0.43.1
    - packaging==19.0
    - pandocfilters==1.4.2
    - pathlib2==2.3.3
    - patsy==0.5.1
    - pbr==5.1.3
    - pexpect==4.6.0
    - pickleshare==0.7.5
    - pkginfo==1.5.0.1
    - plotly==3.7.1
    - prometheus-client==0.6.0
    - prompt-toolkit==1.0.15
    - ptyprocess==0.6.0
    - py4design==0.27
    - pycollada==0.6
    - pygments==2.3.1
    - pyinotify==0.9.6
    - pymc3==3.6
    - pymf==0.1.9
    - pyrsistent==0.14.11
    - pysal==1.14.4.post2
    - pyshp==2.1.0
    - pyyaml==5.1
    - pyzmq==18.0.1
    - qtconsole==4.4.3
    - readme-renderer==24.0
    - requests==2.21.0
    - requests-toolbelt==0.9.1
    - retrying==1.3.3
    - salib==1.2
    - scandir==1.10.0
    - scikit-learn==0.20.3
    - seaborn==0.9.0
    - send2trash==1.5.0
    - simplegeneric==0.8.1
    - snowballstemmer==1.2.1
    - sphinx==1.8.5
    - sphinxcontrib-websupport==1.1.0
    - terminado==0.8.2
    - testpath==0.4.2
    - theano==1.0.4
    - timezonefinder==4.0.1
    - tqdm==4.31.1
    - traitlets==4.3.2
    - twine==1.13.0
    - typing==3.6.6
    - urllib3==1.24.1
    - utm==0.4.2
    - wcwidth==0.1.7
    - webencodings==0.5.1
    - widgetsnbextension==3.4.2
    - xlrd==1.2.0
    - xlwt==1.3.0
    - deap==1.3.0
</code>```

答: I was also faced with the same problem on windows 10, using pycharm with anaconda (python 3.7) latest build as of feb 17,2020. Strangely enough toggling the "use conda package manager" on the project interpreter page in pycharm's settings allowed me to update numpy and install packages normally. Try installing a package without the conda package manager and with the conda package manager. Good luck!</p>

Body:
I was provided with an environment.ubuntu.yml file to be able to create a conda environment. However, running conda create env --file environment.ubuntu.yml I get the following output:

conda env create --file environment.ubuntu.yml
Collecting package metadata (repodata.json): done
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
Examining fontconfig:   5%|▉                 | 10/202 [00:00<00:00, 5393.91it/ ]
Comparing specs that have this dependency:   0%|         | 0/12 [00:00<?, ?it/s]
Finding shortest confli|  path for fontconfig==2.13.1=he4413a7_1000:  12%|▏| 1/8
Finding shortest conflict path for fontconfig==2.13.1=he4413a7_1000:  25%|▎| 2/8
Finding shortest conflict pa/  for fontconfig[version='>=2.13.0,<3.0a0']:  25%|
Finding shortest conflict path for fontconfig[version='>=2.13.0,<3.0a0']:  38%|
Finding shortest conf- ct path for fontconfig[version='>=2.11.1']:  38%|▍| 3/8 [
Finding shortest conflict path for fontconfig[version='>=2.11.1']:  50%|▌| 4/8 [
Finding shortest conflict pa|  for fontconfig[version='>=2.12.4,<3.0a0']:  50%|
...

The Finding shortest conflict path goes on for a long time - apparently it is trying to resolve some dependency issues. Running for 2 hours it is not clear if it will ever stop.

My question is: what is happening here and can I somehow manually speed up this process, e.g. by removing unnecessary dependencies? Since I did not create the environment I don't know which are actually necessary.

The reason why I'm curious is because it is checking conflict paths like fontconfig[version='>=2.12.6,<3.0a0'] when the one in dependencies is 2.13.1 and I have installed it through 2.13.1

Please find below the .yml file for reference.

name: cea
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - dlr-sc
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - conda-forge
  - conda-forge/label/gcc7
  - defaults
dependencies:
  - attrs=19.1.0=py_0
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.5=py_1
  - backports_abc=0.5=py_1
  - boost-cpp=1.68.0=h11c811c_1000
  - bzip2=1.0.6=h14c3975_1002
  - ca-certificates=2019.3.9=hecc5488_0
  - cairo=1.14.12=h80bd089_1005
  - certifi=2019.3.9=py27_0
  - click=7.0=py_0
  - click-plugins=1.0.4=py_0
  - cligj=0.5.0=py_0
  - curl=7.64.1=hf8cf82a_0
  - cycler=0.10.0=py_1
  - descartes=1.1.0=py_2
  - enum34=1.1.6=py27_1001
  - expat=2.2.5=hf484d3e_1002
  - fiona=1.8.6=py27hf242f0b_2
  - fontconfig=2.13.1=he4413a7_1000
  - freetype=2.10.0=he983fc9_0
  - freexl=1.0.5=h14c3975_1002
  - functools32=3.2.3.2=py_3
  - futures=3.2.0=py27_1000
  - gdal=2.4.1=py27h5f563d9_8
  - geopandas=0.4.1=py_1
  - geos=3.7.1=hf484d3e_1000
  - geotiff=1.4.3=h1105359_1000
  - gettext=0.19.8.1=hc5be6a0_1002
  - giflib=5.1.7=h516909a_1
  - glib=2.56.2=had28632_1001
  - hdf4=4.2.13=h9a582f1_1002
  - hdf5=1.10.4=nompi_h3c11f04_1106
  - icu=58.2=hf484d3e_1000
  - jpeg=9c=h14c3975_1001
  - json-c=0.13.1=h14c3975_1001
  - kealib=1.4.10=h1978553_1003
  - kiwisolver=1.0.1=py27h6bb024c_1002
  - krb5=1.16.3=h05b26f9_1001
  - libblas=3.8.0=4_openblas
  - libcblas=3.8.0=4_openblas
  - libcurl=7.64.1=hda55be3_0
  - libdap4=3.19.1=hd48c02d_1000
  - libedit=3.1.20170329=hf8c457e_1001
  - libffi=3.2.1=he1b5a44_1006
  - libgdal=2.4.1=heae24aa_8
  - libiconv=1.15=h516909a_1005
  - libkml=1.3.0=h328b03d_1009
  - liblapack=3.8.0=4_openblas
  - libnetcdf=4.6.2=hbdf4f91_1001
  - libpng=1.6.36=h84994c4_1000
  - libpq=11.2=h4770945_0
  - libspatialindex=1.9.0=he1b5a44_0
  - libspatialite=4.3.0a=hb5ec416_1026
  - libssh2=1.8.2=h22169c7_2
  - libtiff=4.0.10=h648cc4a_1001
  - libuuid=2.32.1=h14c3975_1000
  - libxcb=1.13=h14c3975_1002
  - libxml2=2.9.8=h143f9aa_1005
  - mapclassify=1.0.1=py27_1
  - matplotlib=2.2.3=py27h8a2030e_1
  - matplotlib-base=2.2.3=py27h60b886d_1
  - munch=2.3.2=py_0
  - ncurses=6.1=hf484d3e_1002
  - numpy=1.16.2=py27h8b7e671_1
  - openblas=0.3.5=h9ac9557_1001
  - openjpeg=2.3.0=hf38bd82_1003
  - openssl=1.1.1b=h14c3975_1
  - pandas=0.24.2=py27hf484d3e_0
  - pip=19.0.3=py27_0
  - pixman=0.34.0=h14c3975_1003
  - poppler=0.67.0=h2fc8fa2_1002
  - poppler-data=0.4.9=1
  - postgresql=11.2=h61314c7_0
  - proj4=5.2.0=h14c3975_1001
  - pthread-stubs=0.4=h14c3975_1001
  - pyparsing=2.3.1=py_0
  - pyproj=1.9.6=py27hc0953d3_1000
  - pyqt=5.6.0=py27h13b7fb3_1008
  - python=2.7.15=h721da81_1008
  - python-dateutil=2.8.0=py_0
  - pytz=2018.9=py_0
  - readline=7.0=hf8c457e_1001
  - rtree=0.8.3=py27h666c49c_1002
  - scipy=1.2.1=py27h09a28d5_1
  - setuptools=40.8.0=py27_0
  - shapely=1.6.4=py27h2afed24_1003
  - singledispatch=3.4.0.3=py27_1000
  - sip=4.18.1=py27hf484d3e_1000
  - six=1.12.0=py27_1000
  - sqlite=3.26.0=h67949de_1001
  - subprocess32=3.5.3=py27h14c3975_0
  - tbb=2019.5=hc9558a2_0
  - tk=8.6.9=h84994c4_1001
  - tornado=5.1.1=py27h14c3975_1000
  - tzcode=2018g=h14c3975_1001
  - wheel=0.33.1=py27_0
  - xerces-c=3.2.2=hac72e42_1001
  - xorg-kbproto=1.0.7=h14c3975_1002
  - xorg-libice=1.0.9=h516909a_1004
  - xorg-libsm=1.2.3=h84519dc_1000
  - xorg-libx11=1.6.7=h14c3975_1000
  - xorg-libxau=1.0.9=h14c3975_0
  - xorg-libxdmcp=1.1.3=h516909a_0
  - xorg-libxext=1.3.4=h516909a_0
  - xorg-libxrender=0.9.10=h516909a_1002
  - xorg-renderproto=0.11.1=h14c3975_1002
  - xorg-xextproto=7.3.0=h14c3975_1002
  - xorg-xproto=7.0.31=h14c3975_1007
  - xz=5.2.4=h14c3975_1001
  - zlib=1.2.11=h14c3975_1004
  - freeimageplus=3.18.0=hf484d3e_2
  - gl2ps=1.3.8=h14c3975_4
  - oce=0.17.2=h6bb024c_10
  - pythonocc-core=0.17=py27_1
  - mkl=2017.0.3=0
  - mkl-service=1.1.2=py27_3
  - dbus=1.13.2=h714fa37_1
  - gst-plugins-base=1.14.0=hbbd80ab_1
  - gstreamer=1.14.0=hb453b48_1
  - libgcc-ng=8.2.0=hdf63c60_1
  - libgfortran-ng=7.3.0=hdf63c60_0
  - libstdcxx-ng=8.2.0=hdf63c60_1
  - pcre=8.43=he6710b0_0
  - qt=5.6.3=h8bf5577_3
  - pip:
    - alabaster==0.7.12
    - babel==2.6.0
    - backports.shutil-get-terminal-size==1.0.0
    - bleach==3.1.0
    - chardet==3.0.4
    - cloudpickle==0.8.1
    - configparser==3.7.4
    - cvxopt==1.2.3
    - decorator==4.4.0
    - defusedxml==0.5.0
    - docutils==0.14
    - doit==0.29.0
    - entrypoints==0.3
    - ephem==3.7.6.0
    - funcsigs==1.0.2
    - h5py==2.9.0
    - idna==2.8
    - imagesize==1.1.0
    - importlib-resources==1.0.2
    - ipaddress==1.0.22
    - ipykernel==4.10.0
    - ipython==5.8.0
    - ipython-genutils==0.2.0
    - ipywidgets==7.4.2
    - jinja2==2.10
    - joblib==0.12.5
    - jsonschema==3.0.1
    - jupyter==1.0.0
    - jupyter-client==5.2.4
    - jupyter-console==5.2.0
    - jupyter-core==4.4.0
    - llvmlite==0.28.0
    - lxml==4.3.3
    - markupsafe==1.1.1
    - mistune==0.8.4
    - mock==2.0.0
    - nbconvert==5.4.1
    - nbformat==4.4.0
    - networkx==2.2
    - notebook==5.7.8
    - numba==0.43.1
    - packaging==19.0
    - pandocfilters==1.4.2
    - pathlib2==2.3.3
    - patsy==0.5.1
    - pbr==5.1.3
    - pexpect==4.6.0
    - pickleshare==0.7.5
    - pkginfo==1.5.0.1
    - plotly==3.7.1
    - prometheus-client==0.6.0
    - prompt-toolkit==1.0.15
    - ptyprocess==0.6.0
    - py4design==0.27
    - pycollada==0.6
    - pygments==2.3.1
    - pyinotify==0.9.6
    - pymc3==3.6
    - pymf==0.1.9
    - pyrsistent==0.14.11
    - pysal==1.14.4.post2
    - pyshp==2.1.0
    - pyyaml==5.1
    - pyzmq==18.0.1
    - qtconsole==4.4.3
    - readme-renderer==24.0
    - requests==2.21.0
    - requests-toolbelt==0.9.1
    - retrying==1.3.3
    - salib==1.2
    - scandir==1.10.0
    - scikit-learn==0.20.3
    - seaborn==0.9.0
    - send2trash==1.5.0
    - simplegeneric==0.8.1
    - snowballstemmer==1.2.1
    - sphinx==1.8.5
    - sphinxcontrib-websupport==1.1.0
    - terminado==0.8.2
    - testpath==0.4.2
    - theano==1.0.4
    - timezonefinder==4.0.1
    - tqdm==4.31.1
    - traitlets==4.3.2
    - twine==1.13.0
    - typing==3.6.6
    - urllib3==1.24.1
    - utm==0.4.2
    - wcwidth==0.1.7
    - webencodings==0.5.1
    - widgetsnbextension==3.4.2
    - xlrd==1.2.0
    - xlwt==1.3.0
    - deap==1.3.0


问:
How do you loop through a multiline string in Ruby?
Pretty simple question from a first-time Ruby programmer.

How do you loop through a slab of text in Ruby? Everytime a newline is met, I want to re-start the inner-loop.

```<code>def parse(input)
    ...
end
</code>```

答:
You can also do with with any pattern:</p>

```<code>str.scan(/\w+/) do |w|
  #do something
end
</code>```

OwnerDisplayName: alamodey

Body:
Pretty simple question from a first-time Ruby programmer.

How do you loop through a slab of text in Ruby? Everytime a newline is met, I want to re-start the inner-loop.

def parse(input)
    ...
end

Body:
You can also do with with any pattern:

str.scan(/\w+/) do |w|
  #do something
end

OwnerDisplayName: Lolindrath


问:
Loading fonts into ImageFont from GCS
I am having problems loading fonts in memory, directly from GCS, without creating temporary files.

The goal is to load it into:

```<code>from PIL import Image, ImageFont, ImageDraw
BUCKET_NAME = 'bucket_name'
gs_path = 'path_in_bucket/object.otf'
font_file = load_font_from_gcs(gs_path)
font = ImageFont.truetype(font_file, 18)
</code>```

I tried using the following 2 functions to download:

```<code>from google.cloud import storage

storage_client = storage.Client()

def load_font_from_gcs(gs_path):
    font_file = download_blob_as_string(gs_path)
    return font_file

def download_blob_as_string(source_blob_name, bucket_name=BUCKET_NAME):
    """Downloads a blob from the bucket as string."""

    storage_client = storage.Client()

    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(source_blob_name)
    return blob.download_as_string()
</code>```

However, I keep running into encoding/decoding errors or type errors e.g.

File
  "/anaconda3/envs/ml36/lib/python3.6/site-packages/PIL/ImageFont.py",
  line 161, in init
      font, size, index, encoding, layout_engine=layout_engine TypeError: argument 1 must be encoded string without null bytes, not
  bytes

答:
Wrapping it in a BytesIO works on my Mac:</p>

```<code>from io import BytesIO
...
...
font_file = load_font_from_gcs(gs_path)
font = ImageFont.truetype(BytesIO(font_file), 18)
</code>```

Title: Loading fonts into ImageFont from GCS

Body:
I am having problems loading fonts in memory, directly from GCS, without creating temporary files.

The goal is to load it into:

from PIL import Image, ImageFont, ImageDraw
BUCKET_NAME = 'bucket_name'
gs_path = 'path_in_bucket/object.otf'
font_file = load_font_from_gcs(gs_path)
font = ImageFont.truetype(font_file, 18)

I tried using the following 2 functions to download:

from google.cloud import storage

storage_client = storage.Client()

def load_font_from_gcs(gs_path):
    font_file = download_blob_as_string(gs_path)
    return font_file

def download_blob_as_string(source_blob_name, bucket_name=BUCKET_NAME):
    """Downloads a blob from the bucket as string."""

    storage_client = storage.Client()

    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(source_blob_name)
    return blob.download_as_string()

However, I keep running into encoding/decoding errors or type errors e.g.

File
  "/anaconda3/envs/ml36/lib/python3.6/site-packages/PIL/ImageFont.py",
  line 161, in init
      font, size, index, encoding, layout_engine=layout_engine TypeError: argument 1 must be encoded string without null bytes, not
  bytes

Body:
Wrapping it in a BytesIO works on my Mac:

from io import BytesIO
...
...
font_file = load_font_from_gcs(gs_path)
font = ImageFont.truetype(BytesIO(font_file), 18)


问:
Change String to Decimal Laravel Migration
I'm trying to Alter my current table and can do it just fine with a SQL Query in my migration file like this:

```<code><?php
    public function up()
    {
        Schema::table('xyz', function (Blueprint $table) {
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_needed funding_needed decimal(10, 2) NOT NULL DEFAULT 0.00 ');
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_received funding_received decimal(10, 2) NOT NULL DEFAULT 0.00 ');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('xyz', function (Blueprint $table) {
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_needed funding_needed varchar(191) NOT NULL ');
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_received funding_received varchar(191) NOT NULL DEFAULT 0');
        });
    }

</code>```

But if I do it the this way I get an error:

```<code><?php
    public function up()
    {
        Schema::table('xyz', function (Blueprint $table) {
             $table->decimal('funding_needed', 10, 2)->nullable(false)->default(0.00)->change();
             $table->decimal('funding_received', 10, 2)->nullable(false)->default(0.00)->change();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('xyz', function (Blueprint $table) {
         $table->string('funding_needed', 191)->nullable(false)->default(false)->change();
         $table->string('funding_received', 191)->nullable(false)->default(0)->change();
        });
    }

</code>```

ERROR:

Syntax error or access violation: 1064 You have an error in your SQL
  syntax; check the manual that corresponds to your MySQL server version
  for the right syntax to use near 'CHARACTER SET utf8mb4 DEFAULT '0'
  NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE ' at line 1 (SQL: ALTER
  TABLE xyz CHANGE funding_needed funding_needed NUMERIC(10, 2)
  CHARACTER SET utf8mb4 DEFAULT '0' NOT NULL COLLATE
  utf8mb4_unicode_ci, CHANGE funding_received funding_received
  NUMERIC(10, 2) CHARACTER SET utf8mb4 DEFAULT '0' NOT NULL COLLATE
  utf8mb4_unicode_ci)

I want to do it the 2nd way due to running this in production. I don't want to modify the production migration to match my production database.

答:
As pointed on this Github thread for doctrine/dbal package, which is the package you install before you run this update migrations, there's a bug on changing column types.

Using ->charset(null) along with ->change() should serve as a workaround in the meantime, as pointed on the link.

Body:
I'm trying to Alter my current table and can do it just fine with a SQL Query in my migration file like this:

<?php
    public function up()
    {
        Schema::table('xyz', function (Blueprint $table) {
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_needed funding_needed decimal(10, 2) NOT NULL DEFAULT 0.00 ');
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_received funding_received decimal(10, 2) NOT NULL DEFAULT 0.00 ');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('xyz', function (Blueprint $table) {
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_needed funding_needed varchar(191) NOT NULL ');
        DB::statement('ALTER TABLE mydatabase.xyz CHANGE funding_received funding_received varchar(191) NOT NULL DEFAULT 0');
        });
    }

But if I do it the this way I get an error:

<?php
    public function up()
    {
        Schema::table('xyz', function (Blueprint $table) {
             $table->decimal('funding_needed', 10, 2)->nullable(false)->default(0.00)->change();
             $table->decimal('funding_received', 10, 2)->nullable(false)->default(0.00)->change();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('xyz', function (Blueprint $table) {
         $table->string('funding_needed', 191)->nullable(false)->default(false)->change();
         $table->string('funding_received', 191)->nullable(false)->default(0)->change();
        });
    }

ERROR:

Syntax error or access violation: 1064 You have an error in your SQL
  syntax; check the manual that corresponds to your MySQL server version
  for the right syntax to use near 'CHARACTER SET utf8mb4 DEFAULT '0'
  NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE ' at line 1 (SQL: ALTER
  TABLE xyz CHANGE funding_needed funding_needed NUMERIC(10, 2)
  CHARACTER SET utf8mb4 DEFAULT '0' NOT NULL COLLATE
  utf8mb4_unicode_ci, CHANGE funding_received funding_received
  NUMERIC(10, 2) CHARACTER SET utf8mb4 DEFAULT '0' NOT NULL COLLATE
  utf8mb4_unicode_ci)

I want to do it the 2nd way due to running this in production. I don't want to modify the production migration to match my production database.


问:
In Vim, how do I make visual line selection for a block of code?
For example, in HTML I want to select an entire element. I could do Shift+V, and keep hitting J until I've selected all the lines, but that's cumbersome. Typing vat doesn't do what I want either -- it goes into visual mode, not visual line mode. The problem with not having visual line is that when I yank the text, its not yanking the first line's indentation.

答:
First, you need to install matchit plugin, which provides extended functionality for %. Particularly it allows to jump between matching HTML tags using %.

After that, put cursor on opening HTML tag (on first letter of the tag, not < symbol) and press Shift + v, then %.

This will do line selection from the line you put cursor to the line containing the closing tag.


问:
Python reading text files
Please help I need python to compare text line(s) to words like this.

with open('textfile', 'r') as f:
    contents = f.readlines()
    print(f_contents)
    if f_contents=="a":
        print("text")
```

I also would need it to, read a certain line, and compare that line. But when I run this program it does not do anything no error messages, nor does it print text. Also
How do you get python to write in just line 1? When I try to do it for some reason, it combines both words together can someone help thank you!

答:
what is f_contents it's supposed to be just print(contents)after reading in each line and storing it to contents. Hope that helps :)

An example of reading a file content:

```<code>with open("criticaldocuments.txt", "r") as f:
    for line in f:
       print(line)
       #prints all the lines in this file
       #allows the user to iterate over the file line by line
</code>```

OR what you want is something like this using readlines():

```<code>with open("criticaldocuments.txt", "r") as f:
   contents = f.readlines()
   #readlines() will store each and every line into var contents
   if contents == None:
      print("No lines were stored, file execution failed most likely")
   elif contents == "Password is Password":
      print("We cracked it")
   else:
      print(contents)
      # this returns all the lines if no matches
</code>```

Note:

```<code>contents = f.readlines()
</code>```

Can be done like this too:

```<code>for line in f.readlines():
#this eliminates the ambiguity of what 'contents' is doing
#and you could work through the rest of the code the same way except
#replace the contents with 'line'.
</code>```

Title: Python reading text files

Body:
Please help I need python to compare text line(s) to words like this.

with open('textfile', 'r') as f:
    contents = f.readlines()
    print(f_contents)
    if f_contents=="a":
        print("text")

I also would need it to, read a certain line, and compare that line. But when I run this program it does not do anything no error messages, nor does it print text. Also
How do you get python to write in just line 1? When I try to do it for some reason, it combines both words together can someone help thank you!

Body:
what is f_contents it's supposed to be just print(contents)after reading in each line and storing it to contents. Hope that helps :)

An example of reading a file content:

with open("criticaldocuments.txt", "r") as f:
    for line in f:
       print(line)
       #prints all the lines in this file
       #allows the user to iterate over the file line by line

OR what you want is something like this using readlines():

with open("criticaldocuments.txt", "r") as f:
   contents = f.readlines()
   #readlines() will store each and every line into var contents
   if contents == None:
      print("No lines were stored, file execution failed most likely")
   elif contents == "Password is Password":
      print("We cracked it")
   else:
      print(contents)
      # this returns all the lines if no matches

Note:

contents = f.readlines()

Can be done like this too:

for line in f.readlines():
#this eliminates the ambiguity of what 'contents' is doing
#and you could work through the rest of the code the same way except
#replace the contents with 'line'.


问:
How to replace/add lines from one file to another file
I have a one file like below example and I have requirement to grep the lines which are starting with system_props(cat file1 | grep ^system_props)..

```<code>JAVA_HOME=`find "$AGENT_HOME/jre" -name release -type f 2>/dev/null | sed "s|/release||g"`

system_props="$system_props -sensu.controller.hostName=abc.nam.net"
system_props="$system_props -sensu.controller.port=8181"
system_props="$system_props -sensu.controller.node=Mcagent"

if [ -z "$JAVA_HOME" ]; then
   if [ -d "/opt/middleware" ]; then
      JAVA_HOME=`find /opt/middleware -type d -name jre 2>/dev/null | grep WebSphere | grep java | grep -v grep | sort | uniq`
   fi
fi
</code>```

I have another file called say file2 which having dummy content like below.

```<code>JAVA_HOME=`find "$AGENT_HOME/jre" -name release -type f 2>/dev/null | sed "s|/release||g"`

system_props="$system_props -sensu.controller.hostName=testhost.net"
system_props="$system_props -sensu.controller.port=8080"

if [ -z "$JAVA_HOME" ]; then
   if [ -d "/opt/middleware" ]; then
      JAVA_HOME=`find /opt/middleware -type d -name jre 2>/dev/null | grep WebSphere | grep java | grep -v grep | sort | uniq`
   fi
fi
</code>```

Now my requirement is to replace the content of cat file1 | grep ^system_props to cat file2 | grep ^system_props)

The expected output of the system_props lines should be added in the file2 which are in file1 under same sequence.

```<code>system_props="$system_props -sensu.controller.hostName=abc.nam.net"
system_props="$system_props -sensu.controller.port=8181"
system_props="$system_props -sensu.controller.node=Mcagent"
</code>```

答:
You want to concatenate three file segments:

1. The second file until the first ^system_props

2. The lines from the first file with ^system_props

3. The second file after the last ^system_props

```<code># Part 1
sed '/^system/,$ d' file2
# Part 2
grep '^system' file1
# Or sed -n '/^system/p' file1
# Part 3
sed '1,/^system/d; /^system/ d' file2
</code>```

Together:

```<code>sed '/^system/,$ d' file2; grep '^system' file1; sed '1,/^system/d; /^system/ d' file2
</code>```

This approach can be done with awk too:

```<code>awk -F= 'BEGIN {show=1}
         ARGIND==1 && $1=="system_props" {show=0}
         ARGIND==2 {show=($1=="system_props" ? 1:0)}
         ARGIND==3 && $1=="system_props" {show=1; next}
         show {print}' file2 file1 file2
</code>```

Body:
I have a one file like below example and I have requirement to grep the lines which are starting with system_props(cat file1 | grep ^system_props)..

JAVA_HOME=`find "$AGENT_HOME/jre" -name release -type f 2>/dev/null | sed "s|/release||g"`

system_props="$system_props -sensu.controller.hostName=abc.nam.net"
system_props="$system_props -sensu.controller.port=8181"
system_props="$system_props -sensu.controller.node=Mcagent"

if [ -z "$JAVA_HOME" ]; then
   if [ -d "/opt/middleware" ]; then
      JAVA_HOME=`find /opt/middleware -type d -name jre 2>/dev/null | grep WebSphere | grep java | grep -v grep | sort | uniq`
   fi
fi

I have another file called say file2 which having dummy content like below.

JAVA_HOME=`find "$AGENT_HOME/jre" -name release -type f 2>/dev/null | sed "s|/release||g"`

system_props="$system_props -sensu.controller.hostName=testhost.net"
system_props="$system_props -sensu.controller.port=8080"

if [ -z "$JAVA_HOME" ]; then
   if [ -d "/opt/middleware" ]; then
      JAVA_HOME=`find /opt/middleware -type d -name jre 2>/dev/null | grep WebSphere | grep java | grep -v grep | sort | uniq`
   fi
fi

Now my requirement is to replace the content of cat file1 | grep ^system_props to cat file2 | grep ^system_props)

The expected output of the system_props lines should be added in the file2 which are in file1 under same sequence.

system_props="$system_props -sensu.controller.hostName=abc.nam.net"
system_props="$system_props -sensu.controller.port=8181"
system_props="$system_props -sensu.controller.node=Mcagent"

Body:
You want to concatenate three file segments:

1. The second file until the first ^system_props

2. The lines from the first file with ^system_props

3. The second file after the last ^system_props

# Part 1
sed '/^system/,$ d' file2
# Part 2
grep '^system' file1
# Or sed -n '/^system/p' file1
# Part 3
sed '1,/^system/d; /^system/ d' file2

Together:

sed '/^system/,$ d' file2; grep '^system' file1; sed '1,/^system/d; /^system/ d' file2

This approach can be done with awk too:

awk -F= 'BEGIN {show=1}
         ARGIND==1 && $1=="system_props" {show=0}
         ARGIND==2 {show=($1=="system_props" ? 1:0)}
         ARGIND==3 && $1=="system_props" {show=1; next}
         show {print}' file2 file1 file2


问:
Recursive value in Dataframe
I have something that has been bugging me for a while.

I have a Dataframe, looking like this:

```<code>           Amount  Balance       Date                           Text
90    -442.378339     5000 2018-02-12     PS Bar               04066
502   -183.229472     5000 2018-08-14               VDK EUR    39,95
957    -35.117568     5000 2019-01-28  Fakta Strandlodsve )))) 59260
1334   -15.234783     5000 2019-06-28                          Rente
1867  2934.846978     5000 2019-12-09           Netbank overfï¿½rsel
2304   -30.299886     5000 2019-05-21            MobilePay: Cathrine
2341    21.209920     5000 2019-06-03            MOBILEPAY: KRISTIAN
2357   -90.505760     5000 2019-06-04     DK-NOTA68957 NETTO GODTHÅB
2447  -182.799214     5000 2019-07-03               Forretning: REAL
2955  -121.199545     5000 2019-12-30     DK-NOTA17767 WANNASPORT.DK
</code>```

I want to update the Balance column based on the Amount column.
The balance should start at 5000, but for the second row, the balance should be 5000 - 442,378339 = 4557,62, and for the third row, it should be 4557,62 - 183,229472 = 4374,39.

I have tried df['Balance'] = df['Balance'] + df['Amount'].shift(1)

The second row is correct, but after that it just keeps taking the 5000, and not the previous computed value of Balance.

Title: Recursive value in Dataframe

Body:
I have something that has been bugging me for a while.

I have a Dataframe, looking like this:

           Amount  Balance       Date                           Text
90    -442.378339     5000 2018-02-12     PS Bar               04066
502   -183.229472     5000 2018-08-14               VDK EUR    39,95
957    -35.117568     5000 2019-01-28  Fakta Strandlodsve )))) 59260
1334   -15.234783     5000 2019-06-28                          Rente
1867  2934.846978     5000 2019-12-09           Netbank overfï¿½rsel
2304   -30.299886     5000 2019-05-21            MobilePay: Cathrine
2341    21.209920     5000 2019-06-03            MOBILEPAY: KRISTIAN
2357   -90.505760     5000 2019-06-04     DK-NOTA68957 NETTO GODTHÅB
2447  -182.799214     5000 2019-07-03               Forretning: REAL
2955  -121.199545     5000 2019-12-30     DK-NOTA17767 WANNASPORT.DK

I want to update the Balance column based on the Amount column.
The balance should start at 5000, but for the second row, the balance should be 5000 - 442,378339 = 4557,62, and for the third row, it should be 4557,62 - 183,229472 = 4374,39.

I have tried df['Balance'] = df['Balance'] + df['Amount'].shift(1)

The second row is correct, but after that it just keeps taking the 5000, and not the previous computed value of Balance.

Body:
Let's use cumsum on 'Amount' column:

Try:

df['Balance'] + df['Amount'].cumsum()

Output:

90      4557.621661
502     4374.392189
957     4339.274621
1334    4324.039838
1867    7258.886816
2304    7228.586930
2341    7249.796850
2357    7159.291090
2447    6976.491876
2955    6855.292331
dtype: float64


问:
printing elements of tuple in different places
Is there a way to print a single element in the tuple? Trying to print something like "The max value is " + max + " and it is located in the " + pos + " position." </p>

```<code>public Tuple<int, int> find_oldie(int[] x)
{
     int max = x.Max();
     int pos = Array.IndexOf(x, max);
     return Tuple.Create(max, pos);
}
</code>```

答:
You can use Value.Tuple to return named member of Tuple.

```<code>public (int Max, int Pos) find_oldie(int[] x)
{
    int max = x.Max();
    int pos = Array.IndexOf(x, max);
    return (max, pos);
}
</code>```

@LasseV.Karlsen has already explained in detailed about Value.Tuple and ways to use it but I wanted to add that deconstruct can be used to create just one variable(which will have named members) So one can call above function as:

```<code>var val = ReturnNamedTupple();

Console.WriteLine($"The max value is {val.Max} and it is located in the {val.Pos}");
</code>```

Body:
Is there a way to print a single element in the tuple? Trying to print something like "The max value is " + max + " and it is located in the " + pos + " position."

public Tuple<int, int> find_oldie(int[] x)
{
     int max = x.Max();
     int pos = Array.IndexOf(x, max);
     return Tuple.Create(max, pos);
}

Body:
You can use Value.Tuple to return named member of Tuple.

public (int Max, int Pos) find_oldie(int[] x)
{
    int max = x.Max();
    int pos = Array.IndexOf(x, max);
    return (max, pos);
}

@LasseV.Karlsen has already explained in detailed about Value.Tuple and ways to use it but I wanted to add that deconstruct can be used to create just one variable(which will have named members) So one can call above function as:

var val = ReturnNamedTupple();

Console.WriteLine($"The max value is {val.Max} and it is located in the {val.Pos}");


答:
I think you could add a consecutive index and then group by truncate(index/N), and get the sum of values.

for instance, to get the sum every 3 elements (mysql):

```<code>SELECT truncate((row_number-1)/3,0) grp, sum(sales) total
FROM (
  SELECT @row_number:=@row_number+1 as row_number,
  sales
  FROM (
    SELECT 452 as sales UNION ALL
    SELECT 324 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 232 as sales
  ) as t1, (SELECT @row_number:=0) AS t2) as tf group by grp;
</code>```

http://sqlfiddle.com/#!9/3149e4/524

Title: Get previous consecutive 10 rows sale to get sum

Body:
I have a table t1

**id**        **Date**             **Sales**
102         20180101                    50
102         20180102                    60
102         20180103                    70
102         20180104                    90
102         20180105                    10
102         20180105                   100
102         20180106                   100
102         20180107                    30
102         20180108                    20
102         20180109                    34
102         20180110                    40
102         20180111                    50
102         20180112                    60

Now I want the previous10 records for each row like for 20180111 sum of sale should be 464 which is the sum of the previous 10 records sale and for 20180112 it should be 474.

Body:
I think you could add a consecutive index and then group by truncate(index/N), and get the sum of values.

for instance, to get the sum every 3 elements (mysql):

SELECT truncate((row_number-1)/3,0) grp, sum(sales) total
FROM (
  SELECT @row_number:=@row_number+1 as row_number,
  sales
  FROM (
    SELECT 452 as sales UNION ALL
    SELECT 324 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 342 as sales UNION ALL
    SELECT 232 as sales
  ) as t1, (SELECT @row_number:=0) AS t2) as tf group by grp;

http://sqlfiddle.com/#!9/3149e4/524


问:
Compressing hexadecimal string using GZIP on the web (Javascript)
I have a textarea where the entered value is converted to hexadecimal and concatenated, as shown below:

```<code>4f43 5441 1d00 0000 2400 0000 0004 0000
0200 0000 0000 0000 0000 0000 0000 0000
0200 0000 0206 0073 6b79 626f 780e 0073
6b79 626f 7865 732f 7768 6974 6502 0800
6d61 7074 6974 6c65 1900 4f47 5a20 4564
6974 6f72 2066 6972 7374 2065 7665 7220
6d61 7003 6670 7300 0000 0000 0500 0200
0400 0300 0500 0700 0000 0044 0000 0044
0000 0044 0000 0000 0000 00ff 0000 0500
0000 0544 0000 0544 0000 0044 6e00 3200
0000 0000 0000 0200 0207 0007 0007 0001
0001 0001 0000 0202 0003 0004 0005 0006
0007 0000 0202 0003 0004 0005 0006 0007
0000 0202 0003 0004 0005 0006 0007 0000
0200 0000 0000 0007 0000 0000 0000 0100
0000 0000 0000 0000 0000 0000 0100 0000
0000 0000 0000 0000 0000 0100 0000 0000
0000 0000 0000 0000
</code>```

My goal is to compress this hexadecimal using gzip "online" (i.e without the zlib command line/nodejs) and make the output available for download using a blob.

This is my attempt for now using "PAKO":

html

```<code><script src="https://cdn.jsdelivr.net/pako/1.0.3/pako.min.js"></script>
<textarea id="input"></textarea>
<button onclick="toHex()">Convert to hex</button>
<a id="downloadbtn">Download as gzip</button>
</code>```

javascript

```<code>var pako = window.pako;
function toHex(){
    input = document.getElementById("input").value;
    hexresult = input.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(2,"0"),"");

    gzipresult = pako.gzip(hexresult, { level: 6 });
    download(gzipresult);
}

function download(data){
    downloadbtn = document.getElementById("downloadbtn");
    var blob = new Blob([ data ], {type : "application/gzip",});

    if (window.navigator.msSaveBlob) {
        navigator.msSaveBlob(blob, "output.gz");
    } else {
        var csvUrl = URL.createObjectURL(blob);
        $('#downloadbtn').attr({
            'download': "output.gz",
            'href': csvUrl
        });
    };
}
</code>```

However the output generated by PAKO (gzip) does not match the output generated by zlib, they are not the same...

Is there a way to make the output of both be identical? or
how can I compress a hexadecimal string correctly for gzip using JavaScript?

Update:
@Blex had mentioned the use of Buffer.from, I think it is something native to nodejs (and I need it in the browser) so I tried this standalone script from this repo, however the generated file is still the same (still different from zlib), but anyway, I appreciate the attempt to help!

Comparison

Input: "68656c6c6f20776f726c6421" (Hello world!)

zlib output (mingw command line):

1f8b 0800 4767 4c5e 0003 cb48 cdc9 c957
28cf 2fca 4951 0400 6dc2 b403 0c00 0000

pako output:

1f8b 0800 0000 0000 0003 33b3 3033 354b
06c2 3423 0373 73b3 3473 2320 dbc4 c810
00b2 2eed 2a18 0000 00

答:
Edit: After writing this answer a little too fast, I noticed the outputs were not absolutely the same. There is a one byte difference, corresponding to the OS type header. zlib returns a, which represents TOPS-20, and Pako returns 3, which represents Unix.

zlib returns a Buffer, and pako returns a Uint8Array. To get a Buffer, you can do:

```<code>gzipresult = pako.gzip(hexresult, { level: 6 });
gzipbuffer = Buffer.from(gzipresult);
</code>```

This will give you the exact a similar output to zlib. Here is a simple NodeJS script to test and compare both:

```<code>// Don't forget to `npm i -S pako`
const pako = require("pako");
const zlib = require("zlib");

const input = "Hello world!";
const hexStr = input.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(2,"0"),"");

zlib.gzip(hexStr, function(_, zlibResult) {
  const zlibHex = zlibResult.toString("hex");

  const pakoResult = pako.gzip(hexStr, { level: 6 });
  const pakoHex = Buffer.from(pakoResult).toString("hex");

  console.log("zlib", zlibHex);
  console.log("pako", pakoHex);
  console.log("Outputs are equal ===", zlibHex === pakoHex);
});

/*
Output:
pako 1f8b080000000000000333b13033354b06c23423037373b334732320dbc4c81000bde2d6f318000000
zlib 1f8b080000000000000a33b13033354b06c23423037373b334732320dbc4c81000bde2d6f318000000
                        ^
             actually not the same
Outputs are equal === false
*/
</code>```

Body:
I have a textarea where the entered value is converted to hexadecimal and concatenated, as shown below:

4f43 5441 1d00 0000 2400 0000 0004 0000
0200 0000 0000 0000 0000 0000 0000 0000
0200 0000 0206 0073 6b79 626f 780e 0073
6b79 626f 7865 732f 7768 6974 6502 0800
6d61 7074 6974 6c65 1900 4f47 5a20 4564
6974 6f72 2066 6972 7374 2065 7665 7220
6d61 7003 6670 7300 0000 0000 0500 0200
0400 0300 0500 0700 0000 0044 0000 0044
0000 0044 0000 0000 0000 00ff 0000 0500
0000 0544 0000 0544 0000 0044 6e00 3200
0000 0000 0000 0200 0207 0007 0007 0001
0001 0001 0000 0202 0003 0004 0005 0006
0007 0000 0202 0003 0004 0005 0006 0007
0000 0202 0003 0004 0005 0006 0007 0000
0200 0000 0000 0007 0000 0000 0000 0100
0000 0000 0000 0000 0000 0000 0100 0000
0000 0000 0000 0000 0000 0100 0000 0000
0000 0000 0000 0000

My goal is to compress this hexadecimal using gzip "online" (i.e without the zlib command line/nodejs) and make the output available for download using a blob.

This is my attempt for now using "PAKO":

html

<textarea id="input"></textarea>
<button onclick="toHex()">Convert to hex</button>
Download as gzip</button>

javascript

var pako = window.pako;
function toHex(){
    input = document.getElementById("input").value;
    hexresult = input.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(2,"0"),"");

    gzipresult = pako.gzip(hexresult, { level: 6 });
    download(gzipresult);
}

function download(data){
    downloadbtn = document.getElementById("downloadbtn");
    var blob = new Blob([ data ], {type : "application/gzip",});

    if (window.navigator.msSaveBlob) {
        navigator.msSaveBlob(blob, "output.gz");
    } else {
        var csvUrl = URL.createObjectURL(blob);
        $('#downloadbtn').attr({
            'download': "output.gz",
            'href': csvUrl
        });
    };
}

However the output generated by PAKO (gzip) does not match the output generated by zlib, they are not the same...

Is there a way to make the output of both be identical? or
how can I compress a hexadecimal string correctly for gzip using JavaScript?

Update:
@Blex had mentioned the use of Buffer.from, I think it is something native to nodejs (and I need it in the browser) so I tried this standalone script from this repo, however the generated file is still the same (still different from zlib), but anyway, I appreciate the attempt to help!

Comparison

Input: "68656c6c6f20776f726c6421" (Hello world!)

zlib output (mingw command line):

1f8b 0800 4767 4c5e 0003 cb48 cdc9 c957
28cf 2fca 4951 0400 6dc2 b403 0c00 0000

pako output:

1f8b 0800 0000 0000 0003 33b3 3033 354b
06c2 3423 0373 73b3 3473 2320 dbc4 c810
00b2 2eed 2a18 0000 00

Body:
Edit: After writing this answer a little too fast, I noticed the outputs were not absolutely the same. There is a one byte difference, corresponding to the OS type header. zlib returns a, which represents TOPS-20, and Pako returns 3, which represents Unix.

zlib returns a Buffer, and pako returns a Uint8Array. To get a Buffer, you can do:

gzipresult = pako.gzip(hexresult, { level: 6 });
gzipbuffer = Buffer.from(gzipresult);

This will give you the exact a similar output to zlib. Here is a simple NodeJS script to test and compare both:

// Don't forget to `npm i -S pako`
const pako = require("pako");
const zlib = require("zlib");

const input = "Hello world!";
const hexStr = input.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(2,"0"),"");

zlib.gzip(hexStr, function(_, zlibResult) {
  const zlibHex = zlibResult.toString("hex");

  const pakoResult = pako.gzip(hexStr, { level: 6 });
  const pakoHex = Buffer.from(pakoResult).toString("hex");

  console.log("zlib", zlibHex);
  console.log("pako", pakoHex);
  console.log("Outputs are equal ===", zlibHex === pakoHex);
});

/*
Output:
pako 1f8b080000000000000333b13033354b06c23423037373b334732320dbc4c81000bde2d6f318000000
zlib 1f8b080000000000000a33b13033354b06c23423037373b334732320dbc4c81000bde2d6f318000000
                        ^
             actually not the same
Outputs are equal === false
*/


问:
GWT Project Structure
Right now in our project, we have below mentioned structure. Our project is mainly using GWT & Spring framework.

com.customername.projectname.client.module name

com.customername.projectname.client.rpc.module name

com.customername.projectname.shared.validator.module name

com.customername.projectname.server.module name

com.customername.projectname.spring.dao.module name

com.customername.projectname.spring.service.module name

Our application.gwt.xml contains below entry for source which needs to be coverted in to java script.

```<code>source path='client'
source path='shared'
</code>```

As we are using spring at the server side, we are using spring annotation to mark the services and DAO and then in applicationContext.xml we are using below configuration to scan the DAO and Service Layer.

```<code><context:annotation-config/>
<context:component-scan base-package>
</code>```

Now our client wants to go with below mentioned structure. Grouping everything by module. Also in our case module is not GWT module. It is just like diff. parts of the application.

com.customername.projectname.modulename.client

com.customername.projectname.modulename.rpc

com.customername.projectname.Modulename.validator

com.customername.projectname.Modulename.server

com.customername.projectname.Modulename.spring.dao

com.customername.projectname.Modulename.spring.Service

My question is:

Is the upper approach is recommended considering it is very large application?

If the above approach is to be implemented , how to go about setting up the packages/source files which needs to be converted by gwt compiler from java to java script. Should I mention each module name in application.gwt.xml?

答:
Question 1)
If it makes sense to you, and other developers it sounds like a fairly decent project structure. (Taken from Here)

You should bundle these classes and
  the interface in a package for several
  reasons, including the following:

You and other programmers can easily determine that these types are
  related.

You and other programmers know where to find types that can provide
  graphics-related functions.

The names of your types won't conflict with the type names in other
  packages because the package creates a
  new namespace.

You can allow types within the package to have unrestricted access to
  one another yet still restrict access
  for types outside the package.

Question 2)
Let me just clarify, in Regards to:

Should I mention each module name in application.gwt.xml?

you mean packages right?

```<code>...

    <entry-point class='com.customername.projectname.AppEntryPoint'/>

    <source path="modulename.client"/>
    <source path="modulename.anotherpackage"/>

</module>
</code>```

Any package (starting from the package that the .gwt.xml is in) in the GWT Module, should be referenced in the .gwt.xml if it is to be compiled by the GWT Compiler, any sub-packages of the referenced packages will automatically be compiled by the GWT Compiler.

Not Sure what your question is in regard to the Spring Configuration.

Hope that Helps.

Title: GWT Project Structure

Body:
Right now in our project, we have below mentioned structure. Our project is mainly using GWT & Spring framework.

com.customername.projectname.client.module name

com.customername.projectname.client.rpc.module name

com.customername.projectname.shared.validator.module name

com.customername.projectname.server.module name

com.customername.projectname.spring.dao.module name

com.customername.projectname.spring.service.module name

Our application.gwt.xml contains below entry for source which needs to be coverted in to java script.

source path='client'
source path='shared'

As we are using spring at the server side, we are using spring annotation to mark the services and DAO and then in applicationContext.xml we are using below configuration to scan the DAO and Service Layer.

<context:annotation-config/>
<context:component-scan base-package>

Now our client wants to go with below mentioned structure. Grouping everything by module. Also in our case module is not GWT module. It is just like diff. parts of the application.

com.customername.projectname.modulename.client

com.customername.projectname.modulename.rpc

com.customername.projectname.Modulename.validator

com.customername.projectname.Modulename.server

com.customername.projectname.Modulename.spring.dao

com.customername.projectname.Modulename.spring.Service

My question is:

Is the upper approach is recommended considering it is very large application?

If the above approach is to be implemented , how to go about setting up the packages/source files which needs to be converted by gwt compiler from java to java script. Should I mention each module name in application.gwt.xml?

Body:
Question 1)
If it makes sense to you, and other developers it sounds like a fairly decent project structure. (Taken from Here)

You should bundle these classes and
  the interface in a package for several
  reasons, including the following:

You and other programmers can easily determine that these types are
  related.

You and other programmers know where to find types that can provide
  graphics-related functions.

The names of your types won't conflict with the type names in other
  packages because the package creates a
  new namespace.

You can allow types within the package to have unrestricted access to
  one another yet still restrict access
  for types outside the package.

Question 2)
Let me just clarify, in Regards to:

Should I mention each module name in application.gwt.xml?

you mean packages right?

...

    <entry-point class='com.customername.projectname.AppEntryPoint'/>

    <source path="modulename.client"/>
    <source path="modulename.anotherpackage"/>

</module>

Any package (starting from the package that the .gwt.xml is in) in the GWT Module, should be referenced in the .gwt.xml if it is to be compiled by the GWT Compiler, any sub-packages of the referenced packages will automatically be compiled by the GWT Compiler.

Not Sure what your question is in regard to the Spring Configuration.

Hope that Helps.