问:
Clicking on second accordion first accordion is not closing by default
Hi i am using bootstrap accordion for expanding and displaying the text.Accordion is working fine but when clicking on the second accordion the first one is not closing automatically.It should be closed automatically.Here is my code for that</p>

```<code><div class="accordion" id="myAccordion">
                <button type="button" class="servicesecommerce" data-toggle="collapse" data-target="#collapsible-1" data-parent="#myAccordion">E-Commerce Development</button><br/>
                <div id="collapsible-1"   class="collapse" >
                    <div class="services3">When it comes to e-Commerce websites you need a partner that is focused and experienced in providing companies the best in professional e-Commerce web design solutions. With a team of experts under one roof, Teknotrait goal is to provide you with all of the necessary design, development and marketing services you need to be successful online.</div>
                    <div class="services5">We build E-Commerce Shopping Cart Applications, E-Commerce store front & custom e-commerce shopping cart development solutions.</div>
                    <div class="services6">Teknotrait will help you to build a simple, efficient and familiar shopping interface that can include a number of useful security features such as SSL-A Secure Socket Layer, as the first line of defence against online intruders, utilizing a public-and-private key 128-bit encryption system to uniquely identify individuals carrying out transactions on your website.</div>
                    <div class="services7">Our e-commerce development includes Dedicated SSL Certificate compliance that assures your visitors that your site is secure and that their personal information will remain private so they can conduct secure Internet transactions with confidence.</div>
                </div>

<button type="button" class="servicesmobile" data-toggle="collapse" data-target="#collapsible-3" data-parent="#myAccordion">Mobile App Development</button><br/>
                <div id="collapsible-4" class="collapse" >
                    <div class="services3">Mobile application development refers the process of developing application or software for the mobiles, personal digital assistants and other handheld devices. When it comes to provide mobile application development services to the required clients, we come at the first position. There is no doubt that mobile technology is incredibly gaining popularity in the market and organizations started making presence in this sector</div>
                    <div class="services5">Empowering modern day enterprises, we Teknotrait Solution offer custom business & enterprise mobile apps development solutions which provide better potential and makes the business environment more transparent, intelligent, communication and work flow assistant for user. With our innovative and business – driven approach we work as a companion for the entrepreneurs to thrive and achieve much bigger business perspectives.</div>
                </div>
            </div>
</code>```

答:
<!DOCTYPE html>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example of Bootstrap 3 Accordion</title>
<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">

                    1. What is HTML?

HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. Learn more.

                    2. What is Bootstrap?

Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. Learn more.

                    3. What is CSS?

CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. Learn more.

                                                                    ```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example of Bootstrap 3 Accordion</title>
<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://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<style type="text/css">
    .bs-example{
     margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    1. What is HTML?
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in">
                <div class="panel-body">
                    <p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. Learn more.</p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    2. What is Bootstrap?
                </h4>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. Learn more.</p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    3. What is CSS?
                </h4>
            </div>
            <div id="collapseThree" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. Learn more.</p>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>                                                                    </code>```

Body:
Hi i am using bootstrap accordion for expanding and displaying the text.Accordion is working fine but when clicking on the second accordion the first one is not closing automatically.It should be closed automatically.Here is my code for that

                <button type="button" class="servicesecommerce" data-toggle="collapse" data-target="#collapsible-1" data-parent="#myAccordion">E-Commerce Development</button>

When it comes to e-Commerce websites you need a partner that is focused and experienced in providing companies the best in professional e-Commerce web design solutions. With a team of experts under one roof, Teknotrait goal is to provide you with all of the necessary design, development and marketing services you need to be successful online.

We build E-Commerce Shopping Cart Applications, E-Commerce store front & custom e-commerce shopping cart development solutions.

Teknotrait will help you to build a simple, efficient and familiar shopping interface that can include a number of useful security features such as SSL-A Secure Socket Layer, as the first line of defence against online intruders, utilizing a public-and-private key 128-bit encryption system to uniquely identify individuals carrying out transactions on your website.

Our e-commerce development includes Dedicated SSL Certificate compliance that assures your visitors that your site is secure and that their personal information will remain private so they can conduct secure Internet transactions with confidence.

<button type="button" class="servicesmobile" data-toggle="collapse" data-target="#collapsible-3" data-parent="#myAccordion">Mobile App Development</button>

Mobile application development refers the process of developing application or software for the mobiles, personal digital assistants and other handheld devices. When it comes to provide mobile application development services to the required clients, we come at the first position. There is no doubt that mobile technology is incredibly gaining popularity in the market and organizations started making presence in this sector

Empowering modern day enterprises, we Teknotrait Solution offer custom business & enterprise mobile apps development solutions which provide better potential and makes the business environment more transparent, intelligent, communication and work flow assistant for user. With our innovative and business – driven approach we work as a companion for the entrepreneurs to thrive and achieve much bigger business perspectives.

Body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example of Bootstrap 3 Accordion</title>
<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://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<style type="text/css">
    .bs-example{
     margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">1. What is HTML?</a>
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in">
                <div class="panel-body">
                    <p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. <a href="http://www.tutorialrepublic.com/html-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">2. What is Bootstrap?</a>
                </h4>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. <a href="http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">3. What is CSS?</a>
                </h4>
            </div>
            <div id="collapseThree" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. <a href="http://www.tutorialrepublic.com/css-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example of Bootstrap 3 Accordion</title>
<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://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<style type="text/css">
    .bs-example{
     margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">1. What is HTML?</a>
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in">
                <div class="panel-body">
                    <p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. <a href="http://www.tutorialrepublic.com/html-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">2. What is Bootstrap?</a>
                </h4>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. <a href="http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">3. What is CSS?</a>
                </h4>
            </div>
            <div id="collapseThree" class="panel-collapse collapse">
                <div class="panel-body">
                    <p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. <a href="http://www.tutorialrepublic.com/css-tutorial/" target="_blank">Learn more.</a></p>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>


来源: stackexchange

问:
How to set Animation Slide Down to card view when click on arrow down in ViewHolder?
I tried to set slide down animation to card when the user click on the arrow down icon but it not work when I setAnimationListener(this). it error at "this" keyword.
Note I use recycler view and card in the fragment.
here my code below

```<code>class ListViewHolder extends RecyclerView.ViewHolder{
        TextView tvTitle, tvDescription;
        ImageView ivDropDown;
        LinearLayout ll_footer;
        Button btnClose;
        Animation slideDown;

        public ListViewHolder(View itemView) {
            super(itemView);
            tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
            tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
            ivDropDown = (ImageView) itemView.findViewById(R.id.iv_arrow_down);
            ll_footer = (LinearLayout) itemView.findViewById(R.id.ll_footer);
            btnClose = (Button) itemView.findViewById(R.id.btn_close);

            btnClose.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
//                    callBack.onButtonCloseClick(getAdapterPosition());
                    ll_footer.setVisibility(View.GONE);
                }
            });

            ivDropDown.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    callBack.onImageClick(getAdapterPosition());
                    slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                    ll_footer.setAnimation(slideDown);
                    slideDown.setAnimationListener();
                    ll_footer.setVisibility(View.VISIBLE);
                }
            });
        }
    }
</code>```

答:
You have not start animation.
to do like this:</p>

```<code>class ListViewHolder extends RecyclerView.ViewHolder implements Animation.AnimationListener{
    TextView tvTitle, tvDescription;
    ImageView ivDropDown;
    LinearLayout ll_footer;
    Button btnClose;
    Animation slideDown;

    public ListViewHolder(View itemView) {
        super(itemView);
        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
        ivDropDown = (ImageView) itemView.findViewById(R.id.iv_arrow_down);
        ll_footer = (LinearLayout) itemView.findViewById(R.id.ll_footer);
        btnClose = (Button) itemView.findViewById(R.id.btn_close);

        btnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                    callBack.onButtonCloseClick(getAdapterPosition());
                ll_footer.setVisibility(View.GONE);
            }
        });

        ivDropDown.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.onImageClick(getAdapterPosition());
                slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                ll_footer.startAnimation(slideDown);
                slideDown.setAnimationListener(ListViewHolder.this);
                ll_footer.setVisibility(View.VISIBLE);
            }
        });
    }
    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {

    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I tried to set slide down animation to card when the user click on the arrow down icon but it not work when I setAnimationListener(this). it error at "this" keyword.
Note I use recycler view and card in the fragment.
here my code below

class ListViewHolder extends RecyclerView.ViewHolder{
        TextView tvTitle, tvDescription;
        ImageView ivDropDown;
        LinearLayout ll_footer;
        Button btnClose;
        Animation slideDown;

        public ListViewHolder(View itemView) {
            super(itemView);
            tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
            tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
            ivDropDown = (ImageView) itemView.findViewById(R.id.iv_arrow_down);
            ll_footer = (LinearLayout) itemView.findViewById(R.id.ll_footer);
            btnClose = (Button) itemView.findViewById(R.id.btn_close);

            btnClose.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
//                    callBack.onButtonCloseClick(getAdapterPosition());
                    ll_footer.setVisibility(View.GONE);
                }
            });

            ivDropDown.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    callBack.onImageClick(getAdapterPosition());
                    slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                    ll_footer.setAnimation(slideDown);
                    slideDown.setAnimationListener();
                    ll_footer.setVisibility(View.VISIBLE);
                }
            });
        }
    }

Body:
You have not start animation.
to do like this:

class ListViewHolder extends RecyclerView.ViewHolder implements Animation.AnimationListener{
    TextView tvTitle, tvDescription;
    ImageView ivDropDown;
    LinearLayout ll_footer;
    Button btnClose;
    Animation slideDown;

    public ListViewHolder(View itemView) {
        super(itemView);
        tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
        tvDescription = (TextView) itemView.findViewById(R.id.tv_description);
        ivDropDown = (ImageView) itemView.findViewById(R.id.iv_arrow_down);
        ll_footer = (LinearLayout) itemView.findViewById(R.id.ll_footer);
        btnClose = (Button) itemView.findViewById(R.id.btn_close);

        btnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                    callBack.onButtonCloseClick(getAdapterPosition());
                ll_footer.setVisibility(View.GONE);
            }
        });

        ivDropDown.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                callBack.onImageClick(getAdapterPosition());
                slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                ll_footer.startAnimation(slideDown);
                slideDown.setAnimationListener(ListViewHolder.this);
                ll_footer.setVisibility(View.VISIBLE);
            }
        });
    }
    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {

    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
}


问:
Can I remote install a free iPhone app using WiFi to iPhones connected to it?
I am trying to install an iPhone app to all users connected to my WiFi. Is there a way by which I can achieve that?</p>

答:
Nope; you can only install a new app through the app store, or through iTunes.

EDIT: if you've jailbroken your iPhone, it looks like you can use Installer.app to install packages over wifi. Check that link for instructions on jailbreaking, and on linking to various package sources. If you set up your server as a source, you could then have users install from that server.

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 2.5


问:
How to make class inner ul li css
The following css style be like this:

```<code>ul {
    padding:0 0 0 0;
    margin:0 0 0 0;
}
#foo li {
   list-style:none;
   margin-bottom:25px;
}
ul li img {
   cursor: pointer;
}
</code>```

The ul li has included:

```<code><ul id="foo" class="row">
  <li class="col-lg-3 col-md-3 ">
  <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
  </li>
</ul>
</code>```

Is it possible to change #ul from id into class ? I tried be like this:

```<code>ul {
  padding:0 0 0 0;
  margin:0 0 0 0;
}
li.bar {
  list-style:none;
  margin-bottom:25px;
}
ul li img {
  cursor: pointer;
}

<ul id="" class="row bar">
  <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
  </li>
</ul>
</code>```

It works but there's something wrong that I think it's not working as well.

答:
Try this instead

```<code>ul.bar li{
    list-style:none;
    margin-bottom:25px;
}
</code>```

Or this

```<code>.bar li{
    list-style:none;
    margin-bottom:25px;
}
</code>```

Title: How to make class inner ul li css

Body:
The following css style be like this:

ul {
    padding:0 0 0 0;
    margin:0 0 0 0;
}
#foo li {
   list-style:none;
   margin-bottom:25px;
}
ul li img {
   cursor: pointer;
}

The ul li has included:

Is it possible to change #ul from id into class ? I tried be like this:

ul {
  padding:0 0 0 0;
  margin:0 0 0 0;
}
li.bar {
  list-style:none;
  margin-bottom:25px;
}
ul li img {
  cursor: pointer;
}

It works but there's something wrong that I think it's not working as well.

Body:
Try this instead

ul.bar li{
    list-style:none;
    margin-bottom:25px;
}

Or this

.bar li{
    list-style:none;
    margin-bottom:25px;
}


问:
Integrate Grunt with Visual Studio publish option
I want to execute grunt task when I publish my web application for either dev/test/production.

Right now, when I build my solution, at that time I've configured to execute grunt task.But,when I publish my web app it doesn't execute even if visual studio builds solution before publishing.

Any idea how can I do this?

答:
You have not specified the Visual Studio version. I found this works with the VS 2015 and .Net core

I have used Grunt & Project.JSON files for accomplishing this.

Grunt.JS

```<code>module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');

    grunt.initConfig({

        uglify: {
            options: {
                mangle: false,
                beautify: true
            },
            my_target: {
                files: {
                    'wwwroot/app/app.js':
                        [
                             'wwwroot/*.js',
                             'wwwroot/services/*.js',
                             'wwwroot/view/**/*.js',
                             'wwwroot/common/*.js'
                        ]
                }
            }
        },

        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'wwwroot/app/app.css':
                    [
                        'wwwroot/*.css',
                        'wwwroot/view/**/*.css'
                    ]
                }
            }
        },

        watch: {
            scripts: {
                files: [
                            'wwwroot/services/*.js',
                            'wwwroot/view/**/*.js',
                            'wwwroot/*.js'
                        ],
                tasks: ['uglify']
            },
            css: {
                files: [
                        'wwwroot/*.css',
                        'wwwroot/view/**/*.css'
                        ],
                tasks: ['cssmin']
            }
        },
        clean: {
            prod: {
               src: ['wwwroot/pdf/*']
            }
        }

    });

    grunt.registerTask('build', ['uglify', 'cssmin', 'clean']);
};
</code>```

Project.Json

```<code>"scripts": {
    "prepublish": [ "grunt build" ]

  }
</code>```

Body:
You have not specified the Visual Studio version. I found this works with the VS 2015 and .Net core

I have used Grunt & Project.JSON files for accomplishing this.

Grunt.JS

module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');

    grunt.initConfig({

        uglify: {
            options: {
                mangle: false,
                beautify: true
            },
            my_target: {
                files: {
                    'wwwroot/app/app.js':
                        [
                             'wwwroot/*.js',
                             'wwwroot/services/*.js',
                             'wwwroot/view/**/*.js',
                             'wwwroot/common/*.js'
                        ]
                }
            }
        },

        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'wwwroot/app/app.css':
                    [
                        'wwwroot/*.css',
                        'wwwroot/view/**/*.css'
                    ]
                }
            }
        },

        watch: {
            scripts: {
                files: [
                            'wwwroot/services/*.js',
                            'wwwroot/view/**/*.js',
                            'wwwroot/*.js'
                        ],
                tasks: ['uglify']
            },
            css: {
                files: [
                        'wwwroot/*.css',
                        'wwwroot/view/**/*.css'
                        ],
                tasks: ['cssmin']
            }
        },
        clean: {
            prod: {
               src: ['wwwroot/pdf/*']
            }
        }

    });

    grunt.registerTask('build', ['uglify', 'cssmin', 'clean']);
};

Project.Json

"scripts": {
    "prepublish": [ "grunt build" ]

  }


问:
Caught a throwable exception during processing Closed Resultset: next
So I did try checking for answers before I could ask this question again, I'm getting a closed ResultSet exception for my code below.
The same code worked on development environment when tested for a small set of records. But on QA environment the exception is encountered for 200-300 records being fetched by the query as well.
My question is, if there is no close statement or close connection code why is the closed resultset exception thrown at the While loop in the code below?</p>

```<code>public void extractRecordsAndUpdateData() throws Throwable {
    ConnectionManager mgr =null;

    /*
    * Some authentication code here for user authentication to allow access in the application
    */

    Connection c = null;
    try {
        mgr = mServiceLocator.getConnectionManager();
    }
    catch (Exception newex) {
        newex.printStackTrace();
        customLogWriter.logEntry("Got a Exception during authentication " + newex.getMessage());
    }

    PreparedStatement pSql = null;
    ResultSet myResultSet = null;

    try {
        c = mgr.getConnection(mgr.getSiteName());
        pSql = c.prepareStatement(extractSQL); // extractSQL is a simple select statement fetching records from DB to be processed in the while loop below.
        myResultSet = pSql.executeQuery();

    }catch(SQLException ex){customLogWriter.logEntry("Error " + ex.getMessage());}

    List<List> outerList=new ArrayList<List>();
    while (myResultSet.next())  // Exception encountered on this line of code
    {
        /*Do some processing*/
    }

    customLogWriter.close();
}
</code>```

答:
Poorly structured exception handling. The ResultSet.next() loop should be inside the try block. You should only have one try and one catch (SQLException ...) here.

Don't write code like this. Code that depends on the success of code in a prior try block should be inside that try block.

Body:
So I did try checking for answers before I could ask this question again, I'm getting a closed ResultSet exception for my code below.
The same code worked on development environment when tested for a small set of records. But on QA environment the exception is encountered for 200-300 records being fetched by the query as well.
My question is, if there is no close statement or close connection code why is the closed resultset exception thrown at the While loop in the code below?

public void extractRecordsAndUpdateData() throws Throwable {
    ConnectionManager mgr =null;

    /*
    * Some authentication code here for user authentication to allow access in the application
    */

    Connection c = null;
    try {
        mgr = mServiceLocator.getConnectionManager();
    }
    catch (Exception newex) {
        newex.printStackTrace();
        customLogWriter.logEntry("Got a Exception during authentication " + newex.getMessage());
    }

    PreparedStatement pSql = null;
    ResultSet myResultSet = null;

    try {
        c = mgr.getConnection(mgr.getSiteName());
        pSql = c.prepareStatement(extractSQL); // extractSQL is a simple select statement fetching records from DB to be processed in the while loop below.
        myResultSet = pSql.executeQuery();

    }catch(SQLException ex){customLogWriter.logEntry("Error " + ex.getMessage());}

    List<List> outerList=new ArrayList<List>();
    while (myResultSet.next())  // Exception encountered on this line of code
    {
        /*Do some processing*/
    }

    customLogWriter.close();
}


问:
C - Linked list segment fault
After putting elements in my linked list, when i want to acces them i got a segmentation fault. I try to insert from the head(head is tete), when reading the element I have no problems only in that function

here is the line that causes segmentation fault error:

```<code>if((p->ID.num)>(p2->ID.num))

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>

        typedef struct identifiant//identifiant
        {
            char section[50];
            int num;
        }identifiant;

         typedef struct Date //DATE
        {
            int jj;
            int mm;
            int an;
        }Date;

           typedef struct notes
        {
            float note;
            struct notes* nnext;
        }notes;

          typedef struct LTE
        {
         identifiant ID;
         char Nom[25];
         char Prenom[25];
         Date Date_naissance;
         notes* Tnotes;
         float Moy;
         struct LTE* next;
        }LTE;

         typedef struct coefs
        {
            int coef;
            struct coefs* next;
        }coefs;
           coefs* COEF;
       LTE* tete;

    int main()
    { int NE,NN;

           LTE* p;
           LTE* n;
           LTE* m;

         coefs* q;
       int i,x;
       x=0;

           NE = Saisie_NE();
         NN = Saisie_NN();

         {
         tete=(LTE*)malloc(sizeof(LTE));
         tete->next=0 ;
         Saisie_E(1,tete,NN);
         for(i=2;i<=NE;i++)
          {
           LTE* tmp=(LTE*)malloc(sizeof(LTE));
           Saisie_E(i,tmp,NN);
           tmp->next=tete;
           tete=tmp;
           }
         }....
         //remplir tabeleau des coefs
         {
          COEF=(coefs*)malloc(sizeof(coefs));
          COEF->next=0 ;
          q=COEF;
         for(i=0;i<NN;i++){
           Saisie_coef(i+1,q,NN,&x);
           coefs* tmp=(coefs*)malloc(sizeof(coefs));
           q->next=tmp;
           q=q->next;
         }
         q->next=0;
         }
         //everything works fine until the this function↓↓↓
         {
             p=tete;

        Trier(p,NE);
     }

//here is the functuion ty guys sorry for bad presentation

    void Trier(LTE* p,int NE)
    {
       int tr,i;
       LTE* q;
       LTE* p1;
       LTE* p2;
       p1=p;
    i=0;
    while(tr!=1)
    {   tr=1;
        p=p1;
        for(i=0;i<NE;i++)
        {   p2=p->next;
    //here is the segment fault error

            if((p->ID.num)>(p2->ID.num))
     {q=p->next->next;
                p->next->next=p;
                p->next=q;
                tr=0;
                }
     p=p->next;
        }
    }
</code>```

答:
The problem lies in the below loop. During the loop iterations, when i == (NE-1), p will be pointing to the last node and p->next will be NULL which gets assigned to p2. So, accessing p2->ID.num leads to segmentation fault.

You can either add a check for p2!=NULL or modify your loop logic to prevent this from happening.

```<code> for(i=0;i<NE;i++)
    {   p2=p->next; /* ==> When p becomes the last node, p2 will become NULL */
//here is the segment fault error

        if((p->ID.num)>(p2->ID.num))
 {q=p->next->next;
            p->next->next=p;
            p->next=q;
            tr=0;
            }
 p=p->next;
    }
</code>```

Title: C - Linked list segment fault

Body:
After putting elements in my linked list, when i want to acces them i got a segmentation fault. I try to insert from the head(head is tete), when reading the element I have no problems only in that function

here is the line that causes segmentation fault error:

if((p->ID.num)>(p2->ID.num))

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>

        typedef struct identifiant//identifiant
        {
            char section[50];
            int num;
        }identifiant;

         typedef struct Date //DATE
        {
            int jj;
            int mm;
            int an;
        }Date;

           typedef struct notes
        {
            float note;
            struct notes* nnext;
        }notes;

          typedef struct LTE
        {
         identifiant ID;
         char Nom[25];
         char Prenom[25];
         Date Date_naissance;
         notes* Tnotes;
         float Moy;
         struct LTE* next;
        }LTE;

         typedef struct coefs
        {
            int coef;
            struct coefs* next;
        }coefs;
           coefs* COEF;
       LTE* tete;

    int main()
    { int NE,NN;

           LTE* p;
           LTE* n;
           LTE* m;

         coefs* q;
       int i,x;
       x=0;

           NE = Saisie_NE();
         NN = Saisie_NN();

         {
         tete=(LTE*)malloc(sizeof(LTE));
         tete->next=0 ;
         Saisie_E(1,tete,NN);
         for(i=2;i<=NE;i++)
          {
           LTE* tmp=(LTE*)malloc(sizeof(LTE));
           Saisie_E(i,tmp,NN);
           tmp->next=tete;
           tete=tmp;
           }
         }....
         //remplir tabeleau des coefs
         {
          COEF=(coefs*)malloc(sizeof(coefs));
          COEF->next=0 ;
          q=COEF;
         for(i=0;i<NN;i++){
           Saisie_coef(i+1,q,NN,&x);
           coefs* tmp=(coefs*)malloc(sizeof(coefs));
           q->next=tmp;
           q=q->next;
         }
         q->next=0;
         }
         //everything works fine until the this function↓↓↓
         {
             p=tete;

        Trier(p,NE);
     }

//here is the functuion ty guys sorry for bad presentation

    void Trier(LTE* p,int NE)
    {
       int tr,i;
       LTE* q;
       LTE* p1;
       LTE* p2;
       p1=p;
    i=0;
    while(tr!=1)
    {   tr=1;
        p=p1;
        for(i=0;i<NE;i++)
        {   p2=p->next;
    //here is the segment fault error

            if((p->ID.num)>(p2->ID.num))
     {q=p->next->next;
                p->next->next=p;
                p->next=q;
                tr=0;
                }
     p=p->next;
        }
    }

Body:
The problem lies in the below loop. During the loop iterations, when i == (NE-1), p will be pointing to the last node and p->next will be NULL which gets assigned to p2. So, accessing p2->ID.num leads to segmentation fault.

You can either add a check for p2!=NULL or modify your loop logic to prevent this from happening.

 for(i=0;i<NE;i++)
    {   p2=p->next; /* ==> When p becomes the last node, p2 will become NULL */
//here is the segment fault error

        if((p->ID.num)>(p2->ID.num))
 {q=p->next->next;
            p->next->next=p;
            p->next=q;
            tr=0;
            }
 p=p->next;
    }


问:
phpunit selenium automated tests
I am setting up automated tests to run on a website to ensure everything still works correctly.  I have a webpage displaying a table of records.

I want to test loading up a chosen webpage.

Select a checkbox for a chosen record

Select the 'Process Selected' button

Enter some dummy text in the textarea

Click Confirm to save the record

I have the first 3 steps completed, but I am stuck on step 4.  Can anyone help out please?
Thanks
Conor

```<code><?php
    class AdminUserProcessSelectedNote extends PHPUnit_Extensions_Selenium2TestCase{
        public function setUp()
        {
            $this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
            $this->setPort(4444); // set port # for connection to selenium server
            $this->setBrowser('firefox'); // set the browser to be used
            $this->setBrowserUrl('http://www.myhost.com/');  // set base URL for tests
        }

        public function testAdminUserProcessSelectedNoteSelectReq3()
        {
            $this->url('index.php'); // Set the URL to access the page
        // Select the specific checkbox with the Id
            $viewReqsCheckbox = $this->byId('jqg_requestGrid_request_4506');
        $viewReqsCheckbox ->click();

        // Now, Select the Process Selected button
            $processSelectedBtn = $this -> byId('processStateChangeButton');
        $processSelectedBtn ->click();

        // Make a note and Confirm
        $this->byName('dlg-stateChange-notes');
        $this->setField('dlg-stateChange-notes','TEST NOTE');
        $this->click('Confirm');
    }
    }
?>
</code>```

答:
// byId,byClassName,byXpath you can set value.</p>

```<code> $this->byId('dlg-stateChange-notes')->value('TEST NOTE');
</code>```

Title: phpunit selenium automated tests

Body:
I am setting up automated tests to run on a website to ensure everything still works correctly.  I have a webpage displaying a table of records.

I want to test loading up a chosen webpage.

Select a checkbox for a chosen record

Select the 'Process Selected' button

Enter some dummy text in the textarea

Click Confirm to save the record

I have the first 3 steps completed, but I am stuck on step 4.  Can anyone help out please?
Thanks
Conor

<?php
    class AdminUserProcessSelectedNote extends PHPUnit_Extensions_Selenium2TestCase{
        public function setUp()
        {
            $this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
            $this->setPort(4444); // set port # for connection to selenium server
            $this->setBrowser('firefox'); // set the browser to be used
            $this->setBrowserUrl('http://www.myhost.com/');  // set base URL for tests
        }

        public function testAdminUserProcessSelectedNoteSelectReq3()
        {
            $this->url('index.php'); // Set the URL to access the page
        // Select the specific checkbox with the Id
            $viewReqsCheckbox = $this->byId('jqg_requestGrid_request_4506');
        $viewReqsCheckbox ->click();

        // Now, Select the Process Selected button
            $processSelectedBtn = $this -> byId('processStateChangeButton');
        $processSelectedBtn ->click();

        // Make a note and Confirm
        $this->byName('dlg-stateChange-notes');
        $this->setField('dlg-stateChange-notes','TEST NOTE');
        $this->click('Confirm');
    }
    }
?>

Body:
// byId,byClassName,byXpath you can set value.

 $this->byId('dlg-stateChange-notes')->value('TEST NOTE');


问:
how to convert JSONOBJECT to JSONARRAY when values are coming in list format?
I'am getting jsonobject as [{"id":"[66]"}] how can i convert to jsonarray?

```<code>Here is my code:
 public Object[] showCampaigns(@RequestParam("selectedAccId") String selectedAccId, HttpSession session, Model model) {
        Object[] responseBody = new Object[1];
        List<Long> accountIds=new ArrayList<>();

        try {
            JSONArray clientjson = new JSONArray(selectedAccId);

            for (int i = 0; i < clientjson.length(); ++i) {
                JSONObject rec = clientjson.getJSONObject(i);
                long id = Long.parseLong(rec.getString("id"));
                accountIds.add(id);
            }
}
</code>```

Error I'am gettinbg is:
Long.parseLong(rec.getString("id")) = >Exception occurred in target VM: For input string: "[66]"<

答:
The value for the key id is, as a string, "[66]", which is not actually parsable as a long.

The problem is not necessarily with your code, but with the server from which this response comes, this is where is should be corrected.

If that is not possible:

You need to fetch this as a string, and parse it your own; here is a regex to strip any non digit.

```<code>...
// strip any non digit
String number = rec.getString("id").replaceAll("\\D+","");

// parse number only string
long id = Long.parseLong(number);
</code>```

source of regex

Body:
I'am getting jsonobject as [{"id":"[66]"}] how can i convert to jsonarray?

Here is my code:
 public Object[] showCampaigns(@RequestParam("selectedAccId") String selectedAccId, HttpSession session, Model model) {
        Object[] responseBody = new Object[1];
        List<Long> accountIds=new ArrayList<>();

        try {
            JSONArray clientjson = new JSONArray(selectedAccId);

            for (int i = 0; i < clientjson.length(); ++i) {
                JSONObject rec = clientjson.getJSONObject(i);
                long id = Long.parseLong(rec.getString("id"));
                accountIds.add(id);
            }
}

Error I'am gettinbg is:
Long.parseLong(rec.getString("id")) = >Exception occurred in target VM: For input string: "[66]"<

Body:
The value for the key id is, as a string, "[66]", which is not actually parsable as a long.

The problem is not necessarily with your code, but with the server from which this response comes, this is where is should be corrected.

If that is not possible:

You need to fetch this as a string, and parse it your own; here is a regex to strip any non digit.

...
// strip any non digit
String number = rec.getString("id").replaceAll("\\D+","");

// parse number only string
long id = Long.parseLong(number);

source of regex


问:
iOS CoreData can't get the property using objective-c
I try to using objective-c write the core data.

My swift code can get the User Entites like below

swift3:

```<code> let appDel = UIApplication.shared.delegate as? AppDelegate;
 guard let context = appDel?.persistentContainer.viewContext else{ return }
 let User = User(context: context);
</code>```

I using objective-c write in the viewdidload.

But I can't persistentContainer property.

like below:

Objective-c

```<code>  UIApplication *application = [UIApplication sharedApplication];

  NSManagedObjectContext *context = (AppDelegate*)(application.delegate).
                                     persistentContainer.viewContext;
</code>```

Have anyone can resolve the problem about can't get persistentContainer property?

I using the Xcode8.2.1 objective-c project.

Thank you very much.

答:
*First we should import core data framework in Appdelegate and set the property of persistentContainer
In Appdelegate.h file

```<code>@property (readonly, strong) NSPersistentContainer *persistentContainer;

- (void)saveContext;
</code>```

In Appdelegate.m file

```<code>@synthesize persistentContainer = _persistentContainer;

- (NSPersistentContainer *)persistentContainer {
    // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
    @synchronized (self) {
        if (_persistentContainer == nil) {
            _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"NSURL"];
            [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
                if (error != nil) {
                    // Replace this implementation with code to handle the error appropriately.
                    // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

                    /*
                     Typical reasons for an error here include:
                     * The parent directory does not exist, cannot be created, or disallows writing.
                     * The persistent store is not accessible, due to permissions or data protection when the device is locked.
                     * The device is out of space.
                     * The store could not be migrated to the current model version.
                     Check the error message to determine what the actual problem was.
                    */
                    NSLog(@"Unresolved error %@, %@", error, error.userInfo);
                    abort();
                }
            }];
        }
    }

    return _persistentContainer;
}

#pragma mark - Core Data Saving support

- (void)saveContext {
    NSManagedObjectContext *context = self.persistentContainer.viewContext;
    NSError *error = nil;
    if ([context hasChanges] && ![context save:&error]) {
        // Replace this implementation with code to handle the error appropriately.
        // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
        NSLog(@"Unresolved error %@, %@", error, error.userInfo);
        abort();
    }
}
</code>```

Body:
I try to using objective-c write the core data.

My swift code can get the User Entites like below

swift3:

 let appDel = UIApplication.shared.delegate as? AppDelegate;
 guard let context = appDel?.persistentContainer.viewContext else{ return }
 let User = User(context: context);

I using objective-c write in the viewdidload.

But I can't persistentContainer property.

like below:

Objective-c

  UIApplication *application = [UIApplication sharedApplication];

  NSManagedObjectContext *context = (AppDelegate*)(application.delegate).
                                     persistentContainer.viewContext;

Have anyone can resolve the problem about can't get persistentContainer property?

I using the Xcode8.2.1 objective-c project.

Thank you very much.

Body:
*First we should import core data framework in Appdelegate and set the property of persistentContainer
In Appdelegate.h file

@property (readonly, strong) NSPersistentContainer *persistentContainer;

- (void)saveContext;

In Appdelegate.m file

@synthesize persistentContainer = _persistentContainer;

- (NSPersistentContainer *)persistentContainer {
    // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
    @synchronized (self) {
        if (_persistentContainer == nil) {
            _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"NSURL"];
            [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
                if (error != nil) {
                    // Replace this implementation with code to handle the error appropriately.
                    // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

                    /*
                     Typical reasons for an error here include:
                     * The parent directory does not exist, cannot be created, or disallows writing.
                     * The persistent store is not accessible, due to permissions or data protection when the device is locked.
                     * The device is out of space.
                     * The store could not be migrated to the current model version.
                     Check the error message to determine what the actual problem was.
                    */
                    NSLog(@"Unresolved error %@, %@", error, error.userInfo);
                    abort();
                }
            }];
        }
    }

    return _persistentContainer;
}

#pragma mark - Core Data Saving support

- (void)saveContext {
    NSManagedObjectContext *context = self.persistentContainer.viewContext;
    NSError *error = nil;
    if ([context hasChanges] && ![context save:&error]) {
        // Replace this implementation with code to handle the error appropriately.
        // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
        NSLog(@"Unresolved error %@, %@", error, error.userInfo);
        abort();
    }
}


问:
codeigniter validation process for checking same data in one table
```<code>$sort_order=$this->input->post('sort_order','Sort Of Category','trim|required|max_length[128]|xss_clean|is_unique[categories.sort_order]');
</code>```

Why is the is_unique function not working here?

答:
```<code>$c_name=$this->input->post('c_name');
$sort_order=$this->input->post('sort_order');

$this->load->library('form_validation');

$this->form_validation->set_rules('c_name','Category Name','trim|required|max_length[128]|xss_clean');
$this->form_validation->set_rules('s_order','Sort Order','Sort Of Category','trim|required|xss_clean|is_unique[categories.sort_order]');
</code>```

Body:
$sort_order=$this->input->post('sort_order','Sort Of Category','trim|required|max_length[128]|xss_clean|is_unique[categories.sort_order]');

Why is the is_unique function not working here?


问:
Fragment won't launch
I have onclicklistener that works. I am trying to launch a new fragment from the button click on the list view. Right now, the fragment does not launch. However, the emulator we are using does not crash, so if we're understanding this correctly, it isn't connecting to the new fragment/XML page.

```<code>  public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l)
{
    myBadData.setId(i);
    Fragment fr = new event_description();
    //fr.setArguments(bundle);
    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    //int contId = v.getId();
    fragmentTransaction.add(R.id.page, fr);
   // fragmentTransaction.add(view.getId(), fr);
   // fragmentTransaction.commit();

    Intent intent =new Intent(eventList.this, fr.getClass());

}
</code>```

Here is our XML code for the view that we are trying to add the fragment over top of.

```<code><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/page"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context="com.example.alex.qtapandroid.ui.fragments.DayFragment">

<!-- TODO: Update blank fragment layout -->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" />

    <ListView
        android:id="@+id/dayList"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

 </FrameLayout>
</code>```

答:
You should be using commit() to start your transaction, not an Intent(), you also want to use replace() not add():

```<code> public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l)
{
    //Assuming that this creates a new fragment
    Fragment fr = new event_description();
    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    fragmentTransaction.replace(R.id.page, fr, "TAG ID");
    fragmentTransaction.commit();
}
</code>```

Title: Fragment won't launch

Body:
I have onclicklistener that works. I am trying to launch a new fragment from the button click on the list view. Right now, the fragment does not launch. However, the emulator we are using does not crash, so if we're understanding this correctly, it isn't connecting to the new fragment/XML page.

  public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l)
{
    myBadData.setId(i);
    Fragment fr = new event_description();
    //fr.setArguments(bundle);
    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    //int contId = v.getId();
    fragmentTransaction.add(R.id.page, fr);
   // fragmentTransaction.add(view.getId(), fr);
   // fragmentTransaction.commit();

    Intent intent =new Intent(eventList.this, fr.getClass());

}

Here is our XML code for the view that we are trying to add the fragment over top of.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/page"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context="com.example.alex.qtapandroid.ui.fragments.DayFragment">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" />

    <ListView
        android:id="@+id/dayList"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

 </FrameLayout>

Body:
You should be using commit() to start your transaction, not an Intent(), you also want to use replace() not add():

 public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l)
{
    //Assuming that this creates a new fragment
    Fragment fr = new event_description();
    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    fragmentTransaction.replace(R.id.page, fr, "TAG ID");
    fragmentTransaction.commit();
}


问:
How to format date from database in Yii2
If I have function like this

protected function getAreaValues($model)
 {
  return
  [
   [
    $model->getAttributeLabel('EXPDATE'),TbArea::findOne($model->KODE)->EXPDATE
   ],

  ];
 }```
</div>
</div>
</p>

<p>where EXPDATE IS date data</p>

<p>How to format it in d-M-Y ?</p>

<p>I add formatter in web.php in config like this</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>  'formatter' => [
   'class' => 'yii\i18n\Formatter',
   'nullDisplay' => '-',
   'dateFormat' => 'd-M-Y',
   'datetimeFormat' => 'd-M-Y H:i:s',
   'timeFormat' => 'H:i:s',
  ],</code>```

But still not working

答:
I think this will work</p>

```<code>$DateTime = DateTime::createFromFormat('Y-m-d', $yourOldDateString);
$newDateString = $DateTime->format('d/M/Y');
</code>```

Body:
If I have function like this

protected function getAreaValues($model)
 {
  return
  [
   [
    $model->getAttributeLabel('EXPDATE'),TbArea::findOne($model->KODE)->EXPDATE
   ],

  ];
 }

where EXPDATE IS date data

How to format it in d-M-Y ?

I add formatter in web.php in config like this

  'formatter' => [
   'class' => 'yii\i18n\Formatter',
   'nullDisplay' => '-',
   'dateFormat' => 'd-M-Y',
   'datetimeFormat' => 'd-M-Y H:i:s',
   'timeFormat' => 'H:i:s',
  ],

But still not working

Body:
I think this will work

$DateTime = DateTime::createFromFormat('Y-m-d', $yourOldDateString);
$newDateString = $DateTime->format('d/M/Y');


问:
Linker "Duplicate Symbol" error due to circular reference
I have two header of a class and it's extension(generated by Xcode for NSManaged object). But I'm getting a linker error and I figured out it was due to a circular reference.

Conversation+CoreDataClass.h

```<code>NS_ASSUME_NONNULL_BEGIN

@interface Conversation : NSManagedObject

@end

NS_ASSUME_NONNULL_END

#import "Conversation+CoreDataProperties.h"
</code>```

Conversation+CoreDataProperties.h

```<code>#import "Conversation+CoreDataClass.h"

NS_ASSUME_NONNULL_BEGIN

@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end

NS_ASSUME_NONNULL_END
</code>```

You can clearly see the circular reference here. I found this question where the problem was to add a @class declaration and remove the header. So I commented out the import statement in the Conversation+CoreDataProperties.h and added @class Conversation;. Now two errors pop up saying it's an undefined class. Have attached the screenshot of the error below. I don't quite understand why this is happening and what I need to do to fix it. Any help is much appreciated. Thanks!

Linker error

duplicate symbol _OBJC_CLASS_$_Conversation in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/Conversation+CoreDataClass.o
  duplicate symbol _OBJC_METACLASS_$_Conversation in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/Conversation+CoreDataClass.o
  duplicate symbol _OBJC_CLASS_$_ConversationDate in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/ConversationDate+CoreDataClass.o
  duplicate symbol _OBJC_METACLASS_$_ConversationDate in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/ConversationDate+CoreDataClass.o
  ld: 4 duplicate symbols for architecture arm64 clang: error: linker
  command failed with exit code 1 (use -v to see invocation)

答:
the duplicate symbols warning do result because

You have the class multiple times in your project and the compiler does not know, which to choose (then it is mostly a duplicate linking error)

There is something wrong with your ConversationDate+CoreDataClass

Just a question that raised from your source code: why do you import an extension of the class you want to extend?

```<code>#import "Conversation+CoreDataClass.h"
@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end
</code>```

All the extension class usually needs to know are basically the classes they extend:

```<code>#import "Conversation.h"
@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end
</code>```

Only the implementation file (.m) would have to import the header file. E.g:

```<code>#import "Conversation+CoreDataClass.h"
@implementation Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest {
    // body
    return nil;
}

@end
</code>```

And last question: Are you sure there exists no other class extension with the same name in your project? CoreData might also have created them itself.

Please have a look in your xCode Project like this:

Body:
I have two header of a class and it's extension(generated by Xcode for NSManaged object). But I'm getting a linker error and I figured out it was due to a circular reference.

Conversation+CoreDataClass.h

NS_ASSUME_NONNULL_BEGIN

@interface Conversation : NSManagedObject

@end

NS_ASSUME_NONNULL_END

#import "Conversation+CoreDataProperties.h"

Conversation+CoreDataProperties.h

#import "Conversation+CoreDataClass.h"

NS_ASSUME_NONNULL_BEGIN

@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end

NS_ASSUME_NONNULL_END

You can clearly see the circular reference here. I found this question where the problem was to add a @class declaration and remove the header. So I commented out the import statement in the Conversation+CoreDataProperties.h and added @class Conversation;. Now two errors pop up saying it's an undefined class. Have attached the screenshot of the error below. I don't quite understand why this is happening and what I need to do to fix it. Any help is much appreciated. Thanks!

Linker error

duplicate symbol _OBJC_CLASS_$_Conversation in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/Conversation+CoreDataClass.o
  duplicate symbol _OBJC_METACLASS_$_Conversation in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/Conversation+CoreDataClass.o
  duplicate symbol _OBJC_CLASS_$_ConversationDate in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/ConversationDate+CoreDataClass.o
  duplicate symbol _OBJC_METACLASS_$_ConversationDate in:
      /Users/xxx/Library/Developer/Xcode/DerivedData/xxx-gbhivuwptwzhkldfbmjghkokozgn/Build/Intermediates/xxx.build/Debug-iphoneos/xxx.build/Objects-normal/arm64/ConversationDate+CoreDataClass.o
  ld: 4 duplicate symbols for architecture arm64 clang: error: linker
  command failed with exit code 1 (use -v to see invocation)

Body:
the duplicate symbols warning do result because

You have the class multiple times in your project and the compiler does not know, which to choose (then it is mostly a duplicate linking error)

There is something wrong with your ConversationDate+CoreDataClass

Just a question that raised from your source code: why do you import an extension of the class you want to extend?

#import "Conversation+CoreDataClass.h"
@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end

All the extension class usually needs to know are basically the classes they extend:

#import "Conversation.h"
@interface Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest;

@end

Only the implementation file (.m) would have to import the header file. E.g:

#import "Conversation+CoreDataClass.h"
@implementation Conversation (CoreDataProperties)

+ (NSFetchRequest<Conversation *> *)fetchRequest {
    // body
    return nil;
}

@end

And last question: Are you sure there exists no other class extension with the same name in your project? CoreData might also have created them itself.

Please have a look in your xCode Project like this:


问:
Reducing repeated information in database design
I am designing an application that when users create a new account, their account is populated with several hundred rows of data (predefined options, settings, etc). Most of the users will rarely, if ever, change the information contained in these tables. Are there any good design patterns to reduce the amount of duplicated data in the database tables?

Some ideas I had so far:

Keep the predefined options in their
own tables, and only save custom
options to the user tables. This
would seem to reduce the overhead,
but I can see the database calls
getting really tricky.

Create a new
database for every 100 users or so,
with a separate database for accounts
that points to the users database.
This is, well, not optimal.

Idea 3?

答:
look at the statistics of use of the fields and cluster the ones together that are commonly changed so that if there is no record for that user for those less often changed fields that they fall back to the defaults

i think there was a way with a join or something to do defaults like that


问:
Converting Text to Image on iOS
How to convert Text to Image and show in UIImageview.
Can anyone know the conversion from Text to Image?</p>

答:
SWIFT 3 :

Create an extension for UIImage so that you can use it everywhere:

```<code>extension UIImage {
    class func imageWithLabel(label: UILabel) -> UIImage {
        UIGraphicsBeginImageContextWithOptions(label.bounds.size, false, 0.0)
        label.layer.render(in: UIGraphicsGetCurrentContext()!)
        let img = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return img!
   }
}
</code>```

Now where ever you need to use this to create an image from Text :

// This customisation of label is according to your needs which font , what background color you need. Feel free to change.

```<code>let label = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 20))
label.numberOfLines = 0
label.textAlignment = .center
label.textColor = UIColor.white
label.backgroundColor = UIColor.black
label.font = UIFont(name: "Montserrat", size: 17)
label.text = "YOUR TEXT HERE"
label.sizeToFit()
let image = UIImage.imageWithLabel(label: label)
</code>```

Title: Converting Text to Image on iOS

Body:
SWIFT 3 :

Create an extension for UIImage so that you can use it everywhere:

extension UIImage {
    class func imageWithLabel(label: UILabel) -> UIImage {
        UIGraphicsBeginImageContextWithOptions(label.bounds.size, false, 0.0)
        label.layer.render(in: UIGraphicsGetCurrentContext()!)
        let img = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return img!
   }
}

Now where ever you need to use this to create an image from Text :

// This customisation of label is according to your needs which font , what background color you need. Feel free to change.

let label = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 20))
label.numberOfLines = 0
label.textAlignment = .center
label.textColor = UIColor.white
label.backgroundColor = UIColor.black
label.font = UIFont(name: "Montserrat", size: 17)
label.text = "YOUR TEXT HERE"
label.sizeToFit()
let image = UIImage.imageWithLabel(label: label)


问:
Print shell environment functions on a single line
In bash, running set will display all environment settings. I want to display my functions as a single line for each function. So instead of running set and getting this (for example):

```<code>gcm ()
{
    git commit -m "$@";
    git --no-pager log -1 | grep --color ^commit
}
gcma ()
{
    git commit -a -m "$@";
    git --no-pager log -1 | grep --color ^commit
}
</code>```

I want to see this:

```<code>gcm () { git commit -m "$@"; git --no-pager log -1 | grep --color ^commit }
gcma () { git commit -a -m "$@"; git --no-pager log -1 | grep --color ^commit }
</code>```

So I think I want a sed/awk command that will look for regex ' ()$' and concatenate every line following (with a space separation char) until the regex '^}$' is matched, and anything else should just print as is.

UPDATE: All of the examples submitted so far take all the input and render it on a single line, and that's not exactly right. I want each function (the set of ' ()$' to '^}$', inclusive) as a single line.

答:
Small sed script

Try this:

```<code>declare -f gcm gcma dequote quote |
    sed '1h;1!H;/^}$/!d;s/.//;x;s/\n[ \o11]*//g;s/}$/;}/'
</code>```

may render:

```<code>gcm () { git commit -m "$@";git --no-pager log -1 | grep --color ^commit;}
gcma () { git commit -a -m "$@";git --no-pager log -1 | grep --color ^commit;}
quote () { local quoted=${1//\'/\'\\\'\'};printf "'%s'" "$quoted";}
dequote () { eval printf %s "$1" 2> /dev/null;}
</code>```

I've added semi-column in order to be able to source the output.

Stronger

This version will parse output of set command without argument and take all, but only functions:

```<code>set | sed '/^[a-z0-9A-Z_.-]\+ () *$/,/^}$/{ //{ /()/{h;d;}};H ;/^}$/!d;g;s/\n[ \o11]*//g;s/}$/;}/;p;};d'
</code>```

This could by written:

```<code>set | sed '
    /^[a-z0-9A-Z_.-]\+ () *$/,/^}$/{
      //{
        /()/ {
            h;
            d;
          };
      };
      H;
      /^}$/!d;
      g;
      s/\n[ \o11]*//g;
      s/}$/;}/;
      p;
    };
    d;
'
</code>```

Note: [a-z0-9A-Z_.-]\+ is not well validated: I'm not completely sure about what a function name could contain.

Detailled explanation

There is a runnable sed script with line by line explanation

```<code>#!/bin/sed -nf
# -n modifier won't output anything without explicit 'p' command

/^[a-z0-9A-Z_.-]\+ () *$/ , /^}$/ { # from lines beginning by funcname, to ^}$
    //{                # At first or last line of block...
        /()/{          # If containing '()',
            h;         # place this line in hold space,
            d;         # then delete (go to next line)
        };
    };
    H;                 # Append to hold space
    /^}$/!d;           # If not '^}$', delete this line (go to next line)
    g;                 # replace current line by hold space
    s/\n[ \o11]*//g;   # Suppress each new line and following spaces or tabs
    s/}$/;}/;          # Add semi-colon before last '}' in order to source
    p;                 # print
}
</code>```

Copy this to a file you could call bashFuncToOneLine.sed then chmod +x spacebashFuncToOneLine.sed

```<code>declare -f gcm{,a}  | ./bashFuncToOneLine.sed
gcm () { git commit -m "$@";git --no-pager log -1 | grep --color ^commit;}
gcma () { git commit -a -m "$@";git --no-pager log -1 | grep --color ^commit;}

set | ./bashFuncToOneLine.sed | less -S
</code>```

Body:
In bash, running set will display all environment settings. I want to display my functions as a single line for each function. So instead of running set and getting this (for example):

gcm ()
{
    git commit -m "$@";
    git --no-pager log -1 | grep --color ^commit
}
gcma ()
{
    git commit -a -m "$@";
    git --no-pager log -1 | grep --color ^commit
}

I want to see this:

gcm () { git commit -m "$@"; git --no-pager log -1 | grep --color ^commit }
gcma () { git commit -a -m "$@"; git --no-pager log -1 | grep --color ^commit }

So I think I want a sed/awk command that will look for regex ' ()$' and concatenate every line following (with a space separation char) until the regex '^}$' is matched, and anything else should just print as is.

UPDATE: All of the examples submitted so far take all the input and render it on a single line, and that's not exactly right. I want each function (the set of ' ()$' to '^}$', inclusive) as a single line.

Body:
Small sed script

Try this:

declare -f gcm gcma dequote quote |
    sed '1h;1!H;/^}$/!d;s/.//;x;s/\n[ \o11]*//g;s/}$/;}/'

may render:

gcm () { git commit -m "$@";git --no-pager log -1 | grep --color ^commit;}
gcma () { git commit -a -m "$@";git --no-pager log -1 | grep --color ^commit;}
quote () { local quoted=${1//\'/\'\\\'\'};printf "'%s'" "$quoted";}
dequote () { eval printf %s "$1" 2> /dev/null;}

I've added semi-column in order to be able to source the output.

Stronger

This version will parse output of set command without argument and take all, but only functions:

set | sed '/^[a-z0-9A-Z_.-]\+ () *$/,/^}$/{ //{ /()/{h;d;}};H ;/^}$/!d;g;s/\n[ \o11]*//g;s/}$/;}/;p;};d'

This could by written:

set | sed '
    /^[a-z0-9A-Z_.-]\+ () *$/,/^}$/{
      //{
        /()/ {
            h;
            d;
          };
      };
      H;
      /^}$/!d;
      g;
      s/\n[ \o11]*//g;
      s/}$/;}/;
      p;
    };
    d;
'

Note: [a-z0-9A-Z_.-]\+ is not well validated: I'm not completely sure about what a function name could contain.

Detailled explanation

There is a runnable sed script with line by line explanation

#!/bin/sed -nf
# -n modifier won't output anything without explicit 'p' command

/^[a-z0-9A-Z_.-]\+ () *$/ , /^}$/ { # from lines beginning by funcname, to ^}$
    //{                # At first or last line of block...
        /()/{          # If containing '()',
            h;         # place this line in hold space,
            d;         # then delete (go to next line)
        };
    };
    H;                 # Append to hold space
    /^}$/!d;           # If not '^}$', delete this line (go to next line)
    g;                 # replace current line by hold space
    s/\n[ \o11]*//g;   # Suppress each new line and following spaces or tabs
    s/}$/;}/;          # Add semi-colon before last '}' in order to source
    p;                 # print
}

Copy this to a file you could call bashFuncToOneLine.sed then chmod +x spacebashFuncToOneLine.sed

declare -f gcm{,a}  | ./bashFuncToOneLine.sed
gcm () { git commit -m "$@";git --no-pager log -1 | grep --color ^commit;}
gcma () { git commit -a -m "$@";git --no-pager log -1 | grep --color ^commit;}

set | ./bashFuncToOneLine.sed | less -S


问:
Spring boot with Zuul proxy crashes on Maven, while Gradle works
I have a Spring boot project which is built with Gradle.

I need to migrate it to Maven, which I thought would be easy (should be), but I've encountered an issue in the Zuul depedency, or to be exact: spring-cloud-starter-zuul.

When I run the Spring boot application with the annotation @EnableZuulProxy it produces the following error:

```<code>2017-03-30 00:02:57.521  WARN 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-03-30 00:02:57.521  INFO 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2017-03-30 00:02:57.532  INFO 11380 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@df85e3e
2017-03-30 00:02:57.556 ERROR 11380 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulFilterConfiguration': Unsatisfied dependency expressed through field 'filters'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleHostRoutingFilter' defined in org.springframework.cloud.netflix.zuul.ZuulProxyConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter]: Factory method 'simpleHostRoutingFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
2017-03-30 00:02:57.588  WARN 11380 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-03-30 00:02:57.588 ERROR 11380 --- [           main] o.s.boot.SpringApplication               : Application startup failed
</code>```

The error only occurs on the Maven build, which narrow the problem to the pom.xml file vs build.gradle which does run.

After tinkering with the working build.gradle file, I've managed to produce the error when commenting out this part:

```<code>buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
    }
}
apply plugin: 'org.springframework.boot'
</code>```

So the issue is I don't use the plugin in my maven file?

pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>aaa</groupId>
    <artifactId>helloZuul</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.3.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.4.3.RELEASE</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-zuul -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>
    </dependencies>
</project>
</code>```

build.gradle

```<code>group 'aaa'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

sourceCompatibility = 1.8

jar {
    baseName = 'gs-rest-service'
    version = '0.1.0'
}

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile "org.springframework.boot:spring-boot-starter-web:1.4.3.RELEASE"
    compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zuul', version: '1.2.6.RELEASE'
}
</code>```

How can I make my maven project run? Or more specifically, what is the purpose of the spring boot gradle plugin?

Any help will be greatly appreciated!

答:
You need to add dependency management in your pom.xml like below.</p>

```<code><dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
</code>```

Body:
I have a Spring boot project which is built with Gradle.

I need to migrate it to Maven, which I thought would be easy (should be), but I've encountered an issue in the Zuul depedency, or to be exact: spring-cloud-starter-zuul.

When I run the Spring boot application with the annotation @EnableZuulProxy it produces the following error:

2017-03-30 00:02:57.521  WARN 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2017-03-30 00:02:57.521  INFO 11380 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2017-03-30 00:02:57.532  INFO 11380 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@df85e3e
2017-03-30 00:02:57.556 ERROR 11380 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulFilterConfiguration': Unsatisfied dependency expressed through field 'filters'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleHostRoutingFilter' defined in org.springframework.cloud.netflix.zuul.ZuulProxyConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter]: Factory method 'simpleHostRoutingFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
2017-03-30 00:02:57.588  WARN 11380 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-03-30 00:02:57.588 ERROR 11380 --- [           main] o.s.boot.SpringApplication               : Application startup failed

The error only occurs on the Maven build, which narrow the problem to the pom.xml file vs build.gradle which does run.

After tinkering with the working build.gradle file, I've managed to produce the error when commenting out this part:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
    }
}
apply plugin: 'org.springframework.boot'

So the issue is I don't use the plugin in my maven file?

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>aaa</groupId>
    <artifactId>helloZuul</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.3.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.4.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zuul</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>
    </dependencies>
</project>

build.gradle

group 'aaa'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

sourceCompatibility = 1.8

jar {
    baseName = 'gs-rest-service'
    version = '0.1.0'
}

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile "org.springframework.boot:spring-boot-starter-web:1.4.3.RELEASE"
    compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zuul', version: '1.2.6.RELEASE'
}

How can I make my maven project run? Or more specifically, what is the purpose of the spring boot gradle plugin?

Any help will be greatly appreciated!

Body:
You need to add dependency management in your pom.xml like below.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>


问:
how to multiply ith maximum element in two list , and then get summation of the results
list1=[1,2,3,4,5,6,7]
list2=[6,4,5]
I want to compute multiplication of ith maximum element pair from the two list, and then summation of the results, like 6*7+5*6+4*5.
Is there any python trick with short coding.</p>

答:
```<code>>>> a=[1,2,3,4,5,6,7]
>>> b=[6,4,5]
>>> sum([x*y for x,y in zip(sorted(a, reverse=True), sorted(b, reverse=True))])
92
</code>```

or

```<code>sum(map(lambda a, b: a*b, sorted(a, reverse=True), sorted(b, reverse=True)))
</code>```

There are no special tricks, get familiar with some common functions in python, such as map, sum, sorted, lambda, or more on itertools and functools. And learn some haskell...

Body:
>>> a=[1,2,3,4,5,6,7]
>>> b=[6,4,5]
>>> sum([x*y for x,y in zip(sorted(a, reverse=True), sorted(b, reverse=True))])
92

or

sum(map(lambda a, b: a*b, sorted(a, reverse=True), sorted(b, reverse=True)))

There are no special tricks, get familiar with some common functions in python, such as map, sum, sorted, lambda, or more on itertools and functools. And learn some haskell...


答:
```<code>list1=[1,2,3,4,5,6,7]
list2=[6,4,5]

sum(reduce(lambda a,b:a*b, i, 1) for i in zip(sorted(list1, reverse=True), sorted(list2, reverse=True)))
>>> 92
</code>```

Title: how to multiply ith maximum element in two list , and then get summation of the results

Body:
list1=[1,2,3,4,5,6,7]
list2=[6,4,5]
I want to compute multiplication of ith maximum element pair from the two list, and then summation of the results, like 6*7+5*6+4*5.
Is there any python trick with short coding.


问:
Spring Cloud Data Flow app with separate sink and source
I have this application that would like to deploy using SCDF. It receives a message (sink), processes it asynchronously through a non deterministic or simple pipeline system. At the end, it might or migh not produce an output. If an output is produced I would like to produce a message (source) for other applications to consume. The application can not be splitted into more than one jvm, but more than one instance can be running with no problems. I have found examples that have a source and sink on the same app, but they are connected end to end, wich is not my case. Anybody has solve this problem, any hints?</p>

答: You might be looking at something similar to what is discussed here: https://github.com/spring-cloud/spring-cloud-dataflow/issues/915.</p>


问:
How to make class inner ul li css
The following css style be like this:

```<code>ul {
    padding:0 0 0 0;
    margin:0 0 0 0;
}
#foo li {
   list-style:none;
   margin-bottom:25px;
}
ul li img {
   cursor: pointer;
}
</code>```

The ul li has included:

```<code><ul id="foo" class="row">
  <li class="col-lg-3 col-md-3 ">
  <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
  </li>
</ul>
</code>```

Is it possible to change #ul from id into class ? I tried be like this:

```<code>ul {
  padding:0 0 0 0;
  margin:0 0 0 0;
}
li.bar {
  list-style:none;
  margin-bottom:25px;
}
ul li img {
  cursor: pointer;
}

<ul id="" class="row bar">
  <li class="col-lg-3 col-md-3 ">
    <img class="img-responsive" src="images/photodune-174908-rocking-the-night-away-xs.jpg">
  </li>
</ul>
</code>```

It works but there's something wrong that I think it's not working as well.

答:
Since your li tag doesn't have the .bar class it can't work.

If you want to style the li change the css to:

```<code>.bar li {
    list-style:none;
    margin-bottom:25px;
}
</code>```

or

if you want to style the ul change the css to:

```<code>ul.bar {
    list-style:none;
    margin-bottom:25px;
}
</code>```

With your css code you style a li tag with the .bar class.

Title: How to make class inner ul li css

Body:
The following css style be like this:

ul {
    padding:0 0 0 0;
    margin:0 0 0 0;
}
#foo li {
   list-style:none;
   margin-bottom:25px;
}
ul li img {
   cursor: pointer;
}

The ul li has included:

Is it possible to change #ul from id into class ? I tried be like this:

ul {
  padding:0 0 0 0;
  margin:0 0 0 0;
}
li.bar {
  list-style:none;
  margin-bottom:25px;
}
ul li img {
  cursor: pointer;
}

It works but there's something wrong that I think it's not working as well.

Body:
Since your li tag doesn't have the .bar class it can't work.

If you want to style the li change the css to:

.bar li {
    list-style:none;
    margin-bottom:25px;
}

or

if you want to style the ul change the css to:

ul.bar {
    list-style:none;
    margin-bottom:25px;
}

With your css code you style a li tag with the .bar class.


问:
Can I remote install a free iPhone app using WiFi to iPhones connected to it?
I am trying to install an iPhone app to all users connected to my WiFi. Is there a way by which I can achieve that?</p>

答: No, you can't. You can install app only from iTunes; Apple is very strict in that.</p>


答:
you are trying to parse the String having '[66]' to Long.

You can only transform string which are having only digits to Long

```<code> long id = Long.parseLong(rec.getString("id"));
</code>```

visualize this code as

```<code> long id = Long.parseLong("[66]");
</code>```

Beacuse of this you are getting the issue.

Try to use something like this to remove all punctuation from string including opening and closing brackets.

```<code>String stringId= rec.getString("id").replaceAll("\\p{P}","");
 long id = Long.parseLong(stringId);
</code>```

Title: how to convert JSONOBJECT to JSONARRAY when values are coming in list format?

Body:
I'am getting jsonobject as [{"id":"[66]"}] how can i convert to jsonarray?

Here is my code:
 public Object[] showCampaigns(@RequestParam("selectedAccId") String selectedAccId, HttpSession session, Model model) {
        Object[] responseBody = new Object[1];
        List<Long> accountIds=new ArrayList<>();

        try {
            JSONArray clientjson = new JSONArray(selectedAccId);

            for (int i = 0; i < clientjson.length(); ++i) {
                JSONObject rec = clientjson.getJSONObject(i);
                long id = Long.parseLong(rec.getString("id"));
                accountIds.add(id);
            }
}

Error I'am gettinbg is:
Long.parseLong(rec.getString("id")) = >Exception occurred in target VM: For input string: "[66]"<

Body:
you are trying to parse the String having '[66]' to Long.

You can only transform string which are having only digits to Long

 long id = Long.parseLong(rec.getString("id"));

visualize this code as

 long id = Long.parseLong("[66]");

Beacuse of this you are getting the issue.

Try to use something like this to remove all punctuation from string including opening and closing brackets.

String stringId= rec.getString("id").replaceAll("\\p{P}","");
 long id = Long.parseLong(stringId);


问:
Xamarin remove storyboard
I followed tutorial to create mvvmcross solution. All works well, but I notice there is FirstView (with xib/cs/designer.cs) and also there is Storyboard. How can I remove the storyboard and use purely xibs on this project?

I tried deleted the Main.storyboard and ViewController.cs/designer.cs but that just crash the app and not loading the FirstView at all. Help!

答:
If you remove the Storyboard you need to also update the info.Plist file.

Remove the text Main from the Main Interface

Now you will need to update the AppDelegate of your app to set your ViewController as the RootViewController (the ViewController the App will call when it finished loading).

To make this update your FinishedLaunching method with code like this:

```<code>public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    Window = new UIWindow (UIScreen.MainScreen.Bounds);
    Window.RootViewController = new YourViewController ();
    Window.MakeKeyAndVisible ();

    return true;
}
</code>```

This should work.

Title: Xamarin remove storyboard

Body:
If you remove the Storyboard you need to also update the info.Plist file.

Remove the text Main from the Main Interface

Now you will need to update the AppDelegate of your app to set your ViewController as the RootViewController (the ViewController the App will call when it finished loading).

To make this update your FinishedLaunching method with code like this:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    Window = new UIWindow (UIScreen.MainScreen.Bounds);
    Window.RootViewController = new YourViewController ();
    Window.MakeKeyAndVisible ();

    return true;
}

This should work.