问:
Choose an item in navigation bar and then it leads to showing a text in the page
I am a beginner. I am trying to learn JavaScript, HTML and CSS simultaneously. I have written a test code which has a navigation bar and I would like that a paragraph of text will pop out in the page when I click on any of the items in the menu bar. I have written the following code but it doesn't work.
index.html

```<code><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="index.css">
  <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--creating a navigation bar-->
<nav id="MyNavBar" class="navbar navbar-default">
    <div class="container-fluid">
 <ul id="details" class="nav navbar-nav">

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        Links
        <b class="caret"></b>
    </a>
    <ul id="subdetails" class="dropdown-menu">
        <li><a href="Something">Something</a></li>
        <li><a href="Others">Another thing</a></li>
    </ul>
</li>
</ul>
</div>
</nav>
<div class="background-image"></div>
<section id="content">

</section>
<script type="text/javascript" charset="utf-8">
            $(document).ready(function(){

                $('#MyNavBar ul li a').click(function(){
                    $('#content').load('details.html #' + $(this).attr('href'));
                    return false;
                });

            });
</script>
</body>
</html>
</code>```

index.css

```<code>body {
  font-family: "Serif";
}

.background-image {
  background: url("https://pbs.twimg.com/media/CXAOHDfWMAU2Zmi.jpg");
  background-size: cover;
  position: fixed;
  background-repeat: no-repeat;
  -webkit-filter:blur(3px) grayscale(50%);
  -ms-filter:blur(3px) grayscale(50%);
  filter:blur(3px) grayscale(50%);
  width:100%;
  height:100%;
}
.dropdown {
    position: relative;
    display: inline-block;
    font-family: Lobster;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px 16px;
    z-index: 1;
}
.dropdown:hover .dropdown-menu {
    display: block;
    margin-top: 0;
 }
#MyNavBar {
   background-color:goldenrod;
}
#details {
   background-color:goldenrod;
}
#subdetails {
    background-color: gold;
}
</code>```

details.html

```<code><!DOCTYPE html>
<html>
<body>
<div id="Others">
    <h2>This is Another thing</h2>
    <p>This is a paragraph of textual information about <b>Another thing</b> that will blow your mind.</p>
</div>
<div id="Something">
    <h2>This is Something</h2>
    <p>This is a paragraph of textual information about <b>Something</b> that will blow your mind.</p>
</div>
</body>
</html>
</code>```

How can I make my code to show a text based on selection of an item in the menu?

答:
The problem is that #content is currently behind .background-image since .background-image is position: fixed - setting a non-static position creates a new stacking context with that element and gives it a default z-index so it will appear on top of non-positioned elements.

To move .background-image behind the rest of the content, add z-index: -1

Body:
I am a beginner. I am trying to learn JavaScript, HTML and CSS simultaneously. I have written a test code which has a navigation bar and I would like that a paragraph of text will pop out in the page when I click on any of the items in the menu bar. I have written the following code but it doesn't work.
index.html

<!DOCTYPE html>

  <meta charset="utf-8">
  <link rel="stylesheet" href="index.css">

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

        Links

Something

Another thing

index.css

body {
  font-family: "Serif";
}

.background-image {
  background: url("https://pbs.twimg.com/media/CXAOHDfWMAU2Zmi.jpg");
  background-size: cover;
  position: fixed;
  background-repeat: no-repeat;
  -webkit-filter:blur(3px) grayscale(50%);
  -ms-filter:blur(3px) grayscale(50%);
  filter:blur(3px) grayscale(50%);
  width:100%;
  height:100%;
}
.dropdown {
    position: relative;
    display: inline-block;
    font-family: Lobster;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px 16px;
    z-index: 1;
}
.dropdown:hover .dropdown-menu {
    display: block;
    margin-top: 0;
 }
#MyNavBar {
   background-color:goldenrod;
}
#details {
   background-color:goldenrod;
}
#subdetails {
    background-color: gold;
}

details.html

<!DOCTYPE html>

This is Another thing

This is a paragraph of textual information about Another thing that will blow your mind.

This is Something

This is a paragraph of textual information about Something that will blow your mind.

How can I make my code to show a text based on selection of an item in the menu?


来源: stackexchange

问:
class attributes are not changing after reaching specific width in jquery
```<code>$(window).on('resize', function (event) {
if ($('body').width() <= 480) {

            $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
            $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");

        }
}
</code>```

<p>My code is it should remove the attributes and assign the give value once it reaches width < 480. But this is not happening when i inspect the element and set the screen size as iphone 5s( width:320px). May i know the reason why its not changing? I even changed the body.width() to window.width() but its not working. </p>

答:
Since you attached your code to a resize event you need a resize event to occur for the code to run. This will not happen when the page loads. You can either remove the resize event handler and you code will run when the page loads and see if the body width matches the breakpoint requirement. Or you can use a named function (function declaration) and pass that to the event handler. Then call the named function to run the code initially and then wait for resize events.

If you only want to call this code one time and you're not worried about the viewport size changing above and below 480px after initial page load, then you can just get rid of the resize handler and run your code.

If you want to observe the viewport width after page load and want to react to it anytime it changes above or below 480px then you'll need to do something like I have below.

var $body   = $( 'body' ),
    $rows   = $( '#skills .row [class*=col-]' ),
    $circle = $( 'circle' ),
    atOrUnderBreakpoint = false;

function onResize( e ) {

  var $width = $body.width();

  if ( $width <= 480 && !atOrUnderBreakpoint ) {

    $circle.attr( {
      cx: 115,
      cy: 80,
      r: 80,
      transform: 'rotate( -84 100 99 )'
    } );
    $rows.toggleClass( 'col-xs-6 col-xs-12' ); // Maybe use addClass() or removeClass() here?

    atOrUnderBreakpoint = true;
    console.log( 1 );

  }

  if ( $width > 480 && atOrUnderBreakpoint ) {

    // Example.
    $circle.attr( {
      cx: 50,
      cy: 50,
      r: 20,
      transform: ''
    } );

    atOrUnderBreakpoint = false;
    console.log( 2 );
  }

}

$( window ).on( 'resize', onResize );
onResize(); // Special case, don't wait for resize event this ONE time, apply right away.```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>

<svg viewBox="0 0 100 100" width="100" height="100">
  <circle cx="50" cy="50" r="20" fill="transparent" stroke="hotpink" stroke-width="2" />
</svg></code>```

Above code in JSFiddle: https://jsfiddle.net/rvmvn1t4/ (slide divider side-to-side to change viewport size).

One issue I see with your code and using the resize event is the use of toggeClass(). resize gets called a lot, and the col-xs- class will constantly be added/removed from the elements. This will cause those elements to resize/flicker. Here's an example using background-color, notice it flashes between the two colors. Something similar will likely happen to your element size.

I would consider switching to addClass() or removeClass(), whichever you would need, along with setting something that will prevent your code from running more than one time after it has been applied at the breakpoint (you know, prevent flicker etc.). I used a flag in my example.

ContentLicense: CC BY-SA 3.0

Body:
$(window).on('resize', function (event) {
if ($('body').width() <= 480) {

            $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
            $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");

        }
}

My code is it should remove the attributes and assign the give value once it reaches width < 480. But this is not happening when i inspect the element and set the screen size as iphone 5s( width:320px). May i know the reason why its not changing? I even changed the body.width() to window.width() but its not working.

Body:
Since you attached your code to a resize event you need a resize event to occur for the code to run. This will not happen when the page loads. You can either remove the resize event handler and you code will run when the page loads and see if the body width matches the breakpoint requirement. Or you can use a named function (function declaration) and pass that to the event handler. Then call the named function to run the code initially and then wait for resize events.

If you only want to call this code one time and you're not worried about the viewport size changing above and below 480px after initial page load, then you can just get rid of the resize handler and run your code.

If you want to observe the viewport width after page load and want to react to it anytime it changes above or below 480px then you'll need to do something like I have below.

var $body   = $( 'body' ),
    $rows   = $( '#skills .row [class*=col-]' ),
    $circle = $( 'circle' ),
    atOrUnderBreakpoint = false;

function onResize( e ) {

  var $width = $body.width();

  if ( $width <= 480 && !atOrUnderBreakpoint ) {

    $circle.attr( {
      cx: 115,
      cy: 80,
      r: 80,
      transform: 'rotate( -84 100 99 )'
    } );
    $rows.toggleClass( 'col-xs-6 col-xs-12' ); // Maybe use addClass() or removeClass() here?

    atOrUnderBreakpoint = true;
    console.log( 1 );

  }

  if ( $width > 480 && atOrUnderBreakpoint ) {

    // Example.
    $circle.attr( {
      cx: 50,
      cy: 50,
      r: 20,
      transform: ''
    } );

    atOrUnderBreakpoint = false;
    console.log( 2 );
  }

}

$( window ).on( 'resize', onResize );
onResize(); // Special case, don't wait for resize event this ONE time, apply right away.

<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>

<svg viewBox="0 0 100 100" width="100" height="100">
  <circle cx="50" cy="50" r="20" fill="transparent" stroke="hotpink" stroke-width="2" />
</svg>

Above code in JSFiddle: https://jsfiddle.net/rvmvn1t4/ (slide divider side-to-side to change viewport size).

One issue I see with your code and using the resize event is the use of toggeClass(). resize gets called a lot, and the col-xs- class will constantly be added/removed from the elements. This will cause those elements to resize/flicker. Here's an example using background-color, notice it flashes between the two colors. Something similar will likely happen to your element size.

I would consider switching to addClass() or removeClass(), whichever you would need, along with setting something that will prevent your code from running more than one time after it has been applied at the breakpoint (you know, prevent flicker etc.). I used a flag in my example.


问:
bootstrap sidebar no bg color
Hey i have tried a lot to give the background color of my sidebar from my bootstrap a color but it doesnt work.

here is my code from the page

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <title>ToolsForEver</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1""> <!-- een viewport is de userscreen  dus we gebruiken 100% normale zoom -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="../style.css">
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container-fluid">
    <!-- Dit is voor de logo en dat de je een kleine soort dropdown ziet waarmee je op kleinere toestellen ook beter kan besturen -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="../afbeeldingen/tools.png">ToolsForEver</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">contact <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>    <a href="uitloggen.php" class="btn btn-info" role="button">Uitloggen</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->

</nav>
            <!-- Sidebar -->
        <div id="sidebar">
            <ul class="sidebar-nav">
                <li>
                    <a href="#">Beheer Voorraad</a>
                </li>
                <li>
                    <a href="#">Beheer Medewerkers</a>
                </li>
                <li>
                    <a href="#">Beheer Locaties</a>
                </li>
                <li>
                    <a href="#">Beheer Voorraad</a>
                </li>
                <li>
                    <a href="#">Beheer Voorraad</a>
                </li>
            </ul>
        </div>

<div class = "container">
    <div class = "jumbotron">
        <img src="../afbeeldingen/toolsforever.jpg" alt="ToolsForever" class="img-responsive">
    </div>
</body>
</html>

<?php session_start();
//als session leeg is dan doe je dit
if(empty($_SESSION['email']))
{
    header("location:../index.php");
}

    include 'footer.php';
?>
</code>```

Here is my code of my css file

```<code>body {
    padding-top: 65px;
    padding-left: 135px;
}

.container{
    padding-top: 65px;
    padding-left: 135px;
}

#sidebar{
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    color: blue;
}

.sidebar-nav {
    position: absolute;
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: black;
}
</code>```

Can you guys please help me ;)

thank you!

答:
Have a look at the below snippet i think you want something like this !

body{
  margin:0px;
}
.left-side{
   position:fixed;
   top:0px;
   left:0px;
   width: 20%;
   height: 100vh;
   overflow:auto;
   background-color:red;
}

.right-side{
   position:relative;
   width: 80%;
   margin:0px;
   margin-left:20%;
   min-height: 100vh;
   background-color:blue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="left-side">
  <ul>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li><li>item 1</li>
  <li>item 1</li>
  </ul>
</div>

<div class="right-side">
  Content container
</div></code>```

Title: bootstrap sidebar no bg color

Body:
Hey i have tried a lot to give the background color of my sidebar from my bootstrap a color but it doesnt work.

here is my code from the page

<!DOCTYPE html>

    <title>ToolsForEver</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <link rel="stylesheet" type="text/css" href="../style.css">

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        Toggle navigation

      </button>
      ToolsForEver

contact (current)

Link

    Uitloggen

                    Beheer Voorraad

                    Beheer Medewerkers

                    Beheer Locaties

                    Beheer Voorraad

                    Beheer Voorraad

<?php session_start();
//als session leeg is dan doe je dit
if(empty($_SESSION['email']))
{
    header("location:../index.php");
}

    include 'footer.php';
?>

Here is my code of my css file

body {
    padding-top: 65px;
    padding-left: 135px;
}

.container{
    padding-top: 65px;
    padding-left: 135px;
}

#sidebar{
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    color: blue;
}

.sidebar-nav {
    position: absolute;
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: black;
}

Can you guys please help me ;)

thank you!

Body:
Have a look at the below snippet i think you want something like this !

body{
  margin:0px;
}
.left-side{
   position:fixed;
   top:0px;
   left:0px;
   width: 20%;
   height: 100vh;
   overflow:auto;
   background-color:red;
}

.right-side{
   position:relative;
   width: 80%;
   margin:0px;
   margin-left:20%;
   min-height: 100vh;
   background-color:blue;
}

<div class="left-side">
  <ul>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li>
  <li>item 1</li><li>item 1</li>
  <li>item 1</li>
  </ul>
</div>

<div class="right-side">
  Content container
</div>


问:
inferSchema in spark csv package
i am trying to read a csv file as a spark df by enabling inferSchema, but then am unable to get the fv_df.columns. below is the error message

```<code>>>> fv_df = spark.read.option("header", "true").option("delimiter", "\t").csv('/home/h212957/FacilityView/datapoints_FV.csv', inferSchema=True)
>>> fv_df.columns
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/h212957/spark/python/pyspark/sql/dataframe.py", line 687, in columns
    return [f.name for f in self.schema.fields]
  File "/home/h212957/spark/python/pyspark/sql/dataframe.py", line 227, in schema
    self._schema = _parse_datatype_json_string(self._jdf.schema().json())
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 894, in _parse_datatype_json_string
    return _parse_datatype_json_value(json.loads(json_string))
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 911, in _parse_datatype_json_value
    return _all_complex_types[tpe].fromJson(json_value)
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 562, in fromJson
    return StructType([StructField.fromJson(f) for f in json["fields"]])
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 428, in fromJson
    _parse_datatype_json_value(json["type"]),
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 907, in _parse_datatype_json_value
    raise ValueError("Could not parse datatype: %s" % json_value)
ValueError: Could not parse datatype: decimal(7,-31)
</code>```

However If i don't infer the Schema than I am able to fetch the columns and do further operations. I am unable to get as why this is working in this way. Can anyone please explain me.

答:
I suggest you use the function '.load' rather than '.csv', something like this:

```<code>data = sc.read.load(path_to_file,
                    format='com.databricks.spark.csv',
                    header='true',
                    inferSchema='true').cache()
</code>```

Of you course you can add more options. Then you can simply get you want:

```<code>data.columns
</code>```

Another way of doing this (to get the columns) is to use it this way:

```<code>data = sc.textFile(path_to_file)
</code>```

And to get the headers (columns) just use

```<code>data.first()
</code>```

Looks like you are trying to get your schema from your csv file without opening it! The above should help you to get them and hence manipulate whatever you like.

Note: to use '.columns' your 'sc' should be configured as:

```<code>spark = SparkSession.builder \
            .master("yarn") \
            .appName("experiment-airbnb") \
            .enableHiveSupport() \
            .getOrCreate()
sc = SQLContext(spark)
</code>```

Good luck!

Title: inferSchema in spark csv package

Body:
i am trying to read a csv file as a spark df by enabling inferSchema, but then am unable to get the fv_df.columns. below is the error message

>>> fv_df = spark.read.option("header", "true").option("delimiter", "\t").csv('/home/h212957/FacilityView/datapoints_FV.csv', inferSchema=True)
>>> fv_df.columns
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/h212957/spark/python/pyspark/sql/dataframe.py", line 687, in columns
    return [f.name for f in self.schema.fields]
  File "/home/h212957/spark/python/pyspark/sql/dataframe.py", line 227, in schema
    self._schema = _parse_datatype_json_string(self._jdf.schema().json())
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 894, in _parse_datatype_json_string
    return _parse_datatype_json_value(json.loads(json_string))
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 911, in _parse_datatype_json_value
    return _all_complex_types[tpe].fromJson(json_value)
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 562, in fromJson
    return StructType([StructField.fromJson(f) for f in json["fields"]])
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 428, in fromJson
    _parse_datatype_json_value(json["type"]),
  File "/home/h212957/spark/python/pyspark/sql/types.py", line 907, in _parse_datatype_json_value
    raise ValueError("Could not parse datatype: %s" % json_value)
ValueError: Could not parse datatype: decimal(7,-31)

However If i don't infer the Schema than I am able to fetch the columns and do further operations. I am unable to get as why this is working in this way. Can anyone please explain me.

Body:
I suggest you use the function '.load' rather than '.csv', something like this:

data = sc.read.load(path_to_file,
                    format='com.databricks.spark.csv',
                    header='true',
                    inferSchema='true').cache()

Of you course you can add more options. Then you can simply get you want:

data.columns

Another way of doing this (to get the columns) is to use it this way:

data = sc.textFile(path_to_file)

And to get the headers (columns) just use

data.first()

Looks like you are trying to get your schema from your csv file without opening it! The above should help you to get them and hence manipulate whatever you like.

Note: to use '.columns' your 'sc' should be configured as:

spark = SparkSession.builder \
            .master("yarn") \
            .appName("experiment-airbnb") \
            .enableHiveSupport() \
            .getOrCreate()
sc = SQLContext(spark)

Good luck!


问:
An error has occurred. 500 JHtmlBehavior::polyfill not found
I imported old joomla site via ftp and when I access the administrator page I get this error
"An error has occurred. 500 JHtmlBehavior::polyfill not found"
 and can't do anything but when I open website it's working..</p>

答: We had the same issue with a client today - and it turned out that it was caused by the usage of IE 8 and PHP 7 which resulted in a Joomla bug. We have written a post about it here and we have just answered a similar question on the Joomla StackExchange site. Essentially, all you need to do is to use a different browser (Chrome or FireFox).</p>


问:
NuGet Package restore failed for project myProjectWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'
It's a provider hosted project. It used to work until very recently.

If I create a completely new project/solution, then it works.

If I start the old one, or redownload it from source control, I get the following error:

NuGet Package restore failed for project LocalTheaterWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'

I tried Update-Package -Reinstall but the problem stays.

Any ideas?

答:
For older "locked down" projects with specific package version numbers that you can't update, un-check "Automatically check for missing packages during build in Visual Studio" which is found via:

Nuget Package Manager > Package Manager Settings

This means that if you toggle between newer projects and older projects you need to check and un-check this setting


问:
What fonts do iPhone applications support?
I found a list of iPhone supported font here

http://daringfireball.net/misc/2007/07/iphone-osx-fonts

But I just wanted to confirm that, can we use all this fonts in application, or we are restricted to some class of fonts.

答: I created iFonts so I could email the list to a designer. It's compatible all the way down to 3.0, so you can see what fonts are available on different versions of iOS, and you don't have to worry about whether a web page is accurate or complete. It's been tested all the way up to iOS 7.</p>

OwnerDisplayName: Amit Vaghela


问:
Symfony 3 - Stof Doctrine Extension Uploadable : Edit file
I use stof doctrine uploadable on entity.

The "add" and "remove/delete" actions in my controller run perfectly.

I actualy have a problème to make an edit form for that entity.

Here's my code:

```<code><?php

namespace Kreatike\TutorielBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * Tutoriel
 *
 * @ORM\Table(name="tutoriel")
 * @ORM\Entity(repositoryClass="Kreatike\TutorielBundle\Repository\TutorielRepository")
 * @Gedmo\Uploadable(allowOverwrite=false, appendNumber=true, filenameGenerator="SHA1", path="uploads/KreatikeTutorielBundle/Tutoriel/covers")
 */
class Tutoriel
{

(...)

    /**
     * @ORM\Column(name="cover", type="string")
     * @Gedmo\UploadableFilePath
     */
    private $cover;

(...)

    /**
     * Set cover
     *
     * @param string $cover
     *
     * @return Tutoriel
     */
    public function setCover($cover)
    {
        $this->cover = $cover;

        return $this;
    }

    /**
     * Get cover
     *
     * @return string
     */
    public function getCover()
    {
        return $this->cover;
    }
</code>```

Form:

```<code><?php

namespace Kreatike\TutorielBundle\Form;

use Symfony\Component\Form\AbstractType;

use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
//use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
//use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FileType;

use Symfony\Bridge\Doctrine\Form\Type\EntityType;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TutorielType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('titre',              TextType::class)

            ->add('cover',               FileType::class)
           (...)

            ->add('Valider', SubmitType::class)
            //->add('date') (la date est ajoutée via la fonction __construct de l'entité)
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Kreatike\TutorielBundle\Entity\Tutoriel'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'kreatike_tutorielbundle_tutoriel';
    }

}
</code>```

EditAction:

```<code>public function editAction($slug, Request $request)
{
    $em = $this->getDoctrine()->getManager();
    $tutoriel = $em->getRepository('KreatikeTutorielBundle:Tutoriel')->findOneBy(array('slug' => $slug));

    if($tutoriel===null)
    {
        throw new NotFoundHttpException('Le Tutoriel n\'hexiste pas');
    }

    $form = $this->get('form.factory')->create(TutorielEditType::class, $tutoriel);

    if($request->isMethod('POST') && $form->handleRequest($request)->isValid())
    {

        $uploadableManager = $this->get('stof_doctrine_extensions.uploadable.manager');

        $em->persist($tutoriel);
        $uploadableManager->markEntityToUpload($tutoriel, $tutoriel->getCover());

        $em->flush();

        $request->getSession()->getFlashBag()->add('notice', 'Le tutoriel a bien été modifié.');

        return $this->redirectToRoute('kreatike_tutoriel_view', array(
            'slug'=>$tutoriel->getSlug(),
            ));
    }

    return $this->render('KreatikeTutorielBundle:Tutoriel:edit.html.twig', array(
        'tutoriel'=>$tutoriel,
        'form'=>$form->createView(),
        ));
}
</code>```

The error:

The form's view data is expected to be an instance of class
  Kreatike\TutorielBundle\Entity\Tutoriel, but is a(n) string. You can
  avoid this error by setting the "data_class" option to null or by
  adding a view transformer that transforms a(n) string to an instance
  of Kreatike\TutorielBundle\Entity\Tutoriel.

Indeed my cover field containt the string of the file's path, not a file... and my form get a fileType.

So I think that I need to recover my file from my path in order to hydrate the form's field...

But I have absolutely no idea how to do that...

I try to avoid data_class => null...

Any clue?

Thanks!

答:
Did you set the right enctype on the form tag on the view?

```<code>enctype="multipart/form-data"
</code>```

Usually this type of errors are related to the enctype attribute.

Body:
I use stof doctrine uploadable on entity.

The "add" and "remove/delete" actions in my controller run perfectly.

I actualy have a problème to make an edit form for that entity.

Here's my code:

<?php

namespace Kreatike\TutorielBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * Tutoriel
 *
 * @ORM\Table(name="tutoriel")
 * @ORM\Entity(repositoryClass="Kreatike\TutorielBundle\Repository\TutorielRepository")
 * @Gedmo\Uploadable(allowOverwrite=false, appendNumber=true, filenameGenerator="SHA1", path="uploads/KreatikeTutorielBundle/Tutoriel/covers")
 */
class Tutoriel
{

(...)

    /**
     * @ORM\Column(name="cover", type="string")
     * @Gedmo\UploadableFilePath
     */
    private $cover;

(...)

    /**
     * Set cover
     *
     * @param string $cover
     *
     * @return Tutoriel
     */
    public function setCover($cover)
    {
        $this->cover = $cover;

        return $this;
    }

    /**
     * Get cover
     *
     * @return string
     */
    public function getCover()
    {
        return $this->cover;
    }

Form:

<?php

namespace Kreatike\TutorielBundle\Form;

use Symfony\Component\Form\AbstractType;

use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
//use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
//use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FileType;

use Symfony\Bridge\Doctrine\Form\Type\EntityType;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TutorielType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('titre',              TextType::class)

            ->add('cover',               FileType::class)
           (...)

            ->add('Valider', SubmitType::class)
            //->add('date') (la date est ajoutée via la fonction __construct de l'entité)
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Kreatike\TutorielBundle\Entity\Tutoriel'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'kreatike_tutorielbundle_tutoriel';
    }

}

EditAction:

public function editAction($slug, Request $request)
{
    $em = $this->getDoctrine()->getManager();
    $tutoriel = $em->getRepository('KreatikeTutorielBundle:Tutoriel')->findOneBy(array('slug' => $slug));

    if($tutoriel===null)
    {
        throw new NotFoundHttpException('Le Tutoriel n\'hexiste pas');
    }

    $form = $this->get('form.factory')->create(TutorielEditType::class, $tutoriel);

    if($request->isMethod('POST') && $form->handleRequest($request)->isValid())
    {

        $uploadableManager = $this->get('stof_doctrine_extensions.uploadable.manager');

        $em->persist($tutoriel);
        $uploadableManager->markEntityToUpload($tutoriel, $tutoriel->getCover());

        $em->flush();

        $request->getSession()->getFlashBag()->add('notice', 'Le tutoriel a bien été modifié.');

        return $this->redirectToRoute('kreatike_tutoriel_view', array(
            'slug'=>$tutoriel->getSlug(),
            ));
    }

    return $this->render('KreatikeTutorielBundle:Tutoriel:edit.html.twig', array(
        'tutoriel'=>$tutoriel,
        'form'=>$form->createView(),
        ));
}

The error:

The form's view data is expected to be an instance of class
  Kreatike\TutorielBundle\Entity\Tutoriel, but is a(n) string. You can
  avoid this error by setting the "data_class" option to null or by
  adding a view transformer that transforms a(n) string to an instance
  of Kreatike\TutorielBundle\Entity\Tutoriel.

Indeed my cover field containt the string of the file's path, not a file... and my form get a fileType.

So I think that I need to recover my file from my path in order to hydrate the form's field...

But I have absolutely no idea how to do that...

I try to avoid data_class => null...

Any clue?

Thanks!

Body:
Did you set the right enctype on the form tag on the view?

enctype="multipart/form-data"

Usually this type of errors are related to the enctype attribute.


问:
Checking if a string of numbers is sorted C# in an if statement
I'm trying to figure out how to write an if statement in C# that basically does this</p>

```<code>string myString = "1234";
if( myString is sorted)
    {
        //Do some stuff
    }
else
    {
       // Do some other stuff
    }
</code>```

答:
One way to check would be to simply treat the string as a collection of chars and use the System.Linq extension OrderBy(). Note that the code below will throw an exception if one if the characters is not an integer:

```<code>var input = "1234";
var orderedInput = string.Join("", input.OrderBy(i => int.Parse(i.ToString())));

if (input == orderedInput)
{
    Console.WriteLine("it's sorted.");
}
else
{
    Console.WriteLine("it's not sorted");
}
</code>```

If you want to allow non-numeric characters, you can use string sorting (which will sort by numeric then alphabetic), you can use:

```<code>var orderedInput = string.Join("", input.OrderBy(i => i.ToString()));
</code>```

Body:
I'm trying to figure out how to write an if statement in C# that basically does this

string myString = "1234";
if( myString is sorted)
    {
        //Do some stuff
    }
else
    {
       // Do some other stuff
    }

Body:
One way to check would be to simply treat the string as a collection of chars and use the System.Linq extension OrderBy(). Note that the code below will throw an exception if one if the characters is not an integer:

var input = "1234";
var orderedInput = string.Join("", input.OrderBy(i => int.Parse(i.ToString())));

if (input == orderedInput)
{
    Console.WriteLine("it's sorted.");
}
else
{
    Console.WriteLine("it's not sorted");
}

If you want to allow non-numeric characters, you can use string sorting (which will sort by numeric then alphabetic), you can use:

var orderedInput = string.Join("", input.OrderBy(i => i.ToString()));


问:
How to print all of the file data
Im trying to print all of the file data but at first it doesnt show anything... Why? If i run it few times it shows me the data without the first input...</p>

```<code>class Data:

    def __init__(self):

        self.add = open("user_data.txt", "a")
        self.add.write("data")

    def add_data(self, user_name, password):

        self.add.write(user_name)
        self.add.write(",")
        self.add.write(password)
        self.add.write(";")
        self.read = open("user_data.txt", "r")

    def show_file(self):

        print self.read.read()

d = Data()
d.add_data("asdv", "safvas")
d.show_file()
</code>```

答:
You need to close your file after writing to it. Also, you should open your file for reading in the show_file() method:</p>

```<code> class Data:

def __init__(self):

    self.add = open("user_data.txt", "a")
    self.add.write("data")
    self.add.close()

def add_data(self, user_name, password):
    self.add = open('user_data.txt', 'a')
    self.add.write(user_name)
    self.add.write(",")
    self.add.write(password)
    self.add.write(";")
    self.add.close()

def show_file(self):
    self.read = open("user_data.txt", "r")
    print self.read.read()

d = Data()
d.add_data("asdv", "safvas")
d.show_file()
</code>```

Title: How to print all of the file data

Body:
Im trying to print all of the file data but at first it doesnt show anything... Why? If i run it few times it shows me the data without the first input...

class Data:

    def __init__(self):

        self.add = open("user_data.txt", "a")
        self.add.write("data")

    def add_data(self, user_name, password):

        self.add.write(user_name)
        self.add.write(",")
        self.add.write(password)
        self.add.write(";")
        self.read = open("user_data.txt", "r")

    def show_file(self):

        print self.read.read()

d = Data()
d.add_data("asdv", "safvas")
d.show_file()

Body:
You need to close your file after writing to it. Also, you should open your file for reading in the show_file() method:

 class Data:

def __init__(self):

    self.add = open("user_data.txt", "a")
    self.add.write("data")
    self.add.close()

def add_data(self, user_name, password):
    self.add = open('user_data.txt', 'a')
    self.add.write(user_name)
    self.add.write(",")
    self.add.write(password)
    self.add.write(";")
    self.add.close()

def show_file(self):
    self.read = open("user_data.txt", "r")
    print self.read.read()

d = Data()
d.add_data("asdv", "safvas")
d.show_file()


问:
Monitor Outbound Webservice calls
I'm currently debugging a 3rd party component and I need to monitor to see if it is making an outbound webservice call. Does anyone know of a way of quickly setting up something to monitor this as I step over the code. </p>

答: Old but good and completely free: http://www.nirsoft.net/utils/smsniff.html</p>

ContentLicense: CC BY-SA 2.5

Title: Monitor Outbound Webservice calls


问:
How can I transpose my dataframe so that the rows and columns switch in r?
I have a dataframe (simplified) that looks like this:

```<code>Age, Kodiak, Banana, Banff, Montreal, Fairfax
Age_1, 5, 6 , 7, 9, 2
Age_2, 7, 6, 4, 3, 2
Age_3, 5, 3, 8, 5, 9
</code>```

I would like my dataframe to look more like this:

```<code>Location, Age_1, Age_2, Age_3
Kodiak, 5, 7, 5
Banana, 6, 6, 3
Banff, 7, 4, 8
Montreal, 9, 3, 5
Fairfax, 2, 2, 9
</code>```

I've looked at the transpose function but I'm a bit confused on how to switch both the columns and rows. I'm very new to R.

答:
Use the t() function to transpose dataframes.

For example:

```<code>cars <- mtcars[1:5,1:4]
cars

                   mpg cyl disp  hp
Mazda RX4         21.0   6  160 110
Mazda RX4 Wag     21.0   6  160 110
Datsun 710        22.8   4  108  93
Hornet 4 Drive    21.4   6  258 110
Hornet Sportabout 18.7   8  360 175

t(cars)

     Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive Hornet Sportabout
mpg         21            21       22.8           21.4              18.7
cyl          6             6        4.0            6.0               8.0
disp       160           160      108.0          258.0             360.0
hp         110           110       93.0          110.0             175.0
</code>```

source: https://www.r-statistics.com/tag/transpose/

Body:
I have a dataframe (simplified) that looks like this:

Age, Kodiak, Banana, Banff, Montreal, Fairfax
Age_1, 5, 6 , 7, 9, 2
Age_2, 7, 6, 4, 3, 2
Age_3, 5, 3, 8, 5, 9

I would like my dataframe to look more like this:

Location, Age_1, Age_2, Age_3
Kodiak, 5, 7, 5
Banana, 6, 6, 3
Banff, 7, 4, 8
Montreal, 9, 3, 5
Fairfax, 2, 2, 9

I've looked at the transpose function but I'm a bit confused on how to switch both the columns and rows. I'm very new to R.

Body:
Use the t() function to transpose dataframes.

For example:

cars <- mtcars[1:5,1:4]
cars

                   mpg cyl disp  hp
Mazda RX4         21.0   6  160 110
Mazda RX4 Wag     21.0   6  160 110
Datsun 710        22.8   4  108  93
Hornet 4 Drive    21.4   6  258 110
Hornet Sportabout 18.7   8  360 175

t(cars)

     Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive Hornet Sportabout
mpg         21            21       22.8           21.4              18.7
cyl          6             6        4.0            6.0               8.0
disp       160           160      108.0          258.0             360.0
hp         110           110       93.0          110.0             175.0

source: https://www.r-statistics.com/tag/transpose/


问:
Rails - relative paths - techniques
I am struggling to understand the intricacies of how to address various assets in rails. Having had some help sorting out a related question I wanted to expand a little further.

In my application I have imported a website template (a limited part at present) from wrap bootstrap. I am trying to get this to work and I have been hitting issues with references to images etc that are in none standard folders.

In the wrap bootstrap theme the JavaScript assets are in a folder called js, css assets are in folder called css and images are in a folder called img. Each of these folders have multiple subfolders.

The individual js, css files reference a whole host of paths for different reasons and often these references are failing. I firstly tried to copy all of the assets into the standard rails folders (assets/javascripts etc) but this failed as many of the files imported will reference the js folder. I don't want to move the imported files around for the same reason. My approach therefore has been to try and identify the issues in the imported files and fix the path references.

I have already had assistance with addressing one of the issues in a  block but I have other issues within js and css files. I am also aware that the way relative paths are addressed in development can fail in production when the assets are compiled into the public/assets folder.

I was hoping therefore to get best practice advice on the basis of the 2 issues I know I still need to address.

The first is addressing an image path within a block of JavaScript code as per below:-

```<code>        var setColor = function (color, data_header) {
            jQuery('#style_color').attr("href", "../assets/css/theme-colors/" + color + ".css");
            if(data_header == 'light'){
                jQuery('.logo img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
                jQuery('#logo-footer').attr("src", "../assets/img/themes/logo2-" + color + ".png");
                jQuery('.navbar-brand img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
            } else if(data_header == 'dark'){
                jQuery('.logo img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
                jQuery('#logo-footer').attr("src", "../assets/img/themes/logo2-" + color + ".png");
            }
        }
</code>```

This function is located in assets/js/plugins and is called from a script block located in an html.erb file in assets/views/open_pages. The relative path looks correct but the image doesn't appear, I get an error in the browser console window and in the rails server window I get a routing error. I can't understand how I am meant to reference this relative path in JavaScript as it looks correct to me.

The second issue is similar but in a css file. The snippet below should reference the correct path but again this fails. I also read somewhere that this type of notation can fail in production

```<code>/*Dotted Map*/
.footer-v1 .footer .map-img {
   background: url(../img/map-img.png) 5px 60px no-repeat;
}
</code>```

Could anyone outline how these types of issues should be approached? I am obviously missing something critical in my understanding and it is really impeding progress.

Thanks for your time.

D

答:
This can be a real headache in Rails, trying to work with the assets pipeline. Since at the server you don't have access to the color variable, you have to do something like this. There might be a smarter solution, but I'm not seeing it at the moment at least.

```<code>var link = '';
if (color == 'red') {
  link = "<%= asset_path('theme-colors/red.css') %>";
}
if (color == 'blue') {
  link = "<%= asset_path('theme-colors/blue.css') %>";
}

jQuery('#style_color').attr("href", link);
</code>```

And, as with the earlier answer, you have to add this to config/initializers/assets.rb.

```<code>Rails.application.config.assets.paths << Rails.root.join('assets', 'css')
</code>```

This should move you a bit in the right direction at least. And also have a look at the guides on the assets pipeline.

Title: Rails - relative paths - techniques

Body:
I am struggling to understand the intricacies of how to address various assets in rails. Having had some help sorting out a related question I wanted to expand a little further.

In my application I have imported a website template (a limited part at present) from wrap bootstrap. I am trying to get this to work and I have been hitting issues with references to images etc that are in none standard folders.

In the wrap bootstrap theme the JavaScript assets are in a folder called js, css assets are in folder called css and images are in a folder called img. Each of these folders have multiple subfolders.

The individual js, css files reference a whole host of paths for different reasons and often these references are failing. I firstly tried to copy all of the assets into the standard rails folders (assets/javascripts etc) but this failed as many of the files imported will reference the js folder. I don't want to move the imported files around for the same reason. My approach therefore has been to try and identify the issues in the imported files and fix the path references.

I have already had assistance with addressing one of the issues in a  block but I have other issues within js and css files. I am also aware that the way relative paths are addressed in development can fail in production when the assets are compiled into the public/assets folder.

I was hoping therefore to get best practice advice on the basis of the 2 issues I know I still need to address.

The first is addressing an image path within a block of JavaScript code as per below:-

        var setColor = function (color, data_header) {
            jQuery('#style_color').attr("href", "../assets/css/theme-colors/" + color + ".css");
            if(data_header == 'light'){
                jQuery('.logo img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
                jQuery('#logo-footer').attr("src", "../assets/img/themes/logo2-" + color + ".png");
                jQuery('.navbar-brand img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
            } else if(data_header == 'dark'){
                jQuery('.logo img').attr("src", "../assets/img/themes/logo1-" + color + ".png");
                jQuery('#logo-footer').attr("src", "../assets/img/themes/logo2-" + color + ".png");
            }
        }

This function is located in assets/js/plugins and is called from a script block located in an html.erb file in assets/views/open_pages. The relative path looks correct but the image doesn't appear, I get an error in the browser console window and in the rails server window I get a routing error. I can't understand how I am meant to reference this relative path in JavaScript as it looks correct to me.

The second issue is similar but in a css file. The snippet below should reference the correct path but again this fails. I also read somewhere that this type of notation can fail in production

/*Dotted Map*/
.footer-v1 .footer .map-img {
   background: url(../img/map-img.png) 5px 60px no-repeat;
}

Could anyone outline how these types of issues should be approached? I am obviously missing something critical in my understanding and it is really impeding progress.

Thanks for your time.

D

Body:
This can be a real headache in Rails, trying to work with the assets pipeline. Since at the server you don't have access to the color variable, you have to do something like this. There might be a smarter solution, but I'm not seeing it at the moment at least.

var link = '';
if (color == 'red') {
  link = "<%= asset_path('theme-colors/red.css') %>";
}
if (color == 'blue') {
  link = "<%= asset_path('theme-colors/blue.css') %>";
}

jQuery('#style_color').attr("href", link);

And, as with the earlier answer, you have to add this to config/initializers/assets.rb.

Rails.application.config.assets.paths << Rails.root.join('assets', 'css')

This should move you a bit in the right direction at least. And also have a look at the guides on the assets pipeline.


问:
Create a multi-labelled dataset from a redundant binary one for multi-label classification
I'm given a dataset (dataframe) of the sort:

```<code>x   y

A   a
A   b
B   c
C   g
B   g
</code>```

Here's what I need for multi-label classification-

```<code>x   y

A   a,b
B   c,g
C   g
</code>```

How should I go about it?

答:
Option 1

Use groupby with ','.join

```<code>df.groupby('x').y.apply(','.join).reset_index()

   x    y
0  A  a,b
1  B  c,g
2  C    g
</code>```

Option 2

Use pivot_table with ','.join

```<code>df.pivot_table('y', 'x', aggfunc=','.join).reset_index()

   x    y
0  A  a,b
1  B  c,g
2  C    g
</code>```

Body:
I'm given a dataset (dataframe) of the sort:

x   y

A   a
A   b
B   c
C   g
B   g

Here's what I need for multi-label classification-

x   y

A   a,b
B   c,g
C   g

How should I go about it?

Body:
Option 1

Use groupby with ','.join

df.groupby('x').y.apply(','.join).reset_index()

   x    y
0  A  a,b
1  B  c,g
2  C    g

Option 2

Use pivot_table with ','.join

df.pivot_table('y', 'x', aggfunc=','.join).reset_index()

   x    y
0  A  a,b
1  B  c,g
2  C    g


问:
DNS name from IP address
I need to create a list of IP addresses and DNS names. I
   am trying to get DNS names from IP addresses. I have tried two ways:

try/catch but it ends afterwards.

Without and it just outputs DNS names that I can't relate to the IP addresses.

Here's what I have so far:

```<code>#try {
 Get-Content C:\Users\pintose\Documents\IP_Address.txt | ForEach-Object
{([system.net.dns]::GetHostByAddress($_)).hostname >> C:\Users\user\Documents\hostname.txt}
# }
 # catch {
 if ($_.Exception.Message -like "*The requested name is valid*") {
            Write-Output "UNREACHABLE" | Out-File C:\Users\user\Documents\hostname.txt }
# }
</code>```

答:
Another way...</p>

```<code>$ip_list = Get-Content ./IP_Address.txt

foreach ($ip in $ip_list) {
    try {
        ([system.net.dns]::GetHostByAddress($ip)).hostname |
            Out-File -FilePath ./hostname.txt -Append
    }
    catch {
        if ($_.Exception.Message -like "*The requested name is valid*") {
            Write-Output "UNREACHABLE" | Out-File -FilePath './hostname.txt' -Append }
    }
}
</code>```

Title: DNS name from IP address

Body:
I need to create a list of IP addresses and DNS names. I
   am trying to get DNS names from IP addresses. I have tried two ways:

try/catch but it ends afterwards.

Without and it just outputs DNS names that I can't relate to the IP addresses.

Here's what I have so far:

#try {
 Get-Content C:\Users\pintose\Documents\IP_Address.txt | ForEach-Object
{([system.net.dns]::GetHostByAddress($_)).hostname >> C:\Users\user\Documents\hostname.txt}
# }
 # catch {
 if ($_.Exception.Message -like "*The requested name is valid*") {
            Write-Output "UNREACHABLE" | Out-File C:\Users\user\Documents\hostname.txt }
# }

Body:
Another way...

$ip_list = Get-Content ./IP_Address.txt

foreach ($ip in $ip_list) {
    try {
        ([system.net.dns]::GetHostByAddress($ip)).hostname |
            Out-File -FilePath ./hostname.txt -Append
    }
    catch {
        if ($_.Exception.Message -like "*The requested name is valid*") {
            Write-Output "UNREACHABLE" | Out-File -FilePath './hostname.txt' -Append }
    }
}


问:
Where can I find XFA specs or DTD/schema?
I have a hard time finding specifications or a DTD, RNG, or XSD for XFA.

Adobe lists the "Adobe Supplement to ISO 32000, BaseVersion 1.7, ExtensionLevel 3" on their PDF Reference page. On page 102, there is a link to the "Adobe XML Architecture specifications", however that link is dead, and archive.org did not archive it.

There is an old W3C Note "XFA-Template", which has a link to a DTD, however that link is dead as well, and from archive.org I get the feeling it's never really been alive. (In any case, XFA-Template only seems to be a part of the XFA family of specifications.)

A Google search for "site:adobe.com xfa specifications" turns up a link to "Introduction to XML forms architecture (XFA)". However, there is a DNS problem for me and I can't access it:

$ traceroute6 help.adobe.com
traceroute: unknown host help.adobe.com

Archive.org doesn't help here either.

Any hint where to find that information?

答:
I found a copy of the 3.3 Spec here...

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf

Pages 1554-1555

The XFA schemas are written in the language RELAX: Next Generation
  (RNG) which is described in RELAX-NG. XFA schemas are written in
  this language rather than the more usual XML-Schema 1.0
  because XFA allows free ordering in situations where XML-Schema cannot
  support it.
  ...
  The schemas are included as file attachments in the PDF form of this document. If you are viewing a hard copy, obtain the PDF file from the Adobe website at http://adobe.com/go/xfa_specifications.

note the xfa specifications link does not work, nor does goolge.com/archive.org have it cached.

Files in the specification

config.rng

configuration

connectionset.rng

connections to web services

data.rng

user data portion of the dataSets packet

dataDescription.rng

data description portion of the dataSets
packet

localeset.rng

locale definitions

pdf.rng

accompanying PDF

sourceset.rng

connections to databases

stylesheet.rng

XSLT stylesheet(s) for custom transformation of data and/or the template

template.rng

template

xdp.rng

container for everything else

xfdf.rng

annotations

xmldsig-core-schema.rng

signing control

I'm not sure what your goal is but I wouldn't be investing much time in XFA. It's been removed from the PDF 2.0 specification.

ContentLicense: CC BY-SA 4.0


问:
searching a degenerate string in python
I am am trying to search for an exact pattern match to a degenerate or very slightly "fuzzy" string.

```<code>pattern = 'VGSGSGSGSAS' can be 10-50 characters long
string = "VGSGSGGSGSGSGSGSERGSAS" or "VGSGSGSGSGSGAGERSAS"  #it's actually 400 character long string
string[11] = S|A
re.search(pattern, string) #does not work
</code>```

so string[11] is either S or A. In this sample, I'm searching for the pattern in 2 defined strings, But, I don't want to make 2 separate strings, because there are actually multiple (at least 4) position in the 400 character string that have up to 3 different options each for a character. So I would be looking at making and searching in 24 different strings. And that's for just one sequence. Some of my sequences would turn into 64 different strings. Once I find the result of the search, I want to figure out where it starts and ends, and which string[11] character (S or A) it actually matches. Any ideas how I could do this pattern matching? Thank you!

答:
Actually, if what i understood from your question is correct, you can use re.search() with a list of strings like this example:

```<code>import re

strings = ["VGSEKVTMQNLNDRLAS", "GSEKVTMQNLNDRLAS", "DRLASKVTMQKL", "GSEKVKVTMQPLDRLAS"]
pattern = r'KVTMQ[N|K]L'

for k in strings:
    s = re.search(pattern, k)
    print("Search in: {}  ".format(k), end = ' ')
    if s:
        print("Found: {} in position: {}".format(s.group(), s.span()))
    else:
        print("Not found")
</code>```

Output:

```<code>Search in: VGSEKVTMQNLNDRLAS   Found: KVTMQNL in position: (4, 11)
Search in: GSEKVTMQNLNDRLAS   Found: KVTMQNL in position: (3, 10)
Search in: DRLASKVTMQKL   Found: KVTMQKL in position: (5, 12)
Search in: GSEKVKVTMQPLDRLAS   Not found
</code>```

Title: searching a degenerate string in python

Body:
I am am trying to search for an exact pattern match to a degenerate or very slightly "fuzzy" string.

pattern = 'VGSGSGSGSAS' can be 10-50 characters long
string = "VGSGSGGSGSGSGSGSERGSAS" or "VGSGSGSGSGSGAGERSAS"  #it's actually 400 character long string
string[11] = S|A
re.search(pattern, string) #does not work

so string[11] is either S or A. In this sample, I'm searching for the pattern in 2 defined strings, But, I don't want to make 2 separate strings, because there are actually multiple (at least 4) position in the 400 character string that have up to 3 different options each for a character. So I would be looking at making and searching in 24 different strings. And that's for just one sequence. Some of my sequences would turn into 64 different strings. Once I find the result of the search, I want to figure out where it starts and ends, and which string[11] character (S or A) it actually matches. Any ideas how I could do this pattern matching? Thank you!

Body:
Actually, if what i understood from your question is correct, you can use re.search() with a list of strings like this example:

import re

strings = ["VGSEKVTMQNLNDRLAS", "GSEKVTMQNLNDRLAS", "DRLASKVTMQKL", "GSEKVKVTMQPLDRLAS"]
pattern = r'KVTMQ[N|K]L'

for k in strings:
    s = re.search(pattern, k)
    print("Search in: {}  ".format(k), end = ' ')
    if s:
        print("Found: {} in position: {}".format(s.group(), s.span()))
    else:
        print("Not found")

Output:

Search in: VGSEKVTMQNLNDRLAS   Found: KVTMQNL in position: (4, 11)
Search in: GSEKVTMQNLNDRLAS   Found: KVTMQNL in position: (3, 10)
Search in: DRLASKVTMQKL   Found: KVTMQKL in position: (5, 12)
Search in: GSEKVKVTMQPLDRLAS   Not found


问:
How to find the type of an object in a set?
How do I find the type of an object that is in a set with using one line code?</p>

```<code>setup = {(1,2),(3,4),(5,6)}

>>> type(setup.____)

<class 'int'>
</code>```

答:
```<code>type(setup) # set
type(next(iter(setup))) #tuple
type(next(iter(setup))[0]) #int
</code>```

maybe? its really not clear what your question is... just cause one element of a set is a tuple does not mean all elements in the set are tuples.

Body:
How do I find the type of an object that is in a set with using one line code?

setup = {(1,2),(3,4),(5,6)}

>>> type(setup.____)

<class 'int'>

Body:
type(setup) # set
type(next(iter(setup))) #tuple
type(next(iter(setup))[0]) #int

maybe? its really not clear what your question is... just cause one element of a set is a tuple does not mean all elements in the set are tuples.


问:
Joomla malicious file upload and cross site scripting
My site is under security audit to get the security certification. After audit they gave me two security issues to look at.

Stored Cross Site Scripting: The application must implement server side validation for all user-entered inputs. Only expected values should be accepted. Script tags should be rejected. All user inputs should be sanitized.

Malicious File Upload

I have added the  at filter tags in Joomla global configuration text filters. And also though I have clearly stated for all file upload elements to only use .jpg,.jpeg,.png extensions, I can still upload .php extension files.

How can we rectify these two issues?

Regards

答:
Use the defines.php file to clean the POST data before it reaches the Joomla site, and block any request with $_FILES in it.

If your website needs to allow users to upload files, then make sure that these files only consist of specific file types, and, if you don't need the external world to have access to these files, then block access to these files (in the folder you have them uploaded to) using an htaccess rule.


问:
Git - Diff between branches in old commits
I have this:

```<code>branch: commit 1, commit 2, 3,4
master: commit 1, commit 2, 3,4,5,6,7
</code>```

How can you make a diff between branch after commit 2 (in that point of history) and master in commit 3?

答: Let's name your commits b1, b2, b3, b4; m1, m2, m3, m4, m5, m6, m7. To diff two commits you can run git diff commit1 commit2. In your case it's git diff b2 m3.

Body:
I have this:

branch: commit 1, commit 2, 3,4
master: commit 1, commit 2, 3,4,5,6,7

How can you make a diff between branch after commit 2 (in that point of history) and master in commit 3?


问:
ERR_EMPTY_RESPONSE for localhost when running Docker
Here's my Dockerfile:

```<code># CentOs base image
FROM centos:centos6.8

# install python, pip, apache and other packages
RUN yum -y update; yum clean all
RUN yum -y install epel-release; yum clean all
RUN yum -y install centos-release-scl; yum clean all
RUN yum -y install python27; yum clean all
RUN yum -y install python-devel.x86_64; yum clean all
RUN yum -y install python-pip; yum clean all
RUN yum -y install gcc; yum clean all
RUN yum -y install httpd httpd-devel mod_ssl; yum clean all

# Make a non root user so I can run mod_wsgi without root
# USER adm

# install Python modules needed by the Python app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt

# copy files required for the app to run
COPY . /usr/src/app/

# tell the port number the container should expose
EXPOSE 80

# run the application
# CMD ["mod_wsgi", "start-server run_apache_server.wsgi"]
# CMD ["cat", "/etc/passwd"]
# CMD ["cat", "/etc/group"]
# CMD ["find", "/"]
CMD ["/bin/sh", "-c", "/usr/bin/mod_wsgi-express start-server run_apache_server.wsgi --user adm --group apache"]
</code>```

I can run the app:

```<code>$ docker run -d -P --name myapp jacobirr/pleromatest
</code>```

And see tcp port 80:

```<code>$ docker port myapp
80/tcp -> 0.0.0.0:32769
</code>```

Here's my requirements.txt:

```<code>Flask==0.10.1
Flask-Restless==0.13.1
Flask-SQLAlchemy==0.16
Jinja2==2.7
MarkupSafe==0.18
SQLAlchemy==0.8.2
Werkzeug==0.9.2
gunicorn==17.5
itsdangerous==0.22
mimerender==0.5.4
python-dateutil==2.1
python-mimeparse==0.1.4
requests==1.2.3
six==1.3.0
wsgiref==0.1.2
setuptools==5.4.2
mod_wsgi==4.5.15
</code>```

Why can't I get to localhost:32769 in the browser? I suspect this is related to:

•the user/group running apache?

•the fact that I'm installing mod_wsgi but it's nowhere on the docker "filesystem" so I have to use mod_wsgi-express?

Update:

'1' Netstat shows:

```<code>[root@9003b0d64916 app]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:irdmi                     *:*                         LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     113181 /tmp/mod_wsgi-localhost:8000:0/wsgi.1.0.1.sock
</code>```

'2' httpd seems to be running in my container:

```<code>[root@9003b0d64916 mod_wsgi-localhost:8000:0]# ps aux | grep httpd
root         1  0.0  0.2  64060  5084 ?        Ss   21:17   0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm          6  0.0  0.6 350928 13936 ?        Sl   21:17   0:00 (wsgi:localhost:8000:0)  -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm          7  0.0  0.1  64192  3248 ?        S    21:17   0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
</code>```

答:
Add this to your Dockerfile, just before CMD:

```<code>WORKDIR  /usr/src/app/
</code>```

Assuming that your start-apache-server file is in that directory. This will help wsgi to find the needed file.

Body:
Here's my Dockerfile:

# CentOs base image
FROM centos:centos6.8

# install python, pip, apache and other packages
RUN yum -y update; yum clean all
RUN yum -y install epel-release; yum clean all
RUN yum -y install centos-release-scl; yum clean all
RUN yum -y install python27; yum clean all
RUN yum -y install python-devel.x86_64; yum clean all
RUN yum -y install python-pip; yum clean all
RUN yum -y install gcc; yum clean all
RUN yum -y install httpd httpd-devel mod_ssl; yum clean all

# Make a non root user so I can run mod_wsgi without root
# USER adm

# install Python modules needed by the Python app
COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt

# copy files required for the app to run
COPY . /usr/src/app/

# tell the port number the container should expose
EXPOSE 80

# run the application
# CMD ["mod_wsgi", "start-server run_apache_server.wsgi"]
# CMD ["cat", "/etc/passwd"]
# CMD ["cat", "/etc/group"]
# CMD ["find", "/"]
CMD ["/bin/sh", "-c", "/usr/bin/mod_wsgi-express start-server run_apache_server.wsgi --user adm --group apache"]

I can run the app:

$ docker run -d -P --name myapp jacobirr/pleromatest

And see tcp port 80:

$ docker port myapp
80/tcp -> 0.0.0.0:32769

Here's my requirements.txt:

Flask==0.10.1
Flask-Restless==0.13.1
Flask-SQLAlchemy==0.16
Jinja2==2.7
MarkupSafe==0.18
SQLAlchemy==0.8.2
Werkzeug==0.9.2
gunicorn==17.5
itsdangerous==0.22
mimerender==0.5.4
python-dateutil==2.1
python-mimeparse==0.1.4
requests==1.2.3
six==1.3.0
wsgiref==0.1.2
setuptools==5.4.2
mod_wsgi==4.5.15

Why can't I get to localhost:32769 in the browser? I suspect this is related to:

•the user/group running apache?

•the fact that I'm installing mod_wsgi but it's nowhere on the docker "filesystem" so I have to use mod_wsgi-express?

Update:

'1' Netstat shows:

[root@9003b0d64916 app]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:irdmi                     *:*                         LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     113181 /tmp/mod_wsgi-localhost:8000:0/wsgi.1.0.1.sock

'2' httpd seems to be running in my container:

[root@9003b0d64916 mod_wsgi-localhost:8000:0]# ps aux | grep httpd
root         1  0.0  0.2  64060  5084 ?        Ss   21:17   0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm          6  0.0  0.6 350928 13936 ?        Sl   21:17   0:00 (wsgi:localhost:8000:0)  -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND
adm          7  0.0  0.1  64192  3248 ?        S    21:17   0:00 httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:0/httpd.conf -k start -DFOREGROUND

Body:
Add this to your Dockerfile, just before CMD:

WORKDIR  /usr/src/app/

Assuming that your start-apache-server file is in that directory. This will help wsgi to find the needed file.


问:
C strcmp() not returning 0 as expected
I have been trying to get strcmp to return true in the following program for many days now, I have read the man pages for strcmp, read, write... I have other's posts who have had the exact same problem. The following source code is just a test program that is frustrating the heck out of me, there are some commented out lines that are other attempts I've made at getting strcmp to work as expected.  I have compiled with 'gdb -g' and stepped through one instruction at a time.  The printf statements pretty much tell the whole story.  I cannot get the value of buf, or bufptr to equal 't' ever.  I have simplified the program, and had it just print one character at a time one after the other to the screen and they print as expected from whatever file is read-in, however, as soon as I start playing with strcmp, things get crazy. I cannot for the life of me figure out a way to get the value in buf to be the single char that I am expecting it to be.
When simplified to just the write(1,...) call, it writes the expected single char to stdout, but strcmp to a single 't' never returns 0.  !!!!! Thank you in advance. I originally didnt have bufptr in there and was doing a strcmp to buf itself and also tried using bufptr[0] = buf[0] and the still were not the same.</p>

```<code>#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

#define BUF_SIZE 1

void main(int argc, char *argv[])
{

    char buf[BUF_SIZE];
    int inputFd = open(argv[1], O_RDONLY);
    char tee[] = "t";
    int fff = 999;
    char bufptr[BUF_SIZE];
//  char *bufptr[BUF_SIZE];

    while (read(inputFd, buf, BUF_SIZE) > 0) {
            bufptr[0] = buf[0];
//          bufptr = buf;
            printf("********STRCMP RETURNED->%d\n", fff); // for debugging purposes
            printf("--------tee is -> %s\n", tee);        // for debugging purposes
            printf("++++++++buf is -> %s\n", buf);        // "  "   "
            printf("@@@@@@@@bufptr is -> %s", bufptr);    // "  "   "
            write (1, buf, BUF_SIZE);

            if ((fff = strcmp(tee, bufptr)) == 0)
                printf("THIS CHARACTER IS A T");
    }

    close(inputFd);

}
</code>```

答:
The str-family of functions expects strings as inputs, which are arrays storing null-terminated character sequences. However, you do not provide space in the buffer for the null character. To make the buffers strings, you need to add space for the null-character and zero-out the value so that they end with the null character.

```<code>void main(int argc, char *argv[])
{
    char buf[ BUF_SIZE + 1 ] = {0};
    int inputFd = open(argv[1], O_RDONLY);
    char tee[] = "t";

    while (read(inputFd, buf, BUF_SIZE) > 0) {
        if ( strcmp( tee, buf ) == 0 )
            printf("THIS CHARACTER IS A T");
    }

    close(inputFd);
}
</code>```

Title: C strcmp() not returning 0 as expected

Body:
I have been trying to get strcmp to return true in the following program for many days now, I have read the man pages for strcmp, read, write... I have other's posts who have had the exact same problem. The following source code is just a test program that is frustrating the heck out of me, there are some commented out lines that are other attempts I've made at getting strcmp to work as expected.  I have compiled with 'gdb -g' and stepped through one instruction at a time.  The printf statements pretty much tell the whole story.  I cannot get the value of buf, or bufptr to equal 't' ever.  I have simplified the program, and had it just print one character at a time one after the other to the screen and they print as expected from whatever file is read-in, however, as soon as I start playing with strcmp, things get crazy. I cannot for the life of me figure out a way to get the value in buf to be the single char that I am expecting it to be.
When simplified to just the write(1,...) call, it writes the expected single char to stdout, but strcmp to a single 't' never returns 0.  !!!!! Thank you in advance. I originally didnt have bufptr in there and was doing a strcmp to buf itself and also tried using bufptr[0] = buf[0] and the still were not the same.

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

#define BUF_SIZE 1

void main(int argc, char *argv[])
{

    char buf[BUF_SIZE];
    int inputFd = open(argv[1], O_RDONLY);
    char tee[] = "t";
    int fff = 999;
    char bufptr[BUF_SIZE];
//  char *bufptr[BUF_SIZE];

    while (read(inputFd, buf, BUF_SIZE) > 0) {
            bufptr[0] = buf[0];
//          bufptr = buf;
            printf("********STRCMP RETURNED->%d\n", fff); // for debugging purposes
            printf("--------tee is -> %s\n", tee);        // for debugging purposes
            printf("++++++++buf is -> %s\n", buf);        // "  "   "
            printf("@@@@@@@@bufptr is -> %s", bufptr);    // "  "   "
            write (1, buf, BUF_SIZE);

            if ((fff = strcmp(tee, bufptr)) == 0)
                printf("THIS CHARACTER IS A T");
    }

    close(inputFd);

}

Body:
The str-family of functions expects strings as inputs, which are arrays storing null-terminated character sequences. However, you do not provide space in the buffer for the null character. To make the buffers strings, you need to add space for the null-character and zero-out the value so that they end with the null character.

void main(int argc, char *argv[])
{
    char buf[ BUF_SIZE + 1 ] = {0};
    int inputFd = open(argv[1], O_RDONLY);
    char tee[] = "t";

    while (read(inputFd, buf, BUF_SIZE) > 0) {
        if ( strcmp( tee, buf ) == 0 )
            printf("THIS CHARACTER IS A T");
    }

    close(inputFd);
}


问:
css footer always bottom of page
How do I make the footer always stay bottom of the page (no sticky)? My footer is at the bottom of the screen, but not on the page.

Here is an example of my code.

HTML

```<code><!DOCTYPE html>
<html>
<head>
     <meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
     <link href="styles.css" type="text/css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <div class="header">Header</div>
        <div class="body">Body</div>
        <div class="footer">Footer</div>
    </div>
</body>
</html>
</code>```

CSS

```<code>.footer {
    width:100%;
    height:109px;
    position:absolute;
    bottom:0;
    left:0;
    background-color: purple;
}
</code>```

答: If you're trying to make the footer appear at the bottom of the container, you need to use position:relative on the container, that way the footer will be at the bottom relative to the container.</p>

Title: css footer always bottom of page

Body:
How do I make the footer always stay bottom of the page (no sticky)? My footer is at the bottom of the screen, but not on the page.

Here is an example of my code.

HTML

<!DOCTYPE html>

     <meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
     <link href="styles.css" type="text/css" rel="stylesheet">

Header

Body

Footer

CSS

.footer {
    width:100%;
    height:109px;
    position:absolute;
    bottom:0;
    left:0;
    background-color: purple;
}


问:
Replicate part of production django database to local or staging
I have a Django website with 3 environments (Local, Staging, Production).

Production contains some data that I don't want my developers to have access to (Personal data and financial data of users).

Doing a DB backup restore is not an option for compliance reason.

However we also have some content pages on this website that we manage with Wagtail CMS.

I am looking for a way to sync production data (only some models but specifically the wagtail pages) back to Staging and Developers local environment when they need to.

Ideally I would have a manage command that I can run in another environment to copy data:

Example: ./manage.py sync_from_prod BlogPost this would find all missing blog post in the local or staging environment and would create them in the database. I cannot find any library doing this for Wagtail or Django doing this.

This seems like a common problem and I am surprised to find no Stackoverflow questions or opensource libraries fixing this problem.

If nothing exist I will probably try to write my own django-model-sync (Found this project, but is 3 year old and compatible until django 1.7 and I am on python3 django 1.11)

In order to manage security, a secret could be used by a dev to access a production API exposing the data (over ssl) for example

答:
Potentially you can make use of dumpdata command (or extending the command) in prod to get the JSON export of the blog data and then use loaddata command locally to save into your local environment.

How to implement the workflow is completely up to you, eg. you might want to wrap the dumpdata command in an protected API on prod, then create/run a sync_from_prod command in your local env to call that api and execute the call_command('loaddata', 'data_file.json') command with JSON exported data from prod.

PSEUDO CODE:

```<code># the api view to provide the data on prod
def dumpdata_view(requst):
    output = StringIO.StringIO()
    call_command('dumpdata', output=output)
    output.seek(0)
    return JsonResponse(output.readlines()

# command to execute locally
class sync_from_prod(BaseCommand):
    def handle(self, *args, **kwargs):
        with open('data_file.json', 'w') as f:
            data = requests.get('https://prod/api/dumpdata?model=BlogPost')
            f.write(data.content)
        call_command('loaddata', 'data_file.json')
</code>```

Body:
Potentially you can make use of dumpdata command (or extending the command) in prod to get the JSON export of the blog data and then use loaddata command locally to save into your local environment.

How to implement the workflow is completely up to you, eg. you might want to wrap the dumpdata command in an protected API on prod, then create/run a sync_from_prod command in your local env to call that api and execute the call_command('loaddata', 'data_file.json') command with JSON exported data from prod.

PSEUDO CODE:

# the api view to provide the data on prod
def dumpdata_view(requst):
    output = StringIO.StringIO()
    call_command('dumpdata', output=output)
    output.seek(0)
    return JsonResponse(output.readlines()

# command to execute locally
class sync_from_prod(BaseCommand):
    def handle(self, *args, **kwargs):
        with open('data_file.json', 'w') as f:
            data = requests.get('https://prod/api/dumpdata?model=BlogPost')
            f.write(data.content)
        call_command('loaddata', 'data_file.json')


问:
MDX - Concatenate level's properties and level's members
I an using mondrian and I have this issue: using a query mdx I need to concatenate in each member name belonging to a certain level, its name and a the value of a certain level properties for that member.

Something like CurrentMember.Name = CurrentMember.Name || CurrentMember.Properties("Prop").

Is this possible in some way?

Thanks.
Matteo

答:
In MDX it should look like that

```<code>[Dimension].CurrentMember.Name + [Dimension].CurrentMember.Properties("YourProp")
</code>```

The concatenation operator in MDX is + not ||

Body:
In MDX it should look like that

[Dimension].CurrentMember.Name + [Dimension].CurrentMember.Properties("YourProp")

The concatenation operator in MDX is + not ||