问:
Google Analytics Event Tracking through onclick button
I want to track on how many people is clicking the button and sessions will be collected in Google Analytics. However, the I cannot get any result in Google Analytics Events.
My code is below:

```<code><script>
          function handleOutboundLinkClicks(event) {
  ga('send', 'event', {
    eventCategory: 'Outbound Link',
    eventAction: 'click',
    eventLabel: event.target.href,
    transport: 'beacon'
  });
}

      </script>
</code>```

////
The code for my button is below:

```<code><input type="submit" id="submit" value="Validate and Submit" onclick=”_gaq.push([‘_trackEvent’, ‘form, ‘submit’, ’order sent’, 10]);”/>
</code>```

Then entire code for this page:

```<code>    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Keepsake Florals</title>
    <!--link to external css file-->

<link rel="stylesheet" type="text/css" href="keepsakeflorals.css"/>
<link rel="stylesheet" type="text/css" href="ksform.css" />
<link rel="shortcut icon" href="favicon.ico" />
   <script src="scripts/jquery-1.11.3.min.js"></script>

      <script>

      function handleOutboundLinkClicks(event) {
  ga('send', 'event', {
    eventCategory: 'Outbound Link',
    eventAction: 'click',
    eventLabel: event.target.href,
    transport: 'beacon'
  });
}

      </script>

</head>
<body>

<div id="box">
<h1><a href="index.html" title="click here to return home"> KEEPSAKE FLORALS </a> </h1>
</div>

<div>
<nav id="mainnav">
<a href="index.html"> Home</a> |
<a href="aboutus.html"> About Us  </a> |
<a href="flowers.html"> Flowers </a> |
<a href="order.html"> Order </a> |
<a href="review.html"> Review </a> |
</nav>
</div>

<form action="thankyou.html" id="contact-form">

  <fieldset id="contactinfo">
  <legend> <span> Contact Information </span> </legend>
    <label>
    Name
    <input type="text" name="name" id="nameinput" placeholder="First and last name"  />
    </label>
      <label>
      Email
      <input type="email" name="email" id="emailinput" placeholder="address@example.com" />
      </label>
      <label>
      Phone
      <input type="text" name="phone" id="phoneinput" placeholder="phone number" />
      </label>

     </fieldset>

        <fieldset id="orderflower">
          <legend> <span> Flowers to order </span> </legend>
          <label for="mother" >
             <input type="radio" name="flower" id="mother" value="mother" checked="checked"  />
             Mother's day flower
             </label>
                 <label for="father">
                         <input type="radio" name="flower" id="father" value="father" />
                        Fathers day flower
             </label>
                     <label for="otheroccasion">
                    <input type="radio" name="flower" id="occasion" value="occasion"  />
                    Other occasion flower
                            </label>

             <label for="valentinesday">
                 <input type="radio" name="flower" id="vday" value="vday" />
                  Valentine's Day
                  </label>

             <label for="others">
                <input type="radio" name="flower" id="others" value="others"  />
                  Others

                  <input type="text" name="other" id="otherinput">
                  </label>
              </fieldset>
          <fieldset id="delivery">
          <legend> <span> How to contact you ? </span> </legend>
          <label for "question">
              <input type="radio" name="flower" id="phone"  />
                 Via my handphone number
                 </label>
                  <label for "question">
              <input type="radio" name="flower" id="email"  />
                 Via my email
                 </label>

          </fieldset>
          <fieldset id="helpneeded" >

          <legend> <span> Any help needed? </span> </legend>
          <textarea id="helpneeded" name="helpneeded" rows="4" cols="20"> </textarea>
          </fieldset>
           <input type="submit" id="submit" value="Validate and Submit" onclick=”ga('send', 'event', 'form', 'submit', 'order sent', 10);”/>
</form>
</body>
</html>
</code>```

答:
This is a bit late, but I hope this would help someone who lands on this question.

Your issue is most likely because the Google Analytics Javascript code stops execution once your form gets submitted and loads a new page (thankyou.html). You have two options:

Use the transport property and set its value to beacon:

```<code>ga('send', 'event', 'form', 'submit', 'order sent', 10, {
    transport: 'beacon'
});
</code>```

For browsers that do not support the beacon transport method, you can use a callback function:

In your HTML, modify your submit button (remove the onclick attribute):

```<code><input  type="submit" id="submit" value="Validate and Submit" />
</code>```

Then, add an event listener to this submit button:

```<code>var form = document.getElementById('contact-form');

form.addEventListener('submit', function(e) {
    e.preventDefault(); //prevent the form from submitting immediately

    //Send the event to Google Analytics, and then manually
    //submit the form
    ga('send', 'event', 'form', 'submit', 'order sent', 10, {
            hitCallback: function() {
                form.submit(); //submit the form now
            }
    });
});
</code>```

References:

Outbound link and form tracking

Knowing when the hit has been sent

Body:
I want to track on how many people is clicking the button and sessions will be collected in Google Analytics. However, the I cannot get any result in Google Analytics Events.
My code is below:

////
The code for my button is below:

<input type="submit" id="submit" value="Validate and Submit" onclick=”_gaq.push([‘_trackEvent’, ‘form, ‘submit’, ’order sent’, 10]);”/>

Then entire code for this page:

    <!DOCTYPE html>

    <meta charset="utf-8" />
    <title>Keepsake Florals</title>

<link rel="stylesheet" type="text/css" href="keepsakeflorals.css"/>
<link rel="stylesheet" type="text/css" href="ksform.css" />
<link rel="shortcut icon" href="favicon.ico" />

 KEEPSAKE FLORALS

 Home |
 About Us   |
 Flowers  |
 Order  |
 Review  |

<form action="thankyou.html" id="contact-form">

  <fieldset id="contactinfo">
  <legend>  Contact Information  </legend>

    Name
    <input type="text" name="name" id="nameinput" placeholder="First and last name"  />

      Email
      <input type="email" name="email" id="emailinput" placeholder="address@example.com" />

      Phone
      <input type="text" name="phone" id="phoneinput" placeholder="phone number" />

     </fieldset>

        <fieldset id="orderflower">
          <legend>  Flowers to order  </legend>

             <input type="radio" name="flower" id="mother" value="mother" checked="checked"  />
             Mother's day flower

                         <input type="radio" name="flower" id="father" value="father" />
                        Fathers day flower

                    <input type="radio" name="flower" id="occasion" value="occasion"  />
                    Other occasion flower

                 <input type="radio" name="flower" id="vday" value="vday" />
                  Valentine's Day

                <input type="radio" name="flower" id="others" value="others"  />
                  Others

                  <input type="text" name="other" id="otherinput">

              </fieldset>
          <fieldset id="delivery">
          <legend>  How to contact you ?  </legend>

              <input type="radio" name="flower" id="phone"  />
                 Via my handphone number

              <input type="radio" name="flower" id="email"  />
                 Via my email

          </fieldset>
          <fieldset id="helpneeded" >

          <legend>  Any help needed?  </legend>
          <textarea id="helpneeded" name="helpneeded" rows="4" cols="20"> </textarea>
          </fieldset>
           <input type="submit" id="submit" value="Validate and Submit" onclick=”ga('send', 'event', 'form', 'submit', 'order sent', 10);”/>
</form>

Body:
This is a bit late, but I hope this would help someone who lands on this question.

Your issue is most likely because the Google Analytics Javascript code stops execution once your form gets submitted and loads a new page (thankyou.html). You have two options:

Use the transport property and set its value to beacon:

ga('send', 'event', 'form', 'submit', 'order sent', 10, {
    transport: 'beacon'
});

For browsers that do not support the beacon transport method, you can use a callback function:

In your HTML, modify your submit button (remove the onclick attribute):

<input  type="submit" id="submit" value="Validate and Submit" />

Then, add an event listener to this submit button:

var form = document.getElementById('contact-form');

form.addEventListener('submit', function(e) {
    e.preventDefault(); //prevent the form from submitting immediately

    //Send the event to Google Analytics, and then manually
    //submit the form
    ga('send', 'event', 'form', 'submit', 'order sent', 10, {
            hitCallback: function() {
                form.submit(); //submit the form now
            }
    });
});

References:

Outbound link and form tracking

Knowing when the hit has been sent


来源: stackexchange

问:
Javascript/HTML5 - Store and display score in local storage
I created a game with a score. Every time that there's a collision, it ads 10 points and when the user has made 16 collisions, the game ends, and the score gets stored in localstorage so it can be displayed on a scoreboard.

```<code>  //everytime there's a collision, contador++
  // when contador reaches 16, there's a pop up and the score is saved in local storage.

  if (contador == 16)  {

  localStorage.setItem("pontosSalvos", pontos);

  var pop = document.getElementById ( "alerta_ajuda");
  pop.style.display = 'inline';
  contador = 0;

          }
</code>```

Then, there's a page for the scoreboard with the following code:

```<code>    //the score gets displayed on a span called mensagem

    function mostraPontos() {
    var pontos = localStorage.getItem ("pontosSalvos");
    var span = document.getElementById ("mensagem_pontos");

    span.innerHTML = pontos;
}
</code>```

What I wanted to know is this:
With the code like this, whenever there's a new score, it replaces the previous score in the scoreboard and it only shows the new score.
Is there a way to store/display multiple scores without replacing the old ones?
Thank you!

答:
You can push the scores to an array and save its stringified version to localStorage instead of storing a single value.

To display them in HTML, you should parse the stringified value coming back from localStorage to obtain an array again and map its values to an HTML element of your choice.

Something like this:

const board = document.getElementById('board');

// Load saved scores:

const fakeLocalStorage = {};

let scores = [];

try {
  scores = JSON.parse(fakeLocalStorage.scores);
} catch(err) {}

// Add new scores and save them:

document.getElementById('push').onclick = function() {
  scores.push(Math.floor(Math.random() * 17));

  fakeLocalStorage.scores = JSON.stringify(scores);

  board.innerHTML = scores.map(score => `<li>${ score }</li>`).join('');
};

// Clear all scores and delete them from localStorage:

document.getElementById('clear').onclick = function() {
  scores = [];

  delete fakeLocalStorage.scores;

  board.innerHTML = '';
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button id="push">ADD SCORE</button>
<button id="clear">CLEAR SCORES</button>

<ul id="board"></ul></code>```

Note localStorage is not allowed in StackOverflow snippets, so I just use a normal object fakeLocalStorage in this example. You can just swap it for localStorage in your code and it should still be working as expected.

ContentLicense: CC BY-SA 3.0

Body:
I created a game with a score. Every time that there's a collision, it ads 10 points and when the user has made 16 collisions, the game ends, and the score gets stored in localstorage so it can be displayed on a scoreboard.

  //everytime there's a collision, contador++
  // when contador reaches 16, there's a pop up and the score is saved in local storage.

  if (contador == 16)  {

  localStorage.setItem("pontosSalvos", pontos);

  var pop = document.getElementById ( "alerta_ajuda");
  pop.style.display = 'inline';
  contador = 0;

          }

Then, there's a page for the scoreboard with the following code:

    //the score gets displayed on a span called mensagem

    function mostraPontos() {
    var pontos = localStorage.getItem ("pontosSalvos");
    var span = document.getElementById ("mensagem_pontos");

    span.innerHTML = pontos;
}

What I wanted to know is this:
With the code like this, whenever there's a new score, it replaces the previous score in the scoreboard and it only shows the new score.
Is there a way to store/display multiple scores without replacing the old ones?
Thank you!

Body:
You can push the scores to an array and save its stringified version to localStorage instead of storing a single value.

To display them in HTML, you should parse the stringified value coming back from localStorage to obtain an array again and map its values to an HTML element of your choice.

Something like this:

const board = document.getElementById('board');

// Load saved scores:

const fakeLocalStorage = {};

let scores = [];

try {
  scores = JSON.parse(fakeLocalStorage.scores);
} catch(err) {}

// Add new scores and save them:

document.getElementById('push').onclick = function() {
  scores.push(Math.floor(Math.random() * 17));

  fakeLocalStorage.scores = JSON.stringify(scores);

  board.innerHTML = scores.map(score => `<li>${ score }</li>`).join('');
};

// Clear all scores and delete them from localStorage:

document.getElementById('clear').onclick = function() {
  scores = [];

  delete fakeLocalStorage.scores;

  board.innerHTML = '';
};

<button id="push">ADD SCORE</button>
<button id="clear">CLEAR SCORES</button>

<ul id="board"></ul>

Note localStorage is not allowed in StackOverflow snippets, so I just use a normal object fakeLocalStorage in this example. You can just swap it for localStorage in your code and it should still be working as expected.


问:
Rails 4 + bower-rails gem + bower + bootstrap sass
I have installed bower-rails gem

then in bower file I included bootstrap-sass, it installed bootstrap-sass in vendor/assets/bower_components.

Now according to a resource bower-rails automatically takes care of adding bower_components to assets, so I am trying this in application.css

```<code> *= require_tree .
 *= require_self
 *= require 'bootstrap-sass'
 */
</code>```

But it throws me error that bootstrap-sass file not found.

Do I have to manually add vendor/assets/bower_components to assets?

I am pretty new to rails so some explanation would help a lot.

I am following this resource

EDIT:
On doing rails c and printing Rails.application.config.assets.paths
I can see vendor/assets/bower_components in asset paths
`

答:
Finally I resolved the issue by removing all the bower components and running

rails g bower_rails:initialize

It created an intializer for assets bower_rails.rb, which finally solved the problem

Body:
I have installed bower-rails gem

then in bower file I included bootstrap-sass, it installed bootstrap-sass in vendor/assets/bower_components.

Now according to a resource bower-rails automatically takes care of adding bower_components to assets, so I am trying this in application.css

 *= require_tree .
 *= require_self
 *= require 'bootstrap-sass'
 */

But it throws me error that bootstrap-sass file not found.

Do I have to manually add vendor/assets/bower_components to assets?

I am pretty new to rails so some explanation would help a lot.

I am following this resource

EDIT:
On doing rails c and printing Rails.application.config.assets.paths
I can see vendor/assets/bower_components in asset paths
`


问:
Changing default font in Windows messes up my Win Forms buttons
We have a collection of C# (.NET 2.0) applications that have custom dialog windows. When the user changes the default font size and resolution etc in Windows the edges of the form lose controls (they get pushed off the visible portion of the form) typically dropping off buttons from the bottom. This is problematic for us and will cause issues across other applications using the standard look-and-feel framework we are creating around these applications.

How would you make your entire application independent from windows font changes? How would you integrate this into multiple solutions?

Or better still how can one adapt the entire application to be able to adjust itself with the Windows appearance changes?

答: You could handle the SystemEvents.UserPreferenceChanged event in the Microsoft.Win32 namespace. The UserPreferenceChangedEventArgs parameter will have a Category of UserPreferenceCategory.Window when the system font changes. I think you'll then have to trigger a manual window layout and redraw in response to this event.</p>

OwnerDisplayName: bdwakefield

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Matt Hamilton

OwnerDisplayName: Stu Mackellar


问:
Is there a way to use PredicateBuilder with Azure Table Storage?
Just what it says on the tin, I have a design problem where normally PredicateBuilder would be the obvious answer, but when executing, I get errors such as : </p>

```<code>The expression
((([10007].PartitionKey == "df2907ad-2094-4b7a-9796-d077f14b25bc")
And True)
And Invoke(f => (True AndAlso Invoke(job => (job.MigrationExecutionId == "5fa0bd4c-4745-4452-8e52-a0329c00dafb"), f)), [10007]))
is not supported.
</code>```

<p>Any way to use Predicate builder, or some other form of expression tree syntax to build up a query and run it against Azure Table? </p>

答:
Yes, you can use PredicateBuilder with Azure Table Storage.  Let's say you want to build a query of the format (pseudo code):

```<code>where partitionkey = "X" and (email = "Y" or email = "Z")
</code>```

This can be done as follows

```<code>    public string[] GetByEmail(string companyId, string[] emails)
    {
        var inner = PredicateBuilder.New<IssuerTableEntity>(false);
        foreach (var email in emails.Select(x => x.ToLowerInvariant()).Distinct())
        {
            var temp = email;
            inner = inner.Or(x => x.EmailLowercase == temp);
        }

        var outer = PredicateBuilder.New<MyTableEntity>(false);
        outer = outer.And(x => x.PartitionKey == companyId);
        outer = outer.And(inner);

        CloudTable table = GetTable(MyTableName);
        return table.CreateQuery<MyTableEntity>()
            .Where(outer)
            .Select(x => x.RowKey)
            .ToArray();
    }
</code>```

Note the use of Distinct() - this was because I got errors when supplying duplicates.

Body:
Just what it says on the tin, I have a design problem where normally PredicateBuilder would be the obvious answer, but when executing, I get errors such as :

The expression
((([10007].PartitionKey == "df2907ad-2094-4b7a-9796-d077f14b25bc")
And True)
And Invoke(f => (True AndAlso Invoke(job => (job.MigrationExecutionId == "5fa0bd4c-4745-4452-8e52-a0329c00dafb"), f)), [10007]))
is not supported.

Any way to use Predicate builder, or some other form of expression tree syntax to build up a query and run it against Azure Table?

Body:
Yes, you can use PredicateBuilder with Azure Table Storage.  Let's say you want to build a query of the format (pseudo code):

where partitionkey = "X" and (email = "Y" or email = "Z")

This can be done as follows

    public string[] GetByEmail(string companyId, string[] emails)
    {
        var inner = PredicateBuilder.New<IssuerTableEntity>(false);
        foreach (var email in emails.Select(x => x.ToLowerInvariant()).Distinct())
        {
            var temp = email;
            inner = inner.Or(x => x.EmailLowercase == temp);
        }

        var outer = PredicateBuilder.New<MyTableEntity>(false);
        outer = outer.And(x => x.PartitionKey == companyId);
        outer = outer.And(inner);

        CloudTable table = GetTable(MyTableName);
        return table.CreateQuery<MyTableEntity>()
            .Where(outer)
            .Select(x => x.RowKey)
            .ToArray();
    }

Note the use of Distinct() - this was because I got errors when supplying duplicates.

ContentLicense: CC BY-SA 4.0


问:
How to not use __init__.py as Flask app name?
I have a flask app structured like so:

repo_root

config.py

requirements.txt

my_cool_app/

my_cool_app/__init__.py

my_cool_app/models.py

my_cool_app/views.py

my_cool_app/static/

my_cool_app/templates/

And the contents of my_cool_app/__init__.py looks like:

```<code>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_oauth2_login import GoogleLogin
from flask_login import LoginManager

app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
migrate = Migrate(app, db)

google_login = GoogleLogin(app)
login_manager = LoginManager()
login_manager.init_app(app)

import my_cool_app.models
import my_cool_app.views
</code>```

To run it, I invoke:

```<code>FLASK_APP=my_cool_app/__init__.py flask run
</code>```

Based on a variety of documentation online, I thought I should be able to just set FLASK_APP to the package name my_cool_app. When I do this, and invoke flask run, the application starts but in the browser I immediately see the error:

```<code>flask.cli.NoAppException
flask.cli.NoAppException: The file/path provided (my_cool_app) does not appear to exist.  Please verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py
</code>```

What should I be doing to be able to set the FLASK_APP to just my_cool_app? Or is it more appropriate/typical for FLASK_APP to be set to something else, given the way this flask application is structured?

答: Based on the discussion surrounding this issue, it seems that one can indeed set FLASK_APP=my_cool_app and run successfully with python -m flask run. Not yet sure how this impacts a production config.

Body:
I have a flask app structured like so:

repo_root

config.py

requirements.txt

my_cool_app/

my_cool_app/__init__.py

my_cool_app/models.py

my_cool_app/views.py

my_cool_app/static/

my_cool_app/templates/

And the contents of my_cool_app/__init__.py looks like:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_oauth2_login import GoogleLogin
from flask_login import LoginManager

app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
migrate = Migrate(app, db)

google_login = GoogleLogin(app)
login_manager = LoginManager()
login_manager.init_app(app)

import my_cool_app.models
import my_cool_app.views

To run it, I invoke:

FLASK_APP=my_cool_app/__init__.py flask run

Based on a variety of documentation online, I thought I should be able to just set FLASK_APP to the package name my_cool_app. When I do this, and invoke flask run, the application starts but in the browser I immediately see the error:

flask.cli.NoAppException
flask.cli.NoAppException: The file/path provided (my_cool_app) does not appear to exist.  Please verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py

What should I be doing to be able to set the FLASK_APP to just my_cool_app? Or is it more appropriate/typical for FLASK_APP to be set to something else, given the way this flask application is structured?


问:
ocamlfind: Package `lablgtk2.gnomecanvas' not found on ubuntu 17.04
I am trying to install Frama-C gui Phosphorus from repository (6aa64) on Ubuntu 17.04 (Zesty). Frama-C opam works fine but it lacks the GUI as far as I can tell + I might want to patch frama-C later on so I would like to be able to compile it myself.

First step:

```<code>./configure --enable-gui --enable-verbosemake
</code>```

generates the output:

```<code>configure: ******************
configure: * CONFIGURE MAKE *
configure: ******************
checking for make... make
checking version of make... 4.1
configure: *****************************
configure: * CONFIGURE OCAML COMPILERS *
configure: *****************************
checking for ocamlc... ocamlc
checking version of OCaml... 4.02.3
checking OCaml library path... /usr/lib/ocaml
checking for ocamlopt... ocamlopt
checking ocamlopt version and standard library... ok
checking for ocamlfind... ocamlfind
configure: Distribution mode: all warnings are deactivated
configure: *******************************************
configure: * CONFIGURE MANDATORY TOOLS AND LIBRARIES *
configure: *******************************************
checking for ocamldep... ocamldep
checking for ocamllex... ocamllex
checking for ocamllex.opt... ocamllex.opt
checking for ocamlyacc... ocamlyacc
checking for ocamlcp... ocamlcp
checking for ocamlgraph... found
checking for zarith... found
configure: ******************************************
configure: * CONFIGURE OPTIONAL TOOLS AND LIBRARIES *
configure: ******************************************
checking for ocamldoc... ocamldoc
checking for ocamlmktop... ocamlmktop
checking for otags... no
checking for Apron... not found. The corresponding domains won't be available in Eva
checking for Landmarks... not found.
configure: **********************
configure: * CONFIGURE PLATFORM *
configure: **********************
checking platform... Unix
checking OCaml native threads... ok.
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking assert.h usability... yes
checking assert.h presence... yes
checking for assert.h... yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for unistd.h... (cached) yes
checking how to run the C preprocessor... gcc -E
/* Check whether comments are kept in output */
Default preprocessor is 'gcc -E -C -I.'.
Default preprocessor supported architecture-related options: \"-m32\"; \"-m64\"; \"-m16\";
configure: ***************************
configure: * WISHED FRAMA-C PLUG-INS *
configure: ***************************
checking for src/plugins/callgraph... yes
callgraph... yes
checking for src/plugins/constant_propagation... yes
semantic_constant_folding... yes
checking for src/plugins/from... yes
from_analysis... yes
checking for src/plugins/gui... yes
gui... yes
checking for src/plugins/impact... yes
impact... yes
checking for src/plugins/inout... yes
inout... yes
checking for src/plugins/metrics... yes
metrics... yes
checking for src/plugins/occurrence... yes
occurrence... yes
checking for src/plugins/pdg... yes
pdg... yes
checking for src/plugins/postdominators... yes
postdominators... yes
checking for src/plugins/rte... yes
rtegen... yes
checking for src/plugins/scope... yes
scope... yes
checking for src/plugins/slicing... yes
slicing... yes
checking for src/plugins/sparecode... yes
sparecode... yes
checking for src/plugins/users... yes
users... yes
checking for src/plugins/value... yes
value_analysis... yes
checking for src/plugins/aorai/Makefile.in... yes
aorai... yes
checking for ltl2ba... no
checking for src/plugins/e-acsl/Makefile.in... yes
e_acsl... yes
checking for uname... uname
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for doxygen... doxygen
checking for dot... yes
configure: creating ./config.status
config.status: creating src/plugins/e-acsl/doc/doxygen/doxygen.cfg
config.status: executing default commands
configure: Configure libjemalloc
autoconf
./configure --enable-autogen --with-jemalloc-prefix=__e_acsl_native_ --with-private-namespace=__e_acsl_hidden_
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether compiler supports -std=gnu99... yes
checking whether compiler supports -Wall... yes
checking whether compiler supports -Werror=declaration-after-statement... yes
checking whether compiler supports -Wshorten-64-to-32... no
checking whether compiler supports -Wsign-compare... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether pause instruction is compilable... yes
checking for ar... ar
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking whether malloc_usable_size definition can use const argument... no
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -Werror... yes
checking whether tls_model attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether alloc_size attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(gnu_printf, ...) attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(printf, ...) attribute is compilable... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... /usr/bin/autoconf
checking for memalign... yes
checking for valloc... yes
checking whether compiler supports -O3... yes
checking whether compiler supports -funroll-loops... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether valgrind is compilable... yes
checking whether a program using __builtin_ffsl is compilable... yes
checking LG_PAGE... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for library containing clock_gettime... none required
checking for secure_getenv... yes
checking for issetugid... no
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether C11 atomics is compilable... no
checking whether atomic(9) is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) is compilable... yes
checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
checking for __builtin_clz... yes
checking whether Darwin OSSpin*() is compilable... no
checking whether glibc malloc hook is compilable... yes
checking whether glibc memalign hook is compilable... yes
checking whether pthreads adaptive mutexes is compilable... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating jemalloc.pc
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc_macros.h
config.status: creating include/jemalloc/jemalloc_protos.h
config.status: creating include/jemalloc/jemalloc_typedefs.h
config.status: creating include/jemalloc/internal/jemalloc_internal.h
config.status: creating test/test.sh
config.status: creating test/include/test/jemalloc_test.h
config.status: creating config.stamp
config.status: creating bin/jemalloc-config
config.status: creating bin/jemalloc.sh
config.status: creating bin/jeprof
config.status: creating include/jemalloc/jemalloc_defs.h
config.status: include/jemalloc/jemalloc_defs.h is unchanged
config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
config.status: include/jemalloc/internal/jemalloc_internal_defs.h is unchanged
config.status: creating test/include/test/jemalloc_test_defs.h
config.status: test/include/test/jemalloc_test_defs.h is unchanged
config.status: executing include/jemalloc/internal/private_namespace.h commands
config.status: executing include/jemalloc/internal/private_unnamespace.h commands
config.status: executing include/jemalloc/internal/public_symbols.txt commands
config.status: executing include/jemalloc/internal/public_namespace.h commands
config.status: executing include/jemalloc/internal/public_unnamespace.h commands
config.status: executing include/jemalloc/internal/size_classes.h commands
config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
config.status: executing include/jemalloc/jemalloc_rename.h commands
config.status: executing include/jemalloc/jemalloc_mangle.h commands
config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
config.status: executing include/jemalloc/jemalloc.h commands
checking for src/plugins/loop_analysis/Makefile.in... yes
loop_analysis... yes
checking for src/plugins/nonterm/Makefile.in... yes
nonterm... yes
checking for src/plugins/obfuscator/Makefile.in... yes
obfuscator... yes
checking for src/plugins/print_api... yes
print_api... yes
checking for src/plugins/report/Makefile.in... yes
report... yes
checking for src/plugins/security_slicing/Makefile.in... yes
security_slicing... yes
checking for src/plugins/variadic/Makefile.in... yes
variadic... yes
checking for src/plugins/wp/Makefile.in... yes
wp... yes
configure: *******************************************************
configure: * CONFIGURE TOOLS AND LIBRARIES USED BY SOME PLUG-INS *
configure: *******************************************************
Ocamlfind -> using +lablgtk2.(/usr/lib/ocaml/lablgtk2,/usr/lib/ocaml/lablgtk2)
checking for /usr/lib/ocaml/lablgtk2/lablgtksourceview2.cmxa... yes
checking for /usr/lib/ocaml/lablgtk2/lablgnomecanvas.cmxa... yes
checking for /usr/lib/ocaml/lablgtk2/lablgtk.cmxa... yes
checking for dot... yes
native dynlink works fine. Great.
configure: *************************************
configure: * CHECKING FOR PLUG-IN DEPENDENCIES *
configure: *************************************
configure: WARNING: ltl2ba not found.
configure: WARNING: aorai partially enabled because ltl2ba missing.
checking for coqc... yes
unsupported coqc version 8.6
configure: *********************
configure: * CREATING MAKEFILE *
configure: *********************
configure: creating ./config.status
config.status: creating src/plugins/e-acsl/doc/doxygen/doxygen.cfg
config.status: creating src/plugins/e-acsl/Makefile
config.status: creating src/plugins/loop_analysis/Makefile
config.status: creating src/plugins/nonterm/Makefile
config.status: creating src/plugins/obfuscator/Makefile
config.status: creating src/plugins/report/Makefile
config.status: creating src/plugins/variadic/Makefile
config.status: creating src/plugins/aorai/Makefile
config.status: creating src/plugins/security_slicing/Makefile
config.status: creating src/plugins/wp/Makefile
config.status: creating share/Makefile.config
config.status: executing default commands
configure: *******************************
configure: * SUMMARY: PLUG-INS AVAILABLE *
configure: *******************************
configure: callgraph: yes, dynamic
configure: semantic_constant_folding: yes, dynamic
configure: from_analysis: yes, dynamic
configure: gui: yes
configure: impact: yes, dynamic
configure: inout: yes, dynamic
configure: metrics: yes, dynamic
configure: occurrence: yes, dynamic
configure: pdg: yes, dynamic
configure: postdominators: yes, dynamic
configure: rtegen: yes, dynamic
configure: scope: yes, dynamic
configure: slicing: yes, dynamic
configure: sparecode: yes, dynamic
configure: users: yes, dynamic
configure: value_analysis: yes, dynamic
configure: aorai: partial, dynamic, ltl2ba missing
configure: e_acsl: yes, dynamic
configure: loop_analysis: yes, dynamic
configure: nonterm: yes, dynamic
configure: obfuscator: yes, dynamic
configure: print_api: yes, dynamic
configure: report: yes, dynamic
configure: security_slicing: yes, dynamic
configure: variadic: yes, dynamic
configure: wp: yes, dynamic
</code>```

... which once I run make ends up in:

```<code>ocamlfind ocamlc -c -package findlib -package ocamlgraph -package num -package unix -package str -package dynlink -package bytes -package zarith -w -a  -bin-annot -strict-sequence -safe-string -g -I src/plugins/slicing_types -I src/plugins/pdg_types -I src/plugins/value_types -I src/libraries/stdlib -I src/libraries/utils -I src/libraries/project -I src/libraries/datatype -I src/kernel_internals/parsing -I src/kernel_internals/typing -I src/kernel_internals/runtime -I src/kernel_services/parsetree -I src/kernel_services/ast_data -I src/kernel_services/ast_queries -I src/kernel_services/ast_printing -I src/kernel_services/cmdline_parameters -I src/kernel_services/plugin_entry_points -I src/kernel_services/abstract_interp -I src/kernel_services/visitors -I src/kernel_services/analysis -I src/kernel_services/ast_transformations -I src/plugins/gui -I /home/teto/framac/lib/plugins  -I src/plugins/security_slicing -I /home/teto/framac/lib/plugins  -package findlib -package ocamlgraph -package num -package unix -package str -package dynlink -package bytes -package zarith -w -a  -bin-annot -strict-sequence -safe-string -g -I /home/teto/framac/src/plugins/slicing_types -I /home/teto/framac/src/plugins/pdg_types -I /home/teto/framac/src/plugins/value_types -I /home/teto/framac/src/libraries/stdlib -I /home/teto/framac/src/libraries/utils -I /home/teto/framac/src/libraries/project -I /home/teto/framac/src/libraries/datatype -I /home/teto/framac/src/kernel_internals/parsing -I /home/teto/framac/src/kernel_internals/typing -I /home/teto/framac/src/kernel_internals/runtime -I /home/teto/framac/src/kernel_services/parsetree -I /home/teto/framac/src/kernel_services/ast_data -I /home/teto/framac/src/kernel_services/ast_queries -I /home/teto/framac/src/kernel_services/ast_printing -I /home/teto/framac/src/kernel_services/cmdline_parameters -I /home/teto/framac/src/kernel_services/plugin_entry_points -I /home/teto/framac/src/kernel_services/abstract_interp -I /home/teto/framac/src/kernel_services/visitors -I /home/teto/framac/src/kernel_services/analysis -I /home/teto/framac/src/kernel_services/ast_transformations -I /home/teto/framac/src/plugins/gui -I /home/teto/framac/lib  -package lablgtk2 -package lablgtk2.gnomecanvas -package lablgtk2.sourceview2 src/plugins/security_slicing/security_slicing_parameters.mli
ocamlfind: Package `lablgtk2.gnomecanvas' not found
</code>```

I have libgnomecanvas2(*) installed. The problem was already mentioned here without solution:
https://lists.gforge.inria.fr/pipermail/frama-c-discuss/2017-January/005200.html

I don't know much about ocaml but it seems that gnomecanvas should be found in /usr/lib/ocaml/lablgtk2/. I uploaded a listing of this folder if it can help here https://transfer.sh/4lQol/listing (too big for SO)

Best regards
Matt

答: For some reason (that we, the Frama-c team, do not really understand), Debian deviates significantly from upstream Labgltk2 -- and thus so does the Ubuntu package. In both of these distributions, the OCamlfind package for gnomecanvas is called lablgtk2-gnome.gnomecanvas, not just lablgtk2.gnomecanvas. You can either patch the sources of Frama-c accordingly, but I suggest you instead perform an Opam installation. This will make things simpler in the long term.

Body:
I am trying to install Frama-C gui Phosphorus from repository (6aa64) on Ubuntu 17.04 (Zesty). Frama-C opam works fine but it lacks the GUI as far as I can tell + I might want to patch frama-C later on so I would like to be able to compile it myself.

First step:

./configure --enable-gui --enable-verbosemake

generates the output:

configure: ******************
configure: * CONFIGURE MAKE *
configure: ******************
checking for make... make
checking version of make... 4.1
configure: *****************************
configure: * CONFIGURE OCAML COMPILERS *
configure: *****************************
checking for ocamlc... ocamlc
checking version of OCaml... 4.02.3
checking OCaml library path... /usr/lib/ocaml
checking for ocamlopt... ocamlopt
checking ocamlopt version and standard library... ok
checking for ocamlfind... ocamlfind
configure: Distribution mode: all warnings are deactivated
configure: *******************************************
configure: * CONFIGURE MANDATORY TOOLS AND LIBRARIES *
configure: *******************************************
checking for ocamldep... ocamldep
checking for ocamllex... ocamllex
checking for ocamllex.opt... ocamllex.opt
checking for ocamlyacc... ocamlyacc
checking for ocamlcp... ocamlcp
checking for ocamlgraph... found
checking for zarith... found
configure: ******************************************
configure: * CONFIGURE OPTIONAL TOOLS AND LIBRARIES *
configure: ******************************************
checking for ocamldoc... ocamldoc
checking for ocamlmktop... ocamlmktop
checking for otags... no
checking for Apron... not found. The corresponding domains won't be available in Eva
checking for Landmarks... not found.
configure: **********************
configure: * CONFIGURE PLATFORM *
configure: **********************
checking platform... Unix
checking OCaml native threads... ok.
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking assert.h usability... yes
checking assert.h presence... yes
checking for assert.h... yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for unistd.h... (cached) yes
checking how to run the C preprocessor... gcc -E
/* Check whether comments are kept in output */
Default preprocessor is 'gcc -E -C -I.'.
Default preprocessor supported architecture-related options: \"-m32\"; \"-m64\"; \"-m16\";
configure: ***************************
configure: * WISHED FRAMA-C PLUG-INS *
configure: ***************************
checking for src/plugins/callgraph... yes
callgraph... yes
checking for src/plugins/constant_propagation... yes
semantic_constant_folding... yes
checking for src/plugins/from... yes
from_analysis... yes
checking for src/plugins/gui... yes
gui... yes
checking for src/plugins/impact... yes
impact... yes
checking for src/plugins/inout... yes
inout... yes
checking for src/plugins/metrics... yes
metrics... yes
checking for src/plugins/occurrence... yes
occurrence... yes
checking for src/plugins/pdg... yes
pdg... yes
checking for src/plugins/postdominators... yes
postdominators... yes
checking for src/plugins/rte... yes
rtegen... yes
checking for src/plugins/scope... yes
scope... yes
checking for src/plugins/slicing... yes
slicing... yes
checking for src/plugins/sparecode... yes
sparecode... yes
checking for src/plugins/users... yes
users... yes
checking for src/plugins/value... yes
value_analysis... yes
checking for src/plugins/aorai/Makefile.in... yes
aorai... yes
checking for ltl2ba... no
checking for src/plugins/e-acsl/Makefile.in... yes
e_acsl... yes
checking for uname... uname
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for doxygen... doxygen
checking for dot... yes
configure: creating ./config.status
config.status: creating src/plugins/e-acsl/doc/doxygen/doxygen.cfg
config.status: executing default commands
configure: Configure libjemalloc
autoconf
./configure --enable-autogen --with-jemalloc-prefix=__e_acsl_native_ --with-private-namespace=__e_acsl_hidden_
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether compiler supports -std=gnu99... yes
checking whether compiler supports -Wall... yes
checking whether compiler supports -Werror=declaration-after-statement... yes
checking whether compiler supports -Wshorten-64-to-32... no
checking whether compiler supports -Wsign-compare... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether pause instruction is compilable... yes
checking for ar... ar
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking whether malloc_usable_size definition can use const argument... no
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -Werror... yes
checking whether tls_model attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether alloc_size attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(gnu_printf, ...) attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(printf, ...) attribute is compilable... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... /usr/bin/autoconf
checking for memalign... yes
checking for valloc... yes
checking whether compiler supports -O3... yes
checking whether compiler supports -funroll-loops... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether valgrind is compilable... yes
checking whether a program using __builtin_ffsl is compilable... yes
checking LG_PAGE... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for library containing clock_gettime... none required
checking for secure_getenv... yes
checking for issetugid... no
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether C11 atomics is compilable... no
checking whether atomic(9) is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) is compilable... yes
checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
checking for __builtin_clz... yes
checking whether Darwin OSSpin*() is compilable... no
checking whether glibc malloc hook is compilable... yes
checking whether glibc memalign hook is compilable... yes
checking whether pthreads adaptive mutexes is compilable... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating jemalloc.pc
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc_macros.h
config.status: creating include/jemalloc/jemalloc_protos.h
config.status: creating include/jemalloc/jemalloc_typedefs.h
config.status: creating include/jemalloc/internal/jemalloc_internal.h
config.status: creating test/test.sh
config.status: creating test/include/test/jemalloc_test.h
config.status: creating config.stamp
config.status: creating bin/jemalloc-config
config.status: creating bin/jemalloc.sh
config.status: creating bin/jeprof
config.status: creating include/jemalloc/jemalloc_defs.h
config.status: include/jemalloc/jemalloc_defs.h is unchanged
config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
config.status: include/jemalloc/internal/jemalloc_internal_defs.h is unchanged
config.status: creating test/include/test/jemalloc_test_defs.h
config.status: test/include/test/jemalloc_test_defs.h is unchanged
config.status: executing include/jemalloc/internal/private_namespace.h commands
config.status: executing include/jemalloc/internal/private_unnamespace.h commands
config.status: executing include/jemalloc/internal/public_symbols.txt commands
config.status: executing include/jemalloc/internal/public_namespace.h commands
config.status: executing include/jemalloc/internal/public_unnamespace.h commands
config.status: executing include/jemalloc/internal/size_classes.h commands
config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
config.status: executing include/jemalloc/jemalloc_rename.h commands
config.status: executing include/jemalloc/jemalloc_mangle.h commands
config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
config.status: executing include/jemalloc/jemalloc.h commands
checking for src/plugins/loop_analysis/Makefile.in... yes
loop_analysis... yes
checking for src/plugins/nonterm/Makefile.in... yes
nonterm... yes
checking for src/plugins/obfuscator/Makefile.in... yes
obfuscator... yes
checking for src/plugins/print_api... yes
print_api... yes
checking for src/plugins/report/Makefile.in... yes
report... yes
checking for src/plugins/security_slicing/Makefile.in... yes
security_slicing... yes
checking for src/plugins/variadic/Makefile.in... yes
variadic... yes
checking for src/plugins/wp/Makefile.in... yes
wp... yes
configure: *******************************************************
configure: * CONFIGURE TOOLS AND LIBRARIES USED BY SOME PLUG-INS *
configure: *******************************************************
Ocamlfind -> using +lablgtk2.(/usr/lib/ocaml/lablgtk2,/usr/lib/ocaml/lablgtk2)
checking for /usr/lib/ocaml/lablgtk2/lablgtksourceview2.cmxa... yes
checking for /usr/lib/ocaml/lablgtk2/lablgnomecanvas.cmxa... yes
checking for /usr/lib/ocaml/lablgtk2/lablgtk.cmxa... yes
checking for dot... yes
native dynlink works fine. Great.
configure: *************************************
configure: * CHECKING FOR PLUG-IN DEPENDENCIES *
configure: *************************************
configure: WARNING: ltl2ba not found.
configure: WARNING: aorai partially enabled because ltl2ba missing.
checking for coqc... yes
unsupported coqc version 8.6
configure: *********************
configure: * CREATING MAKEFILE *
configure: *********************
configure: creating ./config.status
config.status: creating src/plugins/e-acsl/doc/doxygen/doxygen.cfg
config.status: creating src/plugins/e-acsl/Makefile
config.status: creating src/plugins/loop_analysis/Makefile
config.status: creating src/plugins/nonterm/Makefile
config.status: creating src/plugins/obfuscator/Makefile
config.status: creating src/plugins/report/Makefile
config.status: creating src/plugins/variadic/Makefile
config.status: creating src/plugins/aorai/Makefile
config.status: creating src/plugins/security_slicing/Makefile
config.status: creating src/plugins/wp/Makefile
config.status: creating share/Makefile.config
config.status: executing default commands
configure: *******************************
configure: * SUMMARY: PLUG-INS AVAILABLE *
configure: *******************************
configure: callgraph: yes, dynamic
configure: semantic_constant_folding: yes, dynamic
configure: from_analysis: yes, dynamic
configure: gui: yes
configure: impact: yes, dynamic
configure: inout: yes, dynamic
configure: metrics: yes, dynamic
configure: occurrence: yes, dynamic
configure: pdg: yes, dynamic
configure: postdominators: yes, dynamic
configure: rtegen: yes, dynamic
configure: scope: yes, dynamic
configure: slicing: yes, dynamic
configure: sparecode: yes, dynamic
configure: users: yes, dynamic
configure: value_analysis: yes, dynamic
configure: aorai: partial, dynamic, ltl2ba missing
configure: e_acsl: yes, dynamic
configure: loop_analysis: yes, dynamic
configure: nonterm: yes, dynamic
configure: obfuscator: yes, dynamic
configure: print_api: yes, dynamic
configure: report: yes, dynamic
configure: security_slicing: yes, dynamic
configure: variadic: yes, dynamic
configure: wp: yes, dynamic

... which once I run make ends up in:

ocamlfind ocamlc -c -package findlib -package ocamlgraph -package num -package unix -package str -package dynlink -package bytes -package zarith -w -a  -bin-annot -strict-sequence -safe-string -g -I src/plugins/slicing_types -I src/plugins/pdg_types -I src/plugins/value_types -I src/libraries/stdlib -I src/libraries/utils -I src/libraries/project -I src/libraries/datatype -I src/kernel_internals/parsing -I src/kernel_internals/typing -I src/kernel_internals/runtime -I src/kernel_services/parsetree -I src/kernel_services/ast_data -I src/kernel_services/ast_queries -I src/kernel_services/ast_printing -I src/kernel_services/cmdline_parameters -I src/kernel_services/plugin_entry_points -I src/kernel_services/abstract_interp -I src/kernel_services/visitors -I src/kernel_services/analysis -I src/kernel_services/ast_transformations -I src/plugins/gui -I /home/teto/framac/lib/plugins  -I src/plugins/security_slicing -I /home/teto/framac/lib/plugins  -package findlib -package ocamlgraph -package num -package unix -package str -package dynlink -package bytes -package zarith -w -a  -bin-annot -strict-sequence -safe-string -g -I /home/teto/framac/src/plugins/slicing_types -I /home/teto/framac/src/plugins/pdg_types -I /home/teto/framac/src/plugins/value_types -I /home/teto/framac/src/libraries/stdlib -I /home/teto/framac/src/libraries/utils -I /home/teto/framac/src/libraries/project -I /home/teto/framac/src/libraries/datatype -I /home/teto/framac/src/kernel_internals/parsing -I /home/teto/framac/src/kernel_internals/typing -I /home/teto/framac/src/kernel_internals/runtime -I /home/teto/framac/src/kernel_services/parsetree -I /home/teto/framac/src/kernel_services/ast_data -I /home/teto/framac/src/kernel_services/ast_queries -I /home/teto/framac/src/kernel_services/ast_printing -I /home/teto/framac/src/kernel_services/cmdline_parameters -I /home/teto/framac/src/kernel_services/plugin_entry_points -I /home/teto/framac/src/kernel_services/abstract_interp -I /home/teto/framac/src/kernel_services/visitors -I /home/teto/framac/src/kernel_services/analysis -I /home/teto/framac/src/kernel_services/ast_transformations -I /home/teto/framac/src/plugins/gui -I /home/teto/framac/lib  -package lablgtk2 -package lablgtk2.gnomecanvas -package lablgtk2.sourceview2 src/plugins/security_slicing/security_slicing_parameters.mli
ocamlfind: Package `lablgtk2.gnomecanvas' not found

I have libgnomecanvas2(*) installed. The problem was already mentioned here without solution:
https://lists.gforge.inria.fr/pipermail/frama-c-discuss/2017-January/005200.html

I don't know much about ocaml but it seems that gnomecanvas should be found in /usr/lib/ocaml/lablgtk2/. I uploaded a listing of this folder if it can help here https://transfer.sh/4lQol/listing (too big for SO)

Best regards
Matt


问:
how to set the template url in angular 2
I created a new angular app using @angular/cli. in that app template already have app component. inside that app component I want to use another component called user. so inside @Component there is a property called templateUrl and also some says to use only the template. so which one should I use and which is the best. currently I'm trying to use templateUrl with this.

think this is my app.component.ts

```<code>@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
</code>```

and this is my user.component.ts

```<code>@Component({
  selector: 'app-user',
  templateUrl: './user.component.html',
  styleUrls: ['./user.component.css']
})
</code>```

so how can I use my user component with app component. I tried by giving relative paths but it didn't work and gave absolute path didn't work that too. I'm confused. hope your help with this.

答:
use my user component with app component.
  If you want to use user component with app component, then

add the user component inside the template of app
So your app.template. html will contain
<app-user></app-user>

Add the user component inside app.module

@NgModule({
...
declarations: [ AppComponent, UserComponent ]
...
})

You can learn more about multiple components here

Body:
I created a new angular app using @angular/cli. in that app template already have app component. inside that app component I want to use another component called user. so inside @Component there is a property called templateUrl and also some says to use only the template. so which one should I use and which is the best. currently I'm trying to use templateUrl with this.

think this is my app.component.ts

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

and this is my user.component.ts

@Component({
  selector: 'app-user',
  templateUrl: './user.component.html',
  styleUrls: ['./user.component.css']
})

so how can I use my user component with app component. I tried by giving relative paths but it didn't work and gave absolute path didn't work that too. I'm confused. hope your help with this.


问:
run c program at startup
I am a beginner to linux programming. What I want to do is, run a C "Hello World" program at startup. Once the user logs in, run that C program. How can I achieve this?

I am running Ubuntu 8.04.

答: I solved it by writing a bash script</p>

Title: run c program at startup

Body: I solved it by writing a bash script


问:
Adding new python libraries to Edx Studio
I'm working with OpenEdx and i want add new libraries for make new funtionalities.

I have the normal DevStack Edx environment (work in Docker).

I want add google-api-python-client for my project, so i added this package to:

After rebuild the image and run the container i review this packages in respective containers:

Where are my libraries?
It only happen in Studio, in LMS all is well.

So:
- Which is the correct external python packages installation's way?

Thank you!

答:
I realised that the original image haven't all packages installed, and after to run the LMS commands in a copy of the original image the new image is different from the other image: in CMS copy we have a initial image without other change, because doesn't exist other change.

So, for install the new requirements we created a new file for it where we apply  the commands for install and migrate packages:

```<code>set -e
set -o pipefail
set -x

# Bring Studio online
docker-compose $DOCKER_COMPOSE_FILES up -d studio

docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PYTHON_UNINSTALL=1 paver install_prereqs'

#Installing prereqs crashes the process
docker-compose restart studio

# Run edxapp migrations first since they are needed for the service users and OAuth clients
docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PREREQ_INSTALL=1 paver update_db --settings devstack_docker'

docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && paver update_assets --settings devstack_docker'
</code>```

It's all.

Body:
I realised that the original image haven't all packages installed, and after to run the LMS commands in a copy of the original image the new image is different from the other image: in CMS copy we have a initial image without other change, because doesn't exist other change.

So, for install the new requirements we created a new file for it where we apply  the commands for install and migrate packages:

set -e
set -o pipefail
set -x

# Bring Studio online
docker-compose $DOCKER_COMPOSE_FILES up -d studio

docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PYTHON_UNINSTALL=1 paver install_prereqs'

#Installing prereqs crashes the process
docker-compose restart studio

# Run edxapp migrations first since they are needed for the service users and OAuth clients
docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PREREQ_INSTALL=1 paver update_db --settings devstack_docker'

docker-compose exec studio bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && paver update_assets --settings devstack_docker'

It's all.


问:
Converting array and objects in array to pure array
My array is like:

```<code>Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => demo1
        )
    [1] => stdClass Object
        (
            [id] => 2
            [name] => demo2
        )
    [2] => stdClass Object
        (
            [id] => 6
            [name] => otherdemo
        )
)
</code>```

How can I convert the whole array (including objects) to a pure multi-dimensional array?

答:
Just use this :</p>

```<code>json_decode(json_encode($yourArray), true);
</code>```

Body:
My array is like:

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => demo1
        )
    [1] => stdClass Object
        (
            [id] => 2
            [name] => demo2
        )
    [2] => stdClass Object
        (
            [id] => 6
            [name] => otherdemo
        )
)

How can I convert the whole array (including objects) to a pure multi-dimensional array?

Body:
Just use this :

json_decode(json_encode($yourArray), true);


问:
How to communicate from android application to Patient monitoring System (PMS) in the form of packets by using Socket connection?
We are having patient monitoring system which is Wi-Fi enabled. Here the requirement to establish a communication between android application and Patient Monitoring System (PMS) device using Socket connection and communication should be happen in the form of packets. Once initiate the request, it continuously sends the data over Socket, but I am unable to form the data in the form of packets.  Please can anyone help to how to send data in the form of data packets?

The request format is given below.

Header field denotes the type of the operation that is to be performed.

Data payload field contains two fields Length and Actual Data bytes.

The Data length field indicates the number of bytes of data that
  follow.

The Data Payload field is optional.

The header field is shown below :–

1st bit is direction of transfer. 0 – Read, 1 – Write.

The Command field (7 bits) specifies the command to be executed.

The Option1 field will give the information about the parameter
  that is under consideration.

The Option2 (lower 4 bits) and Option3 (upper 4 bits) fields
  are optional. For certain commands, they carry data with specific
  meaning. For certain other commands, they are just ignored.

Commands standards given below:-

Code snippet given below

activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2D3238"
android:padding="10dp">

    <Button
       android:id="@+id/connectBtn"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerInParent="true"
       android:layout_marginTop="10dp"
       android:onClick="onClick"
       android:text="Connect" />
</RelativeLayout>
</code>```

MainActivity.java

```<code>package com.test.pms.app;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.test.pms.app.R;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class MainActivity extends Activity implements View.OnClickListener {
    private Button connectBtn;
    private Socket socket = null;
    private boolean isRunning = false;
    private String ipAddress = "192.168.1.55";
    private int portNumber = 4561;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    connectBtn = (Button) findViewById(R.id.connectBtn);
}

@Override
protected void onResume() {
    super.onResume();
    isRunning = true;
}

@Override
protected void onPause() {
    isRunning = false;
    super.onPause();
}

@Override
public void onClick(View v) {
    int id = v.getId();
    switch (id) {
        case R.id.connectBtn:
            new CommunicateTask().execute();
            break;
    }
}

private class CommunicateTask extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... params) {
        sendData();
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
    }
}

private void sendData() {
    DataOutputStream dataOutputStream = null;
    DataInputStream dataInputStream = null;
    try {
        socket = new Socket(ipAddress, portNumber);
        dataOutputStream = new DataOutputStream(socket.getOutputStream());
        MainActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                connectBtn.setText(getString(R.string.connected));
            }
        });
      /*  byte[] byteArray = new byte[5];
        byteArray[0] = (byte) 1;   //direction 0-write and 1- read
        byteArray[1] = (byte) 3;   // Command Type 3 - CMD_TIMESTAMP
        byteArray[2] = (byte) 1;   //Option1- SPO2
        byteArray[3] = (byte) 0;   //Option2: Nothing
        byteArray[4] = (byte) 1;   //Option3 : RED*/
        String command = "CMD_TIMESTAMP";
        //   byte arr[] = {1, 0, 0, 0, 0, 1, 0, 0};
        dataOutputStream.writeUTF(command);
        dataInputStream = new DataInputStream(socket.getInputStream());
        //dataOutputStream.write(byteArray);
        //dataOutputStream.writeUTF(command);
        //   dataInputStream.write(arr);
        // dataOutputStream.writeUTF("Hello Server");
        while (isRunning) {
            if (socket.isConnected()) {
                String b = dataInputStream.readLine();
            }
        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (socket != null) {
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dataOutputStream != null) {
            try {
                dataOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dataInputStream != null) {
            try {
                dataInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (socket != null) {
        try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
  }
}
</code>```

Here Socket connection is established successfully , but when I try read data from inputStream unable to read. Execution stopped at  dataInputStream.readLine();.

I tried multiple methods to read data from InputStream like

```<code>dataInputStream.readLine();
dataInputStream.readByte();
dataInputStream.read();
</code>```

Please can anyone help me to form request format in the form of packets and read the data in packets?

Thanks in advance.

答:
This is an example on how to set each byte of the header.

To form the header, you can set each byte using hex numbers.

For example:

```<code>byte b = 0xA8;

A == 10 == 0011
8 == 8  == 1000

then b = A8 = 00111000;
</code>```

Example:

Dir: 1
Command: 1010101 (just invented a command)

First byte is 11010101

We separate in two sets of four bits: 1101 0101
Thse binaries reperesent 13 5 in decimal and D 5 in hex

The first byte value for this command is 0xD5

Body:
We are having patient monitoring system which is Wi-Fi enabled. Here the requirement to establish a communication between android application and Patient Monitoring System (PMS) device using Socket connection and communication should be happen in the form of packets. Once initiate the request, it continuously sends the data over Socket, but I am unable to form the data in the form of packets.  Please can anyone help to how to send data in the form of data packets?

The request format is given below.

Header field denotes the type of the operation that is to be performed.

Data payload field contains two fields Length and Actual Data bytes.

The Data length field indicates the number of bytes of data that
  follow.

The Data Payload field is optional.

The header field is shown below :–

1st bit is direction of transfer. 0 – Read, 1 – Write.

The Command field (7 bits) specifies the command to be executed.

The Option1 field will give the information about the parameter
  that is under consideration.

The Option2 (lower 4 bits) and Option3 (upper 4 bits) fields
  are optional. For certain commands, they carry data with specific
  meaning. For certain other commands, they are just ignored.

Commands standards given below:-

Code snippet given below

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2D3238"
android:padding="10dp">

    <Button
       android:id="@+id/connectBtn"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerInParent="true"
       android:layout_marginTop="10dp"
       android:onClick="onClick"
       android:text="Connect" />
</RelativeLayout>

MainActivity.java

package com.test.pms.app;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.test.pms.app.R;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class MainActivity extends Activity implements View.OnClickListener {
    private Button connectBtn;
    private Socket socket = null;
    private boolean isRunning = false;
    private String ipAddress = "192.168.1.55";
    private int portNumber = 4561;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    connectBtn = (Button) findViewById(R.id.connectBtn);
}

@Override
protected void onResume() {
    super.onResume();
    isRunning = true;
}

@Override
protected void onPause() {
    isRunning = false;
    super.onPause();
}

@Override
public void onClick(View v) {
    int id = v.getId();
    switch (id) {
        case R.id.connectBtn:
            new CommunicateTask().execute();
            break;
    }
}

private class CommunicateTask extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... params) {
        sendData();
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
    }
}

private void sendData() {
    DataOutputStream dataOutputStream = null;
    DataInputStream dataInputStream = null;
    try {
        socket = new Socket(ipAddress, portNumber);
        dataOutputStream = new DataOutputStream(socket.getOutputStream());
        MainActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                connectBtn.setText(getString(R.string.connected));
            }
        });
      /*  byte[] byteArray = new byte[5];
        byteArray[0] = (byte) 1;   //direction 0-write and 1- read
        byteArray[1] = (byte) 3;   // Command Type 3 - CMD_TIMESTAMP
        byteArray[2] = (byte) 1;   //Option1- SPO2
        byteArray[3] = (byte) 0;   //Option2: Nothing
        byteArray[4] = (byte) 1;   //Option3 : RED*/
        String command = "CMD_TIMESTAMP";
        //   byte arr[] = {1, 0, 0, 0, 0, 1, 0, 0};
        dataOutputStream.writeUTF(command);
        dataInputStream = new DataInputStream(socket.getInputStream());
        //dataOutputStream.write(byteArray);
        //dataOutputStream.writeUTF(command);
        //   dataInputStream.write(arr);
        // dataOutputStream.writeUTF("Hello Server");
        while (isRunning) {
            if (socket.isConnected()) {
                String b = dataInputStream.readLine();
            }
        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (socket != null) {
            try {
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dataOutputStream != null) {
            try {
                dataOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dataInputStream != null) {
            try {
                dataInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (socket != null) {
        try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
  }
}

Here Socket connection is established successfully , but when I try read data from inputStream unable to read. Execution stopped at  dataInputStream.readLine();.

I tried multiple methods to read data from InputStream like

dataInputStream.readLine();
dataInputStream.readByte();
dataInputStream.read();

Please can anyone help me to form request format in the form of packets and read the data in packets?

Thanks in advance.

Body:
This is an example on how to set each byte of the header.

To form the header, you can set each byte using hex numbers.

For example:

byte b = 0xA8;

A == 10 == 0011
8 == 8  == 1000

then b = A8 = 00111000;

Example:

Dir: 1
Command: 1010101 (just invented a command)

First byte is 11010101

We separate in two sets of four bits: 1101 0101
Thse binaries reperesent 13 5 in decimal and D 5 in hex

The first byte value for this command is 0xD5


问:
Can I link node@6 by force?
Is it ok to link node@6 by force?

```<code>$ which node
$ echo $?
1

$ brew link node
Error: No such keg: /usr/local/Cellar/node

$ brew search node
leafnode          llnode            node              node-build        node@0.10         node@0.12         node@4            node@5            node@6 ✔          nodebrew          nodeenv           nodenv
Caskroom/cask/mindnode-pro          Caskroom/cask/node-profiler         Caskroom/cask/nodebox               Caskroom/cask/nodeclipse            Caskroom/cask/printnode             Caskroom/cask/soundnode

$ brew link node@6
Warning: node@6 is keg-only and must be linked with --force
Note that doing so can interfere with building software.
</code>```

Edit:

I went ahead and did it:

```<code>$ brew link node@6 --force
Linking /usr/local/Cellar/node@6/6.9.5... 7 symlinks created
</code>```

node and npm work fine now.
Scary warning.

答:
I ran in to the same problem and followed the advice of brew info node@6 and added export PATH="/usr/local/opt/node@6/bin:$PATH to my .bash_profile. All the command line tools worked as expected.

(I've actually removed that line for my .bash_profile now and added an alias to set the path manually when I need it.)

Title: Can I link node@6 by force?

Body:
Is it ok to link node@6 by force?

$ which node
$ echo $?
1

$ brew link node
Error: No such keg: /usr/local/Cellar/node

$ brew search node
leafnode          llnode            node              node-build        node@0.10         node@0.12         node@4            node@5            node@6 ✔          nodebrew          nodeenv           nodenv
Caskroom/cask/mindnode-pro          Caskroom/cask/node-profiler         Caskroom/cask/nodebox               Caskroom/cask/nodeclipse            Caskroom/cask/printnode             Caskroom/cask/soundnode

$ brew link node@6
Warning: node@6 is keg-only and must be linked with --force
Note that doing so can interfere with building software.

Edit:

I went ahead and did it:

$ brew link node@6 --force
Linking /usr/local/Cellar/node@6/6.9.5... 7 symlinks created

node and npm work fine now.
Scary warning.


问:
FreeTDS UTF-8 insert in mysql
I have a linux server with mysql with symfony framework installed.
Now i'm trying to get data from sql server 2012 and all works great except when i try to insert value in mysql database.

```<code>SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\x80 IN P...' for column 'note_anagrafica' at row 1
</code>```

Seems that the problem is on data conversion.

The data type of column inside mysql where i'm trying to insert the data is:

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

And the collation is:

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

FreeTds configuration is set on UTF-8 and driver is odbc.

Someone have a solution for this problem?

EDIT:

odbc.ini

```<code>[server]
Driver = FreeTDS
Server = x.x.x.x
Port = 1234
Database = databasename
TDS_Version = 8
client charseg = UTF-8
server charset = CP1252
</code>```

freetds.conf

```<code>[server]
     host = x.x.x.x
     port = 1234
     tds version = 8.0
     client charset = UFT-8
     text size = 20971520
     use uft-16 = true
</code>```

doctrine config for mysql.

```<code>charset: utf8mb4
          default_table_options:
              charset: utf8mb4
              collate: utf8mb4_unicode_ci
</code>```

doctrine config for external mssql database:

```<code>server:
          driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
          host:     "%a_database_host%"
          port:     "%a_database_port%"
          dbname:   "%a_database_name%"
          user:     "%a_database_user%"
          password: "%a_database_password%"
          charset:  utf8mb4
</code>```

from now i'm getting error when i'm trying to insert data to mysql comes from sql server 2012 with doctrine.
Till now i have no problem on reading execpt that if i out the result on the web the special charaters like ø comes with � symbol.
There is a conversion that i have to made before call

```<code>$entityManager->persist($object);
$entityManager->flush();
</code>```

答: Set the charset to utf8mb4 for doctrine config and will do the trick.</p>

Title: FreeTDS UTF-8 insert in mysql

Body:
I have a linux server with mysql with symfony framework installed.
Now i'm trying to get data from sql server 2012 and all works great except when i try to insert value in mysql database.

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\x80 IN P...' for column 'note_anagrafica' at row 1

Seems that the problem is on data conversion.

The data type of column inside mysql where i'm trying to insert the data is:

text

And the collation is:

utf8_unicode_ci

FreeTds configuration is set on UTF-8 and driver is odbc.

Someone have a solution for this problem?

EDIT:

odbc.ini

[server]
Driver = FreeTDS
Server = x.x.x.x
Port = 1234
Database = databasename
TDS_Version = 8
client charseg = UTF-8
server charset = CP1252

freetds.conf

[server]
     host = x.x.x.x
     port = 1234
     tds version = 8.0
     client charset = UFT-8
     text size = 20971520
     use uft-16 = true

doctrine config for mysql.

charset: utf8mb4
          default_table_options:
              charset: utf8mb4
              collate: utf8mb4_unicode_ci

doctrine config for external mssql database:

server:
          driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
          host:     "%a_database_host%"
          port:     "%a_database_port%"
          dbname:   "%a_database_name%"
          user:     "%a_database_user%"
          password: "%a_database_password%"
          charset:  utf8mb4

from now i'm getting error when i'm trying to insert data to mysql comes from sql server 2012 with doctrine.
Till now i have no problem on reading execpt that if i out the result on the web the special charaters like ø comes with � symbol.
There is a conversion that i have to made before call

$entityManager->persist($object);
$entityManager->flush();


问:
Kafka - Topic & Partitions & Consumer
Just wanna understand the basics properly.

Let's say I've a topic called "myTopic" that has 3 partitions P0, P1 & P2.
Each of these partitions will have a leader and the data (messages) for this topic is distributed across these partitions.

1. Producer will always writes to the leader of the partition in a round robin fashion based on the load on the broker. Is that right?

2. How do the producer know the leader of the partition?

3. Consumer reading a particular topic should read all partitions of that topic? Is that correct?

Appreciate your help.

答:
Producer will always writes to the leader of the partition

Yes, always.

in a round robin fashion based on the load on the broker

No. If a partition is explicitly set on a ProducerRecord then that partition is used. Otherwise, if a custom partitioner implementation is provided, that determines the partition. Otherwise, if the msg key is not null, the hash of the key will be used to consistently send msgs with the same key to the same partition. If the msg key is null, only then the msg will indeed be sent to any partition in a round-robin fashion. However, this is irrespective of the load on the broker.

How do the producer know the leader of the partition?

By periodically asking the broker for metadata.

Consumer reading a particular topic should read all partitions of that topic? Is that correct?

Consumers form consumer groups. If there are multiple consumer instances in a consumer group, each consumes a subset of the partitions. But the consumer group as a whole consumes from all partitions. That is, unless you decide to go "low-level" and manage that yourself, which you can do.

Title: Kafka - Topic & Partitions & Consumer


问:
How to create a list from another list according to a function?
I would like to create a list which has values which correspond to another list.
For example if I had:

```<code>listA = [1, 2, 3, 4, 5,...]
</code>```

and I would like to create another list which is the same, except all the values were varied according to x^2 (or any other function), giving:

```<code>listB = [1, 4, 9, 16,25, ...]
</code>```

I have already tried to do this by doing a while loop:

```<code>listA = [1, 2, 3, 4]
listB = range(1, 4, 1)
i = 0
while i <= 4:
    listB [i] = (listA [i]) ** 2
    i = i + 1
print listA
print listB
</code>```

But it just spits out an error message:

```<code>Traceback (most recent call last):
  File "/home/tim/Desktop/Python/test.py", line 5, in <module>
    listB [i] = (listA [i]) ** 2
IndexError: list assignment index out of range
</code>```

Any advice?
Thanks

答:
There are multiple ways of doing what you are asking, others have pointed out list comprehensions and maps.

Reviewing your code:

```<code>listB = range(1, 4, 1)
</code>```

The is only 3 items, [1, 2, 3], range() is up to but not including the stop arg. You don't need to initialise your listB because you can just listB.append() in the loop, so listB = [] is sufficient. Note in python3 this assigns a range() object to listB and it doesn't initialise the list as you intended.

```<code>i = 0
while i <= 4:
</code>```

This loops 5 times, i = 0, 1, 2, 3, 4, and because this is more than listB (and listA) it results in the IndexError you are seeing. The normal way to do fixed loops would be with a for loop, e.g. for i in range(4):. However, you can loop directly over the elements in listA with for i in listA: and this would be considerd more pythonic

```<code>    listB [i] = (listA [i]) ** 2
</code>```

This doesn't work because your loop goes to from 0 to 4 (inclusive) and range(1, 4, 1) is only 3 items [1, 2, 3].

```<code>    i = i + 1
</code>```

Unnecessary with a for loop.

Putting it all together and doing it iteratively as you've described you would do:

```<code>listA = [1, 2, 3, 4]
listB = []
for i in listA:
    listB.append(i**2)

print(listA)  # [1, 2, 3, 4]
print(listB)  # [1, 4, 9, 16]
</code>```

Note: My preference would be for the list comprehension:

```<code>listB = [i**2 for i in listA]
</code>```

Body:
I would like to create a list which has values which correspond to another list.
For example if I had:

listA = [1, 2, 3, 4, 5,...]

and I would like to create another list which is the same, except all the values were varied according to x^2 (or any other function), giving:

listB = [1, 4, 9, 16,25, ...]

I have already tried to do this by doing a while loop:

listA = [1, 2, 3, 4]
listB = range(1, 4, 1)
i = 0
while i <= 4:
    listB [i] = (listA [i]) ** 2
    i = i + 1
print listA
print listB

But it just spits out an error message:

Traceback (most recent call last):
  File "/home/tim/Desktop/Python/test.py", line 5, in <module>
    listB [i] = (listA [i]) ** 2
IndexError: list assignment index out of range

Any advice?
Thanks

Body:
There are multiple ways of doing what you are asking, others have pointed out list comprehensions and maps.

Reviewing your code:

listB = range(1, 4, 1)

The is only 3 items, [1, 2, 3], range() is up to but not including the stop arg. You don't need to initialise your listB because you can just listB.append() in the loop, so listB = [] is sufficient. Note in python3 this assigns a range() object to listB and it doesn't initialise the list as you intended.

i = 0
while i <= 4:

This loops 5 times, i = 0, 1, 2, 3, 4, and because this is more than listB (and listA) it results in the IndexError you are seeing. The normal way to do fixed loops would be with a for loop, e.g. for i in range(4):. However, you can loop directly over the elements in listA with for i in listA: and this would be considerd more pythonic

    listB [i] = (listA [i]) ** 2

This doesn't work because your loop goes to from 0 to 4 (inclusive) and range(1, 4, 1) is only 3 items [1, 2, 3].

    i = i + 1

Unnecessary with a for loop.

Putting it all together and doing it iteratively as you've described you would do:

listA = [1, 2, 3, 4]
listB = []
for i in listA:
    listB.append(i**2)

print(listA)  # [1, 2, 3, 4]
print(listB)  # [1, 4, 9, 16]

Note: My preference would be for the list comprehension:

listB = [i**2 for i in listA]


问:
The executable was signed with invalid entitlements
I am having a problem with ad-hoc distribution on my iPhone. I have developed an application with SDK 3.0. I have a developer's license. I have added certificates and provisioning profiles in my project. So, no problem with that.

But, when I try to install the app on my iPhone, it compiles the project and then displays the error: "The executable was signed with invalid entitlements" in the Organizer window. Am I missing something? I have upgraded my iPhone from 2.2.1 and have downloaded latest SDK from Apple.

Please help me with this issue.

答:
I have just had an exciting three hours battling with this.  I have just upgraded a project to 4.2 and for some reason it just wouldn't work.

I eventually removed the Entitlements.plist file and then created a new one.

File > New File > Code Signing > Entitlement

Name the file Entitlements.plist

Make sure it's in the Resources group in xCode.

It didn't put in the get-task-allow BOOL type in the Entitlements.plist file.  I added it, checked it, saved it, unchecked it, saved it.  This made me feel better.

I then removed the Adhoc and Release profiles I had created.  Re-downloaded them from the  Provisioning Portal and droped them back into the xCode organizer.

I then went into Build Settings and made sure the correct profiles were assigned to the Debug and Release profiles.

I then changed the to Release / Device.  Hit the build button and it worked.

I have no idea why.

OwnerDisplayName: pJosh


问:
rpy2: how to suppress R output
In a Python shell, and using rpy2 when I issue the following command

```<code>In [93]: x = robjects.r.bfast(data, h=0.1, season="none", max_iter=1)
[1]
 "No seasonal model will be fitted!"
</code>```

I get this non-desirable output

```<code>[1]
 "No seasonal model will be fitted!"
</code>```

Is there any way to suppress this output ? I would like to wrap this call to a function and then to an api call. Thus, redirecting output to stdout is non-desirable.

In other words, how to do in rpy2:

```<code>sink("/dev/null")
</code>```

Is there a better way than

```<code>robjects.r('sink("/dev/null")')
</code>```

?

答:
Apparently, the bfast method conditionally prints that message to console with no wrapper to not print which is not advisable code. Reach out to developers on a pull request.

Per this solution, consider R's capture.output which returns character string of output.

```<code>...
from rpy2.robjects.packages import importr

utils = importr('utils')
bfast = importr('bfast')

# NOTICE R's PERIODS CHANGED TO UNDERSCORE TO FIT PYTHON'S OBJECT MODEL
x = utils.capture_output(bfast(data, h=0.1, season="none", max_iter=1))
</code>```

Title: rpy2: how to suppress R output

Body:
In a Python shell, and using rpy2 when I issue the following command

In [93]: x = robjects.r.bfast(data, h=0.1, season="none", max_iter=1)
[1]
 "No seasonal model will be fitted!"

I get this non-desirable output

[1]
 "No seasonal model will be fitted!"

Is there any way to suppress this output ? I would like to wrap this call to a function and then to an api call. Thus, redirecting output to stdout is non-desirable.

In other words, how to do in rpy2:

sink("/dev/null")

Is there a better way than

robjects.r('sink("/dev/null")')

?

Body:
Apparently, the bfast method conditionally prints that message to console with no wrapper to not print which is not advisable code. Reach out to developers on a pull request.

Per this solution, consider R's capture.output which returns character string of output.

...
from rpy2.robjects.packages import importr

utils = importr('utils')
bfast = importr('bfast')

# NOTICE R's PERIODS CHANGED TO UNDERSCORE TO FIT PYTHON'S OBJECT MODEL
x = utils.capture_output(bfast(data, h=0.1, season="none", max_iter=1))


问:
How to use navigate back in for each loop?
I want to click on an element inside a list and go to different page. In this page I m taking a string. Then I go back and do the same for others. But after one iteration my code can't find the second element and shuts down the browser. Am I using the navigator wrong?

Here is my code:

```<code>public MainPage ControlSorting() {

    List <WebElement> listItems=driver.findElement(RESULTCONT).findElements(MEDIA);
    String[] strImdb = new String[listItems.size()];

    int l = 0;
    for (WebElement ele1 : listItems) {

            ele1.click();
            WebElement element   = getElementBy(ABOUTIMDB);
            String a=  element.getAttribute("ng-genre-action");
            String[] parts = a.split(",");
            strImdb[l]=parts[1];
            l++;

        driver.navigate().back();
    }

    return this;
}
</code>```

答:
After going back you have to re identify the object. Please add the following code inside for loop at the first line of your code.

```<code>listItems=driver.findElement(RESULTCONT).findElements(MEDIA);
</code>```

This should work. Please try and let me know.

Body:
I want to click on an element inside a list and go to different page. In this page I m taking a string. Then I go back and do the same for others. But after one iteration my code can't find the second element and shuts down the browser. Am I using the navigator wrong?

Here is my code:

public MainPage ControlSorting() {

    List <WebElement> listItems=driver.findElement(RESULTCONT).findElements(MEDIA);
    String[] strImdb = new String[listItems.size()];

    int l = 0;
    for (WebElement ele1 : listItems) {

            ele1.click();
            WebElement element   = getElementBy(ABOUTIMDB);
            String a=  element.getAttribute("ng-genre-action");
            String[] parts = a.split(",");
            strImdb[l]=parts[1];
            l++;

        driver.navigate().back();
    }

    return this;
}

Body:
After going back you have to re identify the object. Please add the following code inside for loop at the first line of your code.

listItems=driver.findElement(RESULTCONT).findElements(MEDIA);

This should work. Please try and let me know.


问:
How to print/echo visitor browser language through javascript
From the following JavaScript:

```<code><script>
var language = navigator.language || navigator.userLanguage;
</script>
</code>```

...is then possible to echo text related visitor's browser language?

For example: You are watching MyMovieTitle [<?php echo navigator.language ?>]

The javascript should provide me the full language word.
Example: 'English'; 'German'; 'French' and so on...

答:
You could just print the javascript variable

```<code>navigator.language || navigator.userLanguage;
</code>```

But, since, you want,the PHP version use this variable.

```<code>$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
$language = locale_get_display_language($locale);
echo $language; // Non-Ugly version :) . Got anglais for en-US
</code>```

Please check above and see.

Body:
From the following JavaScript:

...is then possible to echo text related visitor's browser language?

For example: You are watching MyMovieTitle [<?php echo navigator.language ?>]

The javascript should provide me the full language word.
Example: 'English'; 'German'; 'French' and so on...

Body:
You could just print the javascript variable

navigator.language || navigator.userLanguage;

But, since, you want,the PHP version use this variable.

$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
$language = locale_get_display_language($locale);
echo $language; // Non-Ugly version :) . Got anglais for en-US

Please check above and see.