问:
White Space Around Adobe Illustrator Generated SVG
Thank you in advance for all the help, I have been trying various resources on the web but is still not able to make this work.

I am trying to create a 3D rectangle box using svg. I prepared the graphic in Adobe Illustrator by apply the 3D feature in the software to a regular rectangle shape and finally exported it as a SVG file. While it looks ok on the screen of illustrator, on browser; the object appears to have a small white border around each of its polygon.

The following is the svg code generated by illustrator. You Can see the whitespace around the polygon after running the snippet. I have to remove the whitespace around it.

<?xml version="1.0" encoding="utf-8"?>

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
  width="965px" height="720.3px" viewBox="0 0 965 720.3" enable-background="new 0 0 965 720.3" xml:space="preserve">
<g id="sections_2_">
 <g>
  <g enable-background="new    ">
   <g>
    <polygon fill="#836EA6" points="595.6,337.1 596.8,344.9 581.8,357.8 580.6,349.9     "/>
   </g>
   <g>
    <polygon fill="#8670A9" points="532,311.5 595.6,337.1 580.6,349.9 568.3,360.1     "/>
   </g>
   <g>
    <polygon fill="#736092" points="568.3,360.1 569.4,368 533.1,319.3 532,311.5     "/>
   </g>
   <g>
    <polygon fill="#BF4142" points="568.3,360.1 569.4,368 508,340.3 506.9,332.5     "/>
   </g>
   <g>
    <polygon fill="#836EA6" points="580.6,349.9 581.8,357.8 569.4,368 568.3,360.1     "/>
   </g>
   <g>
    <polygon fill="#DE4D4E" points="531.9,311.5 568.3,360.1 506.9,332.5 511.7,328.6 524.8,317.8     "/>
   </g>
  </g>
 </g>
</g>
</svg>```

The following image is how it look like on the screen which is the desired look. It has to be a .svg file, so exporting it as jpeg or png is not an option.

答:
That white space is because your SVG viewBox attribute is set to an area much bigger than your design.

You can think of the viewBox in SVG as defining the page size.  In Illustrator, that corresponds to what it calls the "Artboard".

Before you save in Illustrator, go to the Artboard settings (where you set the page size) and choose the option "Fit to Artwork Bounds".  Now when you save, the viewBox should match the size of your design, and the white space should be gone.

Body:
Thank you in advance for all the help, I have been trying various resources on the web but is still not able to make this work.

I am trying to create a 3D rectangle box using svg. I prepared the graphic in Adobe Illustrator by apply the 3D feature in the software to a regular rectangle shape and finally exported it as a SVG file. While it looks ok on the screen of illustrator, on browser; the object appears to have a small white border around each of its polygon.

The following is the svg code generated by illustrator. You Can see the whitespace around the polygon after running the snippet. I have to remove the whitespace around it.

<?xml version="1.0" encoding="utf-8"?>

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
  width="965px" height="720.3px" viewBox="0 0 965 720.3" enable-background="new 0 0 965 720.3" xml:space="preserve">
<g id="sections_2_">
 <g>
  <g enable-background="new    ">
   <g>
    <polygon fill="#836EA6" points="595.6,337.1 596.8,344.9 581.8,357.8 580.6,349.9     "/>
   </g>
   <g>
    <polygon fill="#8670A9" points="532,311.5 595.6,337.1 580.6,349.9 568.3,360.1     "/>
   </g>
   <g>
    <polygon fill="#736092" points="568.3,360.1 569.4,368 533.1,319.3 532,311.5     "/>
   </g>
   <g>
    <polygon fill="#BF4142" points="568.3,360.1 569.4,368 508,340.3 506.9,332.5     "/>
   </g>
   <g>
    <polygon fill="#836EA6" points="580.6,349.9 581.8,357.8 569.4,368 568.3,360.1     "/>
   </g>
   <g>
    <polygon fill="#DE4D4E" points="531.9,311.5 568.3,360.1 506.9,332.5 511.7,328.6 524.8,317.8     "/>
   </g>
  </g>
 </g>
</g>
</svg>

The following image is how it look like on the screen which is the desired look. It has to be a .svg file, so exporting it as jpeg or png is not an option.


来源: stackexchange

问:
pyteomics: calculate mass from a file containing the sequence of several proteins
I want to calculate the mass for every protein of my file.

My code so far:

```<code>from pyteomics import mass
 with open('file.txt') as f:
        for line in f:
             mass.calculate_mass(line)
</code>```

When I replace the mass.calculate_mass with print(line) all the lines are correctly printed. But with mass.calculate_mass(line) come several error messages:

```<code>Traceback (most recent call last):
File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/parser.py", line 275, in parse
    n, body, c = re.match(_modX_sequence, sequence).groups() AttributeError: 'NoneType' object has no attribute 'groups'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 304, in __init__
    self._from_sequence(args[0], aa_comp)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 200, in _from_sequence
    show_unmodified_termini=True)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/parser.py", line 277, in parse
    raise PyteomicsError('Not a valid modX sequence: ' + sequence) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: "Not a valid modX sequence: 'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 307, in __init__
    self._from_formula(args[0], mass_data)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 205, in _from_formula
    raise PyteomicsError('Invalid formula: ' + formula) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: "Invalid formula: 'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/calculatemass.py", line 5, in <module>
    mass.calculate_mass(line)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 499, in calculate_mass
    else Composition(*args, **kwargs))   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 312, in __init__
    'formula'.format(args[0])) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: 'Could not create a Composition object from string: "\'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY\'\n": not a valid sequence or formula'
</code>```

my file looks like this:

```<code>'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'
</code>```

I also tried it with

sequence='MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'

There are no empty lines in my file.
If I try the same in the shell, it works:

```<code>mass.calculate_mass('MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY')
</code>```

49589.2790365072

I also tried mass.calculate_mass(str(line)) but that did not help.

Do you know what I am doing wrong?

答:
It looks like your file contains quotes ('). These are interpreted as part of the sequence and break the parser.
If you just put sequences in your file without any additional characters, it should work fine:

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

Note that the end-of-line characters don't cause any problems, although that is not documented.

ContentLicense: CC BY-SA 3.0

Body:
I want to calculate the mass for every protein of my file.

My code so far:

from pyteomics import mass
 with open('file.txt') as f:
        for line in f:
             mass.calculate_mass(line)

When I replace the mass.calculate_mass with print(line) all the lines are correctly printed. But with mass.calculate_mass(line) come several error messages:

Traceback (most recent call last):
File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/parser.py", line 275, in parse
    n, body, c = re.match(_modX_sequence, sequence).groups() AttributeError: 'NoneType' object has no attribute 'groups'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 304, in __init__
    self._from_sequence(args[0], aa_comp)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 200, in _from_sequence
    show_unmodified_termini=True)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/parser.py", line 277, in parse
    raise PyteomicsError('Not a valid modX sequence: ' + sequence) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: "Not a valid modX sequence: 'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 307, in __init__
    self._from_formula(args[0], mass_data)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 205, in _from_formula
    raise PyteomicsError('Invalid formula: ' + formula) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: "Invalid formula: 'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'\n"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/home/michaela/calculatemass.py", line 5, in <module>
    mass.calculate_mass(line)   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 499, in calculate_mass
    else Composition(*args, **kwargs))   File "/home/michaela/.local/lib/python3.5/site-packages/pyteomics/mass/mass.py", line 312, in __init__
    'formula'.format(args[0])) pyteomics.auxiliary.PyteomicsError: Pyteomics error, message: 'Could not create a Composition object from string: "\'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY\'\n": not a valid sequence or formula'

my file looks like this:

'MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'

I also tried it with

sequence='MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY'

There are no empty lines in my file.
If I try the same in the shell, it works:

mass.calculate_mass('MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY')

49589.2790365072

I also tried mass.calculate_mass(str(line)) but that did not help.

Do you know what I am doing wrong?

Body:
It looks like your file contains quotes ('). These are interpreted as part of the sequence and break the parser.
If you just put sequences in your file without any additional characters, it should work fine:

MELNLTQLPLVHITFCGRPAVSIGVVNLVGLFGSTDYVLLQRIGSQGQTALRKGDGGGRHSKDSRDSSLDSLEIENRVRSSNMKLCRNTGLPVGCYNVVEGGIYDVVRYSDLRKGKVKGMDFATLNRHSDGRPKTRRGCRSRRKRRRDGTVENAAQSTPSDTVSSSFKQPSTPVPTDPSGTSGGTNGVSQRAKVVRAAQPSERKAHQKATKVSQTSKQTGGKEAPAVDEKNSNGTKVERTRTTKPRAPGIPKERPPRVGKEKVQQLKPVAEAAPQHAPSRSPSPRQANSNFAAVVLTASDLRSCDLGSSLSNVSVCTDKAETQMTPTTGPVTTSMQLNKSKHVPSSTGRTAAQDNGAKKTPQVATPVGESANAKKQQDVVDVDNALLVGHGSSSNGKKEGGSTGLANVRTDHSRDVVDRRAAAAPSNSIVECPCAPDAASPELGFVTVESALSRDFSLGSSLASSADSVY

Note that the end-of-line characters don't cause any problems, although that is not documented.


问:
how to check if and else if together in javascript
/html code/
Here there are 4 textbox having minimum & maximum bugdet and area. I want to check the value that maximum value should be greater than minimum area in bugdet and area.I am checking it when the form is submited.
Currently my condtion is not working for else if.

```<code>  <div class="col-xs-12 margin-y">
         <div class="width">
            <label class="col-xs-12 col-md-2">Budget</label>
            <div class="col-xs-12 col-md-10">
               <div class="col-xs-12 col-md-6 no-padding-left no-padding-left no-padding-mobile padding-vertical">
                  <input class=" form-control"   placeholder="Minimum Budget"  id="req_min_budget" name="req_min_budget" onkeypress='return validateArea(event);'>
               </div>
               <div class="col-xs-12 col-md-6 no-padding-right no-padding-left no-padding-mobile padding-vertical">
                  <input class=" form-control"  placeholder="Maximum Budget" id="req_max_budget" name="req_max_budget" onkeypress='return validateArea(event);'><span style="color:#d9534f" id="maxBudgetError"></span>
               </div>
            </div>
         </div>
      </div>
      <div class="col-xs-12 margin-y">
         <div class="width">
            <label class="col-md-4 col-md-2">Carpet Area</label>
            <div class="col-xs-12 col-md-10 no-padding padding-vertical">
               <div class="col-md-4  padding-vertical">
                  <input class=" form-control" placeholder="Minimum Area"  onblur="return validateMaxArea1(this.value)"   id="req_min_area" name="req_min_area" onkeypress='return validateArea(event);'>
               </div>
               <div class="col-md-2  no-padding-left  padding-vertical ">
                <select onchange="return changeUnit(this.value)" id="req_carpet_area_unit" required  name="req_carpet_area_unit" class="btn btn-default dropdown-toggle">
         <!-- <option value=''>Select carpet unit</option> -->
                   <?php
         global $SQFT;

          echo $this->home_model->get_dropdown('area_unit',$SQFT)?>
      </select>
               </div>
               <div class="col-md-4 padding-vertical">
                  <input class=" form-control" onblur="return validateMaxArea(this.value)"  placeholder="Maximum Area" id="req_max_area"  name="req_max_area" onkeypress='return validateArea(event);'/><span style="color:#d9534f" id="maxAreaError"></span>
               </div>
                <div class="col-md-2">
                   <select disabled id="req_carpet_area_unit1" required  name="req_carpet_area_unit1" class="btn btn-default dropdown-toggle">
         <!-- <option value=''>Select carpet unit</option> -->
         <?php
         global $SQFT;

          echo $this->home_model->get_dropdown('area_unit',$SQFT)?>
      </select>
               </div>

            </div>
         </div>
      </div>

      <button type="submit"  class="col-xs-offset-8 col-md-offset-11 btn btn-gray" id="req_submit" name="req_submit">Submit</button>
</code>```

javascript script

```<code>$(function() {
    // Setup form validation on the #register-form element
    $("#register").validate({
        // Specify the validation rules
        // Specify the validation error messages

        submitHandler: function(form)  {
            var req_min_area = $('#req_min_area').val();
            var req_max_area = $('#req_max_area').val();
            var req_min_budget = $('#req_min_budget').val();
            var req_max_budget = $('#req_max_budget').val();

            if(req_min_area!='' && req_max_area!='') {

                if(parseFloat(req_min_area)>parseFloat(req_max_area)) {
                    $('#req_max_area').css('border-color','#d9534f');
                    document.getElementById("maxAreaError").innerHTML = "Maximum area should be greater than minimum";
                } else {
                    insertReqData();
                }
            } else if(req_min_budget!='' && req_max_budget!='') {
                alert(parseFloat(req_min_budget)>parseFloat(req_max_budget));

                if(parseFloat(req_min_budget)>parseFloat(req_max_budget)) {
                    $('#req_max_budget').css('border-color','#d9534f');
                    document.getElementById("maxBudgetError").innerHTML = "Maximum area should be greater than minimum";
                } else {
                    insertReqData();
                }
            } else {
                insertReqData();
            }
        }
    });
});
</code>```

答:
well your else if condition will work when your first condition is false which isn't your goal  TRY THIS</p>

```<code>if(req_min_area!='' && req_max_area!='') {
            if(parseFloat(req_min_area)>parseFloat(req_max_area)) {
                $('#req_max_area').css('border-color','#d9534f');
                document.getElementById("maxAreaError").innerHTML = "Maximum area should be greater than minimum";
            } else {
                insertReqData();
            }
        }
        if(req_min_budget!='' && req_max_budget!='') {
            if(parseFloat(req_min_budget)>parseFloat(req_max_budget)) {
                $('#req_max_budget').css('border-color','#d9534f');
                document.getElementById("maxBudgetError").innerHTML = "Maximum area should be greater than minimum";
            } else {
                insertReqData();
            }
        }
</code>```

Body:
/html code/
Here there are 4 textbox having minimum & maximum bugdet and area. I want to check the value that maximum value should be greater than minimum area in bugdet and area.I am checking it when the form is submited.
Currently my condtion is not working for else if.

            Budget

                  <input class=" form-control"   placeholder="Minimum Budget"  id="req_min_budget" name="req_min_budget" onkeypress='return validateArea(event);'>

                  <input class=" form-control"  placeholder="Maximum Budget" id="req_max_budget" name="req_max_budget" onkeypress='return validateArea(event);'>

            Carpet Area

                  <input class=" form-control" placeholder="Minimum Area"  onblur="return validateMaxArea1(this.value)"   id="req_min_area" name="req_min_area" onkeypress='return validateArea(event);'>

                <select onchange="return changeUnit(this.value)" id="req_carpet_area_unit" required  name="req_carpet_area_unit" class="btn btn-default dropdown-toggle">

                   <?php
         global $SQFT;

          echo $this->home_model->get_dropdown('area_unit',$SQFT)?>
      </select>

                  <input class=" form-control" onblur="return validateMaxArea(this.value)"  placeholder="Maximum Area" id="req_max_area"  name="req_max_area" onkeypress='return validateArea(event);'/>

                   <select disabled id="req_carpet_area_unit1" required  name="req_carpet_area_unit1" class="btn btn-default dropdown-toggle">

         <?php
         global $SQFT;

          echo $this->home_model->get_dropdown('area_unit',$SQFT)?>
      </select>

      <button type="submit"  class="col-xs-offset-8 col-md-offset-11 btn btn-gray" id="req_submit" name="req_submit">Submit</button>

javascript script

$(function() {
    // Setup form validation on the #register-form element
    $("#register").validate({
        // Specify the validation rules
        // Specify the validation error messages

        submitHandler: function(form)  {
            var req_min_area = $('#req_min_area').val();
            var req_max_area = $('#req_max_area').val();
            var req_min_budget = $('#req_min_budget').val();
            var req_max_budget = $('#req_max_budget').val();

            if(req_min_area!='' && req_max_area!='') {

                if(parseFloat(req_min_area)>parseFloat(req_max_area)) {
                    $('#req_max_area').css('border-color','#d9534f');
                    document.getElementById("maxAreaError").innerHTML = "Maximum area should be greater than minimum";
                } else {
                    insertReqData();
                }
            } else if(req_min_budget!='' && req_max_budget!='') {
                alert(parseFloat(req_min_budget)>parseFloat(req_max_budget));

                if(parseFloat(req_min_budget)>parseFloat(req_max_budget)) {
                    $('#req_max_budget').css('border-color','#d9534f');
                    document.getElementById("maxBudgetError").innerHTML = "Maximum area should be greater than minimum";
                } else {
                    insertReqData();
                }
            } else {
                insertReqData();
            }
        }
    });
});

Body:
well your else if condition will work when your first condition is false which isn't your goal  TRY THIS

if(req_min_area!='' && req_max_area!='') {
            if(parseFloat(req_min_area)>parseFloat(req_max_area)) {
                $('#req_max_area').css('border-color','#d9534f');
                document.getElementById("maxAreaError").innerHTML = "Maximum area should be greater than minimum";
            } else {
                insertReqData();
            }
        }
        if(req_min_budget!='' && req_max_budget!='') {
            if(parseFloat(req_min_budget)>parseFloat(req_max_budget)) {
                $('#req_max_budget').css('border-color','#d9534f');
                document.getElementById("maxBudgetError").innerHTML = "Maximum area should be greater than minimum";
            } else {
                insertReqData();
            }
        }


问:
Update trigger to add data from two different tables onto audit table
I've created a after update trigger and would like to add data from two different tables(GORADID and SPRIDEN) when the update fires. The both of the tables are connected by one column(PIDM), so therefore is it possible to also collect data from table 2 ? so far i been getting errors such as ORA: no bind variables..
I also tried doing a select statements. But also no luck. Any suggestions would help.</p>

```<code>error: psl-00049: bad bind variable ':new.spriden_id'
error: psl-00049: bad bind variable ':new.spriden_first_name'
error: psl-00049: bad bind variable ':new.spriden_last_name'
</code>```

答:
Your trigger belongs to GORADID table and  :new and :old represent this table

can you try change your trigger like this ?

```<code>CREATE OR REPLACE TRIGGER GORADID_UPDT_TRG1
   AFTER UPDATE OF GORADID_ADDITIONAL_ID
   ON GORADID
   FOR EACH ROW
DECLARE
   SZRGORA_AUDIT_USER_BANNER_ID    VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_STUDENT_BANNER    VARCHAR2 (9 CHAR);
   SZRGORA_AUDIT_USER_FIRST_NAME   VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_USER_LAST_NAME    VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_ADDITIONAL_ID     VARCHAR2 (50 CHAR);
   SPRIDEN_ID                      VARCHAR2 (9 CHAR);
BEGIN
   SELECT USER INTO SZRGORA_AUDIT_USER_BANNER_ID FROM DUAL;

   SELECT SPRIDEN_ID
     INTO SZRGORA_AUDIT_STUDENT_BANNER
     FROM SPRIDEN
    WHERE     SPRIDEN_PIDM =:old.GORADID_PIDM;

   SELECT SPRIDEN_FIRST_NAME, SPRIDEN_LAST_NAME
     INTO SZRGORA_AUDIT_USER_FIRST_NAME, SZRGORA_AUDIT_USER_LAST_NAME
     FROM SATURN.SPRIDEN
    WHERE SPRIDEN_PIDM = (SELECT PIDM
                            FROM SATURN.IDM_STAFF_AFF_ST
                           WHERE USERNAME = USER);

   INSERT INTO SZRGORA_AUDIT
        VALUES (SZRGORA_AUDIT_STUDENT_BANNER,
                :new.GORADID_ADDITIONAL_ID,
                :old.GORADID_ADDITIONAL_ID,
                SZRGORA_AUDIT_USER_FIRST_NAME,
                SZRGORA_AUDIT_USER_LAST_NAME,
                USER,
                'UPDATE',
                SYSDATE,
                :new.GORADID_SURROGATE_ID,
                :new.GORADID_VERSION,
                :new.GORADID_VPDI_CODE);
END;
</code>```

Body:
I've created a after update trigger and would like to add data from two different tables(GORADID and SPRIDEN) when the update fires. The both of the tables are connected by one column(PIDM), so therefore is it possible to also collect data from table 2 ? so far i been getting errors such as ORA: no bind variables..
I also tried doing a select statements. But also no luck. Any suggestions would help.

error: psl-00049: bad bind variable ':new.spriden_id'
error: psl-00049: bad bind variable ':new.spriden_first_name'
error: psl-00049: bad bind variable ':new.spriden_last_name'

Body:
Your trigger belongs to GORADID table and  :new and :old represent this table

can you try change your trigger like this ?

CREATE OR REPLACE TRIGGER GORADID_UPDT_TRG1
   AFTER UPDATE OF GORADID_ADDITIONAL_ID
   ON GORADID
   FOR EACH ROW
DECLARE
   SZRGORA_AUDIT_USER_BANNER_ID    VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_STUDENT_BANNER    VARCHAR2 (9 CHAR);
   SZRGORA_AUDIT_USER_FIRST_NAME   VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_USER_LAST_NAME    VARCHAR2 (150 CHAR);
   SZRGORA_AUDIT_ADDITIONAL_ID     VARCHAR2 (50 CHAR);
   SPRIDEN_ID                      VARCHAR2 (9 CHAR);
BEGIN
   SELECT USER INTO SZRGORA_AUDIT_USER_BANNER_ID FROM DUAL;

   SELECT SPRIDEN_ID
     INTO SZRGORA_AUDIT_STUDENT_BANNER
     FROM SPRIDEN
    WHERE     SPRIDEN_PIDM =:old.GORADID_PIDM;

   SELECT SPRIDEN_FIRST_NAME, SPRIDEN_LAST_NAME
     INTO SZRGORA_AUDIT_USER_FIRST_NAME, SZRGORA_AUDIT_USER_LAST_NAME
     FROM SATURN.SPRIDEN
    WHERE SPRIDEN_PIDM = (SELECT PIDM
                            FROM SATURN.IDM_STAFF_AFF_ST
                           WHERE USERNAME = USER);

   INSERT INTO SZRGORA_AUDIT
        VALUES (SZRGORA_AUDIT_STUDENT_BANNER,
                :new.GORADID_ADDITIONAL_ID,
                :old.GORADID_ADDITIONAL_ID,
                SZRGORA_AUDIT_USER_FIRST_NAME,
                SZRGORA_AUDIT_USER_LAST_NAME,
                USER,
                'UPDATE',
                SYSDATE,
                :new.GORADID_SURROGATE_ID,
                :new.GORADID_VERSION,
                :new.GORADID_VPDI_CODE);
END;


问:
Replace the type of an object property in a Flow type
Let's say we have defined a very simple object type:

```<code>type A = {
  foo: string,
  bar: number,
  // ... many other properties
};
</code>```

Now we'd like to define a variant of this type, just replacing the type of foo by ?string:

```<code>type A2 = {
  foo: ?string,
  bar: number,
  // ... many other properties, with the same types as in A
};
</code>```

How can that be done, without having to define the whole type again?

It'd be enough if the answer only worked in the particular case of replacing property type T by ?T, since that is my most frequent problem.

答:
I would use the spread operator with exact types (introduced in flow v0.42.0).

```<code>type A = {|
  foo: string,
  bar: number,
  // ... many other properties
|}

type A2 = {
   ...A,
   foo: ?string
}
</code>```

Note: You need to use an exact type for A (the {| ... |} syntax). This is because of how flow handles unsealed (not exact) types when spreading.

Body:
Let's say we have defined a very simple object type:

type A = {
  foo: string,
  bar: number,
  // ... many other properties
};

Now we'd like to define a variant of this type, just replacing the type of foo by ?string:

type A2 = {
  foo: ?string,
  bar: number,
  // ... many other properties, with the same types as in A
};

How can that be done, without having to define the whole type again?

It'd be enough if the answer only worked in the particular case of replacing property type T by ?T, since that is my most frequent problem.

Body:
I would use the spread operator with exact types (introduced in flow v0.42.0).

type A = {|
  foo: string,
  bar: number,
  // ... many other properties
|}

type A2 = {
   ...A,
   foo: ?string
}

Note: You need to use an exact type for A (the {| ... |} syntax). This is because of how flow handles unsealed (not exact) types when spreading.


问:
Command to Change DB Column in Ruby on Rails
Is there a quick console command I can run to change the type I have for an object? It's currently a Ruby Date type, but I would like it to be a Ruby Time type.

I started with this scaffold command:

```<code>$ rails generate scaffold Post title:string content:text postdate:date
</code>```

But wish I would have done the following:

```<code>$ rails generate scaffold Post title:string content:text postdate:time
</code>```

Is there a command and can run to make the update?

答:
If you don't want the mistake to be a permanent part of the migration set, simply migrate down (rake db:rollback), edit your migration file, and migrate back up (rake db:migrate).

Edit: To answer your question about there being a single command? Yes, there is. After editing your migration:

```<code>rake db:migrate:redo
</code>```

This runs the "down" followed by the "up" in just one command.

ContentLicense: CC BY-SA 2.5

Body:
Is there a quick console command I can run to change the type I have for an object? It's currently a Ruby Date type, but I would like it to be a Ruby Time type.

I started with this scaffold command:

$ rails generate scaffold Post title:string content:text postdate:date

But wish I would have done the following:

$ rails generate scaffold Post title:string content:text postdate:time

Is there a command and can run to make the update?

Body:
If you don't want the mistake to be a permanent part of the migration set, simply migrate down (rake db:rollback), edit your migration file, and migrate back up (rake db:migrate).

Edit: To answer your question about there being a single command? Yes, there is. After editing your migration:

rake db:migrate:redo

This runs the "down" followed by the "up" in just one command.


问:
Display random post for 24h as home page Wordpress
I'm looking for a way to display the content of my random post as a main page. This post should be displayed for 24h. Meaning: on Monday my home page shows post1, on Tuesday, when one enters my home page again, it displays post2, etc.

Posts are picked randomly from my posts list...

I've spent couple of hours already looking for the right plugin... no luck so far :/

答:
```<code>$randomPosts = get_posts(array(
   'orderby' => 'rand',
   'posts_per_page' => 1,
   'tag' => $tag,
));
</code>```


问:
Change Date Format
I am using the UI DatePicker from jQuery UI as the standalone picker. I have this code:

And I'm using this code for getting a selected date

```<code>select: function (selectedDate) {

     $("#customer1").show();
          $("#selected-date").text(selectedDate);

      },
</code>```

It's working perfect but not in correct format.

It's showing "Wed Jun 14 2017 00:00:00 GMT+0000
" in this format but I want like 14/06/2017.

Please help me to get in this format dd/mm/yy

Thanks

答:
I used this code and it's working absolutely perfect :)

select: function ( selectedDate) {

```<code>                  $("#customer1").show();
                  var selectedDate = moment(selectedDate).format("DD/MM/YYYY");
                  $("#selected-date").text(selectedDate);
              }
</code>```

Title: Change Date Format

Body:
I am using the UI DatePicker from jQuery UI as the standalone picker. I have this code:

And I'm using this code for getting a selected date

select: function (selectedDate) {

     $("#customer1").show();
          $("#selected-date").text(selectedDate);

      },

It's working perfect but not in correct format.

It's showing "Wed Jun 14 2017 00:00:00 GMT+0000
" in this format but I want like 14/06/2017.

Please help me to get in this format dd/mm/yy

Thanks

Body:
I used this code and it's working absolutely perfect :)

select: function ( selectedDate) {

                  $("#customer1").show();
                  var selectedDate = moment(selectedDate).format("DD/MM/YYYY");
                  $("#selected-date").text(selectedDate);
              }


问:
Vertically centered text in a dynamic height wrapper
I'd normally just use line-height for vertical centering, but on this occasion the layout I'm working to is a little trickier.

I've put together this jsfiddle to show where I'm at so far. All the CSS hacks suggest using table-cell trickery for this but I can only get it to work if the wrapper has an absolute height, so for me this text isn't vertically centered:

```<code><div class="wrap">
    <a href="#">
        <img src="http://www.thekrausemouse.com/wp-content/uploads/2016/03/sample-1.jpg" />
        <span class="text"><span>Text that might span multiple lines</span></span>
    </a>
</div>
</code>```

https://jsfiddle.net/fdtbvmcw/

What I basically need is for the text, regardless of how many lines it spans, to sit in the middle of the image. The image can't be a background-image and I can't attach fixed widths or heights to the wrapper.

The wrapper is simulating a responsive column within a bigger page template and I need the image to retain full width of that column you see. Other HTML can be added within the column if need be.

Thoughts?

答:
Flexbox can do that...

.wrap {
  height: auto;
  position: relative;
  width: 50%;
}

.wrap a img {
  height: auto;
  width: 100%;
}

.wrap a span.text {
  height: 100%;
  left: 0;
  position: absolute;
  text-align: center;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrap a span.text span {
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  line-height: 1.25
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrap">

    <img src="http://www.thekrausemouse.com/wp-content/uploads/2016/03/sample-1.jpg" />
    <span class="text"><span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id praesentium nihil iure amet dolore nulla totam modi </span></span>

</div></code>```

Body:
I'd normally just use line-height for vertical centering, but on this occasion the layout I'm working to is a little trickier.

I've put together this jsfiddle to show where I'm at so far. All the CSS hacks suggest using table-cell trickery for this but I can only get it to work if the wrapper has an absolute height, so for me this text isn't vertically centered:

        Text that might span multiple lines

https://jsfiddle.net/fdtbvmcw/

What I basically need is for the text, regardless of how many lines it spans, to sit in the middle of the image. The image can't be a background-image and I can't attach fixed widths or heights to the wrapper.

The wrapper is simulating a responsive column within a bigger page template and I need the image to retain full width of that column you see. Other HTML can be added within the column if need be.

Thoughts?

Body:
Flexbox can do that...

.wrap {
  height: auto;
  position: relative;
  width: 50%;
}

.wrap a img {
  height: auto;
  width: 100%;
}

.wrap a span.text {
  height: 100%;
  left: 0;
  position: absolute;
  text-align: center;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrap a span.text span {
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  line-height: 1.25
}

<div class="wrap">
  <a href="#">
    <img src="http://www.thekrausemouse.com/wp-content/uploads/2016/03/sample-1.jpg" />
    <span class="text"><span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id praesentium nihil iure amet dolore nulla totam modi </span></span>
  </a>
</div>


问:
How can I add an image to the back of a CALayer after rotate 90 degrees?
I want to add a back image to a CALayer when the my rotation transform degree is higher than 90.

It is just like a Flipboard flip animation.

This is my current code:

```<code> CALayer *layer = self.view.layer;

 int frames = 130;

 layer.anchorPoint = CGPointMake(0, 0.5);

 CATransform3D transform = CATransform3DIdentity;
 transform.m34 = 1.0 / -2000.0;
 transform = CATransform3DRotate(transform, -frames * M_PI / 180.0, 0.0, 1.0, 0.0);

 self.view.layer.transform = transform;

 CAKeyframeAnimation *pivot = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

 NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:45];
 NSMutableArray *times = [[NSMutableArray alloc] initWithCapacity:45];

 for (int i = 0; i < frames; i++) {

  CATransform3D transform = CATransform3DIdentity;
  transform.m34 = 1.0 / -2000.0;
  transform = CATransform3DRotate(transform, -M_PI / 180.0 * i, 0.0, 1.0, 0.0);

  [values addObject:[NSValue valueWithCATransform3D:transform]];
  [times addObject:[NSNumber numberWithFloat:(float)i / (frames - 1)]];
 }

 pivot.values = values;
 pivot.keyTimes = times;

 [values release];
 [times release];

 pivot.duration = 0.5f;
 pivot.calculationMode = kCAAnimationLinear;

 [layer addAnimation: pivot forKey: @"pivot"];
</code>```

Could anyone tell me how to add a back image just like the flip effect.

答:
As far as I know, the easiest way to do it is to add two sublayers representing the front side and the back side of the page. Set both the sublayers' doubleSided property to NO. Set the back side layer transform to the same flipped transform you're animating to. Then, when the page's front side faces the viewer, the front side layer is visible and the back side layer is "hidden", and vice versa.

See GeekGameBoard source code (Card.m) for a sample of the technique.

Body:
I want to add a back image to a CALayer when the my rotation transform degree is higher than 90.

It is just like a Flipboard flip animation.

This is my current code:

 CALayer *layer = self.view.layer;

 int frames = 130;

 layer.anchorPoint = CGPointMake(0, 0.5);

 CATransform3D transform = CATransform3DIdentity;
 transform.m34 = 1.0 / -2000.0;
 transform = CATransform3DRotate(transform, -frames * M_PI / 180.0, 0.0, 1.0, 0.0);

 self.view.layer.transform = transform;

 CAKeyframeAnimation *pivot = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

 NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:45];
 NSMutableArray *times = [[NSMutableArray alloc] initWithCapacity:45];

 for (int i = 0; i < frames; i++) {

  CATransform3D transform = CATransform3DIdentity;
  transform.m34 = 1.0 / -2000.0;
  transform = CATransform3DRotate(transform, -M_PI / 180.0 * i, 0.0, 1.0, 0.0);

  [values addObject:[NSValue valueWithCATransform3D:transform]];
  [times addObject:[NSNumber numberWithFloat:(float)i / (frames - 1)]];
 }

 pivot.values = values;
 pivot.keyTimes = times;

 [values release];
 [times release];

 pivot.duration = 0.5f;
 pivot.calculationMode = kCAAnimationLinear;

 [layer addAnimation: pivot forKey: @"pivot"];

Could anyone tell me how to add a back image just like the flip effect.


问:
How to count total number of table rows from ajax response? How to create search field for that table?
I am getting table data from ajax response like this :

```<code>function fetch_data(){
  $.ajax({
    url: "menu_table.php",
    method: "POST",
    success: function(data) {
      $('#menu_table_data').html(data);
    }
  });
}

fetch_data();
</code>```

Table:

```<code><table id="menu_table">
  <thead>
    <tr>
      <th class="centerText" data-field="item_id">ID</th>
      <th class="centerText" data-field="name">Name</th>
      <th class="centerText" data-field="price">Price</th>
      <th class="centerText" data-field="type">Type</th>
      <th class="centerText" data-field="image">Image</th>
      <th class="centerText" data-field="description">Description</th>
      <th class="centerText" data-field="cooking">Instructions</th>
      <th class="centerText" data-field="ingredients">Ingredients</th>
      <th class="centerText" data-field="warnings">Warnings</th>
      <th class="centerText" data-field="Storage">Storage</th>
      <th class="centerText" data-field="Size">Size</th>
      <th class="centerText" data-field="edit">Edit</th>
      <th class="centerText" data-field="delete">Delete</th>
    </tr>
  </thead>
  <tbody style="text-align:center;" id="menu_table_data"></tbody>
</table>
</code>```

How do I count total number of rows from ajax response?

How can I create a search field to search from this table?

menu_table.php:

```<code>while($data = mysqli_fetch_array($search))
{
$output .= '<tr><td>'.$data['id'].'</td>
            <td><div class="text_area">'.$data['name'].'</div></td>
            <td>'.$data['price'].'</td>
            <td>'.$data['type'].'</td>
            <td><div id="div_image">
            <img src="uploaded_images/'.$data['image'].'" class="thumbnail" height="100" width="80" /></div></td>
            <td><div class="text_area">'.$data['description'].'</div></td>
            <td><div class="text_area">'.$data['cooking_instructions'].'<div></td>
            <td><div class="text_area">'.$data['ingredients'].'</div></td>
            <td><div class="text_area">'.$data['allergen_warnings'].'</div></td>
            <td>'.$data['storage_instructions'].'</td>
            <td>'.$data['case_size'].'</td>   <td><a class="btn btn-primary glyphicon glyphicon-edit" role="button" onclick="EditModal(`'.$data['id'].'`,`'.$data['name'].'`,`'.$data['price'].'`,`'.$data['description'].'`,`'.$data['type'].'`,`'.$data['cooking_instructions'].'`,`'.$data['ingredients'].'`,`'.$data['allergen_warnings'].'`,`'.$data['storage_instructions'].'`,`'.$data['case_size'].'`,`'."uploaded_images/".$data['image'].'`)"></a></td>   <td><a class="btn btn-danger glyphicon glyphicon-remove" role="button" onclick="DeleteModal('.$data['id'].')"></a></td><tr>';}
</code>```

答:
after you change html

```<code>$("#menu_table_data tr")
</code>```

will give you all table rows

to create a search field

```<code>var searchKey = "some given key in some form";
$("#menu_table_data tr").each(function(item){
 if(item.text().indexOf(searchKey)>=0){
     item.addClass("hideResult");
 }else{
     item.removeClass("hideResult");
 }
});
</code>```

and you can hide negative results

```<code>.hideResult{
    display: none;
}
</code>```

also you can filter data without append it at the begining. $ function takes aprameters other than selectors too.

for example

```<code>var somehtml = '<div>some text</div>';

$(somehtml).text() //this will gives you 'some text'
</code>```

Body:
I am getting table data from ajax response like this :

function fetch_data(){
  $.ajax({
    url: "menu_table.php",
    method: "POST",
    success: function(data) {
      $('#menu_table_data').html(data);
    }
  });
}

fetch_data();

Table:

      ID
      Name
      Price
      Type
      Image
      Description
      Instructions
      Ingredients
      Warnings
      Storage
      Size
      Edit
      Delete

How do I count total number of rows from ajax response?

How can I create a search field to search from this table?

menu_table.php:

while($data = mysqli_fetch_array($search))
{
$output .= '
'.$data['id'].'

'.$data['name'].'

            '.$data['price'].'
            '.$data['type'].'

'.$data['description'].'

'.$data['cooking_instructions'].'

'.$data['ingredients'].'

'.$data['allergen_warnings'].'

            '.$data['storage_instructions'].'
            '.$data['case_size'].'	   <a class="btn btn-primary glyphicon glyphicon-edit" role="button" onclick="EditModal(`'.$data['id'].'`,`'.$data['name'].'`,`'.$data['price'].'`,`'.$data['description'].'`,`'.$data['type'].'`,`'.$data['cooking_instructions'].'`,`'.$data['ingredients'].'`,`'.$data['allergen_warnings'].'`,`'.$data['storage_instructions'].'`,`'.$data['case_size'].'`,`'."uploaded_images/".$data['image'].'`)">
';}

Body:
after you change html

$("#menu_table_data tr")

will give you all table rows

to create a search field

var searchKey = "some given key in some form";
$("#menu_table_data tr").each(function(item){
 if(item.text().indexOf(searchKey)>=0){
     item.addClass("hideResult");
 }else{
     item.removeClass("hideResult");
 }
});

and you can hide negative results

.hideResult{
    display: none;
}

also you can filter data without append it at the begining. $ function takes aprameters other than selectors too.

for example

var somehtml = '<div>some text</div>';

$(somehtml).text() //this will gives you 'some text'


问:
Formatting till Hour only in a Date Time Variable
I have a DateTime variable, with an example value as 2017-03-06-09.35.44.660000

I would like to have these values till Hours only: 2017-03-06-09

How do I do this in R?

答:
Using the lubridate package:

```<code>library(lubridate)
time <- "2017-03-06-09.35.44.660000"
time2 <- ymd_hms(time)
time3 <- ymd_h(paste0(year(time2), "-", month(time2), "-", day(time2), "-", hour(time2)))
time3
# "2017-03-06 09:00:00 UTC"
</code>```

Body:
Using the lubridate package:

library(lubridate)
time <- "2017-03-06-09.35.44.660000"
time2 <- ymd_hms(time)
time3 <- ymd_h(paste0(year(time2), "-", month(time2), "-", day(time2), "-", hour(time2)))
time3
# "2017-03-06 09:00:00 UTC"


问:
extracting multiples values from status table in mysql
I've got 3 tables, 2 of which contain data and one contains statuses for the other two.

table A contains data

table B contains data

table S contains Status values for A and B

Example of Status table entries:

I'm trying to build a query to extract all the statuses for a range of data entries from A and B.
Example of desired result:

I've already got a piece of code that works but is really slow, especially since there are like 10 statuses, and sometimes for hundreds of entries at a time.

```<code>select S.owner, S.foreign_key,
       s1 as ordered_Status, s2 as payed_Status, s3 as dispached_Status
from S as s1, S as s2, S as s3
where s1 like '%ordered%'
and s2 like '%payed%'
and s3 like '%dispached%'
group by S.foreign_key;
</code>```

The criteria by which i select the foreign_key is also not shown here but you can imagine it slows down the query even more.
There has to be a more efficient way of extracting this information.

I'm not sure it's relevant but as for the structures of table A and B:

Table A:

Table B:

I make the selection based on product and time. The updated sql query based on the new information would be:

```<code>select S.owner, S.foreign_key,
       s1 as ordered_Status, s2 as payed_Status, s3 as dispached_Status
from S as s1, S as s2, S as s3, A, B
where s1 like '%ordered%'
and s1.foreign_key=A.id
and s2 like '%payed%'
and s2.foreign_key=A.id
and s3 like '%dispached%'
and s3.foreign_key=B.id
and B.fk_A=A.id
and B.fk_product=99
and A.date_created > '2017-07-04 08:00:00'
group by S.foreign_key;
</code>```

答:
The query is very slow due to the multiple self joins you do in your query. You can get your desired output by using the case when statement like below,

case(when(status_name='ordered' and status=1 then 1 else 0)) as ordered_status

Body:
I've got 3 tables, 2 of which contain data and one contains statuses for the other two.

table A contains data

table B contains data

table S contains Status values for A and B

Example of Status table entries:

I'm trying to build a query to extract all the statuses for a range of data entries from A and B.
Example of desired result:

I've already got a piece of code that works but is really slow, especially since there are like 10 statuses, and sometimes for hundreds of entries at a time.

select S.owner, S.foreign_key,
       s1 as ordered_Status, s2 as payed_Status, s3 as dispached_Status
from S as s1, S as s2, S as s3
where s1 like '%ordered%'
and s2 like '%payed%'
and s3 like '%dispached%'
group by S.foreign_key;

The criteria by which i select the foreign_key is also not shown here but you can imagine it slows down the query even more.
There has to be a more efficient way of extracting this information.

I'm not sure it's relevant but as for the structures of table A and B:

Table A:

Table B:

I make the selection based on product and time. The updated sql query based on the new information would be:

select S.owner, S.foreign_key,
       s1 as ordered_Status, s2 as payed_Status, s3 as dispached_Status
from S as s1, S as s2, S as s3, A, B
where s1 like '%ordered%'
and s1.foreign_key=A.id
and s2 like '%payed%'
and s2.foreign_key=A.id
and s3 like '%dispached%'
and s3.foreign_key=B.id
and B.fk_A=A.id
and B.fk_product=99
and A.date_created > '2017-07-04 08:00:00'
group by S.foreign_key;


问:
Java 8 streams do something with an element which has a boolean field
I wanna make streams from a list, and do something with an object if an certain field is true.

Let me show you what have I done till now:

```<code>    List<UserData> userDataList = new ArrayList<>();

    phoneNumbers.forEach(phoneNumber -> {
        if (phoneNumber.getPrimary()) {
            UserData userData = new UserData();
            userData.setDescription(phoneNumber.getType());
            userData.setValue(phoneNumber.getNumber);
            userDataList.add(userData);
        }
    });
</code>```

So if phoneNumber.getPrimary() == true will do the following task, if not -
 ignore it.

答:
Yes, you can combine filter with map to transform the List of relevant elements into a Stream of UserData, and then collect them into a List:

```<code>List<UserData> userDataList =
    phoneNumbers.stream()
                .filter(p -> p.getPrimary()) // or filter(ClassName::getPrimary)
                .map(p -> {
                         UserData userData = new UserData();
                         userData.setDescription(p.getType());
                         userData.setValue(p.getNumber());
                         return userData;
                         })
                .collect(Collectors.toList());
</code>```

And if UserData has a constructor that takes the type and number, you can make the code shorter:

```<code>List<UserData> userDataList =
    phoneNumbers.stream()
                .filter(p -> p.getPrimary()) // or filter(ClassName::getPrimary)
                .map(p -> new UserData(p.getType(),p.getNumber()))
                .collect(Collectors.toList());
</code>```

Body:
I wanna make streams from a list, and do something with an object if an certain field is true.

Let me show you what have I done till now:

    List<UserData> userDataList = new ArrayList<>();

    phoneNumbers.forEach(phoneNumber -> {
        if (phoneNumber.getPrimary()) {
            UserData userData = new UserData();
            userData.setDescription(phoneNumber.getType());
            userData.setValue(phoneNumber.getNumber);
            userDataList.add(userData);
        }
    });

So if phoneNumber.getPrimary() == true will do the following task, if not -
 ignore it.

Body:
Yes, you can combine filter with map to transform the List of relevant elements into a Stream of UserData, and then collect them into a List:

List<UserData> userDataList =
    phoneNumbers.stream()
                .filter(p -> p.getPrimary()) // or filter(ClassName::getPrimary)
                .map(p -> {
                         UserData userData = new UserData();
                         userData.setDescription(p.getType());
                         userData.setValue(p.getNumber());
                         return userData;
                         })
                .collect(Collectors.toList());

And if UserData has a constructor that takes the type and number, you can make the code shorter:

List<UserData> userDataList =
    phoneNumbers.stream()
                .filter(p -> p.getPrimary()) // or filter(ClassName::getPrimary)
                .map(p -> new UserData(p.getType(),p.getNumber()))
                .collect(Collectors.toList());


问:
Change Color Of button According to time
I want to change the color of button according to my shift timings. Likewise if it's a morning shift going the button color should be blue and in the evening it should automatically change to red or any different color. I need four different colors. Can anyone help me in this?

$(document).ready(function(){
  $("#hex").on('change', function(){
    var hex = $("#hex").val();
    $("#btn").css({"background-color":hex});
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="hex" />
<input type="button" id="btn" /></code>```

答:
Below is the sample code to help you. Just get the hours from the Date(), use the if-else condition or switch-case and add the colors that you want:

$(document).ready(function() {
  var hours = new Date().getHours();
  var color = '#d00';
  if (hours < 12)
    color = '#FFF';
  else if (hours > 12 && hours < 15)
    color = '#000';
  $("#btn").css({
    "background-color": color
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="hex" />
<input type="button" id="btn" /></code>```

Body:
I want to change the color of button according to my shift timings. Likewise if it's a morning shift going the button color should be blue and in the evening it should automatically change to red or any different color. I need four different colors. Can anyone help me in this?

$(document).ready(function(){
  $("#hex").on('change', function(){
    var hex = $("#hex").val();
    $("#btn").css({"background-color":hex});
  });
});

<input type="text" id="hex" />
<input type="button" id="btn" />

Body:
Below is the sample code to help you. Just get the hours from the Date(), use the if-else condition or switch-case and add the colors that you want:

$(document).ready(function() {
  var hours = new Date().getHours();
  var color = '#d00';
  if (hours < 12)
    color = '#FFF';
  else if (hours > 12 && hours < 15)
    color = '#000';
  $("#btn").css({
    "background-color": color
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="hex" />
<input type="button" id="btn" />


问:
What happens in the background of array initialization in c?
Given that this is legal

```<code>uint8_t bytes[4] = { 1, 2, 3, 4 };
</code>```

And this is not:

```<code>uint8_t bytes2[4];
bytes2 = { 1, 2, 3, 4 };
</code>```

what does { 1, 2, 3, 4 } represent?

Am assuming it's neither an rvalue or an lvalue. A preprocessor code candy that expands to something?

答:
{1,2,3,4} is an initializer list. It an be used to specify the initial value of an object with at least 4 elements, be they array elements or structure members including those of nested objects.

You cannot use this syntax to assign values to an array as this:

```<code>bytes2 = {1,2,3,4};
</code>```

Because the syntax is not supported, and arrays are not lvalues.

You can use intializer lists as part of a C99 syntax known as compound literals to create objects and use them as rvalues for assignment, return values or function arguments:

```<code>struct quad { int x, y, z, t; };

struct quad p;
p = (struct quad){1,2,3,4};
</code>```

You still cannot use this for arrays because they are not lvalues, but you can achieve the same effect with a call to memcpy():

```<code>uint8_t bytes2[4];
memcpy(bytes2, (uint8_t[4]){1,2,3,4}, sizeof(bytes2));
</code>```

This statement is compiled by clang as a single intel instruction as can be seen on Godbolt's Compiler Explorer

Body:
Given that this is legal

uint8_t bytes[4] = { 1, 2, 3, 4 };

And this is not:

uint8_t bytes2[4];
bytes2 = { 1, 2, 3, 4 };

what does { 1, 2, 3, 4 } represent?

Am assuming it's neither an rvalue or an lvalue. A preprocessor code candy that expands to something?

Body:
{1,2,3,4} is an initializer list. It an be used to specify the initial value of an object with at least 4 elements, be they array elements or structure members including those of nested objects.

You cannot use this syntax to assign values to an array as this:

bytes2 = {1,2,3,4};

Because the syntax is not supported, and arrays are not lvalues.

You can use intializer lists as part of a C99 syntax known as compound literals to create objects and use them as rvalues for assignment, return values or function arguments:

struct quad { int x, y, z, t; };

struct quad p;
p = (struct quad){1,2,3,4};

You still cannot use this for arrays because they are not lvalues, but you can achieve the same effect with a call to memcpy():

uint8_t bytes2[4];
memcpy(bytes2, (uint8_t[4]){1,2,3,4}, sizeof(bytes2));

This statement is compiled by clang as a single intel instruction as can be seen on Godbolt's Compiler Explorer


问:
Oracle Error PLS-00323: subprogram or cursor is declared in a package specification and must be defined in the package body
Can someone help me put my pl/sql procedure in a package? I've tried and I'm struggling with it:

This is what I have, for my package specification:

```<code>CREATE OR REPLACE PACKAGE film_pkg
IS
title VARCHAR2(100);
PROCEDURE get_films(fname VARCHAR2);
END film_pkg;

--
</code>```

This is my package body where im running into the problems:

```<code>  CREATE OR REPLACE PACKAGE BODY film_pkg
IS
   PROCEDURE get_films (fname    IN     film.title%TYPE,
                        r_date      OUT film.release_date%TYPE,
                        dur         OUT film.duration%TYPE)
   AS
   BEGIN
      SELECT release_date, duration
        INTO r_date, dur
        FROM FILM
       WHERE title = fname;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         r_date := '';
         dur := '';
   END get_films;
END film_pkg;
</code>```

if anyone could help me fix the errors i'd appreciate it:

```<code>Error(4,11): PLS-00323: subprogram or cursor 'GET_FILMS' is declared in a package specification and must be defined in the package body
</code>```

答:
"subprogram or cursor 'M115_EDIT' is declared in a package specification and must be defined in the package body"

I got this error while i was working on my project.the reason for this was the a parameter name that was inside the procedure defined in the body did not match with the corresponding parameter name in the body.

my specification:

my body

my market_code parameter is different in the body when compared with the specification where it is defined as sub_market_code.error occurred due to this difference.
i changed the sub_market_code parameter in the specification to market_code so that it matches with the body and this solved the problem mentioned above.

clearly 2 parameters that are mentioned in your body implementation of the procedure 'r_date' and 'dur' are not defined in the specification.error is due to this difference between the body and the specification.

Body:
Can someone help me put my pl/sql procedure in a package? I've tried and I'm struggling with it:

This is what I have, for my package specification:

CREATE OR REPLACE PACKAGE film_pkg
IS
title VARCHAR2(100);
PROCEDURE get_films(fname VARCHAR2);
END film_pkg;

--

This is my package body where im running into the problems:

  CREATE OR REPLACE PACKAGE BODY film_pkg
IS
   PROCEDURE get_films (fname    IN     film.title%TYPE,
                        r_date      OUT film.release_date%TYPE,
                        dur         OUT film.duration%TYPE)
   AS
   BEGIN
      SELECT release_date, duration
        INTO r_date, dur
        FROM FILM
       WHERE title = fname;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         r_date := '';
         dur := '';
   END get_films;
END film_pkg;

if anyone could help me fix the errors i'd appreciate it:

Error(4,11): PLS-00323: subprogram or cursor 'GET_FILMS' is declared in a package specification and must be defined in the package body


问:
Unable to create array of objects in angularjs in foreach loop
I am developing web application in angularjs. I have one foreach loop to loop through scope object. Below is my js code.

```<code>$scope.details = [];
$scope.apply = function() {
    angular.forEach($scope.screenMap, function(value, key) {
        //$scope.details.push(value.scrn_id, value.Read, value.Write);
        $scope.details.push("ID", value.scrn_id);
        $scope.details.push("Read", value.Read);
        $scope.details.push("Write", value.Write);
    });
    console.log($scope.details);
}
</code>```

After looping I get total 18 entries for 3 iterations.

What I am expecting is

```<code>  ID:1  Read:True  Write: False
  ID:2  Read:False  Write: True
  ID:3  Read:True  Write: False
  ID:4  Read:False  Write: True
</code>```

may I know how can I get array in above format?

答:
You have to push to the array the values as an object to achieve this.</p>

```<code>$scope.details = [];
        $scope.apply = function () {
            angular.forEach($scope.screenMap, function (value, key) {
                //$scope.details.push(value.scrn_id, value.Read, value.Write);
                $scope.details.push({"ID":value.scrn_id,"Read":value.Read,"Write":value.Write});
            });
            console.log($scope.details);
        }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am developing web application in angularjs. I have one foreach loop to loop through scope object. Below is my js code.

$scope.details = [];
$scope.apply = function() {
    angular.forEach($scope.screenMap, function(value, key) {
        //$scope.details.push(value.scrn_id, value.Read, value.Write);
        $scope.details.push("ID", value.scrn_id);
        $scope.details.push("Read", value.Read);
        $scope.details.push("Write", value.Write);
    });
    console.log($scope.details);
}

After looping I get total 18 entries for 3 iterations.

What I am expecting is

  ID:1  Read:True  Write: False
  ID:2  Read:False  Write: True
  ID:3  Read:True  Write: False
  ID:4  Read:False  Write: True

may I know how can I get array in above format?

Body:
You have to push to the array the values as an object to achieve this.

$scope.details = [];
        $scope.apply = function () {
            angular.forEach($scope.screenMap, function (value, key) {
                //$scope.details.push(value.scrn_id, value.Read, value.Write);
                $scope.details.push({"ID":value.scrn_id,"Read":value.Read,"Write":value.Write});
            });
            console.log($scope.details);
        }


答:
Try this code </p>

```<code>$scope.details = [];
$scope.apply = function () {
    angular.forEach($scope.screenMap, function (value, key) {
        var obj = {
            "ID" : value.scrn_id,
            "Read" : value.Read,
            "Write" :  value.Write
        };
        $scope.details.push(obj);
    });
    console.log($scope.details);
}
</code>```

Title: Unable to create array of objects in angularjs in foreach loop

Body:
Try this code

$scope.details = [];
$scope.apply = function () {
    angular.forEach($scope.screenMap, function (value, key) {
        var obj = {
            "ID" : value.scrn_id,
            "Read" : value.Read,
            "Write" :  value.Write
        };
        $scope.details.push(obj);
    });
    console.log($scope.details);
}


答:
push it as an object</p>

```<code>$scope.details = [];
        $scope.apply = function () {
            angular.forEach($scope.screenMap, function (value, key) {

                $scope.details.push({"ID": value.scrn_id,
                                    "Read": value.Read,
                                    "Write": value.Write});
            });
            console.log($scope.details);
        }
</code>```

Body:
push it as an object

$scope.details = [];
        $scope.apply = function () {
            angular.forEach($scope.screenMap, function (value, key) {

                $scope.details.push({"ID": value.scrn_id,
                                    "Read": value.Read,
                                    "Write": value.Write});
            });
            console.log($scope.details);
        }


问:
R: using hatched fill in plots
I was using R to make some plots for a report. I see that the plots don't seem to be so smooth. I am new to R so don't know much. But how do I get smooth plots?

Also by default the plots are filled with solid colors but I want to have hatched fills in my pie charts and bar plots. Is there a way to do that in R, I couldn't find it through a basic google search so I put this question here.

答:
Note that cross hatching and filling with lines is a hold over from the days when the only way to get quality graphics was with pen plotters (devices that literally drew the plot using a mechanical arm and a pen).  Solid fills did not work well on those devices, often making holes in the paper when trying.

Now with high quality monitors and printers, solid fills are prefered, in fact research has shown that cross hatching can cause optical illusions due to the Moire effect, so are best avoided.

Pie charts are also best avoided, the only thing they do better than bar charts is hide and obscure data.  Dotplots are becoming prefered to bar charts and with dotplots you don't need to worry about fills.

I know this does not answer the question you asked, but it does answer the one you should have asked.

Title: R: using hatched fill in plots


问:
how to add an attribute programmatically to product in magento1.9?
I'm beginner in Magento, and I used Magento1.9 CE,
I want to add an attribute, programmatically, in catalog/product.
I mean, that I want to see it in orange box that I highlighted on

This Image

I change version in magento/app/code/core/Mage/Catalog/etc/config.xml file

```<code>`<modules>
    <Mage_Catalog>
        <version>1.6.0.0.19.1.15</version>
    </Mage_Catalog>
 </modules>`
</code>```

and I add this file /magento/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-data-upgrade-1.6.0.0.19.1.15.php

```<code>$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'promotion', array(
    'group'             => 'promotion',
    'type'              => 'text',
    'backend'           =>
    'catalog/product_attribute_backend_promotion',
    'frontend'          => '',
    'label'             => 'promotion',
    'input'             => 'text',
    'class'             => '',
    'source'            => '',
    'global'            => Mage_Eav_Model_Entity_Setup::SCOPE_GLOBAL,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => false,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => 'simple,virtual',
    'is_configurable'   => false
));
</code>```

when I refreshed add product page, In database core_resource table, catalog_setup version changed to 1.6.0.0.19.1.15 but nothing happend to eav_attribute

what should I do to add 'promotion' in eav_attribute table?

答:
Step1: first create a php file.

Step2: write below code in file.

```<code><?php
require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttribute('catalog_product', 'custom_att', array(
            'group'           => 'General',
            'label'           => 'Custom att',
            'input'           => 'text',
            'type'            => 'varchar',
            'required'        => 0,
            'visible_on_front'=> 1,
            'filterable'      => 0,
            'searchable'      => 0,
            'comparable'      => 0,
            'user_defined'    => 1,
            'is_configurable' => 0,
            'global'          => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'note'            => '',
));
$installer->endSetup();
?>
</code>```

Step3: put this file on root and run this file by url. Then product attribute are created.

Body:
I'm beginner in Magento, and I used Magento1.9 CE,
I want to add an attribute, programmatically, in catalog/product.
I mean, that I want to see it in orange box that I highlighted on

This Image

I change version in magento/app/code/core/Mage/Catalog/etc/config.xml file

`<modules>
    <Mage_Catalog>
        <version>1.6.0.0.19.1.15</version>
    </Mage_Catalog>
 </modules>`

and I add this file /magento/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-data-upgrade-1.6.0.0.19.1.15.php

$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'promotion', array(
    'group'             => 'promotion',
    'type'              => 'text',
    'backend'           =>
    'catalog/product_attribute_backend_promotion',
    'frontend'          => '',
    'label'             => 'promotion',
    'input'             => 'text',
    'class'             => '',
    'source'            => '',
    'global'            => Mage_Eav_Model_Entity_Setup::SCOPE_GLOBAL,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => false,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => 'simple,virtual',
    'is_configurable'   => false
));

when I refreshed add product page, In database core_resource table, catalog_setup version changed to 1.6.0.0.19.1.15 but nothing happend to eav_attribute

what should I do to add 'promotion' in eav_attribute table?

Body:
Step1: first create a php file.

Step2: write below code in file.

<?php
require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$installer->addAttribute('catalog_product', 'custom_att', array(
            'group'           => 'General',
            'label'           => 'Custom att',
            'input'           => 'text',
            'type'            => 'varchar',
            'required'        => 0,
            'visible_on_front'=> 1,
            'filterable'      => 0,
            'searchable'      => 0,
            'comparable'      => 0,
            'user_defined'    => 1,
            'is_configurable' => 0,
            'global'          => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'note'            => '',
));
$installer->endSetup();
?>

Step3: put this file on root and run this file by url. Then product attribute are created.


答:
```<code>       angular.forEach($scope.screenMap, function (value, key) {

            $scope.details.push({
              "ID": value.scrn_id,
              "Read": value.Read,
              "Write", value.Write
            });
        });
</code>```


问:
SQL replace a null xml value
I'm a beginner in sql, and I don't know how to find a solution to my problem.

I have a table with items, a column contains xml value. I want to check if a field exist and update it.

I find a way to modify an existing xml value, but when it's NULL it doesn't work

there is my code :

```<code>SELECT @xml=IDA_Xml,
   @isData = IDA_Xml.exist('(/Root/Data[1]/text())[1]')
FROM DATA
WHERE IDA_UId=@guid

If (@xml is NULL)
BEGIN
    -- Create a xml value with <Root></Root>
    -- It will be update later
    -- set isData to 0
END

IF (@isData = 0)
    UPDATE ItemData SET IDA_Xml.modify
    ('
        insert <Data Name = "Info">{sql:variable("@number")}</Data>
        into (/Root/*)[1]
    ')
    WHERE IDA_UId = @guid;
ELSE
    UPDATE ItemData SET IDA_Xml.modify
    ('
        replace value of (/Root/Data[1]/text())[1]
        with    sql:variable("@number")
    ')
    WHERE IDA_UId = @guid;
</code>```

答:
Following your code structure

```<code>SELECT @xml=IDA_Xml,
   @isData = IDA_Xml.exist('(/Root/Data[1]/text())[1]')
FROM DATA
WHERE IDA_UId=@guid

If (@xml is NULL)
BEGIN
    UPDATE ItemData SET IDA_Xml =  CAST('<root/>' as XML)
    WHERE IDA_UId = @guid;
    SET @isData = 0;
END

IF (@isData = 0)
    UPDATE ItemData SET IDA_Xml.modify
    ('
        insert <Data Name = "Info">{sql:variable("@number")}</Data>
        into (/Root/*)[1]
    ')
    WHERE IDA_UId = @guid;
ELSE
    UPDATE ItemData SET IDA_Xml.modify
    ('
        replace value of (/Root/Data[1]/text())[1]
        with    sql:variable("@number")
    ')
    WHERE IDA_UId = @guid;
</code>```

But I'd better restructured it using single update instead of first two updates kind of

```<code>SET IDA_Xml =  CAST('construct your entire xml here' as XML)
</code>```

Title: SQL replace a null xml value

Body:
I'm a beginner in sql, and I don't know how to find a solution to my problem.

I have a table with items, a column contains xml value. I want to check if a field exist and update it.

I find a way to modify an existing xml value, but when it's NULL it doesn't work

there is my code :

SELECT @xml=IDA_Xml,
   @isData = IDA_Xml.exist('(/Root/Data[1]/text())[1]')
FROM DATA
WHERE IDA_UId=@guid

If (@xml is NULL)
BEGIN
    -- Create a xml value with <Root></Root>
    -- It will be update later
    -- set isData to 0
END

IF (@isData = 0)
    UPDATE ItemData SET IDA_Xml.modify
    ('
        insert <Data Name = "Info">{sql:variable("@number")}</Data>
        into (/Root/*)[1]
    ')
    WHERE IDA_UId = @guid;
ELSE
    UPDATE ItemData SET IDA_Xml.modify
    ('
        replace value of (/Root/Data[1]/text())[1]
        with    sql:variable("@number")
    ')
    WHERE IDA_UId = @guid;

Body:
Following your code structure

SELECT @xml=IDA_Xml,
   @isData = IDA_Xml.exist('(/Root/Data[1]/text())[1]')
FROM DATA
WHERE IDA_UId=@guid

If (@xml is NULL)
BEGIN
    UPDATE ItemData SET IDA_Xml =  CAST('<root/>' as XML)
    WHERE IDA_UId = @guid;
    SET @isData = 0;
END

IF (@isData = 0)
    UPDATE ItemData SET IDA_Xml.modify
    ('
        insert <Data Name = "Info">{sql:variable("@number")}</Data>
        into (/Root/*)[1]
    ')
    WHERE IDA_UId = @guid;
ELSE
    UPDATE ItemData SET IDA_Xml.modify
    ('
        replace value of (/Root/Data[1]/text())[1]
        with    sql:variable("@number")
    ')
    WHERE IDA_UId = @guid;

But I'd better restructured it using single update instead of first two updates kind of

SET IDA_Xml =  CAST('construct your entire xml here' as XML)


问:
How to make UITableView ignore UINavigationController
So I have this screen:

Current TableViewController

This image is a subview of a UIView, which I use as a header for a table:

```<code>class CoursesDetailPageHeader: UITableViewHeaderFooterView {

    @IBOutlet weak var imageView: UIImageView!

    override func awakeFromNib() {
        super.awakeFromNib()

        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
    }

    func setDefaultImage() {
        imageView.image = UIImage(named: "header")
    }
}
</code>```

And my tableView:

```<code>override func viewDidLoad() {
    super.viewDidLoad()

    let headerNib = UINib(nibName: "CoursesDetailPageHeader", bundle: nil)
    tableView.register(headerNib, forHeaderFooterViewReuseIdentifier: "pageHeader")
}

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 220
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let pageHeader = tableView.dequeueReusableHeaderFooterView(withIdentifier: "pageHeader") as! CoursesDetailPageHeader
    pageHeader.setDefaultImage()

    return pageHeader
}
</code>```

What should I do, to bring the tableView to the top, so that there is no empty space (where the transparent navController)?

UPD:
To show what I want to have:
Desired TableViewController

SOLVED:
Thank to @kathayatnk issue was solved with the following code:

```<code>let statusBarHeight = UIApplication.shared.statusBarFrame.height
let navigationBarHeight = navigationController!.navigationBar.frame.size.height
let insets = UIEdgeInsets(top: -(statusBarHeight + navigationBarHeight), left: 0, bottom: 0, right: 0)
self.tableView.contentInset = insets
</code>```

答:
You can probably set the insets of the embedded tableView</p>

```<code>let insets = UIEdgeInsets(top: -64.0, left: 0, bottom: 0, right: 0)
self.tableView.contentInset = insets;
</code>```

Body:
So I have this screen:

Current TableViewController

This image is a subview of a UIView, which I use as a header for a table:

class CoursesDetailPageHeader: UITableViewHeaderFooterView {

    @IBOutlet weak var imageView: UIImageView!

    override func awakeFromNib() {
        super.awakeFromNib()

        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
    }

    func setDefaultImage() {
        imageView.image = UIImage(named: "header")
    }
}

And my tableView:

override func viewDidLoad() {
    super.viewDidLoad()

    let headerNib = UINib(nibName: "CoursesDetailPageHeader", bundle: nil)
    tableView.register(headerNib, forHeaderFooterViewReuseIdentifier: "pageHeader")
}

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 220
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let pageHeader = tableView.dequeueReusableHeaderFooterView(withIdentifier: "pageHeader") as! CoursesDetailPageHeader
    pageHeader.setDefaultImage()

    return pageHeader
}

What should I do, to bring the tableView to the top, so that there is no empty space (where the transparent navController)?

UPD:
To show what I want to have:
Desired TableViewController

SOLVED:
Thank to @kathayatnk issue was solved with the following code:

let statusBarHeight = UIApplication.shared.statusBarFrame.height
let navigationBarHeight = navigationController!.navigationBar.frame.size.height
let insets = UIEdgeInsets(top: -(statusBarHeight + navigationBarHeight), left: 0, bottom: 0, right: 0)
self.tableView.contentInset = insets

Body:
You can probably set the insets of the embedded tableView

let insets = UIEdgeInsets(top: -64.0, left: 0, bottom: 0, right: 0)
self.tableView.contentInset = insets;