问:
How Important is to understand Erlang VM to learn Elixir
I am new to Elixir, even new to functional programming. I know python and Java. I use them for my data-science project. Is it necessary to understand Erlang VM to learn Elixir? If yes then how I can understand Erlang VM ?

If there is a guideline to follow to learn Elixir, it will be very beneficial for people like me.

答:
It probably isn't necessary to understand the erlang syntax outside of how to call erlang functions in elixir. Its fun to learn erlang(the language) but the more important part to understand are the things about the BEAM (the erlang/elixir VM) like..

The Actor Model https://www.youtube.com/watch?v=7erJ1DV_Tlo which will be an intro understanding to the next point..

Processes, Supervisors & Workers http://learnyousomeerlang.com/building-applications-with-otp

learn things like the "let it crash mantra" how that changes why you don't hardly ever see (and shouldn't rely on) try/catches in elixir.

immutable data

ets tables and other types of storage that the BEAM provides by default.

how to spin up/use processes

clustering

These are some of the things that the VM gives you. And some of the architecture that make the patterns you will see in elixir different
then many other languages.


来源: stackexchange

问:
Swift array reduction: cannot use mutating member on immutable value
I have the following code that attempts to consolidate redundant elements of an array:

```<code>var items : [String] = ["hello", "world", "!", "hello"]

var mutableSet = Set<String>()

items.reduce(mutableSet, combine: { (set: Set<String>, element: String) in
    return set.insert(element)
})
</code>```

set.insert(element) gives me the error Cannot use mutating member on immutable value: 'set' is a 'let' constant. What's wrong and how can I fix it?

答:
The problem with the OP's code is that the accumulator in the reduce is immutable so it won't allow you to use the mutating function insert().

A tidy solution is to define an non-mutating equivalent to insert() called inserting() in an extension to Set as follows.

```<code>extension Set {
    //returns a new set with the element inserted
    func inserting(_ element: Element) -> Set<Element> {
        var set = self
        set.insert(element)
        return set
    }
}
</code>```

Now we can write the reduce as follows

```<code>var items : [String] = ["hello", "world", "!", "hello"]

let set = items.reduce(Set<String>()){ accumulator, element in
    accumulator.inserting(element)
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have the following code that attempts to consolidate redundant elements of an array:

var items : [String] = ["hello", "world", "!", "hello"]

var mutableSet = Set<String>()

items.reduce(mutableSet, combine: { (set: Set<String>, element: String) in
    return set.insert(element)
})

set.insert(element) gives me the error Cannot use mutating member on immutable value: 'set' is a 'let' constant. What's wrong and how can I fix it?

Body:
The problem with the OP's code is that the accumulator in the reduce is immutable so it won't allow you to use the mutating function insert().

A tidy solution is to define an non-mutating equivalent to insert() called inserting() in an extension to Set as follows.

extension Set {
    //returns a new set with the element inserted
    func inserting(_ element: Element) -> Set<Element> {
        var set = self
        set.insert(element)
        return set
    }
}

Now we can write the reduce as follows

var items : [String] = ["hello", "world", "!", "hello"]

let set = items.reduce(Set<String>()){ accumulator, element in
    accumulator.inserting(element)
}


问:
what is the macro used for in a vtkobject?
what is macro used for in a vtkobject?

example

```<code>vtkStandardNewMacro(vtkLidarPoint);
</code>```

And why is the constructor static?

```<code>static vtkLidarPoint *New();
</code>```

答:
It's not a constructor. It's a factory method.

The macro looks like it just implements the factory method. See here.

Body:
what is macro used for in a vtkobject?

example

vtkStandardNewMacro(vtkLidarPoint);

And why is the constructor static?

static vtkLidarPoint *New();


答: the answer to this is 33 107. Based off the last comparison statement in the main code we can see that the second number has to be equivalent to 0x6b which is 107 in decimal else it will explode. To get the first number I simply examined the dump code for func4 and saw that it was going through a binary search. Since we know from the main code that the value of the first number has to be between 19 and 35 based off the two comparisons, we can pick 27 as our first guess and see that the number needs to be higher than 27. Going through the registers at different stages throughout the code helped! </p>

Title: Binary Bomb Phase 4, Stepping into func4 call

Body:
So I'm having some trouble with this assembly code and finding out what two digits are the answers. All I know is the input is supposed to be two digits separated by a space and based off the last comparison the last digit should equal 0x6b which is 107 in decimal. Func4 does something to the eax value to make it 107 but I'm not really sure. So what two numbers will be taken as input?. Any help would be appreciated.

0x000000000040135a <+0>:    sub    $0x18,%rsp
0x000000000040135e <+4>:    lea    0x8(%rsp),%rcx
0x0000000000401363 <+9>:    lea    0xc(%rsp),%rdx
0x0000000000401368 <+14>:   mov    $0x402e78,%esi
0x000000000040136d <+19>:   mov    $0x0,%eax
0x0000000000401372 <+24>:   callq  0x400d60 <__isoc99_sscanf@plt>
0x0000000000401377 <+29>:   cmp    $0x2,%eax
0x000000000040137a <+32>:   jne    0x40138a <phase_4+48>
0x000000000040137c <+34>:   mov    0xc(%rsp),%eax
0x0000000000401380 <+38>:   cmp    $0x13,%eax
0x0000000000401383 <+41>:   jle    0x40138a <phase_4+48>
0x0000000000401385 <+43>:   cmp    $0x23,%eax
0x0000000000401388 <+46>:   jle    0x401395 <phase_4+59>
0x000000000040138a <+48>:   mov    $0x0,%eax
0x000000000040138f <+53>:   callq  *0x20340b(%rip)  <explode_bomb>
0x0000000000401395 <+59>:   mov    $0x23,%edx
0x000000000040139a <+64>:   mov    $0x0,%esi
0x000000000040139f <+69>:   mov    0xc(%rsp),%edi
0x00000000004013a3 <+73>:   callq  0x4010bc <func4>
0x00000000004013a8 <+78>:   cmp    $0x6b,%eax
0x00000000004013ab <+81>:   jne    0x4013b4 <phase_4+90>
0x00000000004013ad <+83>:   cmpl   $0x6b,0x8(%rsp)
0x00000000004013b2 <+88>:   je     0x4013bf <phase_4+101>
0x00000000004013b4 <+90>:   mov    $0x0,%eax
0x00000000004013b9 <+95>:   callq  *0x2033e1(%rip)       <explode_bomb>
0x00000000004013bf <+101>:  add    $0x18,%rsp
0x00000000004013c3 <+105>:  retq

step into func4

 0x00000000004010bc <+0>:   push   %rbx
 0x00000000004010bd <+1>:   mov    %edx,%eax
 0x00000000004010bf <+3>:   sub    %esi,%eax
 0x00000000004010c1 <+5>:   mov    %eax,%ebx
 0x00000000004010c3 <+7>:   shr    $0x1f,%ebx
 0x00000000004010c6 <+10>:  lea    (%rbx,%rax,1),%eax
 0x00000000004010c9 <+13>:  sar    %eax
 0x00000000004010cb <+15>:  lea    (%rax,%rsi,1),%ebx
 0x00000000004010ce <+18>:  cmp    %edi,%ebx
 0x00000000004010d0 <+20>:  jle    0x4010de <func4+34>
 0x00000000004010d2 <+22>:  lea    -0x1(%rbx),%edx
 0x00000000004010d5 <+25>:  callq  0x4010bc <func4>
 0x00000000004010da <+30>:  add    %eax,%ebx
 0x00000000004010dc <+32>:  jmp    0x4010ec <func4+48>
 0x00000000004010de <+34>:  cmp    %edi,%ebx
 0x00000000004010e0 <+36>:  jge    0x4010ec <func4+48>
 0x00000000004010e2 <+38>:  lea    0x1(%rbx),%esi
 0x00000000004010e5 <+41>:  callq  0x4010bc <func4>
 0x00000000004010ea <+46>:  add    %eax,%ebx
 0x00000000004010ec <+48>:  mov    %ebx,%eax
 0x00000000004010ee <+50>:  pop    %rbx
 0x00000000004010ef <+51>:  retq


问:
Remove everything between tag Regex
I m trying to remove everything inside any html tag:

input:

```<code><a class="yoyo"> <h1 id="test"> hello </h1> </a>
</code>```

weird example but well

output:

```<code><a><h1>hello</h1></a>
</code>```

I ve tried /(<\w)(?:.*)(>)/gmi but its not working...

If you have any clue on that .
Thanks

So to explain it more after your comment I scrapped a website and I have a .txt file that i wanna clean. It will contain the whole html of a page and i want to clean every single html tag and remove the spaces aswell.
So everything between any <* and > should be removed.

答:
Do this using DOM methods. Loop over all elements, iterate the attributes and remove them

let cont = document.getElementById('demo-container'),
  els = cont.querySelectorAll('*');

[].slice.call(els).forEach(el => {
  [].slice.call(el.attributes).forEach(attr => {
    el.removeAttribute(attr.name);
  })
});

console.log(cont.innerHTML)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="demo-container">

    <h1 id="test"> hello </h1>

</div></code>```

Title: Remove everything between tag Regex

Body:
I m trying to remove everything inside any html tag:

input:

 hello

weird example but well

output:

hello

I ve tried /(<\w)(?:.*)(>)/gmi but its not working...

If you have any clue on that .
Thanks

So to explain it more after your comment I scrapped a website and I have a .txt file that i wanna clean. It will contain the whole html of a page and i want to clean every single html tag and remove the spaces aswell.
So everything between any <* and > should be removed.

Body:
Do this using DOM methods. Loop over all elements, iterate the attributes and remove them

let cont = document.getElementById('demo-container'),
  els = cont.querySelectorAll('*');

[].slice.call(els).forEach(el => {
  [].slice.call(el.attributes).forEach(attr => {
    el.removeAttribute(attr.name);
  })
});

console.log(cont.innerHTML)

<div id="demo-container">
  <a class="yoyo">
    <h1 id="test"> hello </h1>
  </a>
</div>


问:
XSLT Transformation get element based on condition and map it to sibling
I need to transfrom xml with the below rule. Iam stuck in transformation.

Rule as below:

For each match of ns1:Account/ns3:Policies/ns3:Policy/ns3:PolicyConditions/ns3:PolicyCondition/ns3:PolicyConditionCriteria/ns3:Value that matches with ns1:Account/ns3:Locations/ns3:Name.I need to get the value of ns1:Account/ns3:Policies/ns3:Policy/ns3:PolicyConditions/ns3:PolicyCondition/ns2:ItemData and create new tag and map it to ns1:Account/ns3:Locations/ns3:LocationConditions/ns3:LocationCondition/ns2:ConditionId and hardcode ns1:Account/ns3:Locations/ns3:LocationConditions/ns3:LocationCondition/ns2:ConditionId to 0

Attached sample input and expected output

Input XML:

```<code><ns1:Account xmlns:ns1="API.ExposureWorkflow">
   <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
   <ns3:Locations xmlns:ns3="API.Objects.Exposure">
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC1-BU1</ns3:Name>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU1</ns3:Name>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU3</ns3:Name>
      </ns3:Location>
   </ns3:Locations>
   <ns3:Policies xmlns:ns3="API.Objects.Exposure">
      <ns3:Policy>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:PolicyConditions>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns3:PolicyConditionCriterias/>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">28</ns2:ItemData>
               <ns3:Name>EQ Blanket28</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">29</ns2:ItemData>
               <ns3:Name>EQ Blanket29</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU3</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
         </ns3:PolicyConditions>
      </ns3:Policy>
   </ns3:Policies>
</ns1:Account>
</code>```

XSLT:

```<code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:ns1="API.ExposureWorkflow" xmlns:ns2="API.Objects" xmlns:ns3="API.Objects.Exposure">
                <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

                <!-- template to copy elements -->
                <xsl:template match="*">
                                <xsl:element name="{name()}">
                                                <xsl:apply-templates select="@* | node()"/>
                                </xsl:element>
                </xsl:template>
                <!-- template to copy attributes -->
                <xsl:template match="@*">
                                <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
                </xsl:template>
                <!-- template to copy the rest of the nodes -->
                <xsl:template match="comment() | text() | processing-instruction()">
                                <xsl:copy/>
                </xsl:template>
</xsl:stylesheet>
</code>```

Expected ouput:

```<code><ns1:Account xmlns:ns1="API.ExposureWorkflow">
   <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
   <ns3:Locations xmlns:ns3="API.Objects.Exposure">
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC1-BU1</ns3:Name>
          <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">28</ns2:ConditionId>
            </ns3:LocationCondition>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">29</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU1</ns3:Name>
         <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">28</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU3</ns3:Name>
         <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">29</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
   </ns3:Locations>
   <ns3:Policies xmlns:ns3="API.Objects.Exposure">
      <ns3:Policy>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:PolicyConditions>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns3:PolicyConditionCriterias/>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">28</ns2:ItemData>
               <ns3:Name>EQ Blanket28</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">29</ns2:ItemData>
               <ns3:Name>EQ Blanket29</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU3</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
         </ns3:PolicyConditions>
      </ns3:Policy>
   </ns3:Policies>
</ns1:Account>
</code>```

答:
I managed to translate the xml,just was thinking if there is any better easy way to implement.

```<code>    <xsl:for-each select="ns3:Location">
        <xsl:variable name="locationName">
            <xsl:value-of select="ns3:Name" />
        </xsl:variable>
        <xsl:copy>
            <xsl:apply-templates select="@* | node()" />
            <ns3:LocConditions>
                <xsl:for-each select="//ns3:PolicyConditions/ns3:PolicyCondition">
                    <xsl:for-each
                        select="ns3:PolicyConditionCriterias/ns3:PolicyConditionCriteria">
                        <xsl:if test="ns3:Value=$locationName">
                            <!--Zero or more repetitions: -->
                            <ns3:LocCondition>
                                <ns2:Id>0</ns2:Id>

                                <ns2:ConditionId>
                                    <xsl:value-of select="../../ns2:ItemData" />

                                </ns2:ConditionId>
                            </ns3:LocCondition>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:for-each>
            </ns3:LocConditions>
        </xsl:copy>
    </xsl:for-each>

</xsl:template>

            <!-- template to copy elements -->
            <xsl:template match="*">
                            <xsl:element name="{name()}">
                                            <xsl:apply-templates select="@* | node()"/>
                            </xsl:element>
            </xsl:template>
            <!-- template to copy attributes -->
            <xsl:template match="@*">
                            <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
            </xsl:template>
            <!-- template to copy the rest of the nodes -->
            <xsl:template match="comment() | text() | processing-instruction()">
                            <xsl:copy/>
            </xsl:template>
</code>```

Body:
I need to transfrom xml with the below rule. Iam stuck in transformation.

Rule as below:

For each match of ns1:Account/ns3:Policies/ns3:Policy/ns3:PolicyConditions/ns3:PolicyCondition/ns3:PolicyConditionCriteria/ns3:Value that matches with ns1:Account/ns3:Locations/ns3:Name.I need to get the value of ns1:Account/ns3:Policies/ns3:Policy/ns3:PolicyConditions/ns3:PolicyCondition/ns2:ItemData and create new tag and map it to ns1:Account/ns3:Locations/ns3:LocationConditions/ns3:LocationCondition/ns2:ConditionId and hardcode ns1:Account/ns3:Locations/ns3:LocationConditions/ns3:LocationCondition/ns2:ConditionId to 0

Attached sample input and expected output

Input XML:

<ns1:Account xmlns:ns1="API.ExposureWorkflow">
   <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
   <ns3:Locations xmlns:ns3="API.Objects.Exposure">
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC1-BU1</ns3:Name>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU1</ns3:Name>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU3</ns3:Name>
      </ns3:Location>
   </ns3:Locations>
   <ns3:Policies xmlns:ns3="API.Objects.Exposure">
      <ns3:Policy>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:PolicyConditions>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns3:PolicyConditionCriterias/>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">28</ns2:ItemData>
               <ns3:Name>EQ Blanket28</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">29</ns2:ItemData>
               <ns3:Name>EQ Blanket29</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU3</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
         </ns3:PolicyConditions>
      </ns3:Policy>
   </ns3:Policies>
</ns1:Account>

XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:ns1="API.ExposureWorkflow" xmlns:ns2="API.Objects" xmlns:ns3="API.Objects.Exposure">
                <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

                <xsl:template match="*">
                                <xsl:element name="{name()}">
                                                <xsl:apply-templates select="@* | node()"/>
                                </xsl:element>
                </xsl:template>

                <xsl:template match="@*">
                                <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
                </xsl:template>

                <xsl:template match="comment() | text() | processing-instruction()">
                                <xsl:copy/>
                </xsl:template>
</xsl:stylesheet>

Expected ouput:

<ns1:Account xmlns:ns1="API.ExposureWorkflow">
   <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
   <ns3:Locations xmlns:ns3="API.Objects.Exposure">
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC1-BU1</ns3:Name>
          <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">28</ns2:ConditionId>
            </ns3:LocationCondition>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">29</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU1</ns3:Name>
         <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">28</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
      <ns3:Location>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:Name>LOC2-BU3</ns3:Name>
         <ns3:LocationConditions>
            <ns3:LocationCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ConditionId xmlns:ns2="API.Objects">29</ns2:ConditionId>
            </ns3:LocationCondition>
      </ns3:LocationConditions>
      </ns3:Location>
   </ns3:Locations>
   <ns3:Policies xmlns:ns3="API.Objects.Exposure">
      <ns3:Policy>
         <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
         <ns3:PolicyConditions>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns3:PolicyConditionCriterias/>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">28</ns2:ItemData>
               <ns3:Name>EQ Blanket28</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
            <ns3:PolicyCondition>
               <ns2:Id xmlns:ns2="API.Objects">0</ns2:Id>
               <ns2:ItemData xmlns:ns2="API.Objects">29</ns2:ItemData>
               <ns3:Name>EQ Blanket29</ns3:Name>
               <ns3:PolicyConditionCriterias>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC1-BU1</ns3:Value>
                  </ns3:PolicyConditionCriteria>
                  <ns3:PolicyConditionCriteria>
                     <ns3:Value>LOC2-BU3</ns3:Value>
                  </ns3:PolicyConditionCriteria>
               </ns3:PolicyConditionCriterias>
            </ns3:PolicyCondition>
         </ns3:PolicyConditions>
      </ns3:Policy>
   </ns3:Policies>
</ns1:Account>

Body:
I managed to translate the xml,just was thinking if there is any better easy way to implement.

    <xsl:for-each select="ns3:Location">
        <xsl:variable name="locationName">
            <xsl:value-of select="ns3:Name" />
        </xsl:variable>
        <xsl:copy>
            <xsl:apply-templates select="@* | node()" />
            <ns3:LocConditions>
                <xsl:for-each select="//ns3:PolicyConditions/ns3:PolicyCondition">
                    <xsl:for-each
                        select="ns3:PolicyConditionCriterias/ns3:PolicyConditionCriteria">
                        <xsl:if test="ns3:Value=$locationName">
                            <!--Zero or more repetitions: -->
                            <ns3:LocCondition>
                                <ns2:Id>0</ns2:Id>

                                <ns2:ConditionId>
                                    <xsl:value-of select="../../ns2:ItemData" />

                                </ns2:ConditionId>
                            </ns3:LocCondition>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:for-each>
            </ns3:LocConditions>
        </xsl:copy>
    </xsl:for-each>

</xsl:template>

            <!-- template to copy elements -->
            <xsl:template match="*">
                            <xsl:element name="{name()}">
                                            <xsl:apply-templates select="@* | node()"/>
                            </xsl:element>
            </xsl:template>
            <!-- template to copy attributes -->
            <xsl:template match="@*">
                            <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
            </xsl:template>
            <!-- template to copy the rest of the nodes -->
            <xsl:template match="comment() | text() | processing-instruction()">
                            <xsl:copy/>
            </xsl:template>


问:
Talend warning and error messages are black
When I was using Talend on Windows, I could see warning and error messages.
Now that I am using Talend on Linux, all I can see is black rectangles.

Do I need to embedded or install missing java libraries? If so, how do I find those missing?

Here are what I am using:

Ubuntu 17-04

Talend Open Studio for Big Data

Openjdk 1.8.0_131

Edit
Here is a capture of the black rectangle when I hover the warning sign on one of my table.

答:
This seems to be connected to your desktop engine (KDE / Gnome) and Eclipse.

See the answers from this question https://askubuntu.com/questions/45001/how-to-fix-black-tooltips-in-eclipse to check out how you can resolve the issue.


问:
Getting previous RadioButton value from RadioGroup inside a RecyclerView

In the above value when I check the option "salt" it gives me the value of same position from the above item. So in this case it gives me "CH6"

Like this when i check "Water" it gives me "CH4".

So here is my RecyclerView,

```<code>  public class QuestionsAdapter extends

    RecyclerView.Adapter<QuestionsAdapter.ViewHolder> {

            List<String> names = new ArrayList<>();
            Context c;
            String username;
            Map<String,Object> map = new HashMap<>();
            ArrayList<QuestionData> questions = new ArrayList<>();

            public QuestionsAdapter(Context c) {
                this.c = c;
            }

            public void updateQuestion(ArrayList<QuestionData> data){
                this.questions = data;
                notifyDataSetChanged();
            }
            public class ViewHolder extends RecyclerView.ViewHolder {
                TextView q;
                RadioButton r1;
                RadioButton r2;
                RadioButton r3;
                RadioButton r4;
                RadioGroup rg;

                public ViewHolder(View itemView) {
                    super (itemView);
                    rg = (RadioGroup)itemView.findViewById(R.id.RGroup);
                    q = (TextView)itemView.findViewById(R.id.question);
                    r1 = (RadioButton)itemView.findViewById(R.id.no1);
                    r2 = (RadioButton)itemView.findViewById(R.id.no2);
                    r3 = (RadioButton)itemView.findViewById(R.id.no3);
                    r4 = (RadioButton)itemView.findViewById(R.id.no4);

                }
            }

            @Override
            public QuestionsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View v = LayoutInflater.from (parent.getContext ()).inflate (R.layout.qnalayout, parent, false);
                return new ViewHolder(v);

            }

            @Override
            public void onBindViewHolder(final ViewHolder holder, int position) {
                final QuestionData qholder =  questions.get(position);

                String question= qholder.getQuestion();
                final String qid = qholder.getId();

                final ArrayList<String> options = new ArrayList<>();
                options.add(qholder.getO1());
                options.add(qholder.getO2());
                options.add(qholder.getO3());
                options.add(qholder.getO4());
                Collections.shuffle(options);
                final String o1 = options.get(0);
                String o2 = options.get(1);
                String o3 = options.get(2);
                String o4 =  options.get(3);
                final String[] answer = new String[1];
                holder.q.setText(question);
                holder.r1.setText(o1);
                holder.r2.setText(o2);
                holder.r3.setText(o3);
                holder.r4.setText(o4);
                holder.rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                        switch (checkedId){
                            case R.id.no1:
                                Toast.makeText(c, holder.r1.getText().toString(), Toast.LENGTH_SHORT).show();
                                break;
                            case R.id.no2:
                                Toast.makeText(c, holder.r2.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                            case R.id.no3:
                                Toast.makeText(c, holder.r3.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                            case R.id.no4:
                                Toast.makeText(c, holder.r4.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                        }
                        RadioButton checked = (RadioButton)findViewById(checkedId);
                        answer[0] = checked.getText().toString();
                        Toast.makeText(c, checked.getText().toString(), Toast.LENGTH_SHORT).show();
                        map.put(qid,answer[0]);
                        System.out.println(map);
                    }
                });

            }

            @Override
            public int getItemCount() {
                if (questions!=null){
                    return questions.size();

                }else {
                    return 0;
                }
            }

        }
</code>```

Thanks in advance!

答:
Instead of:

```<code>RadioButton checked = (RadioButton)findViewById(checkedId);
</code>```

Perform:

```<code>RadioButton checked = (RadioButton) group.findViewById(checkedId);
</code>```

Body:
In the above value when I check the option "salt" it gives me the value of same position from the above item. So in this case it gives me "CH6"

Like this when i check "Water" it gives me "CH4".

So here is my RecyclerView,

  public class QuestionsAdapter extends

    RecyclerView.Adapter<QuestionsAdapter.ViewHolder> {

            List<String> names = new ArrayList<>();
            Context c;
            String username;
            Map<String,Object> map = new HashMap<>();
            ArrayList<QuestionData> questions = new ArrayList<>();

            public QuestionsAdapter(Context c) {
                this.c = c;
            }

            public void updateQuestion(ArrayList<QuestionData> data){
                this.questions = data;
                notifyDataSetChanged();
            }
            public class ViewHolder extends RecyclerView.ViewHolder {
                TextView q;
                RadioButton r1;
                RadioButton r2;
                RadioButton r3;
                RadioButton r4;
                RadioGroup rg;

                public ViewHolder(View itemView) {
                    super (itemView);
                    rg = (RadioGroup)itemView.findViewById(R.id.RGroup);
                    q = (TextView)itemView.findViewById(R.id.question);
                    r1 = (RadioButton)itemView.findViewById(R.id.no1);
                    r2 = (RadioButton)itemView.findViewById(R.id.no2);
                    r3 = (RadioButton)itemView.findViewById(R.id.no3);
                    r4 = (RadioButton)itemView.findViewById(R.id.no4);

                }
            }

            @Override
            public QuestionsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View v = LayoutInflater.from (parent.getContext ()).inflate (R.layout.qnalayout, parent, false);
                return new ViewHolder(v);

            }

            @Override
            public void onBindViewHolder(final ViewHolder holder, int position) {
                final QuestionData qholder =  questions.get(position);

                String question= qholder.getQuestion();
                final String qid = qholder.getId();

                final ArrayList<String> options = new ArrayList<>();
                options.add(qholder.getO1());
                options.add(qholder.getO2());
                options.add(qholder.getO3());
                options.add(qholder.getO4());
                Collections.shuffle(options);
                final String o1 = options.get(0);
                String o2 = options.get(1);
                String o3 = options.get(2);
                String o4 =  options.get(3);
                final String[] answer = new String[1];
                holder.q.setText(question);
                holder.r1.setText(o1);
                holder.r2.setText(o2);
                holder.r3.setText(o3);
                holder.r4.setText(o4);
                holder.rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                        switch (checkedId){
                            case R.id.no1:
                                Toast.makeText(c, holder.r1.getText().toString(), Toast.LENGTH_SHORT).show();
                                break;
                            case R.id.no2:
                                Toast.makeText(c, holder.r2.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                            case R.id.no3:
                                Toast.makeText(c, holder.r3.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                            case R.id.no4:
                                Toast.makeText(c, holder.r4.getText().toString(), Toast.LENGTH_SHORT).show();

                                break;
                        }
                        RadioButton checked = (RadioButton)findViewById(checkedId);
                        answer[0] = checked.getText().toString();
                        Toast.makeText(c, checked.getText().toString(), Toast.LENGTH_SHORT).show();
                        map.put(qid,answer[0]);
                        System.out.println(map);
                    }
                });

            }

            @Override
            public int getItemCount() {
                if (questions!=null){
                    return questions.size();

                }else {
                    return 0;
                }
            }

        }

Thanks in advance!

Body:
Instead of:

RadioButton checked = (RadioButton)findViewById(checkedId);

Perform:

RadioButton checked = (RadioButton) group.findViewById(checkedId);


问:
Program Flow C#
I am learning C# at the moment. In the example below, I believe I have the correct code but there must be an error or two (maybe more) somewhere. Please see the code below:

```<code>    public static string ReturnAgeGroup(int age)
    {
        if (age >= 65)
        {
            return "senior citizen";
        }
        if (age < 21)
        {
            return "minor";
        }
        if (age >= 21 & age < 65)
        {
            return "adult";
        }
    }
</code>```

There is a red squiggly line underneath RetrunAgeGroup, which says not all code paths return a value when I hover over it. Why is this? Every possibility, regarding age, is covered by the conditions.

Is/are there any other error(s) that I have failed to identify?

Regards

答:
Remove last if and just leave return "adult".

Compiler doesnt consider conditions, when it validates code paths. It's like street signs. If it says, that you can go left or right, then you can. Compiler dont care, if just after the turn there's huge pile of garbage and road is unpassable. Similar here. There's 3 conditions, which might or might not be true. Since after last one there's no more code and your function is expected to return value under all circumstances you get that warning.

Title: Program Flow C#

Body:
I am learning C# at the moment. In the example below, I believe I have the correct code but there must be an error or two (maybe more) somewhere. Please see the code below:

    public static string ReturnAgeGroup(int age)
    {
        if (age >= 65)
        {
            return "senior citizen";
        }
        if (age < 21)
        {
            return "minor";
        }
        if (age >= 21 & age < 65)
        {
            return "adult";
        }
    }

There is a red squiggly line underneath RetrunAgeGroup, which says not all code paths return a value when I hover over it. Why is this? Every possibility, regarding age, is covered by the conditions.

Is/are there any other error(s) that I have failed to identify?

Regards


问:
When i Choose from The main Menu I Get: game.sh: 423: Syntax error: end of file unexpected (expecting "fi")
```<code>!# /bin/sh
# game.sh:
#  Chooses games based on genre and title
#  Also Shows descriptions of games

# Genre Menu
clear
printf "%s\n" "Game genre Menu"
printf "%s\n"
printf "%s\n" "1. First Person Shooter"
printf "%s\n" "2. Arcade"
printf "%s\n" "3. RPG"
printf "%s\n" "4. RPG (Infocom A-Jo)" #1-12
printf "%s\n" "5. RPG (Infocom Le-St)" #13-24
printf "%s\n" "6. RPG (Infocom Su-Zo)" #25-36
printf "%s\n" "7. RPG (Infocom ZZinvisiclues)" #37-45
read -p "Enter Number: " GENRE
 if [ $GENRE = 1 ]
 then
 # Menu for First Person Shooters
 clear
 printf "%s\n" "First Person Shooter Menu"
 printf "%s\n"
 printf "%s\n" "1. DOOM"
 printf "%s\n" "2. DOOM II"
 printf "%s\n" "3. Final DOOM (TNT)"
 printf "%s\n" "4. Final DOOM (Plutonia)"
 printf "%s\n" "5. Quake"
 printf "%s\n" "6. Duke Nukem 3D Atomic Edition"
 printf "%s\n" "7. Heretic"
 printf "%s\n" "8. Hexen"
 printf "%s\n" "9. Shadow Warrior"
 read -p "Enter Number: " FPSGAME
  # FPSGAME Choices
  if [ $FPSGAME = 1 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/doom/prboom/
    ./prboom
  elif [ $FPSGAME = 2 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/doom2/prboom/
    ./prboom
  elif [ $FPSGAME = 3 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/tnt/prboom/
    ./prboom
  elif [ $FPSGAME = 4 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/plutonia/prboom/
    ./prboom
  elif [ $FPSGAME = 5 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/sdlquake/
    ./sdlquake
  elif [ $FPSGAME = 6 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/eduke32/
    ./eduke32
  elif [ $FPSGAME = 7 ]
  then
    cd /mnt/mmcblk0p1/BKUP/Games/hheritic-0.2.0-src/
    ./hheretic-sdl
  elif [ $FPSGAME = 8 ]
  then
  cd /mnt/mmcblk0p1/BKUP/Games/hhexen-1.6.0/
  ./hhexen-sdl
  elif [ $FPSGAME = 9 ]
  then
  cd /mnt/mmcblk0p1/BKUP/Games/Shadow_Warrior/
  ./sw
  else
    printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 2 ]
 then
 # Menu for Arcade
 clear
 printf "%s\n" "Arcade Menu"
 printf "%s\n"
 printf "%s\n" "1. ASCII Portal"
 printf "%s\n" "2. Dave Gnukem"
 printf "%s\n" "3. Open Liero"
 printf "%s\n" "4. Open Tyrian"
 printf "%s\n" "5. PowerManga"
 printf "%s\n" "6. Asteroids"
 printf "%s\n" "7. Spout"
 printf "%s\n" "8. TCGS Car"
 read -p "Enter Number: " ARCGAME
  # ARCGAME Choices
  if [ $ARCGAME = 1 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/asciiportal/
   ./asciiportal
  elif [ $ARCGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/DaveGnukem/
   ./davegnukem.dge
  elif [ $ARCGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/openliero/
   ./liero1.34
  elif [ $ARCGAME = 4 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/opentyrian
   ./opentyrian.dge
  elif [ $ARCGAME = 5 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/powermanga
   ./powermanga
  elif [ $ARCGAME = 6 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/sdlroids
   ./sdlroids
  elif [ $ARCGAME = 7 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/spout/
   ./spout
  elif [ $ARCGAME = 8 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/tcgs_car/
   ./tcgs_Car
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 3 ]
 then
 # Menu for RPG
 clear
 printf "%s\n" "RPG Menu"
 printf "%s\n"
 printf "%s\n" "1. Meritous"
 printf "%s\n" "2. Nethack"
 printf "%s\n" "3. Powder"
 read -p "Enter Number: " RPGGAME
  # RPGGAME Choices
  if [ $RPGGAME = 1 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/meritous/
   ./meritous.dge
  elif [ $RPGGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/nethack-3.4.3-nanonote-bin/
   ./nethack
  elif [ $RPGGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/powder
   ./powder
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 4 ]
 then
 # Menu for RPG (Infocom A-Jo)
 clear
 printf "%s\n" "RPG {Infocom A-Jo) Menu"
 printf "%s\n"
 printf "%s\n" "1. A Mind Forever Voyaging (1985)"
 printf "%s\n" "2. Arthur (1989)"
 printf "%s\n" "3. Ballyhoo (1986)"
 printf "%s\n" "4. Beyond Zork: The Coconut of Quendor (1987)"
 printf "%s\n" "5. Border Zone (1987)"
 printf "%s\n" "6. Bureaucracy (1987)"
 printf "%s\n" "7. Cutthroats (1984)"
 printf "%s\n" "8. Deadline (1982)"
 printf "%s\n" "9. Enchanter (1983)"
 printf "%s\n" "10. Hollywood Hijinx (1986)"
 printf "%s\n" "11. Infidel (1983)"
 printf "%s\n" "12. Journey (1989)"
 read -p "Enter Number: " INFOAJGAME
  # INFOAJGAME Choices
  if [ $INFOAJGAME = 1 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/A_Mind_Forever_Voyaging/Amfv.z4
  elif [ $INFOAJGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Arthur/ARTHUR.Z6
  elif [ $INFOAJGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Ballyhoo/Ballyhoo.z3
  elif [ $INFOAJGAME = 4 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Beyond_Zork_The_Coconut_of_Quendor/BeyondZo.z5
  elif [ $INFOAJGAME = 5 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Border_Zone/Borderzo.z5
  elif [ $INFOAJGAME = 6 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Bureaucracy/BureaucrPATCHED.z4
  elif [ $INFOAJGAME = 7 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Cutthroats/Cutthroa.z3
  elif [ $INFOAJGAME = 8 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Deadline/Deadline.z3
  elif [ $INFOAJGAME = 9 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Enchanter/Enchante.z3
  elif [ $INFOAJGAME = 10 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Hollywood_Hijinx/Hollywoo.z3
  elif [ $INFOAJGAME = 11 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Infidel/Infidel.z3
  elif [ $INFOAJGAME = 12 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   ./frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Journey/Journey.z6
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 5 ]
 then
 # Menu for RPG (Infocom Le-St)
 clear
 printf "%s\n" "RPG {Infocom Le-St) Menu"
 printf "%s\n"
 printf "%s\n" "1. Leather Goddesses of Phobos (1986)"
 printf "%s\n" "2. Moonmist (1986)"
 printf "%s\n" "3. Nord and Bert Couldn't Make Head or Tail of It (1987)"
 printf "%s\n" "4. Planetfall (1983)"
 printf "%s\n" "5. Plundered Hearts (1987)"
 printf "%s\n" "6. Seastalker (1984)"
 printf "%s\n" "7. Sherlock: The Riddle of the Crown Jewels (1987)"
 printf "%s\n" "8. Shogun (1988)"
 printf "%s\n" "9. Sorcerer (1984)"
 printf "%s\n" "10. Spellbreaker (1985)"
 printf "%s\n" "11. Starcross (1982)"
 printf "%s\n" "12. Stationfall (1987)"
 read -p "Enter Number: " INFOLSGAME
  # INFOLSGAME Choices
  if [ $INFOLSGAME = 1 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Leather_Goddesses_of_Phobos/Leather.z3
  if [ $INFOLSGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Moonmist/Moonmist.z3
  if [ $INFOLSGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Nord_and_Bert_Couldnt_Make_Head_or_Tail_of_It/Nordandb.z4
  if [ $INFOLSGAME = 4 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Planetfall/Planetfa.z3
  if [ $INFOLSGAME = 5 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Plundered_Hearts/Plundere.z3
  if [ $INFOLSGAME = 6 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Seastalker/Seastalk.z3
  if [ $INFOLSGAME = 7 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Sherlock_The_Riddle_of_the_Crown_Jewels/Sherlock.z5
  if [ $INFOLSGAME = 8 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Shogun/Shogun.z6
  if [ $INFOLSGAME = 9 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Sorcerer/Sorcerer.z3
  if [ $INFOLSGAME = 10 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Spellbreaker/Spellbre.z3
  if [ $INFOLSGAME = 11 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Starcross/Starcros.z3
  if [ $INFOLSGAME = 12 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Stationfall/Stationf.z3
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 6 ]
 then
 # Menu for RPG (Infocom Su-Zo)
 clear
 printf "%s\n" "RPG (Infocom Su-Zo) Menu"
 printf "%s\n"
 printf "%s\n" "1. Suspect (1984)"
 printf "%s\n" "2. Suspended (1983)"
 printf "%s\n" "3. The Hitchhikers Guide To The Galaxy (1987)"
 printf "%s\n" "4. The Lurking Horror (1984)"
 printf "%s\n" "5. The Witness (1982)"
 printf "%s\n" "6. Trinity (1986)"
 printf "%s\n" "7. Wishbringer (1985)"
 printf "%s\n" "8. Zork 1: The Great Underground Empire (1981)"
 printf "%s\n" "9. Zork 2: The Wizard of Frobozz (1981)"
 printf "%s\n" "10. Zork 3: The Dungeon Master (1982)"
 printf "%s\n" "11. Zork: The Undiscovered Underground (1997)"
 printf "%s\n" "12. Zork Zero: The Revenge of Megaboz (1988)"
 read -p "Enter Number: " INFOSZGAME
  # INFOSZGAME Choices
  if [ $INFOSZGAME = 1 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Suspect/Suspect.z3
  if [ $INFOSZGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Suspended/Suspend.z3
  if [ $INFOSZGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/The_Hitchhikers_Guide_To_The_Galaxy/Hitchhik.z5
  if [ $INFOSZGAME = 4 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/The_Lurking_Horror/Lurking.z3
  if [ $INFOSZGAME = 5 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/The_Witness/Witness.z3
  if [ $INFOSZGAME = 6 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Trinity/Trinity.z4
  if [ $INFOSZGAME = 7 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Wishbringer/Wishbrin.z3
  if [ $INFOSZGAME = 8 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Zork_1_The_Great_Underground_Empire/Zork1.z3
  if [ $INFOSZGAME = 9 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Zork_2_The_Wizard_of_Frobozz/Zork2.z3
  if [ $INFOSZGAME = 10 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Zork_3_The_Dungeon_Master/Zork3.z3
  if [ $INFOSZGAME = 11 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Zork_The_Undiscovered_Underground/ZTUU.Z5
  if [ $INFOSZGAME = 12 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/Zork_Zero_The_Revenge_of_Megaboz/Zork0.z6
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

 elif [ $GENRE = 7 ]
 then
 # Menu for RPG (Infocom ZZinvisiclues)
 clear
 printf "%s\n" "RPG (Infocom ZZinvisiclues) Menu"
 printf "%s\n"
 printf "%s\n" "1. advntizm"
 printf "%s\n" "2. comdyizm"
 printf "%s\n" "3. diversizm"
 printf "%s\n" "4. fant1izm"
 printf "%s\n" "5. fant2izm"
 printf "%s\n" "6. hitchhik"
 printf "%s\n" "7. mystizm"
 printf "%s\n" "8. scifizm"
 read -p "Enter Number: " INFOZZGAME
  # INFOZZGAME Choices
  if [ $INFOZZGAME = 1 ]
   then
  cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/advntizm.z5
  if [ $INFOZZGAME = 2 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/comdyizm.z5
  if [ $INFOZZGAME = 3 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/diversizm.z5
  if [ $INFOZZGAME = 4 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/fant1izm.z5
  if [ $INFOZZGAME = 5 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/fant2izm.z5
  if [ $INFOZZGAME = 6 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/hitchhik.z5
  if [ $INFOZZGAME = 7 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/mystizm.z5
  if [ $INFOZZGAME = 8 ]
  then
   cd /mnt/mmcblk0p1/BKUP/Games/frotz/
   .frotz /mnt/mmcblk0p1/BKUP/Games/frotz/infocom/zzInvisiclues/scifizm.z5
  else
   printf "%s\n" "Oops! Unknown Selection."
  fi

fi
</code>```

答: fi is the closing tag to if in bash shell scripting. This means one of your if statements is unmatched to a fi. Find this without line numbers is hard.

ContentLicense: CC BY-SA 2.5


问:
How to remove unused strange element from site?
i have one little issue that cant resolve myself. I want to remove second box (at bottom) in this page but when inspect CSS found that both elements are defined as :

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

so dont know how to handle that box, and remove it. Form in that page are generated by "User registration & user profile – Profile Builder plugin".

答:
Try this in your javascript file, or add it in  in your .

```<code>document.getElementsByTagName('pre')[1].remove()
</code>```

You also have jquery on the site without the traditional $ alias, so you can also do:

```<code>jquery('pre').eq(1).remove();
</code>```

Body:
i have one little issue that cant resolve myself. I want to remove second box (at bottom) in this page but when inspect CSS found that both elements are defined as :

so dont know how to handle that box, and remove it. Form in that page are generated by "User registration & user profile – Profile Builder plugin".

Body:
Try this in your javascript file, or add it in <script></script> in your <head>.

document.getElementsByTagName('pre')[1].remove()

You also have jquery on the site without the traditional $ alias, so you can also do:

jquery('pre').eq(1).remove();


问:
Error when testing react components with jest and css-modules
I'm trying to test my components with jest, react, redux but I keep getting the following error:

```<code> ● Test suite failed to run
        stream-react-redux/src/containers/App/App.css:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){.app {

    SyntaxError: Unexpected token .
</code>```

I have followed the instructions on how to add the identity-obj-proxy and configuring my .jestrc file, but I keep getting the same error. The problem came when I started using css-modules and importing them in my components

Here is my .jestrc:

```<code>{
  "moduleFileExtensions": [ "js", "jsx"],
  "moduleNameMapper": {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
    "^.+\\.(css)$": "identity-obj-proxy"
  },
  "transform": {
    "^.+\\.(js|jsx)$": "babel-jest"
  },
  "verbose": true
}
</code>```

I have also added the ["es2015", { "modules": false } ] inside my .babelrc file.

答:
I took a look at the Jest docs and, just to be clear, did you install identity-obj-proxy?

npm install --save-dev identity-obj-proxy

Also, I see that the recommended file regex in the Jest docs is

"\\.(css|less)$": "identity-obj-proxy"

may try switching yours to match.

Finally, you could try a jest plugin like jest-css-modules

https://github.com/justinsisley/Jest-CSS-Modules

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to test my components with jest, react, redux but I keep getting the following error:

 ● Test suite failed to run
        stream-react-redux/src/containers/App/App.css:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){.app {

    SyntaxError: Unexpected token .

I have followed the instructions on how to add the identity-obj-proxy and configuring my .jestrc file, but I keep getting the same error. The problem came when I started using css-modules and importing them in my components

Here is my .jestrc:

{
  "moduleFileExtensions": [ "js", "jsx"],
  "moduleNameMapper": {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
    "^.+\\.(css)$": "identity-obj-proxy"
  },
  "transform": {
    "^.+\\.(js|jsx)$": "babel-jest"
  },
  "verbose": true
}

I have also added the ["es2015", { "modules": false } ] inside my .babelrc file.


问:
Definition of goto out of main and print threads
I have two questions about Go code. This is my program.
This program controls the presence of a nickname in a "database".

```<code>package main

import "fmt"

func rcv(){
  if r := recover() ; r != nil {
    fmt.Println("retry.")
    main()
  }
}
func main(){
defer rcv()
INSERT:
  fmt.Println("Insert a nickname: ")
  var s string
  fmt.Scanln(&s)
  switch {
  case len(s) <= 0 :
    fmt.Println(fmt.Errorf("error empty"))
    goto INSERT
  case s=="mark"||s=="andrea":
    fmt.Println("Accept, the nickname is",s)
  default :
    fmt.Println("ATTENTION, nickname not found")
    panic("Error.")
  }
}
</code>```

My questions are:

Using the recover function ( rcv () ), at the end of it, the recalled of main() is sent running like another thread? The principal main() function ends when the second is executed or whenever the panic is raised, the recover function create another process? (example: if the input nickname is wrong 5 times, 5 more main functions are started, so 6 Main running functions?) If create multiple executions of the main(), is there a way to print threads/process id or something like that?

I used the INSERT label and the goto construct. Can I use goto outside the main function (example: at the end of the rcv() function to return to the top of the main function)?
I could use goto instead of calling the main() function at the end of the rcv()

答:
1. About defer

defer statement execute function BEFORE exiting scope. So stack of caller-func is remaining while executing defer-func.

```<code>func foo() (err error) {
    defer func() {
        err = io.EOF
    }()
}
</code>```

It will crash with stackoverflow

2. About goto

See documentation

A "goto" statement transfers control to the statement with the corresponding label within the same function.

So you can't label outside func.

3. About question

How do I get back to the beginning of the main () function?

```<code>package main

func Main() {
    // do your main
}

func main() {
    for {
        Main()
    }
}
</code>```

Body:
I have two questions about Go code. This is my program.
This program controls the presence of a nickname in a "database".

package main

import "fmt"

func rcv(){
  if r := recover() ; r != nil {
    fmt.Println("retry.")
    main()
  }
}
func main(){
defer rcv()
INSERT:
  fmt.Println("Insert a nickname: ")
  var s string
  fmt.Scanln(&s)
  switch {
  case len(s) <= 0 :
    fmt.Println(fmt.Errorf("error empty"))
    goto INSERT
  case s=="mark"||s=="andrea":
    fmt.Println("Accept, the nickname is",s)
  default :
    fmt.Println("ATTENTION, nickname not found")
    panic("Error.")
  }
}

My questions are:

Using the recover function ( rcv () ), at the end of it, the recalled of main() is sent running like another thread? The principal main() function ends when the second is executed or whenever the panic is raised, the recover function create another process? (example: if the input nickname is wrong 5 times, 5 more main functions are started, so 6 Main running functions?) If create multiple executions of the main(), is there a way to print threads/process id or something like that?

I used the INSERT label and the goto construct. Can I use goto outside the main function (example: at the end of the rcv() function to return to the top of the main function)?
I could use goto instead of calling the main() function at the end of the rcv()

Body:
1. About defer

defer statement execute function BEFORE exiting scope. So stack of caller-func is remaining while executing defer-func.

func foo() (err error) {
    defer func() {
        err = io.EOF
    }()
}

It will crash with stackoverflow

2. About goto

See documentation

A "goto" statement transfers control to the statement with the corresponding label within the same function.

So you can't label outside func.

3. About question

How do I get back to the beginning of the main () function?

package main

func Main() {
    // do your main
}

func main() {
    for {
        Main()
    }
}


问:
Generate Controller and Model
I am newbie with Laravel and I played around laravel 4(Beta version). I want to know how to generate Controller and Model by command line use php artisan. But I don't know how to do them.

答:
For generate Model , controller with resources and migration best command is:</p>

```<code>php artisan make:model ModelName -m -cr
</code>```

Title: Generate Controller and Model

Body:
For generate Model , controller with resources and migration best command is:

php artisan make:model ModelName -m -cr


问:
Custom Settings in Android Studio
I want to make a section in my app to allow the user to specify a range of time. I'm trying to make the design to something like android timers at the moment, but I'm having trouble. Would I need to make a custom preference for the design, or would I need to use SharedPreferences in a Fragment?

Image of Android Clock Design

Additional Question:I'm using a Crystal double range seekbar that is visible when I run the app, but it doesn't show when in Android XML design.

答: I am not getting your usecase here. As far my understand, you need a screen to ask the user to the enter the date range like date from & to. If so, my suggestion would have the different screen to get those values and storre those in a SQLite.</p>

Title: Custom Settings in Android Studio


问:
Odoo installation ''error: [Errno 98] Address already in use''
I followed this installation guide for odoo and I get an error in the very end
when I run odoo-bin file it gives me this error

```<code>teo@teo-Lenovo-Yoga-3-14:/opt/odoo/odoo-10.0$ ./odoo-bin
2017-07-06 15:03:20,583 3754 INFO ? odoo: Odoo version 10.0
2017-07-06 15:03:20,583 3754 INFO ? odoo: addons paths: ['/home/teo/.local/share/Odoo/addons/10.0', u'/opt/odoo/odoo-10.0/odoo/addons', u'/opt/odoo/odoo-10.0/addons']
2017-07-06 15:03:20,583 3754 INFO ? odoo: database: default@default:default
2017-07-06 15:03:20,601 3754 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
Exception in thread odoo.service.httpd:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 251, in http_thread
    self.httpd = ThreadedWSGIServerReloadable(self.interface, self.port, app)
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 106, in __init__
    handler=RequestHandler)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 440, in __init__
    HTTPServer.__init__(self, (host, int(port)), handler)
  File "/usr/lib/python2.7/SocketServer.py", line 417, in __init__
    self.server_bind()
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 116, in server_bind
    super(ThreadedWSGIServerReloadable, self).server_bind()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "/usr/lib/python2.7/SocketServer.py", line 431, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use
</code>```

I think it may be related to the odoo.conf file because I specify a port but it still assumes de default port 8069

this is my odoo.conf file

```<code>[options]

; This is the password that allows database operations:

; admin_passwd = PASSWORD

db_host = False

db_port = 8470

db_user = odoo

db_password = False

addons_path = /opt/odoo/odoo-10.0/addons

;Log Settings

logfile = /var/log/odoo/odoo.log

log_level = error
</code>```

Does anyone have an idea of what's happening, for the record I tried to install odoo before but failed so I already had DB user created for e.g.

答:
Because odoo service automatically start when system starts, so you have to kill the odoo-service manually, and then run the ./odoo-bin file, at which point you should be able to see odoo running again.

```<code>sudo pkill -9 python
</code>```

By doing this you'll stop python from finding the odoo service process id and subsequently killing that process.

```<code>ps aux | grep odoo
sudo kill <process id>
</code>```

There are multiple pid running with odoo, ending with /etc/odoo-server.conf, which you have to select.

I think the best option is probably

```<code>sudo pkill -9 python
</code>```

All the best, I hope I solved your problem.

Body:
I followed this installation guide for odoo and I get an error in the very end
when I run odoo-bin file it gives me this error

teo@teo-Lenovo-Yoga-3-14:/opt/odoo/odoo-10.0$ ./odoo-bin
2017-07-06 15:03:20,583 3754 INFO ? odoo: Odoo version 10.0
2017-07-06 15:03:20,583 3754 INFO ? odoo: addons paths: ['/home/teo/.local/share/Odoo/addons/10.0', u'/opt/odoo/odoo-10.0/odoo/addons', u'/opt/odoo/odoo-10.0/addons']
2017-07-06 15:03:20,583 3754 INFO ? odoo: database: default@default:default
2017-07-06 15:03:20,601 3754 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
Exception in thread odoo.service.httpd:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 251, in http_thread
    self.httpd = ThreadedWSGIServerReloadable(self.interface, self.port, app)
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 106, in __init__
    handler=RequestHandler)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 440, in __init__
    HTTPServer.__init__(self, (host, int(port)), handler)
  File "/usr/lib/python2.7/SocketServer.py", line 417, in __init__
    self.server_bind()
  File "/opt/odoo/odoo-10.0/odoo/service/server.py", line 116, in server_bind
    super(ThreadedWSGIServerReloadable, self).server_bind()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "/usr/lib/python2.7/SocketServer.py", line 431, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 98] Address already in use

I think it may be related to the odoo.conf file because I specify a port but it still assumes de default port 8069

this is my odoo.conf file

[options]

; This is the password that allows database operations:

; admin_passwd = PASSWORD

db_host = False

db_port = 8470

db_user = odoo

db_password = False

addons_path = /opt/odoo/odoo-10.0/addons

;Log Settings

logfile = /var/log/odoo/odoo.log

log_level = error

Does anyone have an idea of what's happening, for the record I tried to install odoo before but failed so I already had DB user created for e.g.

Body:
Because odoo service automatically start when system starts, so you have to kill the odoo-service manually, and then run the ./odoo-bin file, at which point you should be able to see odoo running again.

sudo pkill -9 python

By doing this you'll stop python from finding the odoo service process id and subsequently killing that process.

ps aux | grep odoo
sudo kill <process id>

There are multiple pid running with odoo, ending with /etc/odoo-server.conf, which you have to select.

I think the best option is probably

sudo pkill -9 python

All the best, I hope I solved your problem.


问:
How to use loop to create multiple columns
I am struggling with creating multiple columns in a DRY way.

I have searched google and stack exchange and I am still struggling with the below.

```<code>df <- data.frame(red = 1:10, blue=seq(1,30,3))

myfunction <- function(x){
  log(x) + 10
}

df$green <- myfunction(df$red)
df$yellow <- myfunction(df$blue)
</code>```

My questions are:

how can I create the green and yellow columns using a for loop?

how can I create the green and yellow using an apply function?

答:
As pointed out by Sotos, apply is slower than lapply. So I believe the optimal solution is:</p>

```<code>df[,c("green","yellow")] <- lapply(df, myfunction)
</code>```

Body:
I am struggling with creating multiple columns in a DRY way.

I have searched google and stack exchange and I am still struggling with the below.

df <- data.frame(red = 1:10, blue=seq(1,30,3))

myfunction <- function(x){
  log(x) + 10
}

df$green <- myfunction(df$red)
df$yellow <- myfunction(df$blue)

My questions are:

how can I create the green and yellow columns using a for loop?

how can I create the green and yellow using an apply function?

Body:
As pointed out by Sotos, apply is slower than lapply. So I believe the optimal solution is:

df[,c("green","yellow")] <- lapply(df, myfunction)


问:
Using time stamps as input to Neural Networks to reconstruct particle tracks
So here's the thing: consider a detector, made of several vertical strings, each hosting 60 sensors distributed equidistantly, as shown in the following picture (dark dots are sensors):

Particles will then flow through and produce pulses on each sensor that you can use. Informations include time of passing by, coordinates (stringnumber+position on string or cartesian coordinates), total charge, etc.

The final goal is to reconstruct angles of incoming particles and their energies. Though we first just consider a simple classification problem of finding out whether the particle came in form the north or south hemisphere (i.e. from the top or bottom direction of the detector.

As input values we use every timestamp of each sensor, their exact position hasn't to be passed as it will be encoded by the position of the timestamp in the input list.
The problem we have is with sensor that didn't detect any particle. Is it clever to insert their timestamp as float("Inf")? Leaving their time as zero is another option, but it will then be ambiguous with the sensor that triggered as first (having timestamps normalised to [0,1]).

I'd be glad to hear any hint from people who have already worked with timestamps in neural networks. Also, if you have any good idea on developing NN's for our future tasks please share them! The planned approach are convolutional (deep) neural networks, but we still have to think about how to encode sensor-positions in that irregular hexagonal shape.

答:
A few points to consider:
- How about -1?
- How about NaN?

What language are you programming in?


问:
Searching strings where substring occur at specific positions with negative look-ahead
I am just facing a probem when trying to create a regex which should help finding strings including specific combinations of substrings.

For example i am searching for the substring combination:

ab-ab-cd

1) "xxxabxxxxxxabxxxxcdxxx" -> should be a match

2) "xxxabxxxxabxxxxabxxxxcdxxxx -> no match

3) "xxxabxxxxxxxxxxcdxxxx -> no match

to make it even more complicated:

4) "xxxabxxxxxabxxxxcdxxxabxxx -> should also be a match

My substring combinations could also be like this:

ab-cd

or

ab-ab-ab-cd

or

ab-cd-ab-cd

For all these (and more) examples I am looking for a systematic way to build the corresponding regexes in a systematic way so that only strings are found as matches where the substrings occur in the right order and with correct frequency.

I got something like this for the "ab-ab-cd" substring search but it fails in cases like 4) of my examples.

```<code>p = re.compile("(?:(?!ab).)*ab.*?ab(?!.*ab).*cd",re.IGNORECASE)
</code>```

In cases like 4) this one works in but in also matches strings like 2):

```<code>p = re.compile("(?:(?!ab).)*ab(?:(?!ab).)*ab((?!ab|cd)*).*cd", re.IGNORECASE)
</code>```

Could you please point me to my mistake?

Thanks a lot!

EDIT:

Sorry to all, that my question was not clear enough. I tried to break my problem down into a more simple case, which might have been no good idea.
Here comes the detailed explanation of the problem:

I have list of (protein) sequences and to assign a specific type to each sequence on the basis of sequence patterns.

Therefore I created a dictionary with type-name as key and feature template (list of sequence features in a specific order) as value, e.g.:

type_a -> [A,A,B,C]

type_b -> [A,B,C]

type_c -> [A,B,A,B]

In other dict I have (simple) regex patters for each feature, e.g.:

A -> [PHT]AG[QP]LI

B -> RS[TP]EV

C -> ...

D -> ...

Now each template (type_a, type_b,...) I now to systematically build the concatenated regex patters (i.e. for type_a build a regex searching for A,A,B,C).
That would than result into another dict with types as key and and the complete regex as value.

Now I want to go through each sequence in my list of sequences and map all complete regex templates against each sequence. In best case, only one complete regex (type) should match the sequence.

Taking the example from above, having the following regex-templates:

cd

ab-cd

ab-ab-cd

ab-ab-ab-cd

ab-cd-ab-cd

ab-ab-cd-ab

"xxxabxxxxxxabxxxxcdxxx"

->this sequence should match the regex for the template "ab-ab-cd" and not any of the others

With the following regex I could perfectly look for ab-ab-cd.

```<code>p = re.compile("(?:(?!ab).)*ab.*?ab(?!.*ab).*cd",re.IGNORECASE)
</code>```

If my tests were correct it would only match sequence 1) from above and not 2) or 3).

However, if I would like to search for ab-ab-cd-ab the negative look-ahead would not allow to find the last ab. I found something like the following code to break the negative look-ahead after the second "ab" part. In my understand the negative look-ahead should stop with the "cd", so that the last "ab" could be matches again.

```<code>p = re.compile("(?:(?!ab).)*ab(?:(?!ab).)*ab((?!ab|cd)*).*cd", re.IGNORECASE)
</code>```

It solves the problem with the last "ab" from ab-ab-cd-ab.
But somehow it now does not only match the for 2 times "ab" before the "cd" (Sequence 1) - ab-ab-cd) but also the 3 (or more) times "ab" before the "cd" (Sequence 2, ab-ab-ab-cd), which it should not.

I hope my problem is more clear. Thanks a lot for all the answers, I will try the code tomorrow when I am back at work. Any further answers are highly appreciated, explanations of the regex code (I am pretty new to regex) and suggestions with re.functions (match, final...) to use.

Thanks

答:
Why do you need the negative look ahead?
Why not use something as simple as that:

```<code>*ab.*ab.*cd
</code>```

Or if you need it to find a match from the beginning of the line, you can use:

```<code>^.*ab.*ab.*cd
</code>```

Edit:
After your comment I understood what you need. Try this one:

```<code>^(?:(?!ab).)*ab(?:(?!ab).)*ab(?:(?!ab).)*cd
</code>```

Body:
I am just facing a probem when trying to create a regex which should help finding strings including specific combinations of substrings.

For example i am searching for the substring combination:

ab-ab-cd

1) "xxxabxxxxxxabxxxxcdxxx" -> should be a match

2) "xxxabxxxxabxxxxabxxxxcdxxxx -> no match

3) "xxxabxxxxxxxxxxcdxxxx -> no match

to make it even more complicated:

4) "xxxabxxxxxabxxxxcdxxxabxxx -> should also be a match

My substring combinations could also be like this:

ab-cd

or

ab-ab-ab-cd

or

ab-cd-ab-cd

For all these (and more) examples I am looking for a systematic way to build the corresponding regexes in a systematic way so that only strings are found as matches where the substrings occur in the right order and with correct frequency.

I got something like this for the "ab-ab-cd" substring search but it fails in cases like 4) of my examples.

p = re.compile("(?:(?!ab).)*ab.*?ab(?!.*ab).*cd",re.IGNORECASE)

In cases like 4) this one works in but in also matches strings like 2):

p = re.compile("(?:(?!ab).)*ab(?:(?!ab).)*ab((?!ab|cd)*).*cd", re.IGNORECASE)

Could you please point me to my mistake?

Thanks a lot!

EDIT:

Sorry to all, that my question was not clear enough. I tried to break my problem down into a more simple case, which might have been no good idea.
Here comes the detailed explanation of the problem:

I have list of (protein) sequences and to assign a specific type to each sequence on the basis of sequence patterns.

Therefore I created a dictionary with type-name as key and feature template (list of sequence features in a specific order) as value, e.g.:

type_a -> [A,A,B,C]

type_b -> [A,B,C]

type_c -> [A,B,A,B]

In other dict I have (simple) regex patters for each feature, e.g.:

A -> [PHT]AG[QP]LI

B -> RS[TP]EV

C -> ...

D -> ...

Now each template (type_a, type_b,...) I now to systematically build the concatenated regex patters (i.e. for type_a build a regex searching for A,A,B,C).
That would than result into another dict with types as key and and the complete regex as value.

Now I want to go through each sequence in my list of sequences and map all complete regex templates against each sequence. In best case, only one complete regex (type) should match the sequence.

Taking the example from above, having the following regex-templates:

cd

ab-cd

ab-ab-cd

ab-ab-ab-cd

ab-cd-ab-cd

ab-ab-cd-ab

"xxxabxxxxxxabxxxxcdxxx"

->this sequence should match the regex for the template "ab-ab-cd" and not any of the others

With the following regex I could perfectly look for ab-ab-cd.

p = re.compile("(?:(?!ab).)*ab.*?ab(?!.*ab).*cd",re.IGNORECASE)

If my tests were correct it would only match sequence 1) from above and not 2) or 3).

However, if I would like to search for ab-ab-cd-ab the negative look-ahead would not allow to find the last ab. I found something like the following code to break the negative look-ahead after the second "ab" part. In my understand the negative look-ahead should stop with the "cd", so that the last "ab" could be matches again.

p = re.compile("(?:(?!ab).)*ab(?:(?!ab).)*ab((?!ab|cd)*).*cd", re.IGNORECASE)

It solves the problem with the last "ab" from ab-ab-cd-ab.
But somehow it now does not only match the for 2 times "ab" before the "cd" (Sequence 1) - ab-ab-cd) but also the 3 (or more) times "ab" before the "cd" (Sequence 2, ab-ab-ab-cd), which it should not.

I hope my problem is more clear. Thanks a lot for all the answers, I will try the code tomorrow when I am back at work. Any further answers are highly appreciated, explanations of the regex code (I am pretty new to regex) and suggestions with re.functions (match, final...) to use.

Thanks

Body:
Why do you need the negative look ahead?
Why not use something as simple as that:

*ab.*ab.*cd

Or if you need it to find a match from the beginning of the line, you can use:

^.*ab.*ab.*cd

Edit:
After your comment I understood what you need. Try this one:

^(?:(?!ab).)*ab(?:(?!ab).)*ab(?:(?!ab).)*cd


问:
Q: Rails Best Practices for database calls
Quick question. I am building out a portfolio application for an artist, currently have 9 tables of different types of projects (exhibitions, press, news, texts, photography, etc). As a visual artist, he wants his site to represent his vision.

Background:

edit: The information is loaded from the controller originally, not from an API call. I later changed it to an API call because I was worried 9 calls from the controller was too much.

This means the site is graphic and information heavy. Loading all the information just for the navigation was 15 mb (and this was after shrinking the images when needed and running them through tinypng). I put all the information off to different layout views to be rendered only when needed to keep loading times down and offset it, which helped speed everything. But this setup no matter which way resulted in 9 different database calls on each page load.

I rebuilt the back end to API endpoints, so the information is only pulled from the database when needed. This has slightly increased the load time for the information though, only like a second more if that. I'm not bothered by it, but the artist might be.

Actual Question

So I've been wondering for the past few days, is 9 database calls too much at once and how will it affect scalability? Postgres database for reference. Normal load, I cant imagine too many users will view the site on any given time, so I wouldnt be worried about it. But when he has an exhibition and there are 100-500 people using the site at once, thats 900-4500 database calls each page load. Or with the API route, people may only do 1 or 2 calls before finding what they want. I just want to follow the industry best practice for handling this situation and this seemed like a good time to ask this question.

Also, this will be hosted on heroku currently, and wondering which way (all at once or API routes) will be better for handling postgres connections since the free tier (which will be enough 95% of the time) has a limit of 20 connections. Though for months where he has a show we could bump it up to the next tier for 60 connections.

答:
I'm not an expert but I've been dealing with a lot of issues regarding optimisation and I'll give some of my own suggestions:

serve all static assets through a CDN - unless you really know what you're doing let the CDN handle caching

you mention it has a built in CMS for it - version all images uploaded into different sizes, so you can optimise display through versioning (thumbs for thumbs, midsize (max-width 1920<->3840) for everything else and only save/use bigger than those sizes if really needed)

understand JPG compression - you can lower it from the usual 100% to around 70% (this does depend on the actual images) without loosing any meaningful information - this is non rails related, and should be done as step on optimising all image content

for optimising the images added through the CMS you can use RMagick or Minimagick. In RMagick you have access to self.quality when processing images - unless images have transparencies always convert to JPG & quality down to 70<->80%

cache the queries to the db themselves - heroku caching

I personally use a technique to load the images only after html rendering

```<code>function loadPortfolios() {
  var collections = $(".profile_collection");
  var imageObj = new Image();
  var image;
  $.each(collections, function () {
    image = $(this).data('source');
    imageObj.src = image;
    $(this).css({ backgroundImage: 'url('+image+')', backgroundRepeat: 'no-repeat', backgroundSize: "cover", backgroundPosition: 'center' });
  });
  $.each($('.image_portfolio, .hover_image'), function() {
    imageObj.src=$(this).data('url');
  });
}
</code>```

This works by having data attributes in the types of "portfolio". So once the website is loaded and JS ready fired, this function gets called. Instantiating a JS Image object (new Image()), followed by attributing a url to the .src attribute makes it start loading the images. I haven't benchmarked it yet, but will soon - not sure it really plays a part but if you try it let me know. The reason why I use this this way is because it's more important for me to reduce the number of requests for external elements, in order to load the JS, so that the website is functional the soonest possible. And then start getting the images.

I'm sure there's plenty of other optimisations that could be done.
EDIT:

If you're getting bogged down on the database queries as well, look at the amount of helper methods you're using both in the controller and views (when you load a lot of stuff it can really render things slower). Then look at how you're querying things. Some examples could help.

Body:
I'm not an expert but I've been dealing with a lot of issues regarding optimisation and I'll give some of my own suggestions:

serve all static assets through a CDN - unless you really know what you're doing let the CDN handle caching

you mention it has a built in CMS for it - version all images uploaded into different sizes, so you can optimise display through versioning (thumbs for thumbs, midsize (max-width 1920<->3840) for everything else and only save/use bigger than those sizes if really needed)

understand JPG compression - you can lower it from the usual 100% to around 70% (this does depend on the actual images) without loosing any meaningful information - this is non rails related, and should be done as step on optimising all image content

for optimising the images added through the CMS you can use RMagick or Minimagick. In RMagick you have access to self.quality when processing images - unless images have transparencies always convert to JPG & quality down to 70<->80%

cache the queries to the db themselves - heroku caching

I personally use a technique to load the images only after html rendering

function loadPortfolios() {
  var collections = $(".profile_collection");
  var imageObj = new Image();
  var image;
  $.each(collections, function () {
    image = $(this).data('source');
    imageObj.src = image;
    $(this).css({ backgroundImage: 'url('+image+')', backgroundRepeat: 'no-repeat', backgroundSize: "cover", backgroundPosition: 'center' });
  });
  $.each($('.image_portfolio, .hover_image'), function() {
    imageObj.src=$(this).data('url');
  });
}

This works by having data attributes in the types of "portfolio". So once the website is loaded and JS ready fired, this function gets called. Instantiating a JS Image object (new Image()), followed by attributing a url to the .src attribute makes it start loading the images. I haven't benchmarked it yet, but will soon - not sure it really plays a part but if you try it let me know. The reason why I use this this way is because it's more important for me to reduce the number of requests for external elements, in order to load the JS, so that the website is functional the soonest possible. And then start getting the images.

I'm sure there's plenty of other optimisations that could be done.
EDIT:

If you're getting bogged down on the database queries as well, look at the amount of helper methods you're using both in the controller and views (when you load a lot of stuff it can really render things slower). Then look at how you're querying things. Some examples could help.


问:
Django queries with complex filter
I have the following model:

```<code>...
from django.contrib.auth.models import User

class TaxonomyNode(models.Model):
    node_id = models.CharField(max_length=20)
    name = models.CharField(max_length=100)
    ...

class Annotation(models.Model):
    ...
    taxonomy_node = models.ForeignKey(TaxonomyNode, blank=True, null=True)

class Vote(models.Model):
    created_by = models.ForeignKey(User, related_name='votes', null=True, on_delete=models.SET_NULL)
    vote = models.FloatField()
    annotation = models.ForeignKey(Annotation, related_name='votes')
    ...
</code>```

In the app, a User can produce Vote for an Annotation instance.
A User can vote only once for an Annotation instance.
I want to get a query set with the TaxonomyNode which a User can still annotate a least one of its Annotation. For now, I do it that way:

```<code>def user_can_annotate(node_id, user):
    if Annotation.objects.filter(node_id=node_id).exclude(votes__created_by=user).count() == 0:
        return False
    else:
        return True

def get_categories_to_validate(user):
    """
    Returns a query set with the TaxonomyNode which have Annotation that can be validated by a user
    """
    nodes = TaxonomyNode.objects.all()
    nodes_to_keep = [node.node_id for node in nodes if self.user_can_annotate(node.node_id, user)]
    return nodes.filter(node_id__in=nodes_to_keep)

categories_to_validate = get_category_to_validate(<user instance>)
</code>```

I guess there is a way to do it in one query, that would speed up the process quite a lot. In brief, I want to exclude from the TaxonomyNode set, all the nodes that have all their annotations already voted once by the user.

Any idea of how I could do it? With django ORM or in SQL?
I have Django version 1.10.6

答:
Try to use this:

```<code>#SQL query
unvoted_annotations = Annotation.objects.exclude(votes__created_by=user).select_related('taxonomy_node')

#remove duplicates
taxonomy_nodes=[]
for annotation in unvoted_annotations:
    if annotation.taxonomy_node not in taxonomy_nodes:
        taxonomy_nodes.append(annotation.taxonomy_node)
</code>```

There would be only one SQL query as select_related will return the related taxonomy_node in a single query. Also there might be a better way to remove duplicates, eg: by using .distinct().

Title: Django queries with complex filter

Body:
I have the following model:

...
from django.contrib.auth.models import User

class TaxonomyNode(models.Model):
    node_id = models.CharField(max_length=20)
    name = models.CharField(max_length=100)
    ...

class Annotation(models.Model):
    ...
    taxonomy_node = models.ForeignKey(TaxonomyNode, blank=True, null=True)

class Vote(models.Model):
    created_by = models.ForeignKey(User, related_name='votes', null=True, on_delete=models.SET_NULL)
    vote = models.FloatField()
    annotation = models.ForeignKey(Annotation, related_name='votes')
    ...

In the app, a User can produce Vote for an Annotation instance.
A User can vote only once for an Annotation instance.
I want to get a query set with the TaxonomyNode which a User can still annotate a least one of its Annotation. For now, I do it that way:

def user_can_annotate(node_id, user):
    if Annotation.objects.filter(node_id=node_id).exclude(votes__created_by=user).count() == 0:
        return False
    else:
        return True

def get_categories_to_validate(user):
    """
    Returns a query set with the TaxonomyNode which have Annotation that can be validated by a user
    """
    nodes = TaxonomyNode.objects.all()
    nodes_to_keep = [node.node_id for node in nodes if self.user_can_annotate(node.node_id, user)]
    return nodes.filter(node_id__in=nodes_to_keep)

categories_to_validate = get_category_to_validate(<user instance>)

I guess there is a way to do it in one query, that would speed up the process quite a lot. In brief, I want to exclude from the TaxonomyNode set, all the nodes that have all their annotations already voted once by the user.

Any idea of how I could do it? With django ORM or in SQL?
I have Django version 1.10.6

Body:
Try to use this:

#SQL query
unvoted_annotations = Annotation.objects.exclude(votes__created_by=user).select_related('taxonomy_node')

#remove duplicates
taxonomy_nodes=[]
for annotation in unvoted_annotations:
    if annotation.taxonomy_node not in taxonomy_nodes:
        taxonomy_nodes.append(annotation.taxonomy_node)

There would be only one SQL query as select_related will return the related taxonomy_node in a single query. Also there might be a better way to remove duplicates, eg: by using .distinct().


问:
Jquery: Is there some way to make val() return an empty string instead of 'undefined' for an empty list?
With Jquery, is there some way to make val() return an empty string instead of 'undefined' when called against an empty list of elements?

E.g., I have this code:

```<code>var x = $('#my-textbox-id').not('.watermark').val();
</code>```

The idea is that I want to get the value of my textbox, but I want an empty string if it is currently showing the watermark (i don't want the watermark value!).

The selector works, but i don't want 'undefined' - I want an empty string ''.

答:
How about:</p>

```<code>var x = $('#my-textbox-id').hasClass("watermark") ? "" : $('#my-textbox-id').val();
</code>```

Body:
With Jquery, is there some way to make val() return an empty string instead of 'undefined' when called against an empty list of elements?

E.g., I have this code:

var x = $('#my-textbox-id').not('.watermark').val();

The idea is that I want to get the value of my textbox, but I want an empty string if it is currently showing the watermark (i don't want the watermark value!).

The selector works, but i don't want 'undefined' - I want an empty string ''.

Body:
How about:

var x = $('#my-textbox-id').hasClass("watermark") ? "" : $('#my-textbox-id').val();


问:
Nokogiri requires Ruby version < 2.3
I am trying to get Rails to work on Windows 10. I am using Ruby 2.3.0, and Rails 4.2.6, and am temporarily using Nokogiri 1.6.3.

When I try running rails new demo, it returns an error:

```<code>An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.
</code>```

When I run gem install nokogiri -v '1.6.7.2 I get:

```<code>ERROR:  Error installing nokogiri:
        nokogiri requires Ruby version < 2.3, >= 1.9.2.
</code>```

How do I update Nokogiri and get Rails to work?

答: Problem solved in version of Nokogiri 1.8.0.</p>

Title: Nokogiri requires Ruby version < 2.3

Body:
I am trying to get Rails to work on Windows 10. I am using Ruby 2.3.0, and Rails 4.2.6, and am temporarily using Nokogiri 1.6.3.

When I try running rails new demo, it returns an error:

An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.

When I run gem install nokogiri -v '1.6.7.2 I get:

ERROR:  Error installing nokogiri:
        nokogiri requires Ruby version < 2.3, >= 1.9.2.

How do I update Nokogiri and get Rails to work?


问:
Restart Python Program after user changes
In my program, I have a config file which gets read on initialization and sets certain runtime variables. While the program is running a user can access and change these values in the config file through a menu I've created. Once these values have been modified I need the program to shut down and restart, so that it can run with the new config values.

I'm programming this in python and I am not sure how to go about doing this.

答:
You can use sys.exit() to terminate the running process, but your best option is probably just to re-intialize/read files rather than terminating your code and restarting (i.e., you could call main() again).
Hope this helps.</p>


问:
How to disable stylesheets in MS Edge without plugins
I tested a site for accessibility and I now have a QA validating that all of the changes were made. The QA needs to validate that the site is still readable with the stylesheets turned off. The QA can only use MS Edge and cannot install any plugins or browser extensions. Has anyone figured out how to turn off stylesheets? Googling this got me nowhere. When I evaluate the site, I use an extension in Chrome so I have never had this issue before.</p>

答:
Press F12 and copy this to console, hit enter</p>

```<code>$('style,link[rel="stylesheet"]').remove()
</code>```

Body:
Press F12 and copy this to console, hit enter

$('style,link[rel="stylesheet"]').remove()