问:
How to change output format of material 2 date-picker
I am using angular material 2 Date-Picker component

The only string input it understands is in ISO date format

Ex. "2017-11-13T10:39:28.300Z"

But i want to patch my form control with locale date value

Ex. "11/13/2017, 4:09:46 PM"

So that it output the later format and even expects this format.

How can i do this? Is there a way to not use ISO but custom formats?

Some Thoughts:

Should i write customDateAdaptor?

Update:

https://stackblitz.com/edit/angular-material-moment-adapter-example-bqvm2f

i have tried to implement custom dateAdaptor by extending nativeDateAdaptor

答:
You probably need to write a completely new adapter or use the moment adapter. @angular/material-moment-adapter:5.0.0-rc0. The moment adapter uses momentjs and allows you much more control on the output format.

Moment is also able to parse different input formats.

The NativeDateAdapter uses the Intl API to format the output date. You can try to provide a custom MAT_NATIVE_DATE_FORMATS instance but I am not sure how far this gets you.

EDIT

You are currently using 2.0.0-beta12 of angular/material, that doesn't fit with your code based on 5.0.0-rc0/master. There are changes in the codebase, especially the deserialize function which is not present in 2.0.0-beta12, that's why it is not being called. If you can't update to angular 5 then look at MatDatepickerInput.setValue/coerceDateProperty which sets the date into your FormControl.


来源: stackexchange

问:
Allocating Array of Pointers on Heap
Does the following create x new objects, or simply allocate space for x objects?:

```<code>Vector3D* binArray = new Vector3D[size];
</code>```

I need to build an array with space for x Vector3D objects on the heap. However, a Vector3D object can only be created when an "add" function is called - this will take the parameters, construct the object on the heap and add its address to the array of Vector3D pointers.

答:
This does create an array of Vector3D objects on the heap.

Each vector is created by calling the Vector3D constructor.

Put a little debugging print statement in the default constructor for Vector3D, and watch the constructor get called the same number of times as you have vectors in your array.

Example:

```<code>#include <iostream>
using namespace std;

class C {
public:
  C() { cout << "Hello default constructor here\n"; }
};

int main() {
  C* cs = new C[5];
}
</code>```

Output is:

```<code>Hello default constructor here
Hello default constructor here
Hello default constructor here
Hello default constructor here
Hello default constructor here
</code>```

If your class does not have a default constructor, you cannot allocate the array in one shot (thank you for the comment @Everyone), so in this case consider using a std::vector or a std::array and adding your Vector3D objects dynamically ---  or even "statically"! Example:

```<code>#include <iostream>
#include <vector>
using namespace std;

class Vector3D {
  double i, j, k;
public:
  Vector3D(double i, double j, double k): i(i), j(j), k(k) {}
};

int main() {
  vector<Vector3D> v = {
    Vector3D(3, 4, 5),
    Vector3D(6, 8, 10),
    Vector3D(7, 24, 25)
  };
  v.push_back(Vector3D(1, 2, 3));
  cout << v.size() << '\n';
}
</code>```

This outputs 4.

You can also make your vector contain pointers to Vector3D objects.

ContentLicense: CC BY-SA 3.0

Title: Allocating Array of Pointers on Heap

Body:
Does the following create x new objects, or simply allocate space for x objects?:

Vector3D* binArray = new Vector3D[size];

I need to build an array with space for x Vector3D objects on the heap. However, a Vector3D object can only be created when an "add" function is called - this will take the parameters, construct the object on the heap and add its address to the array of Vector3D pointers.

Body:
This does create an array of Vector3D objects on the heap.

Each vector is created by calling the Vector3D constructor.

Put a little debugging print statement in the default constructor for Vector3D, and watch the constructor get called the same number of times as you have vectors in your array.

Example:

#include <iostream>
using namespace std;

class C {
public:
  C() { cout << "Hello default constructor here\n"; }
};

int main() {
  C* cs = new C[5];
}

Output is:

Hello default constructor here
Hello default constructor here
Hello default constructor here
Hello default constructor here
Hello default constructor here

If your class does not have a default constructor, you cannot allocate the array in one shot (thank you for the comment @Everyone), so in this case consider using a std::vector or a std::array and adding your Vector3D objects dynamically ---  or even "statically"! Example:

#include <iostream>
#include <vector>
using namespace std;

class Vector3D {
  double i, j, k;
public:
  Vector3D(double i, double j, double k): i(i), j(j), k(k) {}
};

int main() {
  vector<Vector3D> v = {
    Vector3D(3, 4, 5),
    Vector3D(6, 8, 10),
    Vector3D(7, 24, 25)
  };
  v.push_back(Vector3D(1, 2, 3));
  cout << v.size() << '\n';
}

This outputs 4.

You can also make your vector contain pointers to Vector3D objects.


问:
Checking within a range of field of fields
I wasn't quite sure how to word the title, sorry if it doesn't make sense/is misleading.

Note - a "boat" is 3 O's next to each other in an array, so

```<code>_|O|_  _|_|_
_|O|_  O|O|O
 |O|    | |
</code>```

are boats.

So I have an a list of lists (n x n) (working with lists) in which I generate n boats at random spaces. I don't want the boats to be next to each other, touch by corners, or be on top of each other.

A tried checking if a boat would end up on top of another boat in the vein of this:

```<code>if board[y - 2][x] == 'O' or board[y + 2][x] == 'O' ...
</code>```

and so on, which ended up being unsurprisingly long.

I also got index out of range errors, since I was sometimes checking for coordinates not in the field.

So, is there a way I can check for boats in every direction without going out of index range?

Better yet, any ideas on how to make the boats not generate next to each other?

The code for boat generation is here:

```<code>from random import *

side = int(input())
game_state = []

def generate_initial_state():

    for i in range(side):
        game_state.append([])
        for j in range(side):
            game_state[i].append('.')

    for i in range(side):
        # Generate boat origin on random coordinates within the game board,
        # if there's a boat already, generate new ones
        y_cor = randint(0, side-1)
        x_cor = randint(0, side-1)
        while game_state[y_cor][x_cor] == 'O':
            y_cor = randint(0, side - 1)
            x_cor = randint(0, side - 1)
        # Direct chooses if the boat will be generated up, down, or sideways
        direct = randint(1, 4)
        cycle = 0

        while cycle < 3:
        # Generates a boat going from origin in one direction,
        # if the boat would end outside the board, chooses a different direction
            if direct == 1:
                if y_cor + 2 >= side:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor + cycle][x_cor] = 'O'
                    cycle += 1
            elif direct == 2:
                if x_cor + 2 >= side:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor][x_cor + cycle] = 'O'
                    cycle += 1
            elif direct == 3:
                if y_cor - 2 < 0:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor - cycle][x_cor] = 'O'
                    cycle += 1
            elif direct == 4:
                if x_cor - 2 < 0:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor][x_cor - cycle] = 'O'
                    cycle += 1

for i in range(side):
    print(*game_state[i])
</code>```

答:
Your code has, as you complain, too much tedious repeated logic to inspect a point's neighbors. You could turn four tests into one with something like this:

```<code>    offset = [
        (0, -1),
        (-1, 0), (1, 0),
        (0, 1),
    ]
    for xoff, yoff in offset:
        if game_state[x + xoff * cycle][y + yoff * cycle] == 'O':
            report_collision(x, y)
</code>```

Additionally, you could mark the grid with both 'O' for "boat" and 'o' for "bordering a boat", to simplify detecting adjacent boats.

Body:
I wasn't quite sure how to word the title, sorry if it doesn't make sense/is misleading.

Note - a "boat" is 3 O's next to each other in an array, so

_|O|_  _|_|_
_|O|_  O|O|O
 |O|    | |

are boats.

So I have an a list of lists (n x n) (working with lists) in which I generate n boats at random spaces. I don't want the boats to be next to each other, touch by corners, or be on top of each other.

A tried checking if a boat would end up on top of another boat in the vein of this:

if board[y - 2][x] == 'O' or board[y + 2][x] == 'O' ...

and so on, which ended up being unsurprisingly long.

I also got index out of range errors, since I was sometimes checking for coordinates not in the field.

So, is there a way I can check for boats in every direction without going out of index range?

Better yet, any ideas on how to make the boats not generate next to each other?

The code for boat generation is here:

from random import *

side = int(input())
game_state = []

def generate_initial_state():

    for i in range(side):
        game_state.append([])
        for j in range(side):
            game_state[i].append('.')

    for i in range(side):
        # Generate boat origin on random coordinates within the game board,
        # if there's a boat already, generate new ones
        y_cor = randint(0, side-1)
        x_cor = randint(0, side-1)
        while game_state[y_cor][x_cor] == 'O':
            y_cor = randint(0, side - 1)
            x_cor = randint(0, side - 1)
        # Direct chooses if the boat will be generated up, down, or sideways
        direct = randint(1, 4)
        cycle = 0

        while cycle < 3:
        # Generates a boat going from origin in one direction,
        # if the boat would end outside the board, chooses a different direction
            if direct == 1:
                if y_cor + 2 >= side:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor + cycle][x_cor] = 'O'
                    cycle += 1
            elif direct == 2:
                if x_cor + 2 >= side:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor][x_cor + cycle] = 'O'
                    cycle += 1
            elif direct == 3:
                if y_cor - 2 < 0:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor - cycle][x_cor] = 'O'
                    cycle += 1
            elif direct == 4:
                if x_cor - 2 < 0:
                    direct = randint(1, 4)
                else:
                    game_state[y_cor][x_cor - cycle] = 'O'
                    cycle += 1

for i in range(side):
    print(*game_state[i])

Body:
Your code has, as you complain, too much tedious repeated logic to inspect a point's neighbors. You could turn four tests into one with something like this:

    offset = [
        (0, -1),
        (-1, 0), (1, 0),
        (0, 1),
    ]
    for xoff, yoff in offset:
        if game_state[x + xoff * cycle][y + yoff * cycle] == 'O':
            report_collision(x, y)

Additionally, you could mark the grid with both 'O' for "boat" and 'o' for "bordering a boat", to simplify detecting adjacent boats.


问:
SML Error: Win32TextPrimIO:openRd: failed
So I have 2 files, file1.sml & file2.sml both of which have correct code & I'm using a Windows operating system.

When I run Emacs and execute: use "file1.sml", it runs fine but then when I simply go to tab File->Close to close the file and then I drag file2.sml into Emacs and try to run it the same way, it gives the following error:

```<code>[use failed: Io: openIn failed on "file2.sml", Win32TextPrimIO:openRd: failed]
</code>```

I tried restarting SML by doing c-c c-d but it's the same. So what I do is I quit Emacs and then start again and run file2.sml and it runs fine.

Why do I have to quit just to run another file?

答:
there are few things you can right now do.
1. save the file you created before trying to open it.
  i mean yes it sounds lame, but people new to programming ( as you tried to save it as "file.sml" , First save it.
2. try to change \ to //
Win32TextPrimIO:openRd: failed

because it cant find it.

Body:
So I have 2 files, file1.sml & file2.sml both of which have correct code & I'm using a Windows operating system.

When I run Emacs and execute: use "file1.sml", it runs fine but then when I simply go to tab File->Close to close the file and then I drag file2.sml into Emacs and try to run it the same way, it gives the following error:

[use failed: Io: openIn failed on "file2.sml", Win32TextPrimIO:openRd: failed]

I tried restarting SML by doing c-c c-d but it's the same. So what I do is I quit Emacs and then start again and run file2.sml and it runs fine.

Why do I have to quit just to run another file?


问:
how to save image from this url via PHP
I have URLs like this:

https://strg.global/getImage.php?app=mgm&type=adinda-kennedy&imgId=MGM%20Adinda%20Kennedy%20e6057b8e-aa68-4461-8c9a-1d069fc021a4.jpg&size=1080&cachebreaker=1500536003696`

When you visit it the image downloads automatically.

How can I get and save it via PHP?

I've tried file_get_content(), but it returned info in inappropriate format for saving.
I've tried to use Intervention image library and it's method  Image::make($url), but it hasn't worked either.

答:
Get the content from the URL, then create an image from the string you get back with (surprisingly) "imagecreatefromstring". After you have the image you can simply display it or save it  : </p>

```<code>$Res = file_get_contents($URL);
$Img = imagecreatefromstring($Res);
imagepng($Img,"FileName.png");
imagedestroy($Img);
</code>```

Title: how to save image from this url via PHP

Body:
Get the content from the URL, then create an image from the string you get back with (surprisingly) "imagecreatefromstring". After you have the image you can simply display it or save it  :

$Res = file_get_contents($URL);
$Img = imagecreatefromstring($Res);
imagepng($Img,"FileName.png");
imagedestroy($Img);


问:
Floating Burger Menu to the left to align with div id
I am sure this is something very simple but I want to align my burger Nav with the text I have defined. It is currently sitting underneath.

I have tried including the href link within the defined text but this then causes the burger nav to be shown at all times, and not just mobile sizes. Ideally this will only be shown at smaller screen widths.

Here is my code.

body {
  font: 100%/1.5 Arial, Helvetica, sans-serif;
  padding: 0;
  margin: 0;
  background-color: white;
}

/* Style the list 'container'  */

ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Float the list items left - this is the 'magic' that turns a vertical list into a horizontal row */

ul.topnav li {
  float: left;
}

/* style the links  */

ul.topnav li a {
  display: inline-block;
  color: white;
  text-align: center;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

/* hover */

ul.topnav li a:hover {
  color: gold;
}

/* Hide the icon initially  */

ul.topnav li.icon {
  display: none;
}

/* Global */

.container {
  width: 60%;
  margin: auto;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: black;
}

ul {
  margin: 0;
  padding: 0;
}

.subscribe {
  height: 38px;
  background: gold;
  border: 0;
  padding-left: 20px;
  padding-right: 20px;
  color: black;
}

.dark {
  padding: 25px;
  background: #35424a;
  color: white;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Header **/

header {
  background: #35424a;
  color: white;
  padding-top: 30px;
  min-height: 70px;
  border-bottom: gold 5px solid;
}

header a {
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 100%;
}

header li {
  float: left;
  display: inline;
  padding: 0 20px 0 20px;
}

header #branding {
  float: left;
}

header #branding h1 {
  margin: 0;
}

header nav {
  float: right;
  margin-top: 10px;
}

header .highlight {
  color: gold;
}

header a:hover {
  color: gold;
}

h3 .bronze {
  color: #cc6633;
}

h3 .silver {
  color: silver;
}

h3 .gold {
  color: gold;
}

/* Showcase */

#showcase {
  min-height: 400px;
  color: black;
}

#showcase h1 {
  margin-top: 50px;
  font-size: 300%;
  margin-bottom: 10px;
}

#showcase p {
  font-size: 120%;
}

/* Newsletter */

#newsletter {
  padding: 15px;
  color: #ffffff;
  background: #35424a
}

#newsletter h1 {
  float: left;
}

#newsletter form {
  float: right;
  margin-top: 15px;
}

#newsletter input[type="email"] {
  padding: 4px;
  height: 26px;
  width: 250px;
}

/* Sidebar */

aside#sidebar {
  float: right;
  margin-top: 10px;
}

aside#sidebar .quote input,
aside#sidebar .quote textarea {
  top-margin: 10px;
  width: 80%;
  padding: 10px;
}

/* Main-col */

article#main-col {
  float: left;
  width: 65%;
}

/* Imagery */

#social {
  margin-top: 10%;
  text-align: center;
  font-size: 150%;
  color: black;
}

#imagery {
  margin-top: 5%;
  margin-bottom: 5%;
}

#imagery .box {
  float: right;
  text-align: center;
  width: 30%;
  padding: 10px;
}

#imagery .box i {
  font-size: 700%;
}

/* Create four equal columns that floats next to each other */

.column {
  float: left;
  width: 20%;
  padding: 10px;
}

.column img {
  margin-top: 12px;
  width: 100%;
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Services */

ul#services li {
  list-style: none;
  padding: 20px;
  border: #cccccc solid 1px;
  margin-bottom: 5px;
  background: #35424a;
  color: white;
}

footer {
  padding: 20px;
  margin-top: 20px;
  color: black;
  background-color: gold;
  text-align: center;
}

/* Media Queries */

@media(max-width: 768px) {
  header #branding,
  header nav,
  header nav li,
  #newsletter h1,
  #newsletter form,
  #boxes .box,
  article#main-col,
  aside#sidebar {
    float: none;
    text-align: center;
    width: 100%;
  }
  header {
    padding-bottom: 20px;
  }
  #imagery {
    font-size: 50%;
    float: none;
  }
  #showcase h1 {
    margin-top: 40px;
  }
  #newsletter button,
  .quote button {
    display: block;
    width: 100%;
  }
  #newsletter form input[type="email"],
  .quote input,
  .quote textarea {
    width: 100%;
    margin-bottom: 5px;
  }
  /* nav */
  ul.topnav li {
    display: none;
  }
  ul.topnav li.icon {
    display: inline-block;
  }
  ul.topnav.responsive {
    position: relative;
  }
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    /*  'un' float the list items so they return to displaying vertically */
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}

/*css reset
* {

  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
  background-image: url("bg.jpg");
  background-size: cover;  /*this seems better*/

/*background-size: contain;

}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* end reset */```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">

<head>
  <title>DB Plumbing | Home</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="https://use.fontawesome.com/3a2264e344.js"></script>
  <script src="html8shiv.js"></script>
  <link rel="shortcut icon" type="image/png" href="wrench.png" />
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <meta name="desciption" content="Darran Brady Plumbing">
  <meta name="keywords" content="Plumbing, Boilers, Showers, Central Heating, Kitchens, Bathrooms, Installations, Landlord Services, Horsham, West Sussex, Sussex,Barns Green, Billingshurst,Broadbridge Heath,Christ's Hospital, Clemsfold, Copsale,Colgate,Cowfold, Faygate, Handcross, Horsham, Itchingfield, Kingsfold,Lambs Farm,Lower Beeding,Mannings Heath, Maplehurst, Monks Gate, Nuthurst, Partridge Green, Pease Pottage, Roffey, Rowhook, Rusper, Rudgwick, Southwater, Slinfold, Warnham ">
  <meta name="author" content="DB, Darran, Brady, Darran Brady">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script>
    function myFunction() {
      var x = document.getElementById("myTopnav");
      if (x.className === "topnav") {
        x.className += " responsive";
      } else {
        x.className = "topnav";
      }
    }
  </script>
</head>

<body>
  <header>
    <div class="container">
      <div id="branding">
        <h1><span class="highlight">DB</span> Plumbing</h1>
      </div>
      <nav>
        <ul class="topnav" id="myTopnav">
          <li class="active">Home</li>
          <li>About</li>
          <li>Services</li>
          <li>Coverage</li>
          <li>Contact</li>
          <li class="icon">
            ☰
        </ul>
      </nav>
    </div>
  </header>

  <section id="showcase">
    <div class="container">
      <h1>Local Award Winning Trader</h1>
      <h2>Call Darren | <i class="fa fa-phone" aria-hidden="true"></i> 07756848657</h2>
      <p>DB Plumbing provides a full range of general plumbing and repair services, from installing your new bathroom suite to fixing that leaking tap or joint that has been annoying you for ages. </p>

      <p>Our customer's individual requirements are important to us at DB Plumbing. We always provide quality service and products and combined with honesty has made us the first choice of many homes in the Horsham area</p>
    </div>
  </section>

  <section id="newsletter">
    <div class="container">
      <h1>Subscribe To Our Weekly Blog</h1>
      <form>
        <input type="email" placeholder="Subscribe today...">
        <button type="submit" class="subscribe">Subscribe</button>
      </form>
    </div>
  </section>

  <section id="imagery">
    <div class="container">
      <div class="box">
        <i class="fa fa-star" aria-hidden="true"></i>
        <h1>Accredited</h1>
        <p>Gas Safe Accreditted </p>
      </div>
      <div class="box">
        <i class="fa fa-thumbs-up" aria-hidden="true"></i>
        <h1>Reputable</h1>
        <p>"25 years service experience "</p>
      </div>
      <div class="box">
        <i class="fa fa-map-marker" aria-hidden="true"></i>
        <h1>Local</h1>
        <p>Sussex and Surrey Countywide</p>
      </div>
    </div>
  </section>

  <footer>
    <div>
      <p>Darren Brady Plumbing Copyright © 2017</p>
    </div>
  </footer>
</body>

</html></code>```

Wanting to float the burger nav to align with text

答:
Place your button first, on the top of the nav like this

body {
  font: 100%/1.5 Arial, Helvetica, sans-serif;
  padding: 0;
  margin: 0;
  background-color: white;
}

/* Style the list 'container'  */

ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Float the list items left - this is the 'magic' that turns a vertical list into a horizontal row */

ul.topnav li {
  float: left;
}

/* style the links  */

ul.topnav li a {
  display: inline-block;
  color: white;
  text-align: center;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

/* hover */

ul.topnav li a:hover {
  color: gold;
}

/* Hide the icon initially  */

ul.topnav li.icon {
  display: none;
}

/* Global */

.container {
  width: 60%;
  margin: auto;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: black;
}

ul {
  margin: 0;
  padding: 0;
}

.subscribe {
  height: 38px;
  background: gold;
  border: 0;
  padding-left: 20px;
  padding-right: 20px;
  color: black;
}

.dark {
  padding: 25px;
  background: #35424a;
  color: white;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Header **/

header {
  background: #35424a;
  color: white;
  padding-top: 30px;
  min-height: 70px;
  border-bottom: gold 5px solid;
}

header a {
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 100%;
}

header li {
  float: left;
  display: inline;
  padding: 0 20px 0 20px;
}

header #branding {
  float: left;
}

header #branding h1 {
  margin: 0;
}

header nav {
  float: right;
  margin-top: 10px;
}

header .highlight {
  color: gold;
}

header a:hover {
  color: gold;
}

h3 .bronze {
  color: #cc6633;
}

h3 .silver {
  color: silver;
}

h3 .gold {
  color: gold;
}

/* Showcase */

#showcase {
  min-height: 400px;
  color: black;
}

#showcase h1 {
  margin-top: 50px;
  font-size: 300%;
  margin-bottom: 10px;
}

#showcase p {
  font-size: 120%;
}

/* Newsletter */

#newsletter {
  padding: 15px;
  color: #ffffff;
  background: #35424a
}

#newsletter h1 {
  float: left;
}

#newsletter form {
  float: right;
  margin-top: 15px;
}

#newsletter input[type="email"] {
  padding: 4px;
  height: 26px;
  width: 250px;
}

/* Sidebar */

aside#sidebar {
  float: right;
  margin-top: 10px;
}

aside#sidebar .quote input,
aside#sidebar .quote textarea {
  top-margin: 10px;
  width: 80%;
  padding: 10px;
}

/* Main-col */

article#main-col {
  float: left;
  width: 65%;
}

/* Imagery */

#social {
  margin-top: 10%;
  text-align: center;
  font-size: 150%;
  color: black;
}

#imagery {
  margin-top: 5%;
  margin-bottom: 5%;
}

#imagery .box {
  float: right;
  text-align: center;
  width: 30%;
  padding: 10px;
}

#imagery .box i {
  font-size: 700%;
}

/* Create four equal columns that floats next to each other */

.column {
  float: left;
  width: 20%;
  padding: 10px;
}

.column img {
  margin-top: 12px;
  width: 100%;
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Services */

ul#services li {
  list-style: none;
  padding: 20px;
  border: #cccccc solid 1px;
  margin-bottom: 5px;
  background: #35424a;
  color: white;
}

footer {
  padding: 20px;
  margin-top: 20px;
  color: black;
  background-color: gold;
  text-align: center;
}

/* Media Queries */

@media(max-width: 768px) {
  header #branding,
  header nav,
  header nav li,
  #newsletter h1,
  #newsletter form,
  #boxes .box,
  article#main-col,
  aside#sidebar {
    float: none;
    text-align: center;
    width: 100%;
  }
  header {
    padding-bottom: 20px;
  }
  #imagery {
    font-size: 50%;
    float: none;
  }
  #showcase h1 {
    margin-top: 40px;
  }
  #newsletter button,
  .quote button {
    display: block;
    width: 100%;
  }
  #newsletter form input[type="email"],
  .quote input,
  .quote textarea {
    width: 100%;
    margin-bottom: 5px;
  }
  /* nav */
  ul.topnav li {
    display: none;
  }
  ul.topnav li.icon {
    display: inline-block;
  }
  ul.topnav.responsive {
    position: relative;
  }
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    /*  'un' float the list items so they return to displaying vertically */
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}

/*css reset
* {

  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
  background-image: url("bg.jpg");
  background-size: cover;  /*this seems better*/

/*background-size: contain;

}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* end reset */```
<pre class="snippet-code-html lang-html prettyprint-override"><code><head>
  <title>DB Plumbing | Home</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="https://use.fontawesome.com/3a2264e344.js"></script>
  <script src="html8shiv.js"></script>
  <link rel="shortcut icon" type="image/png" href="wrench.png" />
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <meta name="desciption" content="Darran Brady Plumbing">
  <meta name="keywords" content="Plumbing, Boilers, Showers, Central Heating, Kitchens, Bathrooms, Installations, Landlord Services, Horsham, West Sussex, Sussex,Barns Green, Billingshurst,Broadbridge Heath,Christ's Hospital, Clemsfold, Copsale,Colgate,Cowfold, Faygate, Handcross, Horsham, Itchingfield, Kingsfold,Lambs Farm,Lower Beeding,Mannings Heath, Maplehurst, Monks Gate, Nuthurst, Partridge Green, Pease Pottage, Roffey, Rowhook, Rusper, Rudgwick, Southwater, Slinfold, Warnham ">
  <meta name="author" content="DB, Darran, Brady, Darran Brady">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script>
    function myFunction() {
      var x = document.getElementById("myTopnav");
      if (x.className === "topnav") {
        x.className += " responsive";
      } else {
        x.className = "topnav";
      }
    }
  </script>
</head>

<body>
  <header>
    <div class="container">
      <div id="branding">
        <h1><span class="highlight">DB</span> Plumbing</h1>
      </div>
      <nav>
        <div class="icon">
          ☰
        </div>
        <ul class="topnav" id="myTopnav">
          <li class="active">Home</li>
          <li>About</li>
          <li>Services</li>
          <li>Coverage</li>
          <li>Contact</li>

        </ul>
      </nav>
    </div>
  </header>

  <section id="showcase">
    <div class="container">
      <h1>Local Award Winning Trader</h1>
      <h2>Call Darren | <i class="fa fa-phone" aria-hidden="true"></i> 07756848657</h2>
      <p>DB Plumbing provides a full range of general plumbing and repair services, from installing your new bathroom suite to fixing that leaking tap or joint that has been annoying you for ages. </p>

      <p>Our customer's individual requirements are important to us at DB Plumbing. We always provide quality service and products and combined with honesty has made us the first choice of many homes in the Horsham area</p>
    </div>
  </section>

  <section id="newsletter">
    <div class="container">
      <h1>Subscribe To Our Weekly Blog</h1>
      <form>
        <input type="email" placeholder="Subscribe today...">
        <button type="submit" class="subscribe">Subscribe</button>
      </form>
    </div>
  </section>

  <section id="imagery">
    <div class="container">
      <div class="box">
        <i class="fa fa-star" aria-hidden="true"></i>
        <h1>Accredited</h1>
        <p>Gas Safe Accreditted </p>
      </div>
      <div class="box">
        <i class="fa fa-thumbs-up" aria-hidden="true"></i>
        <h1>Reputable</h1>
        <p>"25 years service experience "</p>
      </div>
      <div class="box">
        <i class="fa fa-map-marker" aria-hidden="true"></i>
        <h1>Local</h1>
        <p>Sussex and Surrey Countywide</p>
      </div>
    </div>
  </section>

  <footer>
    <div>
      <p>Darren Brady Plumbing Copyright © 2017</p>
    </div>
  </footer>
</body></code>```

Body:
I am sure this is something very simple but I want to align my burger Nav with the text I have defined. It is currently sitting underneath.

I have tried including the href link within the defined text but this then causes the burger nav to be shown at all times, and not just mobile sizes. Ideally this will only be shown at smaller screen widths.

Here is my code.

body {
  font: 100%/1.5 Arial, Helvetica, sans-serif;
  padding: 0;
  margin: 0;
  background-color: white;
}

/* Style the list 'container'  */

ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Float the list items left - this is the 'magic' that turns a vertical list into a horizontal row */

ul.topnav li {
  float: left;
}

/* style the links  */

ul.topnav li a {
  display: inline-block;
  color: white;
  text-align: center;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

/* hover */

ul.topnav li a:hover {
  color: gold;
}

/* Hide the icon initially  */

ul.topnav li.icon {
  display: none;
}

/* Global */

.container {
  width: 60%;
  margin: auto;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: black;
}

ul {
  margin: 0;
  padding: 0;
}

.subscribe {
  height: 38px;
  background: gold;
  border: 0;
  padding-left: 20px;
  padding-right: 20px;
  color: black;
}

.dark {
  padding: 25px;
  background: #35424a;
  color: white;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Header **/

header {
  background: #35424a;
  color: white;
  padding-top: 30px;
  min-height: 70px;
  border-bottom: gold 5px solid;
}

header a {
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 100%;
}

header li {
  float: left;
  display: inline;
  padding: 0 20px 0 20px;
}

header #branding {
  float: left;
}

header #branding h1 {
  margin: 0;
}

header nav {
  float: right;
  margin-top: 10px;
}

header .highlight {
  color: gold;
}

header a:hover {
  color: gold;
}

h3 .bronze {
  color: #cc6633;
}

h3 .silver {
  color: silver;
}

h3 .gold {
  color: gold;
}

/* Showcase */

#showcase {
  min-height: 400px;
  color: black;
}

#showcase h1 {
  margin-top: 50px;
  font-size: 300%;
  margin-bottom: 10px;
}

#showcase p {
  font-size: 120%;
}

/* Newsletter */

#newsletter {
  padding: 15px;
  color: #ffffff;
  background: #35424a
}

#newsletter h1 {
  float: left;
}

#newsletter form {
  float: right;
  margin-top: 15px;
}

#newsletter input[type="email"] {
  padding: 4px;
  height: 26px;
  width: 250px;
}

/* Sidebar */

aside#sidebar {
  float: right;
  margin-top: 10px;
}

aside#sidebar .quote input,
aside#sidebar .quote textarea {
  top-margin: 10px;
  width: 80%;
  padding: 10px;
}

/* Main-col */

article#main-col {
  float: left;
  width: 65%;
}

/* Imagery */

#social {
  margin-top: 10%;
  text-align: center;
  font-size: 150%;
  color: black;
}

#imagery {
  margin-top: 5%;
  margin-bottom: 5%;
}

#imagery .box {
  float: right;
  text-align: center;
  width: 30%;
  padding: 10px;
}

#imagery .box i {
  font-size: 700%;
}

/* Create four equal columns that floats next to each other */

.column {
  float: left;
  width: 20%;
  padding: 10px;
}

.column img {
  margin-top: 12px;
  width: 100%;
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Services */

ul#services li {
  list-style: none;
  padding: 20px;
  border: #cccccc solid 1px;
  margin-bottom: 5px;
  background: #35424a;
  color: white;
}

footer {
  padding: 20px;
  margin-top: 20px;
  color: black;
  background-color: gold;
  text-align: center;
}

/* Media Queries */

@media(max-width: 768px) {
  header #branding,
  header nav,
  header nav li,
  #newsletter h1,
  #newsletter form,
  #boxes .box,
  article#main-col,
  aside#sidebar {
    float: none;
    text-align: center;
    width: 100%;
  }
  header {
    padding-bottom: 20px;
  }
  #imagery {
    font-size: 50%;
    float: none;
  }
  #showcase h1 {
    margin-top: 40px;
  }
  #newsletter button,
  .quote button {
    display: block;
    width: 100%;
  }
  #newsletter form input[type="email"],
  .quote input,
  .quote textarea {
    width: 100%;
    margin-bottom: 5px;
  }
  /* nav */
  ul.topnav li {
    display: none;
  }
  ul.topnav li.icon {
    display: inline-block;
  }
  ul.topnav.responsive {
    position: relative;
  }
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    /*  'un' float the list items so they return to displaying vertically */
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}

/*css reset
* {

  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
  background-image: url("bg.jpg");
  background-size: cover;  /*this seems better*/

/*background-size: contain;

}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* end reset */

<!DOCTYPE html>

  <title>DB Plumbing | Home</title>
  <link rel="stylesheet" type="text/css" href="style.css">

  <link rel="shortcut icon" type="image/png" href="wrench.png" />
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <meta name="desciption" content="Darran Brady Plumbing">
  <meta name="keywords" content="Plumbing, Boilers, Showers, Central Heating, Kitchens, Bathrooms, Installations, Landlord Services, Horsham, West Sussex, Sussex,Barns Green, Billingshurst,Broadbridge Heath,Christ's Hospital, Clemsfold, Copsale,Colgate,Cowfold, Faygate, Handcross, Horsham, Itchingfield, Kingsfold,Lambs Farm,Lower Beeding,Mannings Heath, Maplehurst, Monks Gate, Nuthurst, Partridge Green, Pease Pottage, Roffey, Rowhook, Rusper, Rudgwick, Southwater, Slinfold, Warnham ">
  <meta name="author" content="DB, Darran, Brady, Darran Brady">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

DB Plumbing

Home

About

Services

Coverage

Contact

            ☰

Local Award Winning Trader

Call Darren |  07756848657

DB Plumbing provides a full range of general plumbing and repair services, from installing your new bathroom suite to fixing that leaking tap or joint that has been annoying you for ages.

Our customer's individual requirements are important to us at DB Plumbing. We always provide quality service and products and combined with honesty has made us the first choice of many homes in the Horsham area

Subscribe To Our Weekly Blog

      <form>
        <input type="email" placeholder="Subscribe today...">
        <button type="submit" class="subscribe">Subscribe</button>
      </form>

Accredited

Gas Safe Accreditted

Reputable

"25 years service experience "

Local

Sussex and Surrey Countywide

Darren Brady Plumbing Copyright © 2017

Wanting to float the burger nav to align with text

Body:
Place your button first, on the top of the nav like this

body {
  font: 100%/1.5 Arial, Helvetica, sans-serif;
  padding: 0;
  margin: 0;
  background-color: white;
}

/* Style the list 'container'  */

ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Float the list items left - this is the 'magic' that turns a vertical list into a horizontal row */

ul.topnav li {
  float: left;
}

/* style the links  */

ul.topnav li a {
  display: inline-block;
  color: white;
  text-align: center;
  text-decoration: none;
  transition: 0.3s;
  font-size: 17px;
}

/* hover */

ul.topnav li a:hover {
  color: gold;
}

/* Hide the icon initially  */

ul.topnav li.icon {
  display: none;
}

/* Global */

.container {
  width: 60%;
  margin: auto;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: black;
}

ul {
  margin: 0;
  padding: 0;
}

.subscribe {
  height: 38px;
  background: gold;
  border: 0;
  padding-left: 20px;
  padding-right: 20px;
  color: black;
}

.dark {
  padding: 25px;
  background: #35424a;
  color: white;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Header **/

header {
  background: #35424a;
  color: white;
  padding-top: 30px;
  min-height: 70px;
  border-bottom: gold 5px solid;
}

header a {
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 100%;
}

header li {
  float: left;
  display: inline;
  padding: 0 20px 0 20px;
}

header #branding {
  float: left;
}

header #branding h1 {
  margin: 0;
}

header nav {
  float: right;
  margin-top: 10px;
}

header .highlight {
  color: gold;
}

header a:hover {
  color: gold;
}

h3 .bronze {
  color: #cc6633;
}

h3 .silver {
  color: silver;
}

h3 .gold {
  color: gold;
}

/* Showcase */

#showcase {
  min-height: 400px;
  color: black;
}

#showcase h1 {
  margin-top: 50px;
  font-size: 300%;
  margin-bottom: 10px;
}

#showcase p {
  font-size: 120%;
}

/* Newsletter */

#newsletter {
  padding: 15px;
  color: #ffffff;
  background: #35424a
}

#newsletter h1 {
  float: left;
}

#newsletter form {
  float: right;
  margin-top: 15px;
}

#newsletter input[type="email"] {
  padding: 4px;
  height: 26px;
  width: 250px;
}

/* Sidebar */

aside#sidebar {
  float: right;
  margin-top: 10px;
}

aside#sidebar .quote input,
aside#sidebar .quote textarea {
  top-margin: 10px;
  width: 80%;
  padding: 10px;
}

/* Main-col */

article#main-col {
  float: left;
  width: 65%;
}

/* Imagery */

#social {
  margin-top: 10%;
  text-align: center;
  font-size: 150%;
  color: black;
}

#imagery {
  margin-top: 5%;
  margin-bottom: 5%;
}

#imagery .box {
  float: right;
  text-align: center;
  width: 30%;
  padding: 10px;
}

#imagery .box i {
  font-size: 700%;
}

/* Create four equal columns that floats next to each other */

.column {
  float: left;
  width: 20%;
  padding: 10px;
}

.column img {
  margin-top: 12px;
  width: 100%;
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

/* Services */

ul#services li {
  list-style: none;
  padding: 20px;
  border: #cccccc solid 1px;
  margin-bottom: 5px;
  background: #35424a;
  color: white;
}

footer {
  padding: 20px;
  margin-top: 20px;
  color: black;
  background-color: gold;
  text-align: center;
}

/* Media Queries */

@media(max-width: 768px) {
  header #branding,
  header nav,
  header nav li,
  #newsletter h1,
  #newsletter form,
  #boxes .box,
  article#main-col,
  aside#sidebar {
    float: none;
    text-align: center;
    width: 100%;
  }
  header {
    padding-bottom: 20px;
  }
  #imagery {
    font-size: 50%;
    float: none;
  }
  #showcase h1 {
    margin-top: 40px;
  }
  #newsletter button,
  .quote button {
    display: block;
    width: 100%;
  }
  #newsletter form input[type="email"],
  .quote input,
  .quote textarea {
    width: 100%;
    margin-bottom: 5px;
  }
  /* nav */
  ul.topnav li {
    display: none;
  }
  ul.topnav li.icon {
    display: inline-block;
  }
  ul.topnav.responsive {
    position: relative;
  }
  ul.topnav.responsive li.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  ul.topnav.responsive li {
    float: none;
    /*  'un' float the list items so they return to displaying vertically */
    display: inline;
  }
  ul.topnav.responsive li a {
    display: block;
    text-align: left;
  }
}

/*css reset
* {

  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
  background-image: url("bg.jpg");
  background-size: cover;  /*this seems better*/

/*background-size: contain;

}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* end reset */

<head>
  <title>DB Plumbing | Home</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="https://use.fontawesome.com/3a2264e344.js"></script>
  <script src="html8shiv.js"></script>
  <link rel="shortcut icon" type="image/png" href="wrench.png" />
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <meta name="desciption" content="Darran Brady Plumbing">
  <meta name="keywords" content="Plumbing, Boilers, Showers, Central Heating, Kitchens, Bathrooms, Installations, Landlord Services, Horsham, West Sussex, Sussex,Barns Green, Billingshurst,Broadbridge Heath,Christ's Hospital, Clemsfold, Copsale,Colgate,Cowfold, Faygate, Handcross, Horsham, Itchingfield, Kingsfold,Lambs Farm,Lower Beeding,Mannings Heath, Maplehurst, Monks Gate, Nuthurst, Partridge Green, Pease Pottage, Roffey, Rowhook, Rusper, Rudgwick, Southwater, Slinfold, Warnham ">
  <meta name="author" content="DB, Darran, Brady, Darran Brady">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script>
    function myFunction() {
      var x = document.getElementById("myTopnav");
      if (x.className === "topnav") {
        x.className += " responsive";
      } else {
        x.className = "topnav";
      }
    }
  </script>
</head>

<body>
  <header>
    <div class="container">
      <div id="branding">
        <h1><span class="highlight">DB</span> Plumbing</h1>
      </div>
      <nav>
        <div class="icon">
          <a href="javascript:void(0);" style="font-size:130%;" onclick="myFunction()">☰</a>
        </div>
        <ul class="topnav" id="myTopnav">
          <li class="active"><a href="home8.html">Home</a></li>
          <li><a href="about8.html">About</a></li>
          <li><a href="services8.html">Services</a></li>
          <li><a href="coverage8.html">Coverage</a></li>
          <li><a href="contact8.html">Contact</a></li>

        </ul>
      </nav>
    </div>
  </header>

  <section id="showcase">
    <div class="container">
      <h1>Local Award Winning Trader</h1>
      <h2>Call Darren | <i class="fa fa-phone" aria-hidden="true"></i><a href="tel:+07756848657"> 07756848657</a></h2>
      <p>DB Plumbing provides a full range of general plumbing and repair services, from installing your new bathroom suite to fixing that leaking tap or joint that has been annoying you for ages. </p>

      <p>Our customer's individual requirements are important to us at DB Plumbing. We always provide quality service and products and combined with honesty has made us the first choice of many homes in the Horsham area</p>
    </div>
  </section>

  <section id="newsletter">
    <div class="container">
      <h1>Subscribe To Our Weekly Blog</h1>
      <form>
        <input type="email" placeholder="Subscribe today...">
        <button type="submit" class="subscribe">Subscribe</button>
      </form>
    </div>
  </section>

  <section id="imagery">
    <div class="container">
      <div class="box">
        <i class="fa fa-star" aria-hidden="true"></i>
        <h1>Accredited</h1>
        <p>Gas Safe Accreditted </p>
      </div>
      <div class="box">
        <i class="fa fa-thumbs-up" aria-hidden="true"></i>
        <h1>Reputable</h1>
        <p>"25 years service experience "</p>
      </div>
      <div class="box">
        <i class="fa fa-map-marker" aria-hidden="true"></i>
        <h1>Local</h1>
        <p>Sussex and Surrey Countywide</p>
      </div>
    </div>
  </section>

  <footer>
    <div>
      <p>Darren Brady Plumbing Copyright &copy; 2017</p>
    </div>
  </footer>
</body>


问:
Why do I get a type mismatch error comparing two strings
Into a macro I inserted for if criteria the following condition:

```<code>[Forms]![NavigationForm]![NavigationSubform].[Report]![Field]<>"Empty"
</code>```

Note That [Field] is set to short text and default value ="Empty"

The rezult is that when I run the macro I get the type mismatch error.

答:
Have you tried using the StrComp() function?
Here's the documentation

Body:
Into a macro I inserted for if criteria the following condition:

[Forms]![NavigationForm]![NavigationSubform].[Report]![Field]<>"Empty"

Note That [Field] is set to short text and default value ="Empty"

The rezult is that when I run the macro I get the type mismatch error.


问:
parse string object without using JSON
I need to parse an object from html element attribute (like angular does it) without using JSON.parse or something

For example I have a DIV like this

```<code><div some-attribute="{key1: 1 > 0, key2: true || false}"></div>
</code>```

And after parsing I need just string representation of all that I have in this object:

```<code>{'key1': '1 > 0', 'key2': 'true || false'}
</code>```

Is there any ability to parse it this way without inventing a new parser?

答:
Thanks all guys, I realized that I should just create a parser for this. This is the first version (on Coffee, not pure JS)</p>

```<code>class Parser
    self = @

    constructor: ->

    @quotes: '\'"`'

    @object: (dataStr) ->
        dataStr = $dp.fn.trim dataStr
        if dataStr[0] isnt '{' or dataStr.slice(-1) isnt '}'
            return null
        dataStr = dataStr.slice 1, dataStr.length - 1

        o = {}
        pair =
            key: ''
            value: ''
        addPair = ->
            o[$dp.fn.trim(pair.key)] = $dp.fn.trim pair.value
            pair.key = pair.value = ''
        quoteOpened = null
        underCursor = 'key'

        for ch, i in dataStr
            skip = false

            if ch in self.quotes
                unless quoteOpened
                    quoteOpened = ch
                    skip = true
                else if quoteOpened and ch is quoteOpened
                    quoteOpened = null
                    skip = true

            unless quoteOpened
                switch
                    when ch is ':'
                        underCursor = 'border'
                    when underCursor is 'border' and not /\s/.test ch
                        underCursor = 'value'
                    when ch is ','
                        underCursor = 'key'
                        addPair()
                        skip = true

            pair[underCursor] += ch if underCursor isnt 'border' and not skip

        addPair() if pair.key or pair.value
        o
</code>```

Title: parse string object without using JSON

Body:
I need to parse an object from html element attribute (like angular does it) without using JSON.parse or something

For example I have a DIV like this

 0, key2: true || false}">

And after parsing I need just string representation of all that I have in this object:

{'key1': '1 > 0', 'key2': 'true || false'}

Is there any ability to parse it this way without inventing a new parser?

Body:
Thanks all guys, I realized that I should just create a parser for this. This is the first version (on Coffee, not pure JS)

class Parser
    self = @

    constructor: ->

    @quotes: '\'"`'

    @object: (dataStr) ->
        dataStr = $dp.fn.trim dataStr
        if dataStr[0] isnt '{' or dataStr.slice(-1) isnt '}'
            return null
        dataStr = dataStr.slice 1, dataStr.length - 1

        o = {}
        pair =
            key: ''
            value: ''
        addPair = ->
            o[$dp.fn.trim(pair.key)] = $dp.fn.trim pair.value
            pair.key = pair.value = ''
        quoteOpened = null
        underCursor = 'key'

        for ch, i in dataStr
            skip = false

            if ch in self.quotes
                unless quoteOpened
                    quoteOpened = ch
                    skip = true
                else if quoteOpened and ch is quoteOpened
                    quoteOpened = null
                    skip = true

            unless quoteOpened
                switch
                    when ch is ':'
                        underCursor = 'border'
                    when underCursor is 'border' and not /\s/.test ch
                        underCursor = 'value'
                    when ch is ','
                        underCursor = 'key'
                        addPair()
                        skip = true

            pair[underCursor] += ch if underCursor isnt 'border' and not skip

        addPair() if pair.key or pair.value
        o


问:
Problem with Parallax Normal Mapping in Opengl , GLSL
I've got a terrible issue with parallax normal mapping and I don't know what can be the problem.

(OpenGL 2.0, C++, WinXP)

My results:

(green are normals, blue are tangents and red are binormals (bitangents) )

Normal mapping is working fine so I assume the tangent vectors are good.
The weird thing is, on some  walls of cube, parallax mapping is done correctly and in others it is not.
I'm sure my GLSL code is OK because I copied it from http://www.dhpoware.com/demos/index.html
where you can find a working parallax normal mapping demo - which works on my computer, too.

I tried also 2 ways to calculate tangent vectors so it should not be an issue.
I tried switching from DisplayList to VBO and in reverse, it gave the same results, so tangents are probably transferred correctly (I even tried to transfer it as gl_Color).

Height map is loading correctly, I tried to set it as a diffuse map and it looked OK.

glGetError() gives me No Errors and shader compile logs says so.

Of course, I checked texture coordinates over nine thousand times.

mystery... I don't even know what part of code analyze, have you guys got any suggestions ?

答:
Wild guess following

I'd bet either on a tangent basis (vectors) problem, or on view vector being transformed/considered in the wrong coordinate space.

Without more information, it's difficult for me to say more...

Some source code, or animation of the problem would be helpful.

ContentLicense: CC BY-SA 2.5


问:
Select specific column based on data supplied using Powershell
I have a csv file that may have unknown headers, one of the columns will contain email addresses for example.

Is there a way to select only the column that contains the email addresses and save it as a list to a variable?

One csv could have the header say email, another could say emailaddresses, another could say email addresses another file might not even have the word email in the header. As you can see, the headers are different. So I want to be able to detect the correct column first and use that data further in the script. Once the column is identified based on the data it contains, select that column only.

I've tried the where-object and select-string cmdlets. With both, the output is the entire array and not just the data in the column I am wanting.

```<code>$CSV = import-csv file.csv
$CSV | Where {$_ -like "*@domain.com"}
</code>```

This outputs the entire array as all rows will contain this data.

答:
Other method:</p>

```<code>$PathFile="c:\temp\test.csv"
$columnName=$null

$content=Get-Content $PathFile

foreach ($item in $content)
{
   $SplitRow= $item -split ','
   $Cpt=0..($SplitRow.Count - 1) | where {$SplitRow[$_] -match ".*@*.\..*"} | select -first 1

   if ($Cpt)
   {
       $columnName=($content[0] -split ',')[$Cpt]
       break
   }
}

if ($columnName)
{
   import-csv "c:\temp\test.csv" | select $columnName
}
else
{
    "No Email column founded"
}
</code>```

Body:
I have a csv file that may have unknown headers, one of the columns will contain email addresses for example.

Is there a way to select only the column that contains the email addresses and save it as a list to a variable?

One csv could have the header say email, another could say emailaddresses, another could say email addresses another file might not even have the word email in the header. As you can see, the headers are different. So I want to be able to detect the correct column first and use that data further in the script. Once the column is identified based on the data it contains, select that column only.

I've tried the where-object and select-string cmdlets. With both, the output is the entire array and not just the data in the column I am wanting.

$CSV = import-csv file.csv
$CSV | Where {$_ -like "*@domain.com"}

This outputs the entire array as all rows will contain this data.

Body:
Other method:

$PathFile="c:\temp\test.csv"
$columnName=$null

$content=Get-Content $PathFile

foreach ($item in $content)
{
   $SplitRow= $item -split ','
   $Cpt=0..($SplitRow.Count - 1) | where {$SplitRow[$_] -match ".*@*.\..*"} | select -first 1

   if ($Cpt)
   {
       $columnName=($content[0] -split ',')[$Cpt]
       break
   }
}

if ($columnName)
{
   import-csv "c:\temp\test.csv" | select $columnName
}
else
{
    "No Email column founded"
}


问:
Joining two tables where id does not equal
I'm struggling getting this query to produce the results I want.

I have:

table1, columns=empid, alt_id

table2, columns=empid, alt_id

I want to get the empid, and alt_id from table 1 where the alt_id does not match the alt_id in table2. They will both have alt_id numbers I just want to get the ones that do not match.

Any ideas?

答:
What does that really mean though? Normally when this is asked, it is of the form "I want all rows from A that have no row matching in B and all in B that have no match in A"

Which looks like this:

```<code>SELECT * FROM
  A
  FULL OUTER JOIN
  B
  ON
    a.id = b.id
</code>```

You'll see a null for any row data where there isn't a matching row on the other side:

```<code>A.id
1
2

B.id
1
3

Result of full outer join:

A.id B.id
1    1
2    null
null 3
</code>```

You, however have asked for A-B join where the IDs aren't equal, which would be the more useless query of:

```<code>SELECT * FROM
  A
  INNER JOIN
  B
  ON
    a.id != b.id
</code>```

And it would look like:

```<code>A.id B.id
1    3
2    1
2    3
</code>```

Body:
What does that really mean though? Normally when this is asked, it is of the form "I want all rows from A that have no row matching in B and all in B that have no match in A"

Which looks like this:

SELECT * FROM
  A
  FULL OUTER JOIN
  B
  ON
    a.id = b.id

You'll see a null for any row data where there isn't a matching row on the other side:

A.id
1
2

B.id
1
3

Result of full outer join:

A.id B.id
1    1
2    null
null 3

You, however have asked for A-B join where the IDs aren't equal, which would be the more useless query of:

SELECT * FROM
  A
  INNER JOIN
  B
  ON
    a.id != b.id

And it would look like:

A.id B.id
1    3
2    1
2    3


问:
multi step string split using php
I have a Wordpress site that I am building for a client and one custom post type field will allow users to enter a link and then the text for the link in a format as pictured below and called resources.

That info them needs to be output in an anchor tag as a
. I am newish to php and this is what I have so far for code

```<code><ul>
<?php
        $rawcontent = get_field("resources");
        $rawcontent = preg_replace("!</?p[^>]*>!", "", $rawcontent);
        $all_links = preg_split("/(\n)/", $rawcontent);
        $firstpart = array_pop(explode(',', $rawcontent));

   foreach($all_links as $link) {
       if(!trim($link)) continue;
       echo "<li><a href='$link'>$firstpart</a></li>";
   }
?>
</ul>
</code>```

when I print $rawcontent (resources) before any of my code executes is apperas as:
www.mylink1.com,link copy 1

www.mylink2.com, link copy 2

www.mylink3.com,link copy 3

with the code I have implemented now it comes out as

How can I get this to return just the link for the href and the just the link copy part for the anchor text for each anchor tag?

答:
I think this will do it.

I first explode on new line just like you do, then I foreach the lines.

When I foreach the lines I explode the line on comma.

Now I have an array with link as first item, and text as the second item.

```<code>$str = "www.mylink1.com,link copy 1
www.mylink2.com, link copy 2
www.mylink3.com,link copy 3";

$lines = explode(PHP_EOL, $str);

Foreach($lines as $line){
    $linktext = explode(",", $line);
    Echo  "<li><a href='$linktext[0]'>$linktext[1]</a></li>";
}
</code>```

https://3v4l.org/9DEoo

I see that your link2 has a space in the text.

You can remove that with trim when you echo.

```<code>Echo  "<li><a href='" . trim($linktext[0]) . "'>" . trim($linktext[1]) . "</a></li>\n";
</code>```

I added trim on both link and text, it can be good to have. Just in case...

https://3v4l.org/6RkW3

Title: multi step string split using php

Body:
I have a Wordpress site that I am building for a client and one custom post type field will allow users to enter a link and then the text for the link in a format as pictured below and called resources.

That info them needs to be output in an anchor tag as a
. I am newish to php and this is what I have so far for code

<?php
        $rawcontent = get_field("resources");
        $rawcontent = preg_replace("!</?p[^>]*>!", "", $rawcontent);
        $all_links = preg_split("/(\n)/", $rawcontent);
        $firstpart = array_pop(explode(',', $rawcontent));

   foreach($all_links as $link) {
       if(!trim($link)) continue;
       echo "
$firstpart
";
   }
?>

when I print $rawcontent (resources) before any of my code executes is apperas as:
www.mylink1.com,link copy 1

www.mylink2.com, link copy 2

www.mylink3.com,link copy 3

with the code I have implemented now it comes out as

How can I get this to return just the link for the href and the just the link copy part for the anchor text for each anchor tag?

Body:
I think this will do it.

I first explode on new line just like you do, then I foreach the lines.

When I foreach the lines I explode the line on comma.

Now I have an array with link as first item, and text as the second item.

$str = "www.mylink1.com,link copy 1
www.mylink2.com, link copy 2
www.mylink3.com,link copy 3";

$lines = explode(PHP_EOL, $str);

Foreach($lines as $line){
    $linktext = explode(",", $line);
    Echo  "<li><a href='$linktext[0]'>$linktext[1]</a></li>";
}

https://3v4l.org/9DEoo

I see that your link2 has a space in the text.

You can remove that with trim when you echo.

Echo  "<li><a href='" . trim($linktext[0]) . "'>" . trim($linktext[1]) . "</a></li>\n";

I added trim on both link and text, it can be good to have. Just in case...

https://3v4l.org/6RkW3


问:
Add service worker code completion to JetBrains WebStorm
I am using WebStorm.

How can I add code completion for JavaScript Service Workers?

I assume I need to add the type-script file in settings/languages&frameworks/javascript/libraries/ however I do not see it in the list.

答:
Support for Service Worker APIs will be available in upcoming 2017.3 - see WEB-20529.
Please try 2017.3 EAP - it bundles Typescript stubs for most popular JavaScript APIs:


问:
Identify the Alexa Dot Versus Show - Is a display present?
We are looking for a function or code to quickly identify if Lambda code is running on an Alexa Dot/Echo or a Show/Spot. More than the device ID, we want the device type.  Based on the device capability, display or no display, the code will provide different types of content. We are hoping not to include a "device registration" feature. We are building a health-related Skill, which will also be for seniors, so we want to include visual interactions if a display is present, in the simplest possible fashion. Suggestions?</p>

答: You should be able to examine the request and determine if a display is present, such as context.System.device.supportedInterfaces, I think it is. Under there you can look for Display, so you are not looking so much for a particular model, rather for specific functionality, such as a display.</p>


问:
On Duplicate Key Update is creating a new row instead of updating
I've got a datatable called buildTracker. A php form Posts the data for submission to create new ID/rows. That much works great. A second form pulls up existing rows for edit -

However instead of updating the existing row, it creates a new row and new key (ID)

How can I get the key to update without creating a new row?

```<code>$enteredBy    = $conn->real_escape_string($_POST['enteredBy']);
   $query   = "INSERT into buildtracker (EnteredBy)
    VALUES('" . $enteredBy . "')
    ON DUPLICATE KEY UPDATE EnteredBy='" . $enteredBy . "'";

$success = $conn->query($query);
</code>```

Where am I going wrong with the updating?

Datatable rows include ID (key) and EnteredBy (text)

答:
You are looking for an update, I would guess.  The update would look like:

```<code>UPDATE buildtracker
    SET EnteredBy = ?
    WHERE <some column> = ?;
</code>```

<some column> = ? would identify this row to be updated.  The only reason you would not have this is if the table contained only one row.

The use of ? is to indicate that you should be using parameters.  You should not be munging query strings with input values; you should use parameters to avoid unexpected syntax errors and sql injection vulnerabilities.

Body:
I've got a datatable called buildTracker. A php form Posts the data for submission to create new ID/rows. That much works great. A second form pulls up existing rows for edit -

However instead of updating the existing row, it creates a new row and new key (ID)

How can I get the key to update without creating a new row?

$enteredBy    = $conn->real_escape_string($_POST['enteredBy']);
   $query   = "INSERT into buildtracker (EnteredBy)
    VALUES('" . $enteredBy . "')
    ON DUPLICATE KEY UPDATE EnteredBy='" . $enteredBy . "'";

$success = $conn->query($query);

Where am I going wrong with the updating?

Datatable rows include ID (key) and EnteredBy (text)

Body:
You are looking for an update, I would guess.  The update would look like:

UPDATE buildtracker
    SET EnteredBy = ?
    WHERE <some column> = ?;

<some column> = ? would identify this row to be updated.  The only reason you would not have this is if the table contained only one row.

The use of ? is to indicate that you should be using parameters.  You should not be munging query strings with input values; you should use parameters to avoid unexpected syntax errors and sql injection vulnerabilities.


问:
Simultaneous equations in r with logrithmic
I have two simultaneous equations I'd like to solve using r. Except the one of the equations has a natural log in it:

Equation 1: U(x; y; z) = 5 ln x + 8 ln y + 12 ln z
(Will get maximized, so set to 0)

Equation 2: 10x + 15y + 30z = 3000

Following this previous post:
Solving simultaneous equations with R

I'm trying:

```<code> a <- rbind(c(5*log, 2*log, 3*log),
       c(10, 15, 30))
 b <- c(0, 3000)
 solve(a, b)
</code>```

I get an non-numeric argument error, since I have nothing plugged in for x in log function.

答:
The solve function you are trying to use is only for linear coupled equations. If you want to solve non linear coupled equations you need to use nleqslv library.

Then G5W is right, your system is lacking one relation.

I give you an example of solving coupled equations with a logarithm and a system with solutions :

```<code>library(nleqslv)

dslnex <- function(x) {
  y <- c(0,30)
  y[1] <- 5*log(x[1]) - x[2]
  y[2] <- 10*x[1] + 15*x[2]
  y
}
xstart <- c(0.5,1)
fstart <- dslnex(xstart)
nleqslv(xstart,dslnex)
</code>```

gives

```<code>$x
[1]  0.8883046 -0.5922030
</code>```

as a solution. If you want to try different resolution methods:

```<code>> z <- testnslv(xstart,dslnex)
> print(z)
Call:
testnslv(x = xstart, fn = dslnex)

Results:
    Method Global termcd Fcnt Jcnt Iter Message     Fnorm
1   Newton  cline      1    4    4    4   Fcrit 8.106e-20
2   Newton  qline      1    4    4    4   Fcrit 8.106e-20
3   Newton  gline      1    4    4    4   Fcrit 8.106e-20
4   Newton pwldog      1    4    4    4   Fcrit 8.106e-20
5   Newton dbldog      1    4    4    4   Fcrit 8.106e-20
6   Newton   hook      1    4    4    4   Fcrit 8.106e-20
7   Newton   none      1    4    4    4   Fcrit 8.106e-20
8  Broyden  cline      1    6    1    6   Fcrit 2.473e-24
9  Broyden  qline      1    6    1    6   Fcrit 2.473e-24
10 Broyden  gline      1    6    1    6   Fcrit 2.473e-24
11 Broyden pwldog      1    6    1    6   Fcrit 2.473e-24
12 Broyden dbldog      1    6    1    6   Fcrit 2.473e-24
13 Broyden   hook      1    6    1    6   Fcrit 2.473e-24
14 Broyden   none      1    6    1    6   Fcrit 2.473e-24
</code>```

gives you the method, a message to tell if it has converged or not, and the distance to the solution Fnorm

Body:
I have two simultaneous equations I'd like to solve using r. Except the one of the equations has a natural log in it:

Equation 1: U(x; y; z) = 5 ln x + 8 ln y + 12 ln z
(Will get maximized, so set to 0)

Equation 2: 10x + 15y + 30z = 3000

Following this previous post:
Solving simultaneous equations with R

I'm trying:

 a <- rbind(c(5*log, 2*log, 3*log),
       c(10, 15, 30))
 b <- c(0, 3000)
 solve(a, b)

I get an non-numeric argument error, since I have nothing plugged in for x in log function.

Body:
The solve function you are trying to use is only for linear coupled equations. If you want to solve non linear coupled equations you need to use nleqslv library.

Then G5W is right, your system is lacking one relation.

I give you an example of solving coupled equations with a logarithm and a system with solutions :

library(nleqslv)

dslnex <- function(x) {
  y <- c(0,30)
  y[1] <- 5*log(x[1]) - x[2]
  y[2] <- 10*x[1] + 15*x[2]
  y
}
xstart <- c(0.5,1)
fstart <- dslnex(xstart)
nleqslv(xstart,dslnex)

gives

$x
[1]  0.8883046 -0.5922030

as a solution. If you want to try different resolution methods:

> z <- testnslv(xstart,dslnex)
> print(z)
Call:
testnslv(x = xstart, fn = dslnex)

Results:
    Method Global termcd Fcnt Jcnt Iter Message     Fnorm
1   Newton  cline      1    4    4    4   Fcrit 8.106e-20
2   Newton  qline      1    4    4    4   Fcrit 8.106e-20
3   Newton  gline      1    4    4    4   Fcrit 8.106e-20
4   Newton pwldog      1    4    4    4   Fcrit 8.106e-20
5   Newton dbldog      1    4    4    4   Fcrit 8.106e-20
6   Newton   hook      1    4    4    4   Fcrit 8.106e-20
7   Newton   none      1    4    4    4   Fcrit 8.106e-20
8  Broyden  cline      1    6    1    6   Fcrit 2.473e-24
9  Broyden  qline      1    6    1    6   Fcrit 2.473e-24
10 Broyden  gline      1    6    1    6   Fcrit 2.473e-24
11 Broyden pwldog      1    6    1    6   Fcrit 2.473e-24
12 Broyden dbldog      1    6    1    6   Fcrit 2.473e-24
13 Broyden   hook      1    6    1    6   Fcrit 2.473e-24
14 Broyden   none      1    6    1    6   Fcrit 2.473e-24

gives you the method, a message to tell if it has converged or not, and the distance to the solution Fnorm


问:
Verilog: How to assign the an inout to another inout?
I'm trying to assign the input from an inout port to another inout port used as output. As common practice, I have to set the input port to High-Z:

```<code>inout pin5;
inout pin20;
assign pin20 = 1'bz;
assign pin5 = pin20;
</code>```

This caused both pin5 and pin20 to be routed to high-Z. I know why it's logically happening, but how can I go around it, besides turning pin20 into an input?

Here's the schematics output from my mapper.

答:
Having two IO pins connected like this isn't common. If it is just for simulations you can connect the pins with the Verilog primitive tran.

```<code>module linked_io ( inout io_A, io_B, input i, c );
  tran link(io_A, io_B);
  assign io_A = c ? i : 1'bz;
endmodule
</code>```

tran is generally not recognized by synthesizers. Some vendors have a custom macro that is functionally equivalent to tran that specifically work only for there own toolset. You will need to check the user manual or ask your vendor directly if such a macro exists.

Another approach is to selectively alias ports to the same net with the example below. This was added in Verilog-2001 with an example in IEEE1364-2001 § 12.3.3 Port declarations (same example in SystemVerilog's IEEE1800-2012 § 23.2.2.1 Non-ANSI style port declarations).

```<code>module linked_io ( .io_A(io), .io_B(io), i, c );
  inout io;
  input i, c;
  assign io = c ? i : 1'bz;
endmodule
</code>```

This is the only condition I use the Non-ANSI style; ANSI style is much simpler and cleaner. However, I've found limited support with this port aliasing feature. It is a somewhat obscure feature with little demand so it is a low priority for vendors to implement vs high demand features. That said, it may work with your simulator, synthesizer, etc.

Body:
I'm trying to assign the input from an inout port to another inout port used as output. As common practice, I have to set the input port to High-Z:

inout pin5;
inout pin20;
assign pin20 = 1'bz;
assign pin5 = pin20;

This caused both pin5 and pin20 to be routed to high-Z. I know why it's logically happening, but how can I go around it, besides turning pin20 into an input?

Here's the schematics output from my mapper.

Body:
Having two IO pins connected like this isn't common. If it is just for simulations you can connect the pins with the Verilog primitive tran.

module linked_io ( inout io_A, io_B, input i, c );
  tran link(io_A, io_B);
  assign io_A = c ? i : 1'bz;
endmodule

tran is generally not recognized by synthesizers. Some vendors have a custom macro that is functionally equivalent to tran that specifically work only for there own toolset. You will need to check the user manual or ask your vendor directly if such a macro exists.

Another approach is to selectively alias ports to the same net with the example below. This was added in Verilog-2001 with an example in IEEE1364-2001 § 12.3.3 Port declarations (same example in SystemVerilog's IEEE1800-2012 § 23.2.2.1 Non-ANSI style port declarations).

module linked_io ( .io_A(io), .io_B(io), i, c );
  inout io;
  input i, c;
  assign io = c ? i : 1'bz;
endmodule

This is the only condition I use the Non-ANSI style; ANSI style is much simpler and cleaner. However, I've found limited support with this port aliasing feature. It is a somewhat obscure feature with little demand so it is a low priority for vendors to implement vs high demand features. That said, it may work with your simulator, synthesizer, etc.


问:
Getting the source code of a page from a googlechrome extension
I am writting an extension for googlechrome to display a list of items from a website. The problem I have is that I cannot get the source code of the page I am looking for. When I tried putting it in an iframe, it had code that would change the location of the window. XMLhttpRequest is also only allowed on your own domain. Is there any way I can get the source code for a site from a googlechrome extension through javascript?

here is the manifest:

```<code>{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "browser_action": {
    "default_icon": "icon.png",
    "popup": "popup.html"
  },
  "permissions": [
    "http://api.flickr.com/",
    "http://search.twitter.com/"
  ]
 }
</code>```

答:
It's all described in details here. Long story short:

Declare domain permissions in the manifest.

Make cross-domain request from a background page.

Transfer results to a content script using message passing, if needed.

UPDATE

Here is code that works for me:

Manifest - exactly as yours.

popup.html:

```<code><html>
<head>
<script>
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            alert(xhr.status);
            if (xhr.status == 200) {
                alert(xhr.responseText);
            }
        }
    }
    var url = "http://search.twitter.com/trends/current.json?exclude=hashtags";
    xhr.open("GET", url, true);
    xhr.send();

</script>
</head>
<body></body>
</html>
</code>```

Body:
I am writting an extension for googlechrome to display a list of items from a website. The problem I have is that I cannot get the source code of the page I am looking for. When I tried putting it in an iframe, it had code that would change the location of the window. XMLhttpRequest is also only allowed on your own domain. Is there any way I can get the source code for a site from a googlechrome extension through javascript?

here is the manifest:

{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "browser_action": {
    "default_icon": "icon.png",
    "popup": "popup.html"
  },
  "permissions": [
    "http://api.flickr.com/",
    "http://search.twitter.com/"
  ]
 }

Body:
It's all described in details here. Long story short:

Declare domain permissions in the manifest.

Make cross-domain request from a background page.

Transfer results to a content script using message passing, if needed.

UPDATE

Here is code that works for me:

Manifest - exactly as yours.

popup.html:

<html>
<head>
<script>
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            alert(xhr.status);
            if (xhr.status == 200) {
                alert(xhr.responseText);
            }
        }
    }
    var url = "http://search.twitter.com/trends/current.json?exclude=hashtags";
    xhr.open("GET", url, true);
    xhr.send();

</script>
</head>
<body></body>
</html>


问:
Angular 4 in *ngFor to calculate sum of total value
I'm making a little application in Angular 4,
i want to display sum of total value when iterating through *ngfor.

HTML CODE

```<code><ul *ngFor="let hero of heroes;">
    <li>{{hero.name}}  <span>{{hero.price*hero.qty}}</span></li>
</ul>
<ul>
     <li>Total <span>{{total}}</span></li>
</ul>
</code>```

COMPONENT

```<code> total:number;
 heroes: Hero[];
 ngOnInit():void
 {
 this.heroService.getnewHeroes()
 .then(heroes => {this.heroes = heroes});
 }
</code>```

SERVICE

```<code> getnewHeroes(): Promise<Hero[]>
  {
     return this.http.get('api/heroes').toPromise()
     .then(response => response.json().data as Hero[])
  }
</code>```

I want output like below

abc 500*2

xyz 200*5

Total 2000

答:
Calculate your total in the Component and assign it to a new property. Do not try to do the sum calculation inside the ngFor loop, that is not what it was designed for.

Displaying the total outside the ngFor.

Also you use *ngFor on the element you want to repeat, li in this case. If you put it on ul then you will create a new unordered list for every hero instead of a new list item inside then unordered list tag.

Component code:

```<code>heroes: Hero[];
total: number;
ngAfterContentChecked()  {
    this.total = this.heroes.reduce(funtion(runningValue: number, hero: Hero)=> {
      runningValue = runningValue + (hero.price * hero.qty);
    }, 0);
}
</code>```

Template code:

```<code><ul>
  <li *ngFor="let hero of heroes">{{hero.name}} <span>{{hero.price*hero.qty}}</span></li>
  <li>Total price <span>{{total}}</span></li>
</ul>
</code>```

Body:
I'm making a little application in Angular 4,
i want to display sum of total value when iterating through *ngfor.

HTML CODE

{{hero.name}}  {{hero.price*hero.qty}}

Total {{total}}

COMPONENT

 total:number;
 heroes: Hero[];
 ngOnInit():void
 {
 this.heroService.getnewHeroes()
 .then(heroes => {this.heroes = heroes});
 }

SERVICE

 getnewHeroes(): Promise<Hero[]>
  {
     return this.http.get('api/heroes').toPromise()
     .then(response => response.json().data as Hero[])
  }

I want output like below

abc 500*2

xyz 200*5

Total 2000

Body:
Calculate your total in the Component and assign it to a new property. Do not try to do the sum calculation inside the ngFor loop, that is not what it was designed for.

Displaying the total outside the ngFor.

Also you use *ngFor on the element you want to repeat, li in this case. If you put it on ul then you will create a new unordered list for every hero instead of a new list item inside then unordered list tag.

Component code:

heroes: Hero[];
total: number;
ngAfterContentChecked()  {
    this.total = this.heroes.reduce(funtion(runningValue: number, hero: Hero)=> {
      runningValue = runningValue + (hero.price * hero.qty);
    }, 0);
}

Template code:

<ul>
  <li *ngFor="let hero of heroes">{{hero.name}} <span>{{hero.price*hero.qty}}</span></li>
  <li>Total price <span>{{total}}</span></li>
</ul>


问:
Powershell can not call ImageMagick commands - IM Montage
I wrote a script in PowerShell and I am having various success calling Image Magick's montage.exe on different computers. The computer on which I wrote the script has no problem executing the 'montage' command, however on another computer with IM Installed the script errors out:

```<code>montage : The term 'montage' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At \\Server\Contact_Sheet_Local.ps1:51 char:9
+         montage -verbose -label %t -pointsize 20 -background '#FFFFFF ...
+         ~~~~~~~
+ CategoryInfo          : ObjectNotFound: (montage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
</code>```

I have tried using montage.exe and even tried the entire path C:\Program Files\ImageMagick-7.0.3-Q16\montage.exe. Additionally I tried setting the directory first:

```<code>Set-Location -Path 'C:\Program Files\ImageMagick-7.0.3-Q16'
montage...
</code>```

Each time on a particular computer this fails. I have tried with IM versions 7.0.3-Q16 and 6.9.1-6-Q8 both x64 as both computers are x64

In the past, I have created scripts in .bat that use ImageMagick and I had to define the full path to the .exe as I mentioned above. But this doesn't seem to help in PowerShell.

Does anyone have any advice or experience with this problem?

答:
If your path has spaces, it will fail if you're just trying to execute based on that.  You'll want to utilize the dot operator</p>

```<code>$Exe = 'C:\Program Files\ImageMagick-6.9.1-6-Q8\montage.exe'
If (-not (Test-Path -Path $Exe))
{
    $Exe = 'C:\Program Files\ImageMagick-7.0.3-Q16\montage.exe'
}
. $Exe -arg1 -etc
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I wrote a script in PowerShell and I am having various success calling Image Magick's montage.exe on different computers. The computer on which I wrote the script has no problem executing the 'montage' command, however on another computer with IM Installed the script errors out:

montage : The term 'montage' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At \\Server\Contact_Sheet_Local.ps1:51 char:9
+         montage -verbose -label %t -pointsize 20 -background '#FFFFFF ...
+         ~~~~~~~
+ CategoryInfo          : ObjectNotFound: (montage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I have tried using montage.exe and even tried the entire path C:\Program Files\ImageMagick-7.0.3-Q16\montage.exe. Additionally I tried setting the directory first:

Set-Location -Path 'C:\Program Files\ImageMagick-7.0.3-Q16'
montage...

Each time on a particular computer this fails. I have tried with IM versions 7.0.3-Q16 and 6.9.1-6-Q8 both x64 as both computers are x64

In the past, I have created scripts in .bat that use ImageMagick and I had to define the full path to the .exe as I mentioned above. But this doesn't seem to help in PowerShell.

Does anyone have any advice or experience with this problem?

Body:
If your path has spaces, it will fail if you're just trying to execute based on that.  You'll want to utilize the dot operator

$Exe = 'C:\Program Files\ImageMagick-6.9.1-6-Q8\montage.exe'
If (-not (Test-Path -Path $Exe))
{
    $Exe = 'C:\Program Files\ImageMagick-7.0.3-Q16\montage.exe'
}
. $Exe -arg1 -etc


问:
warning: Unable to read symbols
When I try to run my app in iOS 4.2.1, I am getting following warning messages;

```<code>[Switching to thread 11523]
[Switching to thread 11523]
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
continue
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
warning: Unable to read symbols for /xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found).</code>```

I don't know what is happening here.

Is there any issues, when we get this kind of warning messages ?

答:
I'm sure this will solve your problem: UUID mismatch detected with the loaded library

Johannes

Title: warning: Unable to read symbols

Body:
When I try to run my app in iOS 4.2.1, I am getting following warning messages;

[Switching to thread 11523]
[Switching to thread 11523]
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
continue
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
`/xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/dyld' has changed; re-reading symbols.
warning: Unable to read symbols for /xcode iOS/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found).

I don't know what is happening here.

Is there any issues, when we get this kind of warning messages ?


问:
Why I am getting windows security alert in IE but not Chrome?
I am getting this security alert popup when using IE but not chrome. Did anyone experience this issue and were you able to resolve it?</p>

答: the security pop up is related to the Load Balancer timing out. In Chrome, the popup is not showing but at the background it is throwing an error. So the fix is to increase the Load Balancer so that the tcp connection stays alive until it times out at the backend.</p>