问:
Redirecting to a specific tab on facebook page through facebook app on phone using javascript
I am trying to open a particular page on facebook with particular tab on the facebook app which gets triggered on a button click

This is my code

```<code><button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

function myFunction()
    {
         setTimeout(function () { window.location = "https://www.facebook.com/Savaari/reviews/"; }, 5);
         window.location = "fb://page/300881516665819";

    }
</code>```

I am able to land on the https://www.facebook.com/Savaari/ home page with home tab highlighted through fb://page/300881516665819  if the facebook app is installed on phone

I want to land on the reviews tab instead i tried using fb://page/300881516665819/reviews but it does not work

Is there another syntax to land on a specific tab through facebook app on phone?

Regards
Sajal

答:
Try using this code:

```<code><button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

<script>
function myFunction()
    {
         setTimeout(function () { window.location.href = "https://www.facebook.com/Savaari/reviews/"; }, 5);
         //window.location.href = "fb://page/300881516665819/reviews";

    }

</script>
</code>```

UPDATED:

Newer versions of the FB app does not support fb://page/. You should use fb://facewebmodal/f?href= instead.

So try doing like this:

```<code><button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

    <script>
    function myFunction()
        {
             setTimeout(function () { window.location.href = "fb://facewebmodal/f?href=https://www.facebook.com/Savaari/reviews/"; }, 5);
             //window.location.href = "fb://page/300881516665819/reviews";

        }

    </script>
</code>```

Body:
I am trying to open a particular page on facebook with particular tab on the facebook app which gets triggered on a button click

This is my code

<button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

function myFunction()
    {
         setTimeout(function () { window.location = "https://www.facebook.com/Savaari/reviews/"; }, 5);
         window.location = "fb://page/300881516665819";

    }

I am able to land on the https://www.facebook.com/Savaari/ home page with home tab highlighted through fb://page/300881516665819  if the facebook app is installed on phone

I want to land on the reviews tab instead i tried using fb://page/300881516665819/reviews but it does not work

Is there another syntax to land on a specific tab through facebook app on phone?

Regards
Sajal

Body:
Try using this code:

<button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

<script>
function myFunction()
    {
         setTimeout(function () { window.location.href = "https://www.facebook.com/Savaari/reviews/"; }, 5);
         //window.location.href = "fb://page/300881516665819/reviews";

    }

</script>

UPDATED:

Newer versions of the FB app does not support fb://page/. You should use fb://facewebmodal/f?href= instead.

So try doing like this:

<button  onclick="myFunction()" class="button small user_review">Review your Trip</button>

    <script>
    function myFunction()
        {
             setTimeout(function () { window.location.href = "fb://facewebmodal/f?href=https://www.facebook.com/Savaari/reviews/"; }, 5);
             //window.location.href = "fb://page/300881516665819/reviews";

        }

    </script>


来源: stackexchange

问:
Execution part of an infinite list in Haskell?
I'm a little confused about how exactly Haskell execution works on infinite lists. for example, consider below sum function :

```<code>sum (takeWhile (<10000) (filter odd (map (^2) [1..])))
</code>```

here the code for finding Sum of all odd squares that are smaller than 10000  and I know how these takewhile, filter, map functions work. my doubt is, here the map function is taking one element from the infinite list and squaring it and returning the list of squared elements to the filter function right? in that case it would run infinitely for squaring that infinite list of elements isn't it? or is it taking just one element squaring it and then returning to the filter?

答:
Haskell is as lazy as it can possibly be. It doesn't calculate any value that you don't ask it for, and if you do let nums = filter odd (map (^2) [1..]) you haven't forced it to calculate anything yet. For now it knows that nums is of type Num a => [a] (because of the types of the operations you've described) but it doesn't know anything else about it (and that's fine!)

Even when you run takeWhile (<10000) you're not forcing any numbers. Now ghc knows that takeWhile (<10000) nums has type (Ord a, Num a) => [a] (you've introduced the additional typeclass when you compared by (<)) but that's all it knows.

Even once you call sum, ghc doesn't have to do anything. sum expects a Num a => [a] (technically a (Num a, Foldable t) => t a but let's pretend those are the same thing for right now) and you've given it one. Until you actually ask for the result of that operation, ghc doesn't do anything. You can test this by doing let foobar = sum [1..] in your interpreter. As long as you don't ever ask for the result of foobar, Haskell is fine with that expression.

However, if you ever ask for that result, you've forced the whole line to compute. sum needs its list, so it asks takeWhile (<10000) for it. takeWhile needs its list, so it asks filter odd for it. filter needs its list so it asks map (^2) for it, but filter doesn't need the whole list at a time, so map still works as lazily as possible and gives each number one at a time.

Once takeWhile has found a number (>=10000), it doesn't need anymore and happily hands off to sum, which produces your result and ghc goes back to being lazy, not producing any more results of nums unless you need them.

ContentLicense: CC BY-SA 4.0

Body:
I'm a little confused about how exactly Haskell execution works on infinite lists. for example, consider below sum function :

sum (takeWhile (<10000) (filter odd (map (^2) [1..])))

here the code for finding Sum of all odd squares that are smaller than 10000  and I know how these takewhile, filter, map functions work. my doubt is, here the map function is taking one element from the infinite list and squaring it and returning the list of squared elements to the filter function right? in that case it would run infinitely for squaring that infinite list of elements isn't it? or is it taking just one element squaring it and then returning to the filter?

ContentLicense: CC BY-SA 3.0


问:
401 response in IE browser NTLM authentication
My application is based on spring boot, Tomcat with NTLM authentication. Somewhere from the authentication response in IE is giving 401 in IE. For chrome it is passed and showing response 200.

Below is the response.

答:
Fixed.

Solution is below:
You need to override the WebSecurity-Configure-Method in WebSecurityConfigurerAdapter and exclude some folder: as shown below:

```<code>@Override
public void configure(final WebSecurity web) throws Exception {

  web.ignoring()
  .antMatchers("/static/**")
  .antMatchers("/images/**")
      .antMatchers("/js/**")
      .antMatchers("/json/**")
      .antMatchers("/inclu/**")
      .antMatchers("/lib/**");
</code>```

}

Body:
Fixed.

Solution is below:
You need to override the WebSecurity-Configure-Method in WebSecurityConfigurerAdapter and exclude some folder: as shown below:

@Override
public void configure(final WebSecurity web) throws Exception {

  web.ignoring()
  .antMatchers("/static/**")
  .antMatchers("/images/**")
      .antMatchers("/js/**")
      .antMatchers("/json/**")
      .antMatchers("/inclu/**")
      .antMatchers("/lib/**");

}


问:
Dynamically add ManyToMany relationship to Django objects
My Company class have multiple M2M relationship with itself

class Company(models.Model):

```<code>divisions = models.ManyToManyField('self', symmetrical=False, related_name="parent_companies")
parents = models.ManyToManyField('self', symmetrical=False, related_name="divisions_companies")
comp = models.ManyToManyField('self', symmetrical=False, related_name="comp")
friends = models.ManyToManyField('self', symmetrical=False, related_name="friends")
</code>```

I would like to be able to dynamically add M2M relationship like this, but it obviously does not work. Is there a way to do it dynamically ?

```<code>                    company, was_created = Company.objects.get_or_create(name=info)
                    setattr(self,key, company)
</code>```

答:
Got it. Simply have to pass a list instead..</p>

```<code> company, was_created = Company.objects.get_or_create(name=info)
                        setattr(self,key, [company,])
</code>```

ContentLicense: CC BY-SA 2.5

Body:
My Company class have multiple M2M relationship with itself

class Company(models.Model):

divisions = models.ManyToManyField('self', symmetrical=False, related_name="parent_companies")
parents = models.ManyToManyField('self', symmetrical=False, related_name="divisions_companies")
comp = models.ManyToManyField('self', symmetrical=False, related_name="comp")
friends = models.ManyToManyField('self', symmetrical=False, related_name="friends")

I would like to be able to dynamically add M2M relationship like this, but it obviously does not work. Is there a way to do it dynamically ?

                    company, was_created = Company.objects.get_or_create(name=info)
                    setattr(self,key, company)

Body:
Got it. Simply have to pass a list instead..

 company, was_created = Company.objects.get_or_create(name=info)
                        setattr(self,key, [company,])


问:
What is wrong with using 'Not In' in this SQL query?
I have table called BST as shown below:

Here N is value of node of Binary Tree and P is its Parent node. I have to write a query that will determine if a node is a Root Node, Leaf Node or Inner Node. I wrote below SQL query for this:

```<code>select N,
case
when P is null then 'Root'
when N in (select distinct P from BST) then 'Inner'
when N not in (select distinct P from BST) then 'Leaf'
end as type
from BST
</code>```

However, this is not giving me desired result as last condition for 'Leaf' in Case statement doesn't satisfy for leaf node. I am getting below output in this case:

I have a workaround for now as below query which is giving me expected output:

```<code>select N,
case
when P is null then 'Root'
when N in (select distinct P from BST) then 'Inner'
else 'Leaf'
end as type
from BST
</code>```

Expected Output:

But I can't figure out what's wrong with the first one. Could someone explain me this?

答:
in is a shorthand for a series of = checks. null, is not a value - it's the lack thereof. Whenever applying it to an operator expecting a value (like =, or in), it results in null, which is not "true".

You can think of null as an "unknown" value. I.e. - is an unknown value in a list of values selected from a table? We can't know.

Thus, you have to handle nulls explicitly, as you did in your second query.

Body:
I have table called BST as shown below:

Here N is value of node of Binary Tree and P is its Parent node. I have to write a query that will determine if a node is a Root Node, Leaf Node or Inner Node. I wrote below SQL query for this:

select N,
case
when P is null then 'Root'
when N in (select distinct P from BST) then 'Inner'
when N not in (select distinct P from BST) then 'Leaf'
end as type
from BST

However, this is not giving me desired result as last condition for 'Leaf' in Case statement doesn't satisfy for leaf node. I am getting below output in this case:

I have a workaround for now as below query which is giving me expected output:

select N,
case
when P is null then 'Root'
when N in (select distinct P from BST) then 'Inner'
else 'Leaf'
end as type
from BST

Expected Output:

But I can't figure out what's wrong with the first one. Could someone explain me this?


问:
Button not render right after upgraded xamarin forms
Using xamarin forms to develop a cross platform app, initially the app was built using Xamarin.Forms.2.4.0.38779, target framework was 6.0 and Android support library version 23.3.0. The UI code is:

```<code>// styles
<Style x:Key="DefaultButtonStyle" TargetType="Button">
    <Setter Property="TextColor" Value="DodgerBlue"></Setter>
    <Setter Property="BackgroundColor" Value="Transparent"></Setter>
</Style>
<Style x:Key="RoundBorderButtonStyle" TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
    <Setter Property="BorderWidth" Value="1"></Setter>
    <Setter Property="BorderRadius" Value="30"></Setter>
    <Setter Property="BorderColor" Value="DodgerBlue"></Setter>
</Style>

<StackLayout Margin="15,0" Spacing="20" Orientation="Horizontal">
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Copy"></Button>
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Addresses"></Button>
</StackLayout>
</code>```

Then the vs2017 got updated, so does xamarin forms, so I also updated the project to use latest libraries, with Xamarin.Forms.2.4.0.38779 and android target framework version 8.0, support libraries 26.1.0.1. Then suddenly the button is not rendered correctly. Before update:

after update:

Is there anything else I need to do to update xamarin forms?

Update

I created a minimum test case to show the problem, in vs create a cross-platform project, the only file changed is TestButton/TestButton/MainPage.xaml. The app screenshot:

答:
so I also updated the project to use latest libraries, with Xamarin.Forms.2.4.0.38779 and android target framework version 8.0, support libraries 26.1.0.1. Then suddenly the button is not rendered correctly

I reproduced the problem with your project,and I found it was caused by the Xamarin.Forms library. I noticed in your sample project the version of Xamarin.Forms is latest(2.4.0.74863).

Solution: By downgrading Xamarin.Forms to 2.4.280 and do a clean rebuild and reinstall of the app will fix the problem.

Body:
Using xamarin forms to develop a cross platform app, initially the app was built using Xamarin.Forms.2.4.0.38779, target framework was 6.0 and Android support library version 23.3.0. The UI code is:

// styles

<StackLayout Margin="15,0" Spacing="20" Orientation="Horizontal">
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Copy"></Button>
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Addresses"></Button>
</StackLayout>

Then the vs2017 got updated, so does xamarin forms, so I also updated the project to use latest libraries, with Xamarin.Forms.2.4.0.38779 and android target framework version 8.0, support libraries 26.1.0.1. Then suddenly the button is not rendered correctly. Before update:

after update:

Is there anything else I need to do to update xamarin forms?

Update

I created a minimum test case to show the problem, in vs create a cross-platform project, the only file changed is TestButton/TestButton/MainPage.xaml. The app screenshot:


问:
Reference known property in (List<someClass>)someObject
have tried some searches. Probably my lack of knowledge that I'm not using the right search terms or perhaps just not understanding the answers.

I have a method that is being passed an object, which I want to output a particular value to a text file.
I already know the object will be a List< someClass > of a few different possible classes (customers/employees/items etc). But all of the classes contain the same string property (e.g.) string idNumber.

So something like this:

```<code>public static void OutputFile(object myInput)
{
  foreach (someGenericObject in (List<anyType>)myInput)
  {
    string textToOutput = someGenericObject.idNUmber;
    //output the text to somewhere else here
  }
}
</code>```

I feel like as long as I know that it will always contain a this "idNumber" property regardless of the type, that I should be able to reference it somehow. But I just can't seem to get my head around it?

The error I typically get is something like:

Cannot cast List< Employee > to List< object > etc.

Thanks in advance

答:
If all your classes have the same property you want to access in foreach loop you can do in via interface.</p>

```<code>public interface ISmth {
        int MyProperty { get; set; }
    }

    public class Student : ISmth {
        public int MyProperty { get;  set; }
    }

    public class Employee : ISmth {
        public int MyProperty { get; set; }
    }

public static void DoSmth(object myObj) {
        foreach(ISmth item in (List<object>)myObj) {
            Console.Write(item.MyProperty);
        }
    }

List<Student> stdList = new List<Student>();

DoSmth(stdList.Cast<object>().ToList());
</code>```

Body:
have tried some searches. Probably my lack of knowledge that I'm not using the right search terms or perhaps just not understanding the answers.

I have a method that is being passed an object, which I want to output a particular value to a text file.
I already know the object will be a List< someClass > of a few different possible classes (customers/employees/items etc). But all of the classes contain the same string property (e.g.) string idNumber.

So something like this:

public static void OutputFile(object myInput)
{
  foreach (someGenericObject in (List<anyType>)myInput)
  {
    string textToOutput = someGenericObject.idNUmber;
    //output the text to somewhere else here
  }
}

I feel like as long as I know that it will always contain a this "idNumber" property regardless of the type, that I should be able to reference it somehow. But I just can't seem to get my head around it?

The error I typically get is something like:

Cannot cast List< Employee > to List< object > etc.

Thanks in advance

Body:
If all your classes have the same property you want to access in foreach loop you can do in via interface.

public interface ISmth {
        int MyProperty { get; set; }
    }

    public class Student : ISmth {
        public int MyProperty { get;  set; }
    }

    public class Employee : ISmth {
        public int MyProperty { get; set; }
    }

public static void DoSmth(object myObj) {
        foreach(ISmth item in (List<object>)myObj) {
            Console.Write(item.MyProperty);
        }
    }

List<Student> stdList = new List<Student>();

DoSmth(stdList.Cast<object>().ToList());


问:
Steps to use hibernate in a spring 3 mvc application
Can someone outline the steps required to get hibernate working with spring mvc.

I've seen EntityDao's that basically inherit from a GenericDAo.

The generic Dao has basic operations like GetAll, GetByID, Save, Delete, etc.

And inside their methods they use:

```<code>getHibernateTemplate
</code>```

So basically the Session has to be wired up in a bean, and mysql settings have to be set.

I find the spring documentation to be a little confusing: http://static.springsource.org/spring/docs/3.0.0.RELEASE/spring-framework-reference/html/orm.html#orm-hibernate

答:
There is another way. If you don't want to use HibernateDaoSupport then you could directly inject SessionFactory into your DAO classes. This avoids tying you down to Spring classes.

Refer this for example - Spring Doc

This shows how to use Hibernate APIs directly.

Hope that helps.

Body:
Can someone outline the steps required to get hibernate working with spring mvc.

I've seen EntityDao's that basically inherit from a GenericDAo.

The generic Dao has basic operations like GetAll, GetByID, Save, Delete, etc.

And inside their methods they use:

getHibernateTemplate

So basically the Session has to be wired up in a bean, and mysql settings have to be set.

I find the spring documentation to be a little confusing: http://static.springsource.org/spring/docs/3.0.0.RELEASE/spring-framework-reference/html/orm.html#orm-hibernate


问:
@yield('title') why can't it move to the center
I have been trying this for the past few hours and it for some reason, my title won't move in the center. Is it because I am using yield or something? Also I tried putting it in the head tag using title tag but nothing happen so I have to use a h3 tag, but it won't let me move center.

I have tried many different method but still doesn't work such as:

```<code>#center-text ul{
  list-style-type:none;
  display:flex;
  justify-content: center;
}

padding-right

margin
</code>```

Here is my code:

```<code><!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/title.css') }}" rel="stylesheet">
</head>
<body>
    <div id="app">
        <nav class="navbar navbar-default navbar-static-top">
            <div class="container">
                <div class="navbar-header">

                    <!-- Collapsed Hamburger -->
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false">
                        <span class="sr-only">Toggle Navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    @include('layouts.testSidebar')

                    <!-- Branding Image -->

                </div>

                <div class="collapse navbar-collapse" id="app-navbar-collapse">
                    <!-- Left Side Of Navbar -->
                    <ul class="nav navbar-nav">

                    </ul>

                    <div id="center-text">
                        <ul class="nav navbar-nav navbar-center" id="nav-center">
                            <li>
                                <h3>@yield('title')</h3>
                            </li>
                        </ul>
                    </div>

                    <!-- Right Side Of Navbar -->
                    <ul class="nav navbar-nav navbar-right">
                        <!-- Authentication Links -->
                        @guest
                            <li><a href="{{ route('login') }}">Login</a></li>
                            <li><a href="{{ route('register') }}">Register</a></li>
                        @else
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" style="background-color:blue" style="color:white">
                                    <b>{{ Auth::user()->name }}</b> <span class="caret"></span>
                                </a>

                                <ul class="dropdown-menu" style="background-color: blue">
                                    <li>
                                        <a href="{{ route('logout') }}"
                                            onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();" style="background-color: blue" style="color: white">
                                            <b>Logout</b>
                                        </a>

                                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                            {{ csrf_field() }}
                                        </form>
                                    </li>
                                </ul>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        @yield('content')
    </div>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>

</body>
</html>
</code>```

答:
On the h3 try using bootstraps built in class of text-center

Example:

```<code><h3 class="text-center">@yield('title')</h3>
</code>```

https://getbootstrap.com/docs/3.3/css/#type-alignment

Body:
I have been trying this for the past few hours and it for some reason, my title won't move in the center. Is it because I am using yield or something? Also I tried putting it in the head tag using title tag but nothing happen so I have to use a h3 tag, but it won't let me move center.

I have tried many different method but still doesn't work such as:

#center-text ul{
  list-style-type:none;
  display:flex;
  justify-content: center;
}

padding-right

margin

Here is my code:

<!DOCTYPE html>
getLocale() }}">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="csrf-token" content="{{ csrf_token() }}">

    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/title.css') }}" rel="stylesheet">

                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" aria-expanded="false">
                        Toggle Navigation

                    </button>
                    @include('layouts.testSidebar')

@yield('title')

                        @guest

Login

Register

                        @else

                                    {{ Auth::user()->name }}

                                            Logout

                                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                            {{ csrf_field() }}
                                        </form>

                        @endguest

        @yield('content')

Body:
On the h3 try using bootstraps built in class of text-center

Example:

<h3 class="text-center">@yield('title')</h3>

https://getbootstrap.com/docs/3.3/css/#type-alignment


问:
.htaccess site compression with php5.4
I had my site compressed when my host was using php2.xxx. Now that is has gone to php5.4 the compression no longer works. All I can find on the php site is string compress, which I dont need. This happened on 2 sites with the same host simultaneously

I have been using

```<code><IfModule mod_deflate.c>

# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-  beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
  SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$
^( (gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
 </IfModule>
</IfModule>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
 FilterDeclare   COMPRESS
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/x-icon
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
FilterChain     COMPRESS
FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>

<IfModule !mod_filter.c>
# Legacy versions of Apache
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
 AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>

 </IfModule>
</code>```

Whats the new method for use with the updated php?
Thanks for your consideration.

答:
I'm using this .htacces for my site in php 7

```<code><IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/ld+json" \
                                  "application/manifest+json" \
                                  "application/rdf+xml" \
                                  "application/rss+xml" \
                                  "application/schema+json" \
                                  "application/vnd.geo+json" \
                                  "application/vnd.ms-fontobject" \
                                  "application/x-font-ttf" \
                                  "application/x-javascript" \
                                  "application/x-web-app-manifest+json" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "font/eot" \
                                  "font/opentype" \
                                  "image/bmp" \
                                  "image/svg+xml" \
                                  "image/vnd.microsoft.icon" \
                                  "image/x-icon" \
                                  "text/cache-manifest" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/vcard" \
                                  "text/vnd.rim.location.xloc" \
                                  "text/vtt" \
                                  "text/x-component" \
                                  "text/x-cross-domain-policy" \
                                  "text/xml"
</IfModule>
</code>```

Try this. Its working for me well.

Title: .htaccess site compression with php5.4

Body:
I had my site compressed when my host was using php2.xxx. Now that is has gone to php5.4 the compression no longer works. All I can find on the php site is string compress, which I dont need. This happened on 2 sites with the same host simultaneously

I have been using

<IfModule mod_deflate.c>

# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-  beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
  SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$
^( (gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
 </IfModule>
</IfModule>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
 FilterDeclare   COMPRESS
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/html
 FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/css
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/plain
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $text/x-component
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/javascript
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/json
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/xhtml+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/rss+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/atom+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/vnd.ms-fontobject
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/svg+xml
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $image/x-icon
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $application/x-font-ttf
FilterProvider  COMPRESS  DEFLATE resp=Content-Type $font/opentype
FilterChain     COMPRESS
FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
</IfModule>

<IfModule !mod_filter.c>
# Legacy versions of Apache
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
 AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>

 </IfModule>

Whats the new method for use with the updated php?
Thanks for your consideration.

Body:
I'm using this .htacces for my site in php 7

<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/ld+json" \
                                  "application/manifest+json" \
                                  "application/rdf+xml" \
                                  "application/rss+xml" \
                                  "application/schema+json" \
                                  "application/vnd.geo+json" \
                                  "application/vnd.ms-fontobject" \
                                  "application/x-font-ttf" \
                                  "application/x-javascript" \
                                  "application/x-web-app-manifest+json" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "font/eot" \
                                  "font/opentype" \
                                  "image/bmp" \
                                  "image/svg+xml" \
                                  "image/vnd.microsoft.icon" \
                                  "image/x-icon" \
                                  "text/cache-manifest" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/vcard" \
                                  "text/vnd.rim.location.xloc" \
                                  "text/vtt" \
                                  "text/x-component" \
                                  "text/x-cross-domain-policy" \
                                  "text/xml"
</IfModule>

Try this. Its working for me well.


问:
2D argmax on a numpy array
Starting with a numpy array v:

```<code>v = \
np.array([[0, 0, 0, 0, 0],
          [0, 0, 1, 0, 0],
          [1, 0, 0, 0, 0],
          [0, 1, 0, 0, 0],
          [0, 0, 1, 0, 1],
          [0, 0, 0, 0, 1],
          [0, 0, 0, 1, 1]])
</code>```

I want to find the first non-zero value in each column and multiply those values by 100.

My desired result is:

```<code>array([[  0,   0,   0,   0,   0],
       [  0,   0, 100,   0,   0],
       [100,   0,   0,   0,   0],
       [  0, 100,   0,   0,   0],
       [  0,   0,   1,   0, 100],
       [  0,   0,   0,   0,   1],
       [  0,   0,   0, 100,   1]])
</code>```

I thought to approach this problem by taking the argmax along each axis:

```<code>i = v.argmax(0)
j = v.argmax(1)
v[i, j] *= 100
</code>```

I know I'm not using i and j correctly, so how can I fix this?

答:
You just want to range through the columns</p>

```<code>v[v.argmax(axis=0), np.arange(v.shape[1])] *= 100
</code>```

Title: 2D argmax on a numpy array

Body:
Starting with a numpy array v:

v = \
np.array([[0, 0, 0, 0, 0],
          [0, 0, 1, 0, 0],
          [1, 0, 0, 0, 0],
          [0, 1, 0, 0, 0],
          [0, 0, 1, 0, 1],
          [0, 0, 0, 0, 1],
          [0, 0, 0, 1, 1]])

I want to find the first non-zero value in each column and multiply those values by 100.

My desired result is:

array([[  0,   0,   0,   0,   0],
       [  0,   0, 100,   0,   0],
       [100,   0,   0,   0,   0],
       [  0, 100,   0,   0,   0],
       [  0,   0,   1,   0, 100],
       [  0,   0,   0,   0,   1],
       [  0,   0,   0, 100,   1]])

I thought to approach this problem by taking the argmax along each axis:

i = v.argmax(0)
j = v.argmax(1)
v[i, j] *= 100

I know I'm not using i and j correctly, so how can I fix this?

Body:
You just want to range through the columns

v[v.argmax(axis=0), np.arange(v.shape[1])] *= 100


问:
Docker-compose and nginx proxy
I am trying to use jwilder/nginx-proxy as a reverse proxy for my angular2 app that is broken down into 3 containers (angular, express and database).

I have tried different configurations to proxy requests to my app on port 80, however when I try to run docker-compose I get :

```<code>ERROR: for angular  Cannot start service angular: driver failed programming
external connectivity on endpoint example_angular_1
(335ce6d0c775b7837eb436fff97bbb56bfdcaece22d51049e1eb4bf5ce45553c): Bind for
0.0.0.0:80 failed: port is already allocated
</code>```

While the message is pretty clear that there is a conflict on port 80, I cannot figure out a way to go around it, it works just fine when I set my angular container to work on port 4200 but then I have to specify the port number in url every time I want to visit the page. I am using the reverse proxy because it is not the only app that will be running in my environment

Below is my docker-compose.yml

```<code>version: '3'

services:
    nginx-proxy:
        image: jwilder/nginx-proxy
        container_name: nginx-proxy
        ports: - "80:80"
        volumes: - /var/run/docker.sock:/tmp/docker.sock:ro

    angular:
        build: client
        ports: - "80"
        environment:
            - VIRTUAL_HOST=example.com
            - VIRTUAL_PORT=80
        restart: always

     express:
         build: server
         ports: - "3000:3000"
         links: - database
         restart: always

     database:
         image: mongo
         ports: - "27017:27017"
         restart: always

networks:
  default:
   external:
     name: nginx-proxy
</code>```

And Dockerfile for the angular container

```<code>FROM node:8-alpine as builder

COPY package.json package-lock.json ./

RUN npm set progress=false && npm config set depth 0 && npm cache clean --force

RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app

WORKDIR /ng-app

COPY . .

RUN $(npm bin)/ng build --prod --build-optimizer

FROM nginx:1.13.3-alpine

COPY nginx/default.conf /etc/nginx/conf.d/

RUN rm -rf /usr/share/nginx/html/*

COPY --from=builder /ng-app/dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

EXPOSE 80
</code>```

答:
The browser will speak to the container on the virtual_port that you set.
Maybe you can direct the the request to the backend through an api endpoint </p>

Title: Docker-compose and nginx proxy

Body:
I am trying to use jwilder/nginx-proxy as a reverse proxy for my angular2 app that is broken down into 3 containers (angular, express and database).

I have tried different configurations to proxy requests to my app on port 80, however when I try to run docker-compose I get :

ERROR: for angular  Cannot start service angular: driver failed programming
external connectivity on endpoint example_angular_1
(335ce6d0c775b7837eb436fff97bbb56bfdcaece22d51049e1eb4bf5ce45553c): Bind for
0.0.0.0:80 failed: port is already allocated

While the message is pretty clear that there is a conflict on port 80, I cannot figure out a way to go around it, it works just fine when I set my angular container to work on port 4200 but then I have to specify the port number in url every time I want to visit the page. I am using the reverse proxy because it is not the only app that will be running in my environment

Below is my docker-compose.yml

version: '3'

services:
    nginx-proxy:
        image: jwilder/nginx-proxy
        container_name: nginx-proxy
        ports: - "80:80"
        volumes: - /var/run/docker.sock:/tmp/docker.sock:ro

    angular:
        build: client
        ports: - "80"
        environment:
            - VIRTUAL_HOST=example.com
            - VIRTUAL_PORT=80
        restart: always

     express:
         build: server
         ports: - "3000:3000"
         links: - database
         restart: always

     database:
         image: mongo
         ports: - "27017:27017"
         restart: always

networks:
  default:
   external:
     name: nginx-proxy

And Dockerfile for the angular container

FROM node:8-alpine as builder

COPY package.json package-lock.json ./

RUN npm set progress=false && npm config set depth 0 && npm cache clean --force

RUN npm i && mkdir /ng-app && cp -R ./node_modules ./ng-app

WORKDIR /ng-app

COPY . .

RUN $(npm bin)/ng build --prod --build-optimizer

FROM nginx:1.13.3-alpine

COPY nginx/default.conf /etc/nginx/conf.d/

RUN rm -rf /usr/share/nginx/html/*

COPY --from=builder /ng-app/dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

EXPOSE 80


问:
C# retrieving a list of blobs from Azure
I need to have some archive cleanup code to remove old Azure logs after a certain retention period has occurred.

I am aware that I can do this:

```<code>CloudStorageAccount storageAccount = CloudStorageAccount.Parse("");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("ctr");

var blobList = container.ListBlobs();
foreach(var blob in blobList)
{
    logger.Info($"Blob Name: {blob.Uri}");
}
</code>```

However within my container the structure is

```<code>/
/year/month/day/hour/files
</code>```

So right now there is

```<code>/2017/5/11/14/files
/2017/5/11/17/files
/2017/5/11/22/files
/2017/5/11/23/files
</code>```

and

```<code>/2017/5/12/11/files
</code>```

Where files is multiple backup files.

The for loop only has 1 item in it's collection as the 2017 folder is the root.

Is there a way to retrieve all blobs?

The end goal is to delete all blobs older than the retention period.

答:
Try this pattern. Can be handy when browsing big storages. I found it much more GC and memory footprint friendly</p>

```<code>var blobAccount = "<account>";
var apiKey = "<api-key>";
var containerName = "<container>";
var storageCredentials = new StorageCredentials(blobAccount, apiKey);

var account = new CloudStorageAccount(storageCredentials, true);
var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
var blobLimit = 500

if (container == null) { return; }

var blobContinuationToken = new BlobContinuationToken();

using (var fs = new FileStream("Output.csv", FileMode.Create))
{
    var sw = new StreamWriter(fs);
    sw.WriteLine("Type,Name,Length");

    BlobContinuationToken continuationToken = null;
    do
    {
        var blobList = container.ListBlobsSegmented("",
                                   true,
                                   BlobListingDetails.Metadata,
                                   blobLimit,
                                   continuationToken,
                                   new BlobRequestOptions
                                   {
                                       LocationMode = LocationMode.PrimaryOnly
                                   },
                                   null);

        continuationToken = blobList.ContinuationToken;

        // I was looking only for BlockBlobs
        foreach (var item in blobList.Results.OfType<CloudBlockBlob>())
        {
            sw.WriteLine($"block,\"{item.Name}\",{item.Properties.Length}");
        }

    } while (continuationToken != null);
}
</code>```

Body:
I need to have some archive cleanup code to remove old Azure logs after a certain retention period has occurred.

I am aware that I can do this:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("ctr");

var blobList = container.ListBlobs();
foreach(var blob in blobList)
{
    logger.Info($"Blob Name: {blob.Uri}");
}

However within my container the structure is

/
/year/month/day/hour/files

So right now there is

/2017/5/11/14/files
/2017/5/11/17/files
/2017/5/11/22/files
/2017/5/11/23/files

and

/2017/5/12/11/files

Where files is multiple backup files.

The for loop only has 1 item in it's collection as the 2017 folder is the root.

Is there a way to retrieve all blobs?

The end goal is to delete all blobs older than the retention period.

Body:
Try this pattern. Can be handy when browsing big storages. I found it much more GC and memory footprint friendly

var blobAccount = "<account>";
var apiKey = "<api-key>";
var containerName = "<container>";
var storageCredentials = new StorageCredentials(blobAccount, apiKey);

var account = new CloudStorageAccount(storageCredentials, true);
var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
var blobLimit = 500

if (container == null) { return; }

var blobContinuationToken = new BlobContinuationToken();

using (var fs = new FileStream("Output.csv", FileMode.Create))
{
    var sw = new StreamWriter(fs);
    sw.WriteLine("Type,Name,Length");

    BlobContinuationToken continuationToken = null;
    do
    {
        var blobList = container.ListBlobsSegmented("",
                                   true,
                                   BlobListingDetails.Metadata,
                                   blobLimit,
                                   continuationToken,
                                   new BlobRequestOptions
                                   {
                                       LocationMode = LocationMode.PrimaryOnly
                                   },
                                   null);

        continuationToken = blobList.ContinuationToken;

        // I was looking only for BlockBlobs
        foreach (var item in blobList.Results.OfType<CloudBlockBlob>())
        {
            sw.WriteLine($"block,\"{item.Name}\",{item.Properties.Length}");
        }

    } while (continuationToken != null);
}


问:
Issue with Android Studio and Main Activity.kt expecting member declaration
I have been trying to learn through following YouTube tutorials.  I am using Android Studio 3.1 Canary and I get to the same point in the tutorials and get stuck.  For instance if you go to this YouTube tutorial https://youtu.be/3RMboPhUbmg?t=210 at the 3:30 min mark.

When they are inputting the MaterialSearchView searchView; it shows up for me with a red underline saying "expecting member declaration" and no matter how many searches I try I cannot find an answer.  What is the solution to this error? Thanks

This is the code contained in the Main2Activity.kt. The result should be calling or knowing the toolbar and materialsearchview objects

```<code>import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.Toolbar
import com.miguelcatalan.materialsearchview.MaterialSearchView
import kotlinx.android.synthetic.main.activity_main2.*

class Main2Activity : AppCompatActivity () {
    **MaterialSearchView searchView;**  "expecting member declaration error"
    **Toolbar  toolbar;** "expecting member declaration error"
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        toolbar=(Toolbar()) findViewbyId(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
    *private void searchViewCode()
    {
        searchView=(MaterialSearchView)findViewById(R.id.search_view);
    }
}
</code>```

答:
1) Understand your language syntax

Your tutorial is in Java. You try to write in Kotlin. Java and Kotlin have different syntax and if you reproduce this tutorial word for word in Kotlin, it will fail.

Follow the turorial and write your code in Java. Switch to Kotlin later when you're more confident with what you're doing. Focus on one thing at a time.

2) Find views at the right time

The Activity object is instatiated for you by the framework with a public empty constructor. At this time there are no views to be found. If you call findViewById any time before setContentView it will return null and crash if you try to assign it to a non-nullable variable.

The above applies for both Java and Kotlin.

For Java follow the tutorial. It should look something like this:

```<code>Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}
</code>```

In Kotlin there are several options.

You can use lateinit modifier which allows you to declare a non-nullable variable but assign it later in onCreate.

```<code>lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}
</code>```

<s>
Or you can use lazy delegate. The variable will be assigned when you first access it.

```<code>val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
</code>```

</s>

Don't use the delegate. It creates an unnecessary holder object for each lazy, that's wasteful.

You can also use Kotlin Android Extensions and just access toolbar directly because all of the heavy lifting is done for you.

```<code>override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}
</code>```

Alternatively you can use View Binding available since Android Studio 3.6 Canary 11.

```<code>private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}
</code>```

You get high performance of the first option and strong type safety on top.

Body:
I have been trying to learn through following YouTube tutorials.  I am using Android Studio 3.1 Canary and I get to the same point in the tutorials and get stuck.  For instance if you go to this YouTube tutorial https://youtu.be/3RMboPhUbmg?t=210 at the 3:30 min mark.

When they are inputting the MaterialSearchView searchView; it shows up for me with a red underline saying "expecting member declaration" and no matter how many searches I try I cannot find an answer.  What is the solution to this error? Thanks

This is the code contained in the Main2Activity.kt. The result should be calling or knowing the toolbar and materialsearchview objects

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.Toolbar
import com.miguelcatalan.materialsearchview.MaterialSearchView
import kotlinx.android.synthetic.main.activity_main2.*

class Main2Activity : AppCompatActivity () {
    **MaterialSearchView searchView;**  "expecting member declaration error"
    **Toolbar  toolbar;** "expecting member declaration error"
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        toolbar=(Toolbar()) findViewbyId(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
    *private void searchViewCode()
    {
        searchView=(MaterialSearchView)findViewById(R.id.search_view);
    }
}

Body:
1) Understand your language syntax

Your tutorial is in Java. You try to write in Kotlin. Java and Kotlin have different syntax and if you reproduce this tutorial word for word in Kotlin, it will fail.

Follow the turorial and write your code in Java. Switch to Kotlin later when you're more confident with what you're doing. Focus on one thing at a time.

2) Find views at the right time

The Activity object is instatiated for you by the framework with a public empty constructor. At this time there are no views to be found. If you call findViewById any time before setContentView it will return null and crash if you try to assign it to a non-nullable variable.

The above applies for both Java and Kotlin.

For Java follow the tutorial. It should look something like this:

Toolbar toolbar; // Declare the variable here so it's accessible outside of onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2); // Inflate view hierarchy.
    toolbar = (Toolbar) view.findViewById(R.id.toolbar); // Find your views.
    setSupportActionBar(toolbar);
}

In Kotlin there are several options.

You can use lateinit modifier which allows you to declare a non-nullable variable but assign it later in onCreate.

lateinit var toolbar: Toolbar

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    toolbar = findViewById(R.id.toolbar) as Toolbar
    setSupportActionBar(toolbar)
}

<s>
Or you can use lazy delegate. The variable will be assigned when you first access it.

val toolbar: Toolbar by lazy(LayzThreadSafetyMode.NONE) {
    toolbar = findViewById(R.id.toolbar) as Toolbar
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}

</s>

Don't use the delegate. It creates an unnecessary holder object for each lazy, that's wasteful.

You can also use Kotlin Android Extensions and just access toolbar directly because all of the heavy lifting is done for you.

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    setSupportActionBar(toolbar)
}

Alternatively you can use View Binding available since Android Studio 3.6 Canary 11.

private lateinit var binding: ActivityMain2Binding

@Override
fun onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)
    binding = ActivityMain2Binding.inflate(layoutInflater)
    setContentView(binding.root)
    setSupportActionBar(binding.toolbar)
}

You get high performance of the first option and strong type safety on top.


问:
Telerik RadGrid Inline Editing Modifying the look and feel of it
I would like to change the styling on my RadGrid inline Edit template look. How do I achieve this without needing to add a huge amount of CSS  to my code backend?</p>

答:
There are a number of properties exposed by the grid for you to manipulate:

```<code><telerik:RadGrid
        ID="radgrid"
        runat="server"
        Skin="Vista">
        <MasterTableView
            ItemStyle-VerticalAlign="Top"
            AlternatingItemStyle-VerticalAlign="Top"
            EditFormSettings-FormMainTableStyle-BorderColor="#555555"
            EditFormSettings-FormMainTableStyle-Width="100%"
            EditFormSettings-FormMainTableStyle-BorderWidth="2px"
            EditFormSettings-FormMainTableStyle-BackColor="#f5f5f5"
            CommandItemDisplay="Top">
            <Columns>
            </Columns>
        </MasterTableView>
</telerik:RadGrid>
</code>```

If you look through the available properties you'll see there are many more.

Body:
There are a number of properties exposed by the grid for you to manipulate:

<telerik:RadGrid
        ID="radgrid"
        runat="server"
        Skin="Vista">
        <MasterTableView
            ItemStyle-VerticalAlign="Top"
            AlternatingItemStyle-VerticalAlign="Top"
            EditFormSettings-FormMainTableStyle-BorderColor="#555555"
            EditFormSettings-FormMainTableStyle-Width="100%"
            EditFormSettings-FormMainTableStyle-BorderWidth="2px"
            EditFormSettings-FormMainTableStyle-BackColor="#f5f5f5"
            CommandItemDisplay="Top">
            <Columns>
            </Columns>
        </MasterTableView>
</telerik:RadGrid>

If you look through the available properties you'll see there are many more.


问:
Jmeter Pre-request Script to set value of HTTP Headers
I am trying to execute a pre-request script in Jmeter (similar to what you can do in postman) in order to set Header values at the beginning of every request.
How I can do it?

I am trying to set some Header values in my HTTP Header Manager when the request is made with the pre-request script script below. The values for these headers should be set by this script.

This is the script that I use in postman:

```<code>var client = "SHA256 Credential=" + environment["id"];
var timestamp = Math.floor(Date.now() / 1000);

postman.setEnvironmentVariable('client', client);
postman.setEnvironmentVariable('timestamp', timestamp);
</code>```

(environment["id"] being a preset header).

答:
While passing the values to Jmeter you can pass the header values like this  -
sh jmeter.sh -Jtimestamp =timestamp.

Then you can easily access the value of timestamp in HTTP Header manager using ${__property(timestamp)}

Body:
I am trying to execute a pre-request script in Jmeter (similar to what you can do in postman) in order to set Header values at the beginning of every request.
How I can do it?

I am trying to set some Header values in my HTTP Header Manager when the request is made with the pre-request script script below. The values for these headers should be set by this script.

This is the script that I use in postman:

var client = "SHA256 Credential=" + environment["id"];
var timestamp = Math.floor(Date.now() / 1000);

postman.setEnvironmentVariable('client', client);
postman.setEnvironmentVariable('timestamp', timestamp);

(environment["id"] being a preset header).


问:
Combine Multiple Tables Rows Into Master Table
Happy Monday Everyone!

Have a question and hope you can help. I have a budget spreadsheet that has a budget tab. On this tab is about 8 tables broken down into different categories. Every table in the tab has the exact same columns. Is there a non-vbscript/marco way to create a master table that combines all of the tables into a single table in a different tab. This seems like it would be a no brainer but I have tried everything I can think of and find online and there doesn't seem to be a decent solution without an addon called power query.

答:
I know you asked for a non VBA way, but for completeness I'm adding another answer that also has a VBA solution, because it's dead simple, it's blazingly fast, and it's generic. All you need to do is cut and paste this code into a standard code module, add a button and assign it to trigger the calling routine, give your source tables a name includes the full name of the summary table, and you're good to go.

```<code>Sub CombineTables(loDest As ListObject, Optional lcSource As ListColumn)

Dim ws              As Worksheet
Dim lo              As ListObject
Dim lc              As ListColumn
Dim rDest           As Range
Dim lDestRows       As Long
Dim lSourceRows     As Long

Application.ScreenUpdating = False

If lcSource Is Nothing Then Set lcSource = loDest.ListColumns(1)
If loDest.ListRows.Count > 0 Then loDest.DataBodyRange.Delete

For Each ws In ActiveWorkbook.Worksheets
    For Each lo In ws.ListObjects
        If lo <> loDest Then
            With lo
                If InStr(.Name, loDest.Name & "_") > 0 Then
                    On Error Resume Next
                    lDestRows = loDest.ListRows.Count
                    On Error GoTo 0
                    lSourceRows = .ListRows.Count
                    If lSourceRows > 0 Then

                        'Work out where we want to paste the data to
                        Set rDest = loDest.HeaderRowRange.Offset(1 + lDestRows).Resize(lSourceRows)

                        'Resize the destination table
                        loDest.Resize loDest.Range.Resize(1 + lSourceRows + lDestRows)

                        For Each lc In .ListColumns
                         Intersect(loDest.ListColumns(lc.Name).Range.EntireColumn, rDest).Value2 = lc.DataBodyRange.Value
                        Next lc
                        Set lc = Nothing
                        On Error Resume Next
                        Set lc = .ListColumns(lcSource.Name)
                        On Error GoTo 0
                        If lc Is Nothing Then Intersect(lcSource.Range, rDest.EntireRow).Value2 = ws.Name
                    End If
                End If
            End With
        End If
    Next lo
Next ws

Application.ScreenUpdating = True

End Sub
</code>```

And here's the caller:

```<code>Sub CombineTables_Caller()
CombineTables [SomeName].ListObject, [SomeName].ListObject.ListColumns("Source")
End Sub
</code>```

When I push that button, the code will look throughout the workbook for any tables who's names contain the name of the Destination table (in this case the Table called "SomeName"), and then bring their data through. So if you are adding new tabes, then as long as you prefix their Table names with the name of the destination table, they will be included. Any other tables (such as the one called 'DifferentName' will be ignored.

...and here's the result:

Body:
I know you asked for a non VBA way, but for completeness I'm adding another answer that also has a VBA solution, because it's dead simple, it's blazingly fast, and it's generic. All you need to do is cut and paste this code into a standard code module, add a button and assign it to trigger the calling routine, give your source tables a name includes the full name of the summary table, and you're good to go.

Sub CombineTables(loDest As ListObject, Optional lcSource As ListColumn)

Dim ws              As Worksheet
Dim lo              As ListObject
Dim lc              As ListColumn
Dim rDest           As Range
Dim lDestRows       As Long
Dim lSourceRows     As Long

Application.ScreenUpdating = False

If lcSource Is Nothing Then Set lcSource = loDest.ListColumns(1)
If loDest.ListRows.Count > 0 Then loDest.DataBodyRange.Delete

For Each ws In ActiveWorkbook.Worksheets
    For Each lo In ws.ListObjects
        If lo <> loDest Then
            With lo
                If InStr(.Name, loDest.Name & "_") > 0 Then
                    On Error Resume Next
                    lDestRows = loDest.ListRows.Count
                    On Error GoTo 0
                    lSourceRows = .ListRows.Count
                    If lSourceRows > 0 Then

                        'Work out where we want to paste the data to
                        Set rDest = loDest.HeaderRowRange.Offset(1 + lDestRows).Resize(lSourceRows)

                        'Resize the destination table
                        loDest.Resize loDest.Range.Resize(1 + lSourceRows + lDestRows)

                        For Each lc In .ListColumns
                         Intersect(loDest.ListColumns(lc.Name).Range.EntireColumn, rDest).Value2 = lc.DataBodyRange.Value
                        Next lc
                        Set lc = Nothing
                        On Error Resume Next
                        Set lc = .ListColumns(lcSource.Name)
                        On Error GoTo 0
                        If lc Is Nothing Then Intersect(lcSource.Range, rDest.EntireRow).Value2 = ws.Name
                    End If
                End If
            End With
        End If
    Next lo
Next ws

Application.ScreenUpdating = True

End Sub

And here's the caller:

Sub CombineTables_Caller()
CombineTables [SomeName].ListObject, [SomeName].ListObject.ListColumns("Source")
End Sub

When I push that button, the code will look throughout the workbook for any tables who's names contain the name of the Destination table (in this case the Table called "SomeName"), and then bring their data through. So if you are adding new tabes, then as long as you prefix their Table names with the name of the destination table, they will be included. Any other tables (such as the one called 'DifferentName' will be ignored.

...and here's the result:


问:
Access VBA click determines field
Here's what I'm trying to do using Access/VBA:
I have a field in a form that correlates to a phone number.  However, what I need to do is have the entry populate one of two fields in the table upon entry.  What I mean is that when a person enters a number in the text box, and does not check in the check box next to it, the text will populate the HOME phone field in the table.  But if the check box is checked, the text will populate the WORK phone field in the table.

Any ideas?

答:
In AfterUpdate event of your checkbox place code like this:</p>

```<code>Me.txtPhone.ControlSource = IIf(Me.chkSwitch, "Work", "Home")
</code>```

Title: Access VBA click determines field

Body:
In AfterUpdate event of your checkbox place code like this:

Me.txtPhone.ControlSource = IIf(Me.chkSwitch, "Work", "Home")


问:
odoo doesn't restart after update
I don't know where is the problem, but after an update, odoo doesn't want to restart

I have this :

```<code>sudo service odoo start
Starting odoo: ok

    http://myserver:8069 ==> nothing
</code>```

I try this :

```<code>sudo service odoo stop
Stopping odoo: start-stop-daemon: warning: failed to kill 30691: No such process
ok
</code>```

and

sudo service odoo restart
Restarting odoo: ok

==> I have on google chrome this message : fail connexion

If I do this : top

I have nothing on processus.

If I look my log I have this :

```<code>tail -f odoo-server.log
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/odoo'
2015-05-12 00:19:46,092 8451 INFO ? openerp.service.server: Initiating shutdown
2015-05-12 00:19:46,092 8451 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown
</code>```

If I edit my odoo-server.log

```<code>    2015-05-10 11:28:04,911 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:04] "POST /web/webclient/version_info HTTP/1.1" 200 -
2015-05-10 11:28:05,253 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:05] "POST /web/session/get_session_info HTTP/1.1" 200 -
2015-05-10 11:28:06,101 5121 INFO odoo openerp.service.common: successful login from 'loic.richard@e-imaginis.com' using database 'odoo'
2015-05-10 11:28:06,103 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:06] "POST /web/session/authenticate HTTP/1.1" 200 -
2015-05-10 11:28:06,519 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:06] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:07,953 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:07] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:10,505 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:10] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:11,100 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:11] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 12:33:03,551 5121 INFO odoo werkzeug: 66.249.80.126 - - [10/May/2015 12:33:03] "GET / HTTP/1.1" 200 -
2015-05-10 12:33:04,044 5121 INFO odoo werkzeug: 66.249.80.118 - - [10/May/2015 12:33:04] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-10 19:57:55,248 5121 INFO ? openerp.service.server: Initiating shutdown
2015-05-10 19:57:55,249 5121 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.
2015-05-10 19:58:04,512 24319 INFO ? openerp: OpenERP version 8.0-20150510
2015-05-10 19:58:04,512 24319 INFO ? openerp: addons paths: ['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']
2015-05-10 19:58:04,512 24319 INFO ? openerp: database hostname: localhost
2015-05-10 19:58:04,512 24319 INFO ? openerp: database port: 5432
2015-05-10 19:58:04,512 24319 INFO ? openerp: database user: odoo
2015-05-10 19:58:04,722 24319 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2015-05-11 00:33:19,782 24319 INFO ? openerp.addons.bus.bus: Bus.loop listen imbus on db postgres
2015-05-11 00:33:20,381 24319 INFO ? openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2015-05-11 00:33:20,641 24319 INFO ? openerp.http: HTTP Configuring static files
2015-05-11 00:33:20,651 24319 INFO odoo openerp.modules.loading: loading 1 modules...
2015-05-11 00:33:20,659 24319 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries
2015-05-11 00:33:20,677 24319 INFO odoo openerp.modules.loading: loading 46 modules...
2015-05-11 00:33:20,681 24319 INFO odoo passlib.registry: registered crypt handler 'pbkdf2_sha512': <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
2015-05-11 00:33:20,681 24319 INFO odoo passlib.registry: registered crypt handler 'md5_crypt': <class 'passlib.handlers.md5_crypt.md5_crypt'>
2015-05-11 00:33:20,766 24319 INFO odoo openerp.modules.loading: 46 modules loaded in 0.09s, 0 queries
2015-05-11 00:33:21,449 24319 INFO odoo openerp.modules.loading: Modules loaded.
2015-05-11 00:33:21,451 24319 INFO odoo openerp.addons.base.ir.ir_http: Generating routing map
2015-05-11 00:33:21,607 24319 INFO odoo werkzeug: 66.102.6.237 - - [11/May/2015 00:33:21] "GET / HTTP/1.1" 200 -
2015-05-11 00:33:22,117 24319 INFO odoo werkzeug: 66.102.6.237 - - [11/May/2015 00:33:22] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-11 11:28:14,354 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:14] "POST /web/webclient/version_info HTTP/1.1" 200 -
2015-05-11 11:28:14,746 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:14] "POST /web/session/get_session_info HTTP/1.1" 200 -
2015-05-11 11:28:15,617 24319 INFO odoo openerp.service.common: successful login from 'loic.richard@e-imaginis.com' using database 'odoo'
2015-05-11 11:28:15,620 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:15] "POST /web/session/authenticate HTTP/1.1" 200 -
2015-05-11 11:28:16,889 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:16] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:17,894 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:17] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:20,577 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:20] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:21,031 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:21] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 20:47:16,435 24319 INFO odoo werkzeug: 66.102.6.253 - - [11/May/2015 20:47:16] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-11 23:52:50,600 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:50] "GET / HTTP/1.1" 200 -
2015-05-11 23:52:51,104 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/css/web.assets_common/ceba8ad HTTP/1.1" 200 -
2015-05-11 23:52:51,222 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /logo.png HTTP/1.1" 200 -
2015-05-11 23:52:51,296 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/css/website.assets_frontend/f563fe5 HTTP/1.1" 200 -
2015-05-11 23:52:51,537 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/js/web.assets_common/ceba8ad HTTP/1.1" 200 -
2015-05-11 23:52:51,545 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/js/website.assets_frontend/f563fe5 HTTP/1.1" 200 -
2015-05-11 23:52:52,752 24319 INFO ? werkzeug: 66.36.137.56 - - [11/May/2015 23:52:52] "GET /website/static/src/xml/website.xml HTTP/1.1" 200 -
2015-05-11 23:52:52,813 24319 INFO ? werkzeug: 66.36.137.56 - - [11/May/2015 23:52:52] "GET /website/static/src/img/library/business_stats.jpg HTTP/1.1" 200 -
2015-05-11 23:52:53,851 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:53] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-12 00:02:22,536 24319 INFO ? openerp.service.server: Initiating shutdown
2015-05-12 00:02:22,536 24319 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.
2015-05-12 00:04:04,305 8451 INFO ? openerp: OpenERP version 8.0-20150510
2015-05-12 00:04:04,356 8451 INFO ? openerp: addons paths: ['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']
2015-05-12 00:04:04,356 8451 INFO ? openerp: database hostname: localhost
2015-05-12 00:04:04,356 8451 INFO ? openerp: database port: 5432
2015-05-12 00:04:04,357 8451 INFO ? openerp: database user: odoo
2015-05-12 00:04:06,650 8451 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2015-05-12 00:10:05,444 8451 INFO ? werkzeug: 66.36.137.56 - - [12/May/2015 00:10:05] "GET / HTTP/1.1" 500 -
2015-05-12 00:10:05,456 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
2015-05-12 00:10:05,456 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1279, in __call__
    self.load_addons()
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1289, in load_addons
    for module in sorted(os.listdir(str(addons_path))):
OSError: [Errno 2] No such file or directory: '/opt/odoo/.local/share/Odoo/addons/8.0'
2015-05-12 00:10:06,322 8451 INFO ? werkzeug: 66.36.137.56 - - [12/May/2015 00:10:06] "GET /favicon.ico HTTP/1.1" 500 -
2015-05-12 00:10:06,342 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1280, in __call__
    return self.dispatch(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1391, in dispatch
    explicit_session = self.setup_session(httprequest)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1312, in setup_session
    session_gc(self.session_store)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/func.py", line 41, in __get__
    value = self.fget(obj)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1265, in session_store
    path = openerp.tools.config.session_dir
  File "/usr/lib/python2.7/dist-packages/openerp/tools/config.py", line 695, in session_dir
    os.makedirs(d, 0700)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/odoo'
</code>```

If I remember I deleted in my opt, odoo directory

Is it the problem ?

I try to recreate the directory :

```<code>/opt/odoo/.local/share/Odoo/addons/8.0
</code>```

Doesn't work

maybe the problem come from the link ?

```<code>['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']
</code>```

Do you have an idea ? what can I do ?

To contiue my discussion

I try this :

```<code>    ln -s /usr/lib/python2.7/dist-packages/openerp/addons /opt/odoo/.local/share/Odoo/addons/8.0
sudo service restart
</code>```

doesn't work

and finally this

```<code>root@.......:/opt# apt-get install odoo
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets suivants seront mis à jour :
  odoo
1 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 48,8 Mo dans les archives.
Après cette opération, 1 024 o d'espace disque supplémentaires seront utilisés.
Réception de : 1 http://nightly.odoo.com/8.0/nightly/deb/ ./ odoo 8.0.20150513 [48,8 MB]
48,8 Mo réceptionnés en 0s (49,8 Mo/s)
Lecture des fichiers de modifications (« changelog »)... Terminé
(Lecture de la base de données... 81772 fichiers et répertoires déjà installés.)
Préparation du remplacement de odoo 8.0.20150512 (en utilisant .../odoo_8.0.20150513_all.deb) ...
Stopping odoo: start-stop-daemon: warning: failed to kill 3316: No such process
ok
Dépaquetage de la mise à jour de odoo ...
Paramétrage de odoo (8.0.20150513) ...
</code>```

doesn't work also

and finally I tried this :

```<code>sudo service odoo stop
Stopping odoo: start-stop-daemon: warning: failed to kill 3491: No such process
ok
</code>```

Nobody has been this problem ?

答:
Maybe you dont have permission to access that directory for that you can give permission to that directory
For that got to that path through terminal and than follow this command</p>

```<code>sudo chmod  777 -R //opt/odoo/.local/share/Odoo/addons/(your folder name)
</code>```

Title: odoo doesn't restart after update

Body:
I don't know where is the problem, but after an update, odoo doesn't want to restart

I have this :

sudo service odoo start
Starting odoo: ok

    http://myserver:8069 ==> nothing

I try this :

sudo service odoo stop
Stopping odoo: start-stop-daemon: warning: failed to kill 30691: No such process
ok

and

sudo service odoo restart
Restarting odoo: ok

==> I have on google chrome this message : fail connexion

If I do this : top

I have nothing on processus.

If I look my log I have this :

tail -f odoo-server.log
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/odoo'
2015-05-12 00:19:46,092 8451 INFO ? openerp.service.server: Initiating shutdown
2015-05-12 00:19:46,092 8451 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown

If I edit my odoo-server.log

    2015-05-10 11:28:04,911 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:04] "POST /web/webclient/version_info HTTP/1.1" 200 -
2015-05-10 11:28:05,253 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:05] "POST /web/session/get_session_info HTTP/1.1" 200 -
2015-05-10 11:28:06,101 5121 INFO odoo openerp.service.common: successful login from 'loic.richard@e-imaginis.com' using database 'odoo'
2015-05-10 11:28:06,103 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:06] "POST /web/session/authenticate HTTP/1.1" 200 -
2015-05-10 11:28:06,519 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:06] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:07,953 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:07] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:10,505 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:10] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 11:28:11,100 5121 INFO odoo werkzeug: 66.36.137.56 - - [10/May/2015 11:28:11] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-10 12:33:03,551 5121 INFO odoo werkzeug: 66.249.80.126 - - [10/May/2015 12:33:03] "GET / HTTP/1.1" 200 -
2015-05-10 12:33:04,044 5121 INFO odoo werkzeug: 66.249.80.118 - - [10/May/2015 12:33:04] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-10 19:57:55,248 5121 INFO ? openerp.service.server: Initiating shutdown
2015-05-10 19:57:55,249 5121 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.
2015-05-10 19:58:04,512 24319 INFO ? openerp: OpenERP version 8.0-20150510
2015-05-10 19:58:04,512 24319 INFO ? openerp: addons paths: ['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']
2015-05-10 19:58:04,512 24319 INFO ? openerp: database hostname: localhost
2015-05-10 19:58:04,512 24319 INFO ? openerp: database port: 5432
2015-05-10 19:58:04,512 24319 INFO ? openerp: database user: odoo
2015-05-10 19:58:04,722 24319 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2015-05-11 00:33:19,782 24319 INFO ? openerp.addons.bus.bus: Bus.loop listen imbus on db postgres
2015-05-11 00:33:20,381 24319 INFO ? openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2015-05-11 00:33:20,641 24319 INFO ? openerp.http: HTTP Configuring static files
2015-05-11 00:33:20,651 24319 INFO odoo openerp.modules.loading: loading 1 modules...
2015-05-11 00:33:20,659 24319 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries
2015-05-11 00:33:20,677 24319 INFO odoo openerp.modules.loading: loading 46 modules...
2015-05-11 00:33:20,681 24319 INFO odoo passlib.registry: registered crypt handler 'pbkdf2_sha512': <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
2015-05-11 00:33:20,681 24319 INFO odoo passlib.registry: registered crypt handler 'md5_crypt': <class 'passlib.handlers.md5_crypt.md5_crypt'>
2015-05-11 00:33:20,766 24319 INFO odoo openerp.modules.loading: 46 modules loaded in 0.09s, 0 queries
2015-05-11 00:33:21,449 24319 INFO odoo openerp.modules.loading: Modules loaded.
2015-05-11 00:33:21,451 24319 INFO odoo openerp.addons.base.ir.ir_http: Generating routing map
2015-05-11 00:33:21,607 24319 INFO odoo werkzeug: 66.102.6.237 - - [11/May/2015 00:33:21] "GET / HTTP/1.1" 200 -
2015-05-11 00:33:22,117 24319 INFO odoo werkzeug: 66.102.6.237 - - [11/May/2015 00:33:22] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-11 11:28:14,354 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:14] "POST /web/webclient/version_info HTTP/1.1" 200 -
2015-05-11 11:28:14,746 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:14] "POST /web/session/get_session_info HTTP/1.1" 200 -
2015-05-11 11:28:15,617 24319 INFO odoo openerp.service.common: successful login from 'loic.richard@e-imaginis.com' using database 'odoo'
2015-05-11 11:28:15,620 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:15] "POST /web/session/authenticate HTTP/1.1" 200 -
2015-05-11 11:28:16,889 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:16] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:17,894 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:17] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:20,577 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:20] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 11:28:21,031 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 11:28:21] "POST /web/dataset/search_read HTTP/1.1" 200 -
2015-05-11 20:47:16,435 24319 INFO odoo werkzeug: 66.102.6.253 - - [11/May/2015 20:47:16] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-11 23:52:50,600 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:50] "GET / HTTP/1.1" 200 -
2015-05-11 23:52:51,104 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/css/web.assets_common/ceba8ad HTTP/1.1" 200 -
2015-05-11 23:52:51,222 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /logo.png HTTP/1.1" 200 -
2015-05-11 23:52:51,296 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/css/website.assets_frontend/f563fe5 HTTP/1.1" 200 -
2015-05-11 23:52:51,537 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/js/web.assets_common/ceba8ad HTTP/1.1" 200 -
2015-05-11 23:52:51,545 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:51] "GET /web/js/website.assets_frontend/f563fe5 HTTP/1.1" 200 -
2015-05-11 23:52:52,752 24319 INFO ? werkzeug: 66.36.137.56 - - [11/May/2015 23:52:52] "GET /website/static/src/xml/website.xml HTTP/1.1" 200 -
2015-05-11 23:52:52,813 24319 INFO ? werkzeug: 66.36.137.56 - - [11/May/2015 23:52:52] "GET /website/static/src/img/library/business_stats.jpg HTTP/1.1" 200 -
2015-05-11 23:52:53,851 24319 INFO odoo werkzeug: 66.36.137.56 - - [11/May/2015 23:52:53] "GET /favicon.ico HTTP/1.1" 404 -
2015-05-12 00:02:22,536 24319 INFO ? openerp.service.server: Initiating shutdown
2015-05-12 00:02:22,536 24319 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.
2015-05-12 00:04:04,305 8451 INFO ? openerp: OpenERP version 8.0-20150510
2015-05-12 00:04:04,356 8451 INFO ? openerp: addons paths: ['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']
2015-05-12 00:04:04,356 8451 INFO ? openerp: database hostname: localhost
2015-05-12 00:04:04,356 8451 INFO ? openerp: database port: 5432
2015-05-12 00:04:04,357 8451 INFO ? openerp: database user: odoo
2015-05-12 00:04:06,650 8451 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2015-05-12 00:10:05,444 8451 INFO ? werkzeug: 66.36.137.56 - - [12/May/2015 00:10:05] "GET / HTTP/1.1" 500 -
2015-05-12 00:10:05,456 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
2015-05-12 00:10:05,456 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1279, in __call__
    self.load_addons()
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1289, in load_addons
    for module in sorted(os.listdir(str(addons_path))):
OSError: [Errno 2] No such file or directory: '/opt/odoo/.local/share/Odoo/addons/8.0'
2015-05-12 00:10:06,322 8451 INFO ? werkzeug: 66.36.137.56 - - [12/May/2015 00:10:06] "GET /favicon.ico HTTP/1.1" 500 -
2015-05-12 00:10:06,342 8451 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi
    execute(app)
  File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 285, in app
    return self.app(e, s)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1280, in __call__
    return self.dispatch(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1391, in dispatch
    explicit_session = self.setup_session(httprequest)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1312, in setup_session
    session_gc(self.session_store)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/func.py", line 41, in __get__
    value = self.fget(obj)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1265, in session_store
    path = openerp.tools.config.session_dir
  File "/usr/lib/python2.7/dist-packages/openerp/tools/config.py", line 695, in session_dir
    os.makedirs(d, 0700)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/odoo'

If I remember I deleted in my opt, odoo directory

Is it the problem ?

I try to recreate the directory :

/opt/odoo/.local/share/Odoo/addons/8.0

Doesn't work

maybe the problem come from the link ?

['/opt/odoo/.local/share/Odoo/addons/8.0', u'/usr/lib/python2.7/dist-packages/openerp/addons']

Do you have an idea ? what can I do ?

To contiue my discussion

I try this :

    ln -s /usr/lib/python2.7/dist-packages/openerp/addons /opt/odoo/.local/share/Odoo/addons/8.0
sudo service restart

doesn't work

and finally this

root@.......:/opt# apt-get install odoo
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets suivants seront mis à jour :
  odoo
1 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 48,8 Mo dans les archives.
Après cette opération, 1 024 o d'espace disque supplémentaires seront utilisés.
Réception de : 1 http://nightly.odoo.com/8.0/nightly/deb/ ./ odoo 8.0.20150513 [48,8 MB]
48,8 Mo réceptionnés en 0s (49,8 Mo/s)
Lecture des fichiers de modifications (« changelog »)... Terminé
(Lecture de la base de données... 81772 fichiers et répertoires déjà installés.)
Préparation du remplacement de odoo 8.0.20150512 (en utilisant .../odoo_8.0.20150513_all.deb) ...
Stopping odoo: start-stop-daemon: warning: failed to kill 3316: No such process
ok
Dépaquetage de la mise à jour de odoo ...
Paramétrage de odoo (8.0.20150513) ...

doesn't work also

and finally I tried this :

sudo service odoo stop
Stopping odoo: start-stop-daemon: warning: failed to kill 3491: No such process
ok

Nobody has been this problem ?

Body:
Maybe you dont have permission to access that directory for that you can give permission to that directory
For that got to that path through terminal and than follow this command

sudo chmod  777 -R //opt/odoo/.local/share/Odoo/addons/(your folder name)


问:
How can I log a hyperlink click?
I have a hyperlink which I need to log when it's clicked.

I created a small prototype, and the problem is repeatable by creating a new MVC 2 Web app project.

Add

```<code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
</code>```

to the Site.Master file.

And

```<code>public ActionResult LogSomething()
{
    string doNothing = DateTime.Now.ToString();
    return new EmptyResult();
}
</code>```

to the HomeController.cs file

And

```<code><p>
    <a id="lnkTestPost" href="/home/about">Test Post</a>

    <script type="text/javascript">
        $("#lnkTestPost").click(function() {
            $.post("/home/LogSomething");
        });
    </script>
</p>
</code>```

in Home/Index.aspx

Put a break point in the LogSomething() action method in the HomeController.

But when I run it, sometimes the breakpoint is hit, other times it isn't.

I'm assuming it's not being hit due to the actual link sending the browser to another page, but shouldn't the post be made before the link is fired?

Is there anyway I can ensure the logging code is fired?

Please note; adding the logging functionality in the link target is not an option.

EDIT: The original hyperlink is actually to a custom protocol for an app installed on the user PC.  So the link is to something like "myapp:myArgs".  I didn't mention that in order to keep things simple, unfortunately, since none of the answers really apply to me, I now think it's necessary to mention.

答: An approach that I have seen used by many sites, including google, is to have a "redirector" page, so all the links go through that page/controller, you log it, then from there you can redirect them</p>

Title: How can I log a hyperlink click?

Body:
I have a hyperlink which I need to log when it's clicked.

I created a small prototype, and the problem is repeatable by creating a new MVC 2 Web app project.

Add

to the Site.Master file.

And

public ActionResult LogSomething()
{
    string doNothing = DateTime.Now.ToString();
    return new EmptyResult();
}

to the HomeController.cs file

And

    Test Post

in Home/Index.aspx

Put a break point in the LogSomething() action method in the HomeController.

But when I run it, sometimes the breakpoint is hit, other times it isn't.

I'm assuming it's not being hit due to the actual link sending the browser to another page, but shouldn't the post be made before the link is fired?

Is there anyway I can ensure the logging code is fired?

Please note; adding the logging functionality in the link target is not an option.

EDIT: The original hyperlink is actually to a custom protocol for an app installed on the user PC.  So the link is to something like "myapp:myArgs".  I didn't mention that in order to keep things simple, unfortunately, since none of the answers really apply to me, I now think it's necessary to mention.