问:
Limit number of items / length of json for logging
I am working on an API that returns JSON. I am logging my responses, and sometimes the JSON is just absurdly long and basically clogs my log files. Is there a neat way to reduce the length of a JSON, purely for visually logging the data? (not in effect in production)

The basic approach is to reduce arrays over a length of 5 to [first 2, "...", last 2], and dictionaries with more than 4 items to {first 4, "..." : "..."}

The code below is ugly. I am aware that it should be a recursive solution that reduces the items in the same way for a JSON of arbitrary depth - it currently only does so for depth 2.

```<code>def log_reducer(response_log):
original_response_log = response_log
try:
    if type(response_log) == dict:
        if len(response_log) >= 4:  # {123456}
            response_log = dict(list(response_log.items())[:4])
            response_log.update({"...": "..."})  # {1234...}
        for key, value in response_log.items():
            if type(value) == list:
                if len(value) >= 5:  # {key:[123456]}
                    new_item = value[:2] + ['...'] + value[-2:]  # {[12...56]}
                    response_log.update({key: new_item})
            if type(value) == dict:
                if len(value) >= 4:  # {key:{123456}}
                    reduced_dict = dict(list(value.items())[:4])
                    reduced_dict.update({"...": "..."})
                    response_log.update({key: reduced_dict})  # {{1234...}}

    elif type(response_log) == list:
        if len(response_log) >= 5:  # [123456]
            response_log = response_log[:2] + ['...'] + response_log[-2:]  # [12...56]
        for inner_item in response_log:
            if type(inner_item) == list:
                if len(inner_item) >= 5:  # [[123456]]
                    reduced_list = inner_item[:2] + ['...'] + inner_item[-2:]  # [[12...56]]
                    response_log.remove(inner_item)
                    response_log.append(reduced_list)
            if type(inner_item) == dict:
                if len(inner_item) >= 4:  # [{123456}]
                    reduced_dict = dict(list(inner_item.items())[:4])
                    reduced_dict.update({"...": "..."})  # [{1234...}]
                    response_log.remove(inner_item)
                    response_log.append(reduced_dict)
except Exception as e:
    return original_response_log
return response_log
</code>```

The returned response_log is then logged with logger.info(str(response_log))

As you can see, the fact that there can be either arrays or dictionaries at every level makes this task a little more complex, and I am struggling to find a library or code snipped of any kind which would simplify this. If anyone wants to give it a shot, I would appreciate it a lot.

you can use a test JSON like this to see it in effect:

```<code>test_json = {"works": [1, 2, 3, 4, 5, 6],
             "not_affected": [{"1": "1", "2": "2", "3": "3", "4": "4", "5": "5"}],
             "1": "1", "2": "2", "3": "3",
             "removed": "removed"
             }
print("original", test_json)
reduced_log = log_reducer(test_json)
print("reduced", reduced_log)

print("original", test_json)
reduced_log = log_reducer([test_json])  # <- increases nesting depth
print("reduced", reduced_log)
</code>```

答:
You can overwrite the string representation of dicts and lists in python using the def __str__(): method. Using this just recursively call the print function on all elements. It can have a simple boilerplate like this:

```<code>def custom_print(obj):
    log_str = ''
    if type(obj) == list:
        for item in obj:
            log_str += custom_print(item)
    elif type(obj) == dict:
        for k, item in obj.items():
            custom_print(item)
</code>```

Use this custom log function to print into your log file as per your log file format.

Body:
I am working on an API that returns JSON. I am logging my responses, and sometimes the JSON is just absurdly long and basically clogs my log files. Is there a neat way to reduce the length of a JSON, purely for visually logging the data? (not in effect in production)

The basic approach is to reduce arrays over a length of 5 to [first 2, "...", last 2], and dictionaries with more than 4 items to {first 4, "..." : "..."}

The code below is ugly. I am aware that it should be a recursive solution that reduces the items in the same way for a JSON of arbitrary depth - it currently only does so for depth 2.

def log_reducer(response_log):
original_response_log = response_log
try:
    if type(response_log) == dict:
        if len(response_log) >= 4:  # {123456}
            response_log = dict(list(response_log.items())[:4])
            response_log.update({"...": "..."})  # {1234...}
        for key, value in response_log.items():
            if type(value) == list:
                if len(value) >= 5:  # {key:[123456]}
                    new_item = value[:2] + ['...'] + value[-2:]  # {[12...56]}
                    response_log.update({key: new_item})
            if type(value) == dict:
                if len(value) >= 4:  # {key:{123456}}
                    reduced_dict = dict(list(value.items())[:4])
                    reduced_dict.update({"...": "..."})
                    response_log.update({key: reduced_dict})  # {{1234...}}

    elif type(response_log) == list:
        if len(response_log) >= 5:  # [123456]
            response_log = response_log[:2] + ['...'] + response_log[-2:]  # [12...56]
        for inner_item in response_log:
            if type(inner_item) == list:
                if len(inner_item) >= 5:  # [[123456]]
                    reduced_list = inner_item[:2] + ['...'] + inner_item[-2:]  # [[12...56]]
                    response_log.remove(inner_item)
                    response_log.append(reduced_list)
            if type(inner_item) == dict:
                if len(inner_item) >= 4:  # [{123456}]
                    reduced_dict = dict(list(inner_item.items())[:4])
                    reduced_dict.update({"...": "..."})  # [{1234...}]
                    response_log.remove(inner_item)
                    response_log.append(reduced_dict)
except Exception as e:
    return original_response_log
return response_log

The returned response_log is then logged with logger.info(str(response_log))

As you can see, the fact that there can be either arrays or dictionaries at every level makes this task a little more complex, and I am struggling to find a library or code snipped of any kind which would simplify this. If anyone wants to give it a shot, I would appreciate it a lot.

you can use a test JSON like this to see it in effect:

test_json = {"works": [1, 2, 3, 4, 5, 6],
             "not_affected": [{"1": "1", "2": "2", "3": "3", "4": "4", "5": "5"}],
             "1": "1", "2": "2", "3": "3",
             "removed": "removed"
             }
print("original", test_json)
reduced_log = log_reducer(test_json)
print("reduced", reduced_log)

print("original", test_json)
reduced_log = log_reducer([test_json])  # <- increases nesting depth
print("reduced", reduced_log)

Body:
You can overwrite the string representation of dicts and lists in python using the def __str__(): method. Using this just recursively call the print function on all elements. It can have a simple boilerplate like this:

def custom_print(obj):
    log_str = ''
    if type(obj) == list:
        for item in obj:
            log_str += custom_print(item)
    elif type(obj) == dict:
        for k, item in obj.items():
            custom_print(item)

Use this custom log function to print into your log file as per your log file format.


来源: stackexchange

问:
How to convert a list to json in python
have a list with values

```<code>test = ["mark","will","john"]

</code>```

using for loop how to convert this into JSON like this

```<code>test =[{"name":"mark"},{"name":"john"},{"name":"will"}]
</code>```

Tried this

```<code>for i in test :
    print({"name":i})

</code>```

答:
import json

test =[{"name":"mark"},{"name":"john"},{"name":"will"}]

testJson = json.dumps(test)

print(testJson)

```

ContentLicense: CC BY-SA 4.0

Title: How to convert a list to json in python

Body:
have a list with values

test = ["mark","will","john"]

using for loop how to convert this into JSON like this

test =[{"name":"mark"},{"name":"john"},{"name":"will"}]

Tried this

for i in test :
    print({"name":i})


问:
Combining 2 lists and and remove duplicates .Output in a third list .My attempts do not work
I always seem to have a problem when I need to compare 2 list and produce a 3rd list which include all unique items.I need to perform this quite often.

Attempt to reproduce the issue with a noddy example.

Am I missing something?
Thanks for any suggestions

The wanted result

```<code>   Name= Jo1 Surname= Bloggs1 Category= Account
   Name= Jo2 Surname= Bloggs2 Category= Sales
   Name= Jo5 Surname= Bloggs5 Category= Development
   Name= Jo6 Surname= Bloggs6 Category= Management
   Name= Jo8 Surname= Bloggs8 Category= HR
   Name= Jo7 Surname= Bloggs7 Category= Cleaning

class Program
{
    static void Main(string[] args)
    {
          List<Customer> listOne = new List<Customer>();
        List<Customer> listTwo = new List<Customer>();

        listOne.Add(new Customer { Category = "Account", Name = "Jo1", Surname = "Bloggs1" });
        listOne.Add(new Customer { Category = "Sales", Name = "Jo2", Surname = "Bloggs2" });
        listOne.Add(new Customer { Category = "Development", Name = "Jo5", Surname = "Bloggs5" });
        listOne.Add(new Customer { Category = "Management", Name = "Jo6", Surname = "Bloggs6" });

        listTwo.Add(new Customer { Category = "HR", Name = "Jo8", Surname = "Bloggs8" });
        listTwo.Add(new Customer { Category = "Sales", Name = "Jo2", Surname = "Bloggs2" });
        listTwo.Add(new Customer { Category = "Management", Name = "Jo6", Surname = "Bloggs6" });
        listTwo.Add(new Customer { Category = "Development", Name = "Jo5", Surname = "Bloggs5" });
        listTwo.Add(new Customer { Category = "Cleaning", Name = "Jo7", Surname = "Bloggs7" });

    List<Customer> resultList = listOne.Union(listTwo).ToList();//**I get duplicates why????**

        resultList.ForEach(customer => Console.WriteLine("Name= {0} Surname= {1} Category= {2}", customer.Name, customer.Surname, customer.Category));
        Console.Read();

        IEnumerable<Customer> resultList3 = listOne.Except(listTwo);//**Does not work**

        foreach (var customer in resultList3)
        {
            Console.WriteLine("Name= {0} Surname= {1} Category= {2}", customer.Name, customer.Surname, customer.Category);
        }

        **//Does not work**
        var resultList2 = (listOne
                       .Where(n => !(listTwo
                           .Select(o => o.Category))
                           .Contains(n.Category)))
                       .OrderBy(n => n.Category);

        foreach (var customer in resultList2)
        {
            Console.WriteLine("Name= {0}
                             Surname= {1}
                             Category= {2}",
</code>```

customer.Name,
customer.Surname,
customer.Category);
            }
            Console.Read();

```<code>  }
}

public class Customer
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public string Category { get; set; }
}
</code>```

答:
The best option is implement the interface IEqualityComparer and use it within Union or Distinct method as I wrote at the end of this article
http://blog.santiagoporras.com/combinar-listas-sin-duplicados-linq/

Implementation of IEqualityComparer

```<code>public class SaintComparer : IEqualityComparer<Saint>
{
    public bool Equals(Saint item1, Saint item2)
    {
       return item1.Name == item2.Name;
    }

    public int GetHashCode(Saint item)
    {
      int hCode = item.Name.Length;
      return hCode.GetHashCode();
    }
}
</code>```

Use of comparer

```<code>var unionList = list1.Union(list2, new SaintComparer());

</code>```

ContentLicense: CC BY-SA 2.5

Body:
I always seem to have a problem when I need to compare 2 list and produce a 3rd list which include all unique items.I need to perform this quite often.

Attempt to reproduce the issue with a noddy example.

Am I missing something?
Thanks for any suggestions

The wanted result

   Name= Jo1 Surname= Bloggs1 Category= Account
   Name= Jo2 Surname= Bloggs2 Category= Sales
   Name= Jo5 Surname= Bloggs5 Category= Development
   Name= Jo6 Surname= Bloggs6 Category= Management
   Name= Jo8 Surname= Bloggs8 Category= HR
   Name= Jo7 Surname= Bloggs7 Category= Cleaning

class Program
{
    static void Main(string[] args)
    {
          List<Customer> listOne = new List<Customer>();
        List<Customer> listTwo = new List<Customer>();

        listOne.Add(new Customer { Category = "Account", Name = "Jo1", Surname = "Bloggs1" });
        listOne.Add(new Customer { Category = "Sales", Name = "Jo2", Surname = "Bloggs2" });
        listOne.Add(new Customer { Category = "Development", Name = "Jo5", Surname = "Bloggs5" });
        listOne.Add(new Customer { Category = "Management", Name = "Jo6", Surname = "Bloggs6" });

        listTwo.Add(new Customer { Category = "HR", Name = "Jo8", Surname = "Bloggs8" });
        listTwo.Add(new Customer { Category = "Sales", Name = "Jo2", Surname = "Bloggs2" });
        listTwo.Add(new Customer { Category = "Management", Name = "Jo6", Surname = "Bloggs6" });
        listTwo.Add(new Customer { Category = "Development", Name = "Jo5", Surname = "Bloggs5" });
        listTwo.Add(new Customer { Category = "Cleaning", Name = "Jo7", Surname = "Bloggs7" });

    List<Customer> resultList = listOne.Union(listTwo).ToList();//**I get duplicates why????**

        resultList.ForEach(customer => Console.WriteLine("Name= {0} Surname= {1} Category= {2}", customer.Name, customer.Surname, customer.Category));
        Console.Read();

        IEnumerable<Customer> resultList3 = listOne.Except(listTwo);//**Does not work**

        foreach (var customer in resultList3)
        {
            Console.WriteLine("Name= {0} Surname= {1} Category= {2}", customer.Name, customer.Surname, customer.Category);
        }

        **//Does not work**
        var resultList2 = (listOne
                       .Where(n => !(listTwo
                           .Select(o => o.Category))
                           .Contains(n.Category)))
                       .OrderBy(n => n.Category);

        foreach (var customer in resultList2)
        {
            Console.WriteLine("Name= {0}
                             Surname= {1}
                             Category= {2}",

customer.Name,
customer.Surname,
customer.Category);
            }
            Console.Read();

  }
}

public class Customer
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public string Category { get; set; }
}

Body:
The best option is implement the interface IEqualityComparer and use it within Union or Distinct method as I wrote at the end of this article
http://blog.santiagoporras.com/combinar-listas-sin-duplicados-linq/

Implementation of IEqualityComparer

public class SaintComparer : IEqualityComparer<Saint>
{
    public bool Equals(Saint item1, Saint item2)
    {
       return item1.Name == item2.Name;
    }

    public int GetHashCode(Saint item)
    {
      int hCode = item.Name.Length;
      return hCode.GetHashCode();
    }
}

Use of comparer

var unionList = list1.Union(list2, new SaintComparer());


问:
library module and google-services.json files
I am already using an application(has app module) which uses conversations.im as the base. This application has free, paid etc product flavors and debug and release build types. This project already has firebase integration and has 2 applications integrated. I have one google-services.json file in the root directory of the app module.

Now I want to move away from conversations.im(ejabber) and want to implement a separate chat component using cloud firestore. I have created this component as an android library module which I will use in my existing app module.

I want to have separate chat data for this chat library for debug and release types. This will require me to have unique application ids for this library module. But documentation says I cannot have applicationId in a library module.

I am confused where to keep the google-services.json files, in library module or in the app module which will use the chat library module. Looks like can't keep in library because of limitation. And if I keep in app module, library chat module can't work as a separate module in itself.

How should I go about this setup so that I could use different google-services.json files for debug and release types and at the same time make this new module as a library.

答: Logically speaking, any android project should be able to use the library module and all the chat data should belong to the project and not tied to the chat library. If I go by this approach, google-services.json files should reside within the app module and not library module.</p>


问:
Django AdminModel add_view prepopulated fields
I have a simple model being displayed in the admin. In the add view I have 4 fields, with the first field being a foreign key to user. I need to:

Pre-populate the user field.

Make the field read only.

I cannot find any documentation on this. I looked at the following links:

django admin "add page" initial datetime from GET parameters,

Customize Django Admin: Add More Than One Default Inline on Parent Add_View

EDIT:
I found a solution for my first problem here; Djanjo admin: Prefill data when clicking the add-another button next to a ForeignKey dropdown

答:
Here, you need to add jQuery for prepopulate that particular field. Create your own js script file inside static directory of your app & just extend change_form.html of admin site. For example if you want add script.js script into your add template, your extended change_form.html will look like as follows:

```<code>{% extends 'admin/change_form.html' %}
{% load static %}
{% block admin_change_form_document_ready %}
{{ block.super }}
<script type="text/javascript" src="{% static 'qb/js/formset_handlers.js' %}"></script>
{% endblock %}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Here, you need to add jQuery for prepopulate that particular field. Create your own js script file inside static directory of your app & just extend change_form.html of admin site. For example if you want add script.js script into your add template, your extended change_form.html will look like as follows:

{% extends 'admin/change_form.html' %}
{% load static %}
{% block admin_change_form_document_ready %}
{{ block.super }}
<script type="text/javascript" src="{% static 'qb/js/formset_handlers.js' %}"></script>
{% endblock %}


问:
Is there any way to access the address of private instance variable of any class in objective c runtime?
Is there way to access address of private instance variable  of any class by using objective c runtime?

for example:

```<code> self.navigationItem.title
</code>```

Is there any way to get address of _title ivar of UINavigationItem class?

Thanks

答:
Obvious observations: self.navigationItem.title may not be an instance variable, as a getter can do anything it likes to generate a result and the dot notation just calls the getter. Even if it is an instance variable in this version of the OS it may not have been in the past and may not be in the future. Even if title is directly backed by an instance variable, it may not be named _title — it could be called anything whatsoever.

Even in the case where you do know for certain that a class has a particular instance variable, the relevant mechanisms are removed as of Objective-C 2.0. Under the older runtime you could have used:

```<code>#import <objc/runtime.h>

...
Ivar instanceVariable = class_getInstanceVariable([instance class], "varName");
// yes, really, a C-style string

NSLog(@"offset of that var is %d", instanceVariable->ivar_offset);
</code>```

Or, similarly:

```<code>struct exampleClassStruct
{
    @defs(exampleClass);
};
// this is now a struct with the same layout all the same instance variables
// as exampleClass
</code>```

However, you'll now be met with errors like "Invalid application of @defs in non-fragile ABI". So, in conclusion: you can't do what you want to do. Probably the closest thing is to use class_GetProperty, which — like dot notation — doesn't care about memory layouts or whether the thing has the same name or even is really an instance variable. Failing that, class_getInstanceMethod (on the same page) can be used to get a C function pointer to the getter.

EDIT: a quick extra observation, after following alastair's comment below, is that the runtime provides id object_getIvar(id object, Ivar ivar) (link) and a set equivalent, which are the opaque ways to get and set instance variables on a particular class given that their address is now obscured. Those take the Ivar that you get from either
class_getInstanceVariable or object_getInstanceVariable so probably aren't doing any sort of complicated lookup, and explain why you can still get Ivars even though the associated struct now has no public members whatsoever.

EDIT2: please see discussion with alastair below; the final parameter of object_getInstanceVariable and/or the result of ivar_getOffset may be usable to do what you want, depending on your interpretation of the documentation. Supposing you adopt the same reading as alastair, then either of the following would do what you want (coded extemporaneously):

```<code>#import <objc/runtime.h>

void *pointerToInstanceVariableA(id object, const char *variableName)
{
    Ivar instanceVar = class_getInstanceVariable([object class], variableName);
    return (unsigned char *)object + ivar_getOffset(instanceVar);
}

void *pointerToInstanceVariableB(id object, char *variableName)
{
    void *returnValue;
    Ivar instanceVar = object_getInstanceVariable(object, variableName, &returnValue);
    return returnValue;
}
</code>```

Body:
Is there way to access address of private instance variable  of any class by using objective c runtime?

for example:

 self.navigationItem.title

Is there any way to get address of _title ivar of UINavigationItem class?

Thanks

Body:
Obvious observations: self.navigationItem.title may not be an instance variable, as a getter can do anything it likes to generate a result and the dot notation just calls the getter. Even if it is an instance variable in this version of the OS it may not have been in the past and may not be in the future. Even if title is directly backed by an instance variable, it may not be named _title — it could be called anything whatsoever.

Even in the case where you do know for certain that a class has a particular instance variable, the relevant mechanisms are removed as of Objective-C 2.0. Under the older runtime you could have used:

#import <objc/runtime.h>

...
Ivar instanceVariable = class_getInstanceVariable([instance class], "varName");
// yes, really, a C-style string

NSLog(@"offset of that var is %d", instanceVariable->ivar_offset);

Or, similarly:

struct exampleClassStruct
{
    @defs(exampleClass);
};
// this is now a struct with the same layout all the same instance variables
// as exampleClass

However, you'll now be met with errors like "Invalid application of @defs in non-fragile ABI". So, in conclusion: you can't do what you want to do. Probably the closest thing is to use class_GetProperty, which — like dot notation — doesn't care about memory layouts or whether the thing has the same name or even is really an instance variable. Failing that, class_getInstanceMethod (on the same page) can be used to get a C function pointer to the getter.

EDIT: a quick extra observation, after following alastair's comment below, is that the runtime provides id object_getIvar(id object, Ivar ivar) (link) and a set equivalent, which are the opaque ways to get and set instance variables on a particular class given that their address is now obscured. Those take the Ivar that you get from either
class_getInstanceVariable or object_getInstanceVariable so probably aren't doing any sort of complicated lookup, and explain why you can still get Ivars even though the associated struct now has no public members whatsoever.

EDIT2: please see discussion with alastair below; the final parameter of object_getInstanceVariable and/or the result of ivar_getOffset may be usable to do what you want, depending on your interpretation of the documentation. Supposing you adopt the same reading as alastair, then either of the following would do what you want (coded extemporaneously):

#import <objc/runtime.h>

void *pointerToInstanceVariableA(id object, const char *variableName)
{
    Ivar instanceVar = class_getInstanceVariable([object class], variableName);
    return (unsigned char *)object + ivar_getOffset(instanceVar);
}

void *pointerToInstanceVariableB(id object, char *variableName)
{
    void *returnValue;
    Ivar instanceVar = object_getInstanceVariable(object, variableName, &returnValue);
    return returnValue;
}


问:
Count the number of lines having more than N words using AWK
I am having a sample file sample.txt having the contents as below:

```<code>this is me
hello
my name is x
awk tutorials
unable to get this right
</code>```

I want to count the number of lines with more than N words. Let's consider N=3

Hence, the desired output is 2 (3rd line and 5th line).

I have tried the below code:

cat sample.txt | awk 'BEGIN{count=0}{"NF>3" then count++} END{print count}'

My output is always 5 (which is the number of lines in the file; the output remains the same even when N is changed from 3 to 8, indicating that the condition is always True).

答:
Could you please try following.

```<code> awk -v num="3" 'NF>num{count++} END{print count}'  Input_file
</code>```

OR

```<code>awk 'NF>3{count++} END{print count}'  Input_file
</code>```

Problem with OP's code attempt:

OP's method of condition "NF>3" then count++ is not right.

In spite of looking for lines where NF>3 its increasing value of count every time and hence each time output is 5.

Body:
I am having a sample file sample.txt having the contents as below:

this is me
hello
my name is x
awk tutorials
unable to get this right

I want to count the number of lines with more than N words. Let's consider N=3

Hence, the desired output is 2 (3rd line and 5th line).

I have tried the below code:

cat sample.txt | awk 'BEGIN{count=0}{"NF>3" then count++} END{print count}'

My output is always 5 (which is the number of lines in the file; the output remains the same even when N is changed from 3 to 8, indicating that the condition is always True).

Body:
Could you please try following.

 awk -v num="3" 'NF>num{count++} END{print count}'  Input_file

OR

awk 'NF>3{count++} END{print count}'  Input_file

Problem with OP's code attempt:

OP's method of condition "NF>3" then count++ is not right.

In spite of looking for lines where NF>3 its increasing value of count every time and hence each time output is 5.


问:
Why register storage class is explicitly deprecated
In numerical computation in mind, it seems to me that register storage class (which is currently deprecated and removed from the standard) was a good hint for optimization. Was there any specific reason for explicitly removing it from the standard? </p>

答: Because it is pretty much useless nowadays. register keywords is nothing more then a hint to the compiler that "you should try to give me fast access to this variable". But compilers are much better than you at measuring such things, especially if you're not actually benchmarking your code.


问:
Cannot find resource EntityModel.rlinq embedded in assembly
I am trying to run a solution which has entity model included but I am getting weird error which someone already had in the past and can help me solve this. My colleague says that the solution is running fine on his comp and on other computers too, but on mine comp doesn't want to work for some reason. Please let me know if I am missing something, he checked too, and it looks pretty much the same.
Here is the screenshot:

Every advice is welcome.
Thanks, Laziale

答:
I had the same issue this Offical Telerik post helped me.

TLDR:

In Solution Explorer right-click the project containing the rlinq and select Unload Project.

Right-click on the unloaded project and select Edit ProjectName.csproj (vbproj).

Add this to the end of your file:

```<code><Import Condition="Exists('$(MSBuildExtensionsPath)\OpenAccess.targets')" Project="$(MSBuildExtensionsPath)\OpenAccess.targets" />
</code>```

Body:
I had the same issue this Offical Telerik post helped me.

TLDR:

In Solution Explorer right-click the project containing the rlinq and select Unload Project.

Right-click on the unloaded project and select Edit ProjectName.csproj (vbproj).

Add this to the end of your file:

<Import Condition="Exists('$(MSBuildExtensionsPath)\OpenAccess.targets')" Project="$(MSBuildExtensionsPath)\OpenAccess.targets" />


问:
Combine shell command lines in snakemake
I would like to combine two command lines as one single to avoid the intermediate files.

```<code>workdir: "/path/to/workdir/"

rule all:
    input:
        "my.filtered.vcf.gz"

rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        "/Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa |"
        "/Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description="Gene name">') > {output.outvcf}"
</code>```

I am getting invalid syntax error. I would appreciate if you could explain how to combine multiple shell lines in snakemake.

答:
You probably get an invalid syntax because of the " you use in your shell here: Description="Gene name">. This closes your shell. You can either escape these quotes or use the """ syntax:

```<code>rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        "/Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa |"
        "/Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description=\"Gene name\">') > {output.outvcf}"
</code>```

or

```<code>rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        """
        /Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa | /Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description="Gene name">') > {output.outvcf}
        """
</code>```

Note that you can use multi line with """. Example without pipes:

```<code>shell:
    """
    bedtools .... {input} > tempFile
    bcftools .... tempFile > tempFile2
    whatever .... tempFile2 > {output}
    """
</code>```

Body:
I would like to combine two command lines as one single to avoid the intermediate files.

workdir: "/path/to/workdir/"

rule all:
    input:
        "my.filtered.vcf.gz"

rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        "/Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa |"
        "/Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description="Gene name">') > {output.outvcf}"

I am getting invalid syntax error. I would appreciate if you could explain how to combine multiple shell lines in snakemake.

Body:
You probably get an invalid syntax because of the " you use in your shell here: Description="Gene name">. This closes your shell. You can either escape these quotes or use the """ syntax:

rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        "/Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa |"
        "/Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description=\"Gene name\">') > {output.outvcf}"

or

rule bedtools:
    input:
        invcf="/path/to/my.vcf.gz",
        bedgz="/path/to/my.bed.gz"
    output:
        outvcf="my.filtered.vcf.gz"
    shell:
        """
        /Tools/bedtools2/bin/bedtools intersect -a {input.invcf} -b {input.bedgz} -header -wa | /Tools/bcftools/bcftools annotate -c CHROM,FROM,TO,GENE -h <(echo '##INFO=<ID=GENE,Number=1,Type=String,Description="Gene name">') > {output.outvcf}
        """

Note that you can use multi line with """. Example without pipes:

shell:
    """
    bedtools .... {input} > tempFile
    bcftools .... tempFile > tempFile2
    whatever .... tempFile2 > {output}
    """


问:
Filter integer list in Thymeleaf
I am learning about Thymeleaf in Spring, and I am struggling with list fitlering.

The official Tutorial: Using Thymeleaf does not talk about collection filtering and projection, but I found out that Thymeleaf on Spring uses the Spring Expression Language.

This guide states the following:

The syntax of the selection (filtering) operator is : ${collection.?[property == value]}

The syntax of the projection (mapping) operator is : ${collection.![property]}

This is fine if I have a list of objects, for example a list of persons. Then I can perform things like that:

Selection (filtering): e.g., ${persons.?[age >= 18]} selects all persons of at least 18 years

Projection (mapping): e.g., ${persons.![name]} selects the name of every person

Question:

What if I do not have a list of objects (such as a list of persons) but a list of numbers or list of Strings? How can I perform selection (filtering) then? Things like numbers.?[>10] does not work.

答:
After some more search, I found the answer in the Spring Expression Language documentation.

In 10.5.11 Variables the documentation states the #this and #root variables.

The variable #this is always defined and refers to the current evaluation object (against which unqualified references are resolved).

So, assuming I have a list numbers filled with integers, ${numbers.?[#this >= 10]} creates a new list that contains all numbers that are at least 10.

Title: Filter integer list in Thymeleaf


问:
Best practice for assembly and class names when generating dynamic assemblies and types?
I'm generating a dynamic proxy in .NET with TypeBuilder and Emit and there are lots of names going on - assembly name, module name and type names. Is there a best practice or a set of general good ideas around naming of a dynamic proxy, or emitted classes in general? Should the generated proxy contain a name and a random number to prevent class name collisions and so on?

Thanks for any help.

答:
Usually, you will name your class like this:

```<code>MeaningfulName_GUID
</code>```

This solves both problems: In stack traces, you have a speaking name for the class, but because of the GUID in the class name there will be no collisions.

Body:
Usually, you will name your class like this:

MeaningfulName_GUID

This solves both problems: In stack traces, you have a speaking name for the class, but because of the GUID in the class name there will be no collisions.


问:
JavaScript Set value in object
I'm pretty new in JS  and something weird happen to me.
I try to set different value in an object and all the value of the table are changed
It appears the problems come from the creation of the object via a the object call "materialStd"

Value obj.line[0].material.flow of should stay at 123 instead of 3

Is someone able to explain what is happening there Thanks

https://jsfiddle.net/vx6fno9p/5/

var materialStd = {
  flow: 123,
  name: 'Raoul'
};
var obj = {
  id: 0,
  line: [{
      id: 1,
      material: materialStd
    },
    {
      id: 2,
      material: materialStd
    },
    {
      id: 3,
      material: materialStd
    }
  ]
}

testerror();

function testerror() {
  console.info(obj);
  //On appel une fct test

  console.log('' + obj.line[0].material.flow);
  console.log('' + obj.line[1].material.flow);
  console.log('' + obj.line[2].material.flow);

  test(obj);

  console.log('' + obj.line[0].material.flow);
  console.log('' + obj.line[1].material.flow);
  console.log('' + obj.line[2].material.flow);

}

function test(objetTraiter) {
  //  objetTraiter.line[0].material.flow=1;
  // objetTraiter.line[1].material.flow=2;
  objetTraiter.line[2].material.flow = 3;
  console.log('' + objetTraiter.line[0].material.flow);
  console.log('' + objetTraiter.line[1].material.flow);
  console.log('' + objetTraiter.line[2].material.flow);

}```

答:
Because pass by reference.

    var materialStd={flow:123, name:'Raoul'};
    var obj={
    id:0,
    line:[
      {id:1, material:materialStd},
      {id:2, material:materialStd},
      {id:3, material:materialStd}]
    }
    // Compare them
    console.log(
      (obj.line[0].material === obj.line[1].material)
      &&
      (obj.line[1].material === obj.line[2].material)
    ) // true```

As suggested by other answers, clone a fresh reference for your intended behaviour inside obj.line[index]["material"]

Title: JavaScript Set value in object

Body:
Because pass by reference.

    var materialStd={flow:123, name:'Raoul'};
    var obj={
    id:0,
    line:[
      {id:1, material:materialStd},
      {id:2, material:materialStd},
      {id:3, material:materialStd}]
    }
    // Compare them
    console.log(
      (obj.line[0].material === obj.line[1].material)
      &&
      (obj.line[1].material === obj.line[2].material)
    ) // true

As suggested by other answers, clone a fresh reference for your intended behaviour inside obj.line[index]["material"]


问:
How do I initialize a long-lived class in a Flutter app?
I have an Api class that accepts an (optional) authentication token that it uses for making authenticated requests e.g. Api(token: 'a9sa2ksas12').getUserDetails().

If the token is not passed, it has to perform the relatively expensive operation of reading it from sharedPreferences.

```<code>class Api {
  static const BASEURL = "https://api.google.com/";
  final String token;

  Api({ this.token });

  Future<http.response> getUserDetails() async {
    return http.get('$BASEURL/user/', headers: { 'Authorization': token });
  }
}
</code>```

How can I setup my app so that the token is read only once from sharedPreferences and used throughout the app for all future Api() requests?

Some ideas I've considered and think that may work:

Have token be a global variable

Make the API class a singleton, and pass it around between "screens"

答:
Well in general there's nothing bad in making you Repositories a singletons. But on the other hand, I don't like the concept of passing the API classs between the screens.

When widgets use your data source directly without any middleman, like Bloc or Provider, they tend to be polluted with a lot of presentation logic. I personally prefer to separate those concerns and let widgets do what they are made for: rendering the UI. This makes them smaller and easier to test.

What's more the API class should be responsible only for the network calls. It shouldn't be responsible for managing the token. I'd inject to the API class something like:

```<code>class TokenProvider
{
   Future<String> getToken();
}
</code>```

The responsibility of this class would be, you guessed it, to provide a token. It can return cached value or get it from the SharedPreferences. Thanks to this the API doesn't have to care where the token comes and how to handle it. It will do just one thing: api calls.

Body:
I have an Api class that accepts an (optional) authentication token that it uses for making authenticated requests e.g. Api(token: 'a9sa2ksas12').getUserDetails().

If the token is not passed, it has to perform the relatively expensive operation of reading it from sharedPreferences.

class Api {
  static const BASEURL = "https://api.google.com/";
  final String token;

  Api({ this.token });

  Future<http.response> getUserDetails() async {
    return http.get('$BASEURL/user/', headers: { 'Authorization': token });
  }
}

How can I setup my app so that the token is read only once from sharedPreferences and used throughout the app for all future Api() requests?

Some ideas I've considered and think that may work:

Have token be a global variable

Make the API class a singleton, and pass it around between "screens"

Body:
Well in general there's nothing bad in making you Repositories a singletons. But on the other hand, I don't like the concept of passing the API classs between the screens.

When widgets use your data source directly without any middleman, like Bloc or Provider, they tend to be polluted with a lot of presentation logic. I personally prefer to separate those concerns and let widgets do what they are made for: rendering the UI. This makes them smaller and easier to test.

What's more the API class should be responsible only for the network calls. It shouldn't be responsible for managing the token. I'd inject to the API class something like:

class TokenProvider
{
   Future<String> getToken();
}

The responsibility of this class would be, you guessed it, to provide a token. It can return cached value or get it from the SharedPreferences. Thanks to this the API doesn't have to care where the token comes and how to handle it. It will do just one thing: api calls.


问:
GIT merge conflict: after create new branch and deleting some files
I have a problem with a GIT merge. In fact, I have a master branch with this architecture:

```<code>.git
doc
   \__ some files

src
   \__ tools 1
              \__ some files

   \__ tools 2
              \__ some files
</code>```

In my project, I developed tools and I will add other tools in the "src" directory. For that, for each time I want to create a new tool, I will create a new branch named "tools3" from master branch and then remove all directories that I do not need, here "tools 1", "tools 2" and "doc". The reason is that I do not need documentation and other tools to develop.

So now, after those deleting I code my "tools 3" and I commit and push it into the new branch "tools3". It's time to merge my two branches with a git merge tools3 -m "Merge tools3 branch with master branch" (in master branch).

I have two problems, first some conflicts among with documentation files:

CONFLICT MESSAGE:
CONFLICT (modify/delete): doc/api_project.json deleted in tools3 and modified in HEAD. Version HEAD of doc/api_project.json left in tree.

In the second time, the merging removes my "src" files (the ones I deleted earlier in "tools3" branch).

So, how can I fix this merge conflict and then how can I retrieve my removing files in master branch? I think I do not have the best practice to do this type of things with GIT so I am open to any suggestions about GIT practices.

答:
The conflict you're encountering is because another person has made a change in master to one of the files that you have deleted in tools3. As a result, when you're attempting to merge git needs to work out how to apply the changes that were made in master to a file that you deleted before the changes were made.

Visual representation:

```<code>*   - Added doc/api_project.json
|\
| * - Deleted doc/api_project.json
| |
* | - [master] Updated doc/api_project.json
  |
  * - [tools3] Dev work on tools
</code>```

As you can see above, to put those commits in to a single branch, git needs to know how to apply the changes made in the third commit to a file deleted in the second commit.

You shouldn't make any changes in a branch which do not apply to the feature that you're working on in that branch. By deleting files, you've created a commit that deletes those files.

Hopefully you performed the deletion as a separate commit (can we see git log output for your tools3 branch?) which would mean all you'd need to do is remove that commit from your branch before merging.

Removing the deletion operations will solve both your problems, you'll no longer have a conflict and the files that are being removed from the master branch (because you deleted them in tools3) will no longer be removed.

Body:
I have a problem with a GIT merge. In fact, I have a master branch with this architecture:

.git
doc
   \__ some files

src
   \__ tools 1
              \__ some files

   \__ tools 2
              \__ some files

In my project, I developed tools and I will add other tools in the "src" directory. For that, for each time I want to create a new tool, I will create a new branch named "tools3" from master branch and then remove all directories that I do not need, here "tools 1", "tools 2" and "doc". The reason is that I do not need documentation and other tools to develop.

So now, after those deleting I code my "tools 3" and I commit and push it into the new branch "tools3". It's time to merge my two branches with a git merge tools3 -m "Merge tools3 branch with master branch" (in master branch).

I have two problems, first some conflicts among with documentation files:

CONFLICT MESSAGE:
CONFLICT (modify/delete): doc/api_project.json deleted in tools3 and modified in HEAD. Version HEAD of doc/api_project.json left in tree.

In the second time, the merging removes my "src" files (the ones I deleted earlier in "tools3" branch).

So, how can I fix this merge conflict and then how can I retrieve my removing files in master branch? I think I do not have the best practice to do this type of things with GIT so I am open to any suggestions about GIT practices.

Body:
The conflict you're encountering is because another person has made a change in master to one of the files that you have deleted in tools3. As a result, when you're attempting to merge git needs to work out how to apply the changes that were made in master to a file that you deleted before the changes were made.

Visual representation:

*   - Added doc/api_project.json
|\
| * - Deleted doc/api_project.json
| |
* | - [master] Updated doc/api_project.json
  |
  * - [tools3] Dev work on tools

As you can see above, to put those commits in to a single branch, git needs to know how to apply the changes made in the third commit to a file deleted in the second commit.

You shouldn't make any changes in a branch which do not apply to the feature that you're working on in that branch. By deleting files, you've created a commit that deletes those files.

Hopefully you performed the deletion as a separate commit (can we see git log output for your tools3 branch?) which would mean all you'd need to do is remove that commit from your branch before merging.

Removing the deletion operations will solve both your problems, you'll no longer have a conflict and the files that are being removed from the master branch (because you deleted them in tools3) will no longer be removed.


问:
Maven downloading a specific version, how can I force to download an other?
I'm struggling with this maven project.

When I try for example to clean or package the project I get an error like this

```<code>org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
</code>```

I already done a question about that but I realised that in my maven repository I don't have the 2.5 version I only have the 2.4.1 then maven go to the central repository to find that version and throws this error.

But I don't know why maven is looking for that 2.5 version, I'm not declaring it on the pom.xml so where I can change or force maven to look 2.4.1 version?

Also I need to say that this error happens in all my projects (there are all from the same domain)

This is the pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>dom.example.exampleframe</groupId>
        <artifactId>project-parent-exampleframe</artifactId>
        <version>0.0.11.c-SNAPSHOT</version>
    </parent>

    <groupId>dom.example.project</groupId>
    <artifactId>project</artifactId>
    <version>1.9.0-SNAPSHOT</version>
    <name>project</name>
    <packaging>pom</packaging>

    <description>Esquelet d'una aplicació BaseFrame</description>
    <url>http://pro-projectes.example.pro/projects/project</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>**/ejb/*.class</exclude>
                            <exclude>**/domain/*.class</exclude>
                            <exclude>**/services/*.class</exclude>
                            <exclude>**/*Exception.class</exclude>
                            <exclude>**/Constants*.class</exclude>
                            <exclude>**/IConstants*.class</exclude>
                        </excludes>
                        <ignores>
                            <ignore>.+logger\..+</ignore>
                        </ignores>
                    </instrumentation>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- Perfils -->
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ui</module>
                <module>citizen.ui</module>
                <module>ear</module>
            </modules>
        </profile>
        <profile>
            <id>citizen</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ui</module>
                <module>citizen.ui</module>
                <module>ear</module>
            </modules>
        </profile>
        <profile>
            <id>difuse</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ear</module>
            </modules>
        </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <customBundle>${project.exampledir}/src/site/resources/project-info-report_ca.properties</customBundle>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>dependency-info</report>
                            <report>project-team</report>
                            <report>summary</report>
                            <report>scm</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.14.1</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- Només s'ha d'incloure-hi la definició -->
                    <excludePackageNames>dom.example.project.serveis.ejb;dom.example.project.serveis.impl;dom.example.project.ui</excludePackageNames>
                    <!-- No hem d'incloure-hi els arxius de test -->
                    <excludes>**/*Test.java</excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changes-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <xmlPath>${exampledir}/src/site/changes.xml</xmlPath>
                    <issueLinkTemplatePerSystem>
                        <Redmine2><![CDATA[%URL%/issues/%ISSUE%]]></Redmine2>
                    </issueLinkTemplatePerSystem>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>changes-report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>cobertura</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>

    <distributionManagement>
        <site>
            <id>mavendocs-example</id>
            <name>mavendocs.example.dom</name>
            <url>${example.url.mavendocs}</url>
        </site>
    </distributionManagement>

    <modules>
        <module>domain</module>
        <module>recources</module>
        <module>logic</module>
        <module>ejb</module>
        <module>ui</module>
        <module>citizen.ui</module>
        <module>ear</module>
        <module>test</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>dom.example.tip</groupId>
            <artifactId>tip.domain</artifactId>
            <version>1.7.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.sca</groupId>
            <artifactId>sca.domain</artifactId>
            <version>1.3.4-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gea</groupId>
            <artifactId>gea.domain</artifactId>
            <version>2.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>examplegd</groupId>
            <artifactId>examplegd.domain</artifactId>
            <version>1.2.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- Dependències del servei de registre. -->
        <dependency>
            <groupId>dom.example.res</groupId>
            <artifactId>res.domain</artifactId>
            <version>1.14.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <!-- Dependències del mòdul d'ASF. -->
        <dependency>
            <groupId>dom.example.exampleframe.modules.asf</groupId>
            <artifactId>bf-modul-asf</artifactId>
            <version>0.0.2-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.alerts</groupId>
            <artifactId>alerts.domain</artifactId>
            <version>0.0.3-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gmc</groupId>
            <artifactId>gmc.domain</artifactId>
            <version>1.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gmc</groupId>
            <artifactId>gmc.recursos</artifactId>
            <version>1.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.exampleframe</groupId>
            <artifactId>exampleframe-transicio</artifactId>
            <version>[0.12.,1.0)</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
</code>```

答: This should have been mentioned in one of your pom files either the child or in one of your parent or grandparent poms. You can use effective-pom goal to see the entire POM structure. This is the goal - org.apache.maven.plugins:maven-help-plugin:3.2.0:effective-pom</p>

Body:
I'm struggling with this maven project.

When I try for example to clean or package the project I get an error like this

org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5

I already done a question about that but I realised that in my maven repository I don't have the 2.5 version I only have the 2.4.1 then maven go to the central repository to find that version and throws this error.

But I don't know why maven is looking for that 2.5 version, I'm not declaring it on the pom.xml so where I can change or force maven to look 2.4.1 version?

Also I need to say that this error happens in all my projects (there are all from the same domain)

This is the pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>dom.example.exampleframe</groupId>
        <artifactId>project-parent-exampleframe</artifactId>
        <version>0.0.11.c-SNAPSHOT</version>
    </parent>

    <groupId>dom.example.project</groupId>
    <artifactId>project</artifactId>
    <version>1.9.0-SNAPSHOT</version>
    <name>project</name>
    <packaging>pom</packaging>

    <description>Esquelet d'una aplicació BaseFrame</description>
    <url>http://pro-projectes.example.pro/projects/project</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>**/ejb/*.class</exclude>
                            <exclude>**/domain/*.class</exclude>
                            <exclude>**/services/*.class</exclude>
                            <exclude>**/*Exception.class</exclude>
                            <exclude>**/Constants*.class</exclude>
                            <exclude>**/IConstants*.class</exclude>
                        </excludes>
                        <ignores>
                            <ignore>.+logger\..+</ignore>
                        </ignores>
                    </instrumentation>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ui</module>
                <module>citizen.ui</module>
                <module>ear</module>
            </modules>
        </profile>
        <profile>
            <id>citizen</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ui</module>
                <module>citizen.ui</module>
                <module>ear</module>
            </modules>
        </profile>
        <profile>
            <id>difuse</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <modules>
                <module>domain</module>
                <module>logic</module>
                <module>resources</module>
                <module>ejb</module>
                <module>ear</module>
            </modules>
        </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <customBundle>${project.exampledir}/src/site/resources/project-info-report_ca.properties</customBundle>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>dependency-info</report>
                            <report>project-team</report>
                            <report>summary</report>
                            <report>scm</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.14.1</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>

                    <excludePackageNames>dom.example.project.serveis.ejb;dom.example.project.serveis.impl;dom.example.project.ui</excludePackageNames>

                    <excludes>**/*Test.java</excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changes-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <xmlPath>${exampledir}/src/site/changes.xml</xmlPath>
                    <issueLinkTemplatePerSystem>
                        <Redmine2><![CDATA[%URL%/issues/%ISSUE%]]></Redmine2>
                    </issueLinkTemplatePerSystem>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>changes-report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>cobertura</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>

    <distributionManagement>
        <site>
            <id>mavendocs-example</id>
            <name>mavendocs.example.dom</name>
            <url>${example.url.mavendocs}</url>
        </site>
    </distributionManagement>

    <modules>
        <module>domain</module>
        <module>recources</module>
        <module>logic</module>
        <module>ejb</module>
        <module>ui</module>
        <module>citizen.ui</module>
        <module>ear</module>
        <module>test</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>dom.example.tip</groupId>
            <artifactId>tip.domain</artifactId>
            <version>1.7.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.sca</groupId>
            <artifactId>sca.domain</artifactId>
            <version>1.3.4-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gea</groupId>
            <artifactId>gea.domain</artifactId>
            <version>2.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>examplegd</groupId>
            <artifactId>examplegd.domain</artifactId>
            <version>1.2.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>dom.example.res</groupId>
            <artifactId>res.domain</artifactId>
            <version>1.14.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>dom.example.exampleframe.modules.asf</groupId>
            <artifactId>bf-modul-asf</artifactId>
            <version>0.0.2-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.alerts</groupId>
            <artifactId>alerts.domain</artifactId>
            <version>0.0.3-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gmc</groupId>
            <artifactId>gmc.domain</artifactId>
            <version>1.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.gmc</groupId>
            <artifactId>gmc.recursos</artifactId>
            <version>1.5.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dom.example.exampleframe</groupId>
            <artifactId>exampleframe-transicio</artifactId>
            <version>[0.12.,1.0)</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>


问:
convert month-day-year into day-month-year using javascript
I'm trying to convert a MM/DD/YYYY date to a long date. So for example, 02/16/2020 would convert to something like 16/02/2020.

Is there a way to make this date conversion accurately?

答:
Use moment for date formatting:

Sample Code:

```<code>moment('02/16/2020').format('16/02/2020');
</code>```

You can play with date by moment.js. It is very useful tool for javascript developer.

Momemet Js Document

For dynamic value:

```<code>moment(yourDate, 'MM/DD/YYYY').format('DD/MM/YYYY');
</code>```

Here, yourDate is your dynamic value date.

Body:
Use moment for date formatting:

Sample Code:

moment('02/16/2020').format('16/02/2020');

You can play with date by moment.js. It is very useful tool for javascript developer.

Momemet Js Document

For dynamic value:

moment(yourDate, 'MM/DD/YYYY').format('DD/MM/YYYY');

Here, yourDate is your dynamic value date.


问:
ASP.NET MVC - HtmlEncode all strings by default
For example, a user creates a new question on a forum.

I send ajax to the server, then I use HtmlEncode to exclude the HTML code before saving it in the database.

Is it possible that HtmlEncode would be used automatically when receiving a request?

Also, when using the attribute (for example [HtmlAllowed]) you can allow html code in request.

Thanks

答:
You can achieve it using custom model binder, every string property or string parameter will go through this method when ASP.NET attempts to bind request to parameters of action method

```<code>public class StringBinder : IModelBinder
{
    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
        bindingContext.ModelState.SetModelValue(bindingContext.ModelName, value);

        var str = (string)value?.ConvertTo(typeof(string));

        str = HttpUtility.HtmlEncode(str);
        return str;
    }
}
</code>```

And in Application_Start()

```<code>ModelBinders.Binders.Add(typeof(string), new StringBinder());
</code>```

Body:
You can achieve it using custom model binder, every string property or string parameter will go through this method when ASP.NET attempts to bind request to parameters of action method

public class StringBinder : IModelBinder
{
    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
        bindingContext.ModelState.SetModelValue(bindingContext.ModelName, value);

        var str = (string)value?.ConvertTo(typeof(string));

        str = HttpUtility.HtmlEncode(str);
        return str;
    }
}

And in Application_Start()

ModelBinders.Binders.Add(typeof(string), new StringBinder());


问:
passing list of strings in efficient way
```<code>#include <iostream>
#include <vector>
#include <string>

void function1(const char** keywords) {  // C like
    for (const char** keyword = keywords; *keyword; ++keyword) {
        std::cout << *keyword << std::endl;
    }
}

void function2(const std::vector<std::string>& keywords) {  // C++11 like
    for(const std::string& keyword : keywords) {
        std::cout << keyword << std::endl;
    }
}

int main() {
    static const char* keywords[] = { "hello", "world", "!", 0 };
    function1(keywords);
    function2({ "hello", "world", "!" });
    return 0;
}
</code>```

Both functions do the same result. I like the new c++11 format of initialization where values are inline and I can skip empty value (zero). The issue is a performance. I expect that function2 will dynamically alocate memory on each invoke. I suppose it wan't be efficient. Is there a better way to implement such function with c++ manner keeping old C efficency?

Update:

There is a little misunderstanding. My concern is usage of std::vector which provokes dynamic memory allocation. In fact I would use std::string in the body of function1 so std::string allocation is not a case. The same std::cout was added by me as an example of usage (not a real case). std::array cannot be used here becouse length of list is not fixed.

I extend my question:
Goal is use only one argument with default empty value to pass list of strings. How to achieve this in most effient and pretty-look way?

So above functions' declarations may look as follows:

```<code>void function1(const char** keywords = nullptr)

void function2(const std::vector<std::string>& keywords = {})
</code>```

Here I see the next problem. Invoking function1 without parameter cost nothing but I expect empty vector initialization in function2. Am I right?

答:
The problem here is that C and C++ compilers are now optimizing compilers... As both function have the same observable result, and as this can be guessed at compile time, a compiler is free to implement function2 the same as function 1 by inlining it.

Even if it does not inline the function, the vector could be prepared at compile time, saving a lot of boiler plate construction.

But you then fall on the dark part in you want to use the code on more that one system: you cannot make sure the way a specific compiler will translate it.

So you fall on the usual rule for low level optimization: it does not really make sense of a language point of view, but only for a specific implementation with a specific configuration (compilation and linking options). And then the only reliable way are assembly code reading and benchmarking for different versions of the code.

Body:
#include <iostream>
#include <vector>
#include <string>

void function1(const char** keywords) {  // C like
    for (const char** keyword = keywords; *keyword; ++keyword) {
        std::cout << *keyword << std::endl;
    }
}

void function2(const std::vector<std::string>& keywords) {  // C++11 like
    for(const std::string& keyword : keywords) {
        std::cout << keyword << std::endl;
    }
}

int main() {
    static const char* keywords[] = { "hello", "world", "!", 0 };
    function1(keywords);
    function2({ "hello", "world", "!" });
    return 0;
}

Both functions do the same result. I like the new c++11 format of initialization where values are inline and I can skip empty value (zero). The issue is a performance. I expect that function2 will dynamically alocate memory on each invoke. I suppose it wan't be efficient. Is there a better way to implement such function with c++ manner keeping old C efficency?

Update:

There is a little misunderstanding. My concern is usage of std::vector which provokes dynamic memory allocation. In fact I would use std::string in the body of function1 so std::string allocation is not a case. The same std::cout was added by me as an example of usage (not a real case). std::array cannot be used here becouse length of list is not fixed.

I extend my question:
Goal is use only one argument with default empty value to pass list of strings. How to achieve this in most effient and pretty-look way?

So above functions' declarations may look as follows:

void function1(const char** keywords = nullptr)

void function2(const std::vector<std::string>& keywords = {})

Here I see the next problem. Invoking function1 without parameter cost nothing but I expect empty vector initialization in function2. Am I right?


问:
Find out which remote branch a local branch is tracking

See also:

  How can I see which Git branches are tracking which remote / upstream branch?

How can I find out which remote branch a local branch is tracking?

Do I need to parse git config output, or is there a command that would do this for me?

答:
git-status porcelain (machine-readable) v2 output looks like this:

```<code>$ git status -b --porcelain=v2
# branch.oid d0de00da833720abb1cefe7356493d773140b460
# branch.head the-branch-name
# branch.upstream gitlab/the-branch-name
# branch.ab +2 -2
</code>```

And to get the branch upstream only:

```<code>$ git status -b --porcelain=v2 | grep -m 1 "^# branch.upstream " | cut -d " " -f 3-
gitlab/the-branch-name
</code>```

If the branch has no upstream, the above command will produce an empty output (or fail with set -o pipefail).

OwnerDisplayName: Readonly

Body:
git-status porcelain (machine-readable) v2 output looks like this:

$ git status -b --porcelain=v2
# branch.oid d0de00da833720abb1cefe7356493d773140b460
# branch.head the-branch-name
# branch.upstream gitlab/the-branch-name
# branch.ab +2 -2

And to get the branch upstream only:

$ git status -b --porcelain=v2 | grep -m 1 "^# branch.upstream " | cut -d " " -f 3-
gitlab/the-branch-name

If the branch has no upstream, the above command will produce an empty output (or fail with set -o pipefail).


问:
Vertical Carousel Layout android
```<code>public class MainActivity extends AppCompatActivity {

    private FeatureCoverFlow coverFlow;
    private CoverFlowAdapter adapter;
    private ArrayList<Game> games;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        coverFlow = (FeatureCoverFlow) findViewById(R.id.coverflow);

        settingDummyData();
        adapter = new CoverFlowAdapter(this, games);
        coverFlow.setAdapter(adapter);
        coverFlow.setOnScrollPositionListener(onScrollListener());
    }

    private FeatureCoverFlow.OnScrollPositionListener onScrollListener() {
        return new FeatureCoverFlow.OnScrollPositionListener() {
            @Override
            public void onScrolledToPosition(int position) {
                Log.v("MainActiivty", "position: " + position);
            }

            @Override
            public void onScrolling() {
                Log.i("MainActivity", "scrolling");
            }
        };
    }

    private void settingDummyData() {
        games = new ArrayList<>();
        games.add(new Game(R.mipmap.assassins_creed, "Assassin Creed 3"));
        games.add(new Game(R.mipmap.avatar_3d, "Avatar 3D"));
        games.add(new Game(R.mipmap.call_of_duty_black_ops_3, "Call Of Duty Black Ops 3"));
        games.add(new Game(R.mipmap.dota_2, "DotA 2"));
        games.add(new Game(R.mipmap.halo_5, "Halo 5"));
        games.add(new Game(R.mipmap.left_4_dead_2, "Left 4 Dead 2"));
        games.add(new Game(R.mipmap.starcraft, "StarCraft"));
        games.add(new Game(R.mipmap.the_witcher_3, "The Witcher 3"));
        games.add(new Game(R.mipmap.tomb_raider, "Tom raider 3"));
        games.add(new Game(R.mipmap.need_for_speed_most_wanted, "Need for Speed Most Wanted"));
    }
}
</code>```

<p>//this is my activity</p>

```<code>public class CoverFlowAdapter extends BaseAdapter {

    private ArrayList<Game> data;
    private AppCompatActivity activity;

    public CoverFlowAdapter(AppCompatActivity context, ArrayList<Game> objects) {
        this.activity = context;
        this.data = objects;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Game getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.item_flow_view, null, false);

            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.gameImage.setImageResource(data.get(position).getImageSource());
        viewHolder.gameName.setText(data.get(position).getName());

        convertView.setOnClickListener(onClickListener(position));

        return convertView;
    }

    private View.OnClickListener onClickListener(final int position) {
        return new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(activity);
                dialog.setContentView(R.layout.dialog_game_info);
                dialog.setCancelable(true); // dimiss when touching outside
                dialog.setTitle("Game Details");

                TextView text = (TextView) dialog.findViewById(R.id.name);
                text.setText(getItem(position).getName());
                ImageView image = (ImageView) dialog.findViewById(R.id.image);
                image.setImageResource(getItem(position).getImageSource());

                dialog.show();
            }
        };
    }

    private static class ViewHolder {
        private TextView gameName;
        private ImageView gameImage;

        public ViewHolder(View v) {
            gameImage = (ImageView) v.findViewById(R.id.image);
            gameName = (TextView) v.findViewById(R.id.name);
        }
    }
}
</code>```

<p>//This is my adapter.Now everythings runs fine but I want to make this coverflow vertically.there is no option of setting orientation in xml..I have tried http://www.codeproject.com/Articles/146145/Android-3D-Carousel.. But I don't want this type of carousel layout I need simple vertical carousel layout.  </p>

答:
Now you can achieve this using viewpager2. We can specify Orientation like recyclerview 'viewPager.orientation = ORIENTATION_VERTICAL'.

Go through this

https://developer.android.com/jetpack/androidx/releases/viewpager2

https://medium.com/google-developer-experts/exploring-the-view-pager-2-86dbce06ff71

Title: Vertical Carousel Layout android

Body:
public class MainActivity extends AppCompatActivity {

    private FeatureCoverFlow coverFlow;
    private CoverFlowAdapter adapter;
    private ArrayList<Game> games;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        coverFlow = (FeatureCoverFlow) findViewById(R.id.coverflow);

        settingDummyData();
        adapter = new CoverFlowAdapter(this, games);
        coverFlow.setAdapter(adapter);
        coverFlow.setOnScrollPositionListener(onScrollListener());
    }

    private FeatureCoverFlow.OnScrollPositionListener onScrollListener() {
        return new FeatureCoverFlow.OnScrollPositionListener() {
            @Override
            public void onScrolledToPosition(int position) {
                Log.v("MainActiivty", "position: " + position);
            }

            @Override
            public void onScrolling() {
                Log.i("MainActivity", "scrolling");
            }
        };
    }

    private void settingDummyData() {
        games = new ArrayList<>();
        games.add(new Game(R.mipmap.assassins_creed, "Assassin Creed 3"));
        games.add(new Game(R.mipmap.avatar_3d, "Avatar 3D"));
        games.add(new Game(R.mipmap.call_of_duty_black_ops_3, "Call Of Duty Black Ops 3"));
        games.add(new Game(R.mipmap.dota_2, "DotA 2"));
        games.add(new Game(R.mipmap.halo_5, "Halo 5"));
        games.add(new Game(R.mipmap.left_4_dead_2, "Left 4 Dead 2"));
        games.add(new Game(R.mipmap.starcraft, "StarCraft"));
        games.add(new Game(R.mipmap.the_witcher_3, "The Witcher 3"));
        games.add(new Game(R.mipmap.tomb_raider, "Tom raider 3"));
        games.add(new Game(R.mipmap.need_for_speed_most_wanted, "Need for Speed Most Wanted"));
    }
}

//this is my activity

public class CoverFlowAdapter extends BaseAdapter {

    private ArrayList<Game> data;
    private AppCompatActivity activity;

    public CoverFlowAdapter(AppCompatActivity context, ArrayList<Game> objects) {
        this.activity = context;
        this.data = objects;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Game getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.item_flow_view, null, false);

            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.gameImage.setImageResource(data.get(position).getImageSource());
        viewHolder.gameName.setText(data.get(position).getName());

        convertView.setOnClickListener(onClickListener(position));

        return convertView;
    }

    private View.OnClickListener onClickListener(final int position) {
        return new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(activity);
                dialog.setContentView(R.layout.dialog_game_info);
                dialog.setCancelable(true); // dimiss when touching outside
                dialog.setTitle("Game Details");

                TextView text = (TextView) dialog.findViewById(R.id.name);
                text.setText(getItem(position).getName());
                ImageView image = (ImageView) dialog.findViewById(R.id.image);
                image.setImageResource(getItem(position).getImageSource());

                dialog.show();
            }
        };
    }

    private static class ViewHolder {
        private TextView gameName;
        private ImageView gameImage;

        public ViewHolder(View v) {
            gameImage = (ImageView) v.findViewById(R.id.image);
            gameName = (TextView) v.findViewById(R.id.name);
        }
    }
}

//This is my adapter.Now everythings runs fine but I want to make this coverflow vertically.there is no option of setting orientation in xml..I have tried http://www.codeproject.com/Articles/146145/Android-3D-Carousel.. But I don't want this type of carousel layout I need simple vertical carousel layout.


问:
IOS App language not change on click button using LanguageManager-iOS-Lokalise0.1.3
I am using LanguageManager-iOS-Lokalise0.1.3 library for changing app language. This works if i restart the App. I want to change app language at run time on click of button. How can I achieve that using LanguageManager-iOS-Lokalise.

答:
No it is not possible, because you need to re render the view controller. One way is to pop to rootView controller and after language change.
P.S you need to change .semanticContentAttribute  to .forceRightToLeft for all class you want to change RToL