问:
Audio is overlapping when incoming call answered by specific audio
I'm trying to play audio file when incoming call is received by code.The problem is that when the incoming call is received , the audio file start playing two times or overlapping the voice. Also the issue is After ending call the audio file doesn't pause or stop it will keep playing until audio file not ends.
The code  i have tried for this is as below:

```<code>    public void onReceive(final Context context, Intent intent) {

     try{
        final MediaPlayer mp= MediaPlayer.create(context,R.raw.audio);

        String state= intent.getStringExtra(TelephonyManager.EXTRA_STATE);
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
            Toast.makeText(context, "Ringing!", Toast.LENGTH_SHORT).show();

            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent1 = new Intent(context, AcceptCall.class);
                    intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                            | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                    context.startActivity(intent1);

                        mp.setLooping(false);
                        mp.start();

                    }

            }, 4000);

        }
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)){
            Toast.makeText(context, "Received!", Toast.LENGTH_SHORT).show();
        }
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)){

            try{
                mp.reset();
                mp.pause();
                mp.seekTo(0);

                Toast.makeText(context, "Idle!", Toast.LENGTH_SHORT).show();
            }catch(Exception e){e.printStackTrace();}

        }

    }catch (Exception e){
        e.printStackTrace();
    }

}
</code>```

Help me out from this

答:
First of all you are not releasing the same MediaPlayer instance as you created before.

A call to MediaPlayer.create(context,R.raw.audio); will create a new MediaPlayer instance each time. So in effect first time you receive broadcast EXTRA_STATE_RINGING you start MP_1 second time when you receive EXTRA_STATE_IDLE you create a new MP_2 and stop/release that instance. Instead keep MediaPlayer reference in your BroadCast class and only create one in TelephonyManager.EXTRA_STATE_RINGING. Like so:

```<code>if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
        Toast.makeText(context, "Ringing!", Toast.LENGTH_SHORT).show();
        mp= MediaPlayer.create(context,R.raw.audio);

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent1 = new Intent(context, AcceptCall.class);
                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                        | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                context.startActivity(intent1);

                    mp.setLooping(false);
                    mp.start();

                }

        }, 4000);

    }

    if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)){

        try{
            mp.stop();
            mp.release();

            Toast.makeText(context, "Idle!", Toast.LENGTH_SHORT).show();
        }catch(Exception e){e.printStackTrace();}

    }
</code>```

So later when you release it in TelephonyManager.EXTRA_STATE_IDLE you release and stop the same one.

Also note that I've also replaced mp.reset()....

Body:
I'm trying to play audio file when incoming call is received by code.The problem is that when the incoming call is received , the audio file start playing two times or overlapping the voice. Also the issue is After ending call the audio file doesn't pause or stop it will keep playing until audio file not ends.
The code  i have tried for this is as below:

    public void onReceive(final Context context, Intent intent) {

     try{
        final MediaPlayer mp= MediaPlayer.create(context,R.raw.audio);

        String state= intent.getStringExtra(TelephonyManager.EXTRA_STATE);
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
            Toast.makeText(context, "Ringing!", Toast.LENGTH_SHORT).show();

            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent1 = new Intent(context, AcceptCall.class);
                    intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                            | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                    context.startActivity(intent1);

                        mp.setLooping(false);
                        mp.start();

                    }

            }, 4000);

        }
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)){
            Toast.makeText(context, "Received!", Toast.LENGTH_SHORT).show();
        }
        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)){

            try{
                mp.reset();
                mp.pause();
                mp.seekTo(0);

                Toast.makeText(context, "Idle!", Toast.LENGTH_SHORT).show();
            }catch(Exception e){e.printStackTrace();}

        }

    }catch (Exception e){
        e.printStackTrace();
    }

}

Help me out from this

Body:
First of all you are not releasing the same MediaPlayer instance as you created before.

A call to MediaPlayer.create(context,R.raw.audio); will create a new MediaPlayer instance each time. So in effect first time you receive broadcast EXTRA_STATE_RINGING you start MP_1 second time when you receive EXTRA_STATE_IDLE you create a new MP_2 and stop/release that instance. Instead keep MediaPlayer reference in your BroadCast class and only create one in TelephonyManager.EXTRA_STATE_RINGING. Like so:

if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
        Toast.makeText(context, "Ringing!", Toast.LENGTH_SHORT).show();
        mp= MediaPlayer.create(context,R.raw.audio);

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent1 = new Intent(context, AcceptCall.class);
                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
                        | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                context.startActivity(intent1);

                    mp.setLooping(false);
                    mp.start();

                }

        }, 4000);

    }

    if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)){

        try{
            mp.stop();
            mp.release();

            Toast.makeText(context, "Idle!", Toast.LENGTH_SHORT).show();
        }catch(Exception e){e.printStackTrace();}

    }

So later when you release it in TelephonyManager.EXTRA_STATE_IDLE you release and stop the same one.

Also note that I've also replaced mp.reset()....


来源: stackexchange

问:
Debatch the Incoming message and create fixed batch of input messages in the orchestration?
http://blogs.msdn.com/b/brajens/archive/2006/07/20/biztalk-custom-receive-pipeline-component-to-batch-messages.aspx

I am following above article, but i want to implement this in orchestration

How can i implement this please advise, here are the some of thoughts i know.

Using foreach loop.

 a)read each single message and added to
new message until it reaches the
fixed batch

   b) using xpath position  /[local-name()='Root' and
namespace-uri()='http://mycompany.com']/[local-name()='content'
and namespace-uri()='' and position()   >= 0 and position < fixed size] (Which is not working)

Call the Custom pipline component ( like above)

First of all thanks guyz for all your valuable replies,

Right now I implemented this in the orchestration using foreach loop, xpath(toget count and single input node) and Message Variable (Created new unbounded message to assign concatenated fixed no of input messages). It is working fine now.

Do you guyz agree to this appoach or do you have any concerns?

答:
The best solution is indeed to use a custom pipeline component such as the one linked to in your question. The beauty of this is that you can call the pipeline from within the orchestration, and it needs not be tied to a specific receive location:
http://geekswithblogs.net/sthomas/archive/2005/06/16/44023.aspx.

Please, notice that the sample component you mention does not make use of a streaming technique; which means it loads the entire contents of the original message in memory. This could be a problem if you intend to process potentially large messages (which is often why debatching is used for).

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
Disabling "You are joining a meeting" voice when PSTN call joins Skype for Business meeting
Is there any way to disable "You are now joining the meeting" voice message when a user calling from PSTN joins a conference?

I tried to change the message following this blog: http://www.skypeadmin.com/2014/10/06/customize-dialin-conference-attendant-prompts-audio/ but it didn't work in Skype for Business Server 2015.

I am working on a UCMA Application which takes calls from PSTN number and joins them in a meeting on Skype for Business.

Edit:

The message is heard by the person who dials into the system using PSTN number. We tried running Set-CsDialInConferencingConfiguration command but it didn't work. The application joins the caller and a user in a conference call. The call is first put on hold, then a user is assigned to that call and the application creates a conference call between them. This is the point where the caller hears a voice saying "You are now joining the meeting."

答:
As you didn´t specify what your application should do and if you expect the announcement in your application or on the user side its not totally clear what you mean. What you can is to control some of those "voice announcements" via Set-CsDialInConferencingConfiguration.

For example:

EnableNameRecording:

Determines whether or not users are asked to record their name before
  entering the conference. Set to True to enable name recording; set to
  False to bypass name recording. The default value is True.

EntryExitAnnouncementsEnabledByDefault:

If set to True announcements will be played each time a participant
  enters or exits a conference. If set to False (the default value),
  entry and exit announcements will not be played.

EntryExitAnnouncementsType:

Indicates the action taken by the system any time a participant enters
  or leaves a conference. (Announcements are made only if the
  EntryExitAnnouncementsEnabledByDefault is set to True.) Valid values
  are: UseNames. The person's name is announced any time her or she
  enters or leaves a conference (for example, "Ken Myer is exiting the
  conference"). ToneOnly. A tone is played any time a participant enters
  or leaves a conference.The default value is UseNames.


问:
Mysql Return all values of a table where column is equal to user input
I have some sql statements that accepts a number and if that number is equal to the value of a column in a database, it should return all rows in the database that has the same value. Unfortunately the rows only return blog_post_id that has a value 0.

This is my codes below:

```<code><?php
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$blog_post_id = !empty($_POST['blog_post_id']) ? $_POST['blog_post_id']
: '';

$pdo=new PDO("mysql:dbname=db;host=localhost","username","password",
$options);
$statement=$pdo->prepare("SELECT * FROM comment WHERE blog_post_id =
'$blog_post_id'");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
$json=json_encode($results);
if ($json)
    echo $json;
else
    echo json_last_error_msg();

?>
</code>```

答:
You are actually missing the point of using the function prepare() and you need to check if the query does actually return any results..

```<code><?php
$options      = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
);
$blog_post_id = !empty($_POST['blog_post_id']) ? $_POST['blog_post_id'] : '';

$pdo       = new PDO("mysql:dbname=db;host=localhost", "username", "password", $options);
$statement = $pdo->prepare("SELECT * FROM comment WHERE blog_post_id = ?");
$statement->execute([$blog_post_id]);
$results   = $statement->fetchAll(PDO::FETCH_ASSOC);

$json = array();

if (count($results) > 0) {
    foreach ($results as $row) {
        $json[] = array(
            'id' => $row['blog_post_id'],
            'Field' => $row['Column'],
            'AnotherField' => $row['AnotherColumn'],
            'AnotherField1' => $row['AnotherColumn1'],
            'ETC' => $row['AnotherColumnName']
        );
    }

    echo json_encode($json);
} else {

    echo "no data found";
}

?>
</code>```

Body:
I have some sql statements that accepts a number and if that number is equal to the value of a column in a database, it should return all rows in the database that has the same value. Unfortunately the rows only return blog_post_id that has a value 0.

This is my codes below:

<?php
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$blog_post_id = !empty($_POST['blog_post_id']) ? $_POST['blog_post_id']
: '';

$pdo=new PDO("mysql:dbname=db;host=localhost","username","password",
$options);
$statement=$pdo->prepare("SELECT * FROM comment WHERE blog_post_id =
'$blog_post_id'");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
$json=json_encode($results);
if ($json)
    echo $json;
else
    echo json_last_error_msg();

?>

Body:
You are actually missing the point of using the function prepare() and you need to check if the query does actually return any results..

<?php
$options      = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
);
$blog_post_id = !empty($_POST['blog_post_id']) ? $_POST['blog_post_id'] : '';

$pdo       = new PDO("mysql:dbname=db;host=localhost", "username", "password", $options);
$statement = $pdo->prepare("SELECT * FROM comment WHERE blog_post_id = ?");
$statement->execute([$blog_post_id]);
$results   = $statement->fetchAll(PDO::FETCH_ASSOC);

$json = array();

if (count($results) > 0) {
    foreach ($results as $row) {
        $json[] = array(
            'id' => $row['blog_post_id'],
            'Field' => $row['Column'],
            'AnotherField' => $row['AnotherColumn'],
            'AnotherField1' => $row['AnotherColumn1'],
            'ETC' => $row['AnotherColumnName']
        );
    }

    echo json_encode($json);
} else {

    echo "no data found";
}

?>


问:
How to center the ul in the HTML
I have this html and CSS code on which I have spent the last 3 hrs and I am still not able to figure out how to center align the top menu bar in my code. The code is as follows:

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <ul>
    <li>Student Attendance</li>
    <li>Edit Students</li>
    <li>Profile</li>
    <li>Logout</li>
  </ul>
</div></code>```

答:
Use flexbox for this:

#container {
  display: flex; /* new */
}

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <ul>
    <li>Student Attendance</li>
    <li>Edit Students</li>
    <li>Profile</li>
    <li>Logout</li>
  </ul>
</div></code>```

Title: How to center the ul in the HTML

Body:
I have this html and CSS code on which I have spent the last 3 hrs and I am still not able to figure out how to center align the top menu bar in my code. The code is as follows:

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}

Student Attendance

Edit Students

Profile

Logout

Body:
Use flexbox for this:

#container {
  display: flex; /* new */
}

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}

<div id="container">
  <ul>
    <li><a style="text-decoration:none;" href="default.asp">Student Attendance</a></li>
    <li><a style="text-decoration:none;" href="news.asp">Edit Students</a></li>
    <li><a style="text-decoration:none;" href="contact.asp">Profile</a></li>
    <li><a style="text-decoration:none;" href="about.asp">Logout</a></li>
  </ul>
</div>


问:
How to prove an assumption given its conclusion from inductive declaration?
Here is a definition of a simple language:

```<code>theory SimpleLang
  imports Main
begin

type_synonym vname = "string"
datatype exp = BConst bool | IConst int | Let vname exp exp | Var vname | And exp exp

datatype type = BType | IType
type_synonym tenv = "vname ⇒ type option"

inductive typing :: "tenv ⇒ exp ⇒ type ⇒ bool"
  ("(1_/ ⊢/ (_ :/ _))" [50,0,50] 50) where
BConstTyping: "Γ ⊢ BConst c : BType" |
IConstTyping: "Γ ⊢ IConst c : IType" |
LetTyping: "⟦Γ ⊢ init : t1; Γ(var ↦ t1) ⊢ body : t⟧ ⟹ Γ ⊢ Let var init body : t" |
VarTyping: "Γ var = Some t ⟹ Γ ⊢ Var var : t" |
AndTyping: "⟦Γ ⊢ a : BType; Γ ⊢ b : BType⟧ ⟹ Γ ⊢ And a b : BType"

lemma AndTypingRev:
  "Γ ⊢ And a b : BType ⟹ Γ ⊢ a : BType ∧ Γ ⊢ b : BType"

end
</code>```

I defined a typing function for expressions. And I'm trying to prove that if And-expression has a Bool Type then both of its arguments have Bool Type too. It's a reversion of AndTyping rule from the theory.

Could you suggest how to prove this lemma? Could it be proved without Isar?

答:
inductive proves an elimination rule called typing.cases for this sort of thing. That allows you to do ‘rule inversion’. The Isar way is to do it like this:

```<code>lemma AndTypingRev:
  assumes "Γ ⊢ And a b : BType"
  shows   "Γ ⊢ a : BType ∧ Γ ⊢ b : BType"
  using assms by (cases rule: typing.cases) auto
</code>```

Since this is the default rule for case distinctions involving typing, you can also just write by cases auto. In any case, if you use cases for this, you should chain in the assumption involving typing with using, from, etc.

You can also do it without chaining using e.g. erule:

```<code>lemma AndTypingRev:
  "Γ ⊢ And a b : BType ⟹ Γ ⊢ a : BType ∧ Γ ⊢ b : BType"
  by (erule typing.cases) auto
</code>```

There is another way: You can use the inductive_cases command to automatically generate a suitable lemma for rule inversion (essentially, it's a specialised version of the typing.cases rule):

```<code>inductive_cases AndTypingRev: "Γ ⊢ And a b : BType"
</code>```

You can make it even more general:

```<code>inductive_cases AndTypingRev: "Γ ⊢ And a b : t"
</code>```

That gives you an elimination rule AndTypingRev that you can use with erule, elim, or cases:

```<code>?Γ ⊢ And ?a ?b : ?t ⟹
    (?t = BType ⟹ ?Γ ⊢ ?a : BType ⟹ ?Γ ⊢ ?b : BType ⟹ ?P) ⟹
  ?P
</code>```

Body:
Here is a definition of a simple language:

theory SimpleLang
  imports Main
begin

type_synonym vname = "string"
datatype exp = BConst bool | IConst int | Let vname exp exp | Var vname | And exp exp

datatype type = BType | IType
type_synonym tenv = "vname ⇒ type option"

inductive typing :: "tenv ⇒ exp ⇒ type ⇒ bool"
  ("(1_/ ⊢/ (_ :/ _))" [50,0,50] 50) where
BConstTyping: "Γ ⊢ BConst c : BType" |
IConstTyping: "Γ ⊢ IConst c : IType" |
LetTyping: "⟦Γ ⊢ init : t1; Γ(var ↦ t1) ⊢ body : t⟧ ⟹ Γ ⊢ Let var init body : t" |
VarTyping: "Γ var = Some t ⟹ Γ ⊢ Var var : t" |
AndTyping: "⟦Γ ⊢ a : BType; Γ ⊢ b : BType⟧ ⟹ Γ ⊢ And a b : BType"

lemma AndTypingRev:
  "Γ ⊢ And a b : BType ⟹ Γ ⊢ a : BType ∧ Γ ⊢ b : BType"

end

I defined a typing function for expressions. And I'm trying to prove that if And-expression has a Bool Type then both of its arguments have Bool Type too. It's a reversion of AndTyping rule from the theory.

Could you suggest how to prove this lemma? Could it be proved without Isar?

Body:
inductive proves an elimination rule called typing.cases for this sort of thing. That allows you to do ‘rule inversion’. The Isar way is to do it like this:

lemma AndTypingRev:
  assumes "Γ ⊢ And a b : BType"
  shows   "Γ ⊢ a : BType ∧ Γ ⊢ b : BType"
  using assms by (cases rule: typing.cases) auto

Since this is the default rule for case distinctions involving typing, you can also just write by cases auto. In any case, if you use cases for this, you should chain in the assumption involving typing with using, from, etc.

You can also do it without chaining using e.g. erule:

lemma AndTypingRev:
  "Γ ⊢ And a b : BType ⟹ Γ ⊢ a : BType ∧ Γ ⊢ b : BType"
  by (erule typing.cases) auto

There is another way: You can use the inductive_cases command to automatically generate a suitable lemma for rule inversion (essentially, it's a specialised version of the typing.cases rule):

inductive_cases AndTypingRev: "Γ ⊢ And a b : BType"

You can make it even more general:

inductive_cases AndTypingRev: "Γ ⊢ And a b : t"

That gives you an elimination rule AndTypingRev that you can use with erule, elim, or cases:

?Γ ⊢ And ?a ?b : ?t ⟹
    (?t = BType ⟹ ?Γ ⊢ ?a : BType ⟹ ?Γ ⊢ ?b : BType ⟹ ?P) ⟹
  ?P


问:
How can i call a receive activity from a xamlx workflow service using javascript?
I need to call a receive activity in my workflow from javascript passing the parameters as json and i need the response as json format too..

I tried everything that i found but nothing works.

Hope you can help me... thanks

答: The Receive activity only supports SOAP requests and at the moment there is no way to do REST style communications with it. One work around would be to create a regular WCF REST service as a wrapper for your workflow and have the JavaScript client go through this wrapper.</p>


问:
Append a Parent to a Child Element using Jquery
I need Help for append a Child element to a parent Element. This is my code.I need to put the $input inside the $temp.

Thanks

```<code>function CaixaPin(){

  var $temp;
  $temp = $("<div></div>");
  $temp.addClass("caixa");

  var $input;
  for(var i=0; i<4; i++){
    $input = $("<div></div>");
    $input.addClass("caixaPin");
    $("body").append($input);
  }

  $("body").append($temp);

}

CaixaPin();
</code>```

答:
You can append to elements that are not already in the dom and are stored in variables like $temp

Change:

```<code>$("body").append($input);
</code>```

To:

```<code>$temp.append($input);
</code>```

Body:
I need Help for append a Child element to a parent Element. This is my code.I need to put the $input inside the $temp.

Thanks

function CaixaPin(){

  var $temp;
  $temp = $("

");
  $temp.addClass("caixa");

  var $input;
  for(var i=0; i<4; i++){
    $input = $("

");
    $input.addClass("caixaPin");
    $("body").append($input);
  }

  $("body").append($temp);

}

CaixaPin();

Body:
You can append to elements that are not already in the dom and are stored in variables like $temp

Change:

$("body").append($input);

To:

$temp.append($input);


问:
Submitting files in Solr
While I submit documents to Solr if Request-Handler is /update I can't submit csv and json files but I can submit xml files.

I have changed Request-Handler to /update/extract. Now I can submit csv,json and xml files. But the problem is when I execute the query I can see the informations about file not the things inside the file.

You can see the outputs: https://ibb.co/eoTQaF

Now, I want to submit csv, json and xml files but I want to see the content of the files too. Do you have any idea ??

答: You can use /update/extract in Request-Handler (qt) instead of only /update. You can submit your json or csv files with this way.

Title: Submitting files in Solr


答:
Here's your code without the float:left;

   #container ul {
        list-style:none;
        margin:auto;
        padding: 0;
    }

    #container ul li a{
        color:#FFFFFF;
    }
    #container ul li{
        background-color:#6068FF;
        width:180px;
        border:1px solid white;
        height:50px;
        line-height:50px;
        text-align:center;
        #float:left;
        align-items:center;
        color:#FFFFFF;
        font-size:18;
    }

    #container ul li:hover{
        background-color:#0BF5F5;
    }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <ul>
  <li>Student Attendance</li>
  <li>Edit Students</li>
  <li>Profile</li>
  <li>Logout</li>
</ul>
</div></code>```

Title: How to center the ul in the HTML

Body:
Here's your code without the float:left;

   #container ul {
        list-style:none;
        margin:auto;
        padding: 0;
    }

    #container ul li a{
        color:#FFFFFF;
    }
    #container ul li{
        background-color:#6068FF;
        width:180px;
        border:1px solid white;
        height:50px;
        line-height:50px;
        text-align:center;
        #float:left;
        align-items:center;
        color:#FFFFFF;
        font-size:18;
    }

    #container ul li:hover{
        background-color:#0BF5F5;
    }

<div id="container">
  <ul>
  <li><a style="text-decoration:none;"href="default.asp">Student Attendance</a></li>
  <li><a style="text-decoration:none;"href="news.asp">Edit Students</a></li>
  <li><a style="text-decoration:none;"href="contact.asp">Profile</a></li>
  <li><a style="text-decoration:none;"href="about.asp">Logout</a></li>
</ul>
</div>


问:
IntelliJ java.lang.ClassNotFoundException: com.intellij.ide.plugins.PluginManager during startup
I use IntelliJ IDEA Community Edition 2017.1.4 x64 and got following error message during application starting process:

Internal error. Please report to
  http://jb.gg/ide/critical-startup-errors

java.lang.ClassNotFoundException:
  com.intellij.ide.plugins.PluginManager
      at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:225)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at com.intellij.ide.Bootstrap.main(Bootstrap.java:36)
      at com.intellij.idea.Main.main(Main.java:79)

I already tried to remove IDE caches folder: https://intellij-support.jetbrains.com/hc/articles/206544519.

答: Your installation is corrupted, please reinstall.</p>


答:
Here's your updated CSS:

Added text-align: center on the
 tag.

```<code>#container ul {
    ...
    text-align: center;
}
</code>```

Removed float: left, and added display: inline-block on
 tags.

```<code>#container ul li {
   display: inline-block;
   ...
   /* float: left; */
}
</code>```

Title: How to center the ul in the HTML

Body:
Here's your updated CSS:

Added text-align: center on the <ul> tag.

#container ul {
    ...
    text-align: center;
}

Removed float: left, and added display: inline-block on <li> tags.

#container ul li {
   display: inline-block;
   ...
   /* float: left; */
}


问:
Check if specific record exists in one to many tables
I have two tables with one-to-many relation with such structure:

```<code>meeting              meeting_person
+--+------------+    +--+----------+-----------+---------+
|id|meeting_type|    |id|meeting_id|person_type|person_id|
+--+------------+    +--+----------+-----------+---------+
|1 |          1 |    |1 |         1|          1|     100 |
|2 |          2 |    |2 |         1|          1|     101 |
+--+------------+    |3 |         1|          2|     102 |
                     |4 |         2|          3|     103 |
                     +--+----------+-----------+---------+
</code>```

What I want to do is check whether the specific record exists before inserting, and if so warn user about it.

The thing is I need to check whether a meeting with such meeting_type and person_id with person_type exists, and that for all persons.

For example, if with given data I wanted to insert meeting with meeting_type = 1 and such meeting_persons:

person_type = 1 and person_id = 100

person_type = 1 and person_id = 101

person_type = 2 and person_id = 102

then user should see warning.

But if I wanted to insert meeting with meeting_type = 1 and such meeting_persons:

person_type = 1 and person_id = 100

then user should not see warning and records should be inserted.

I just cannot think of way, how to check this.

答:
How about:</p>

```<code>WITH MEETING(ID, MEETING_TYPE) AS
 (SELECT 1, 1 FROM DUAL
  UNION SELECT 2, 2 FROM DUAL),
MEETING_PERSON(ID, MEETING_ID, PERSON_TYPE, PERSON_ID) AS
 (SELECT 1, 1, 1, 100 FROM DUAL
  UNION SELECT 2, 1, 1, 101 FROM DUAL
  UNION SELECT 3, 1, 2, 102 FROM DUAL
  UNION SELECT 4, 2, 3, 103 FROM DUAL)
SELECT CASE WHEN COUNT(*) = 0 THEN 'Yes' ELSE 'No' END AS show_warning FROM meeting, meeting_person
WHERE meeting.id = meeting_person.meeting_id
AND meeting.meeting_type = 1
AND (person_type, person_id) NOT IN ( (1,100),(1,101),(2,102) ); -- comment this and uncomment second line for second example to check
--AND (person_type, person_id) NOT IN ( (1,100) );
</code>```

Body:
I have two tables with one-to-many relation with such structure:

meeting              meeting_person
+--+------------+    +--+----------+-----------+---------+
|id|meeting_type|    |id|meeting_id|person_type|person_id|
+--+------------+    +--+----------+-----------+---------+
|1 |          1 |    |1 |         1|          1|     100 |
|2 |          2 |    |2 |         1|          1|     101 |
+--+------------+    |3 |         1|          2|     102 |
                     |4 |         2|          3|     103 |
                     +--+----------+-----------+---------+

What I want to do is check whether the specific record exists before inserting, and if so warn user about it.

The thing is I need to check whether a meeting with such meeting_type and person_id with person_type exists, and that for all persons.

For example, if with given data I wanted to insert meeting with meeting_type = 1 and such meeting_persons:

person_type = 1 and person_id = 100

person_type = 1 and person_id = 101

person_type = 2 and person_id = 102

then user should see warning.

But if I wanted to insert meeting with meeting_type = 1 and such meeting_persons:

person_type = 1 and person_id = 100

then user should not see warning and records should be inserted.

I just cannot think of way, how to check this.

Body:
How about:

WITH MEETING(ID, MEETING_TYPE) AS
 (SELECT 1, 1 FROM DUAL
  UNION SELECT 2, 2 FROM DUAL),
MEETING_PERSON(ID, MEETING_ID, PERSON_TYPE, PERSON_ID) AS
 (SELECT 1, 1, 1, 100 FROM DUAL
  UNION SELECT 2, 1, 1, 101 FROM DUAL
  UNION SELECT 3, 1, 2, 102 FROM DUAL
  UNION SELECT 4, 2, 3, 103 FROM DUAL)
SELECT CASE WHEN COUNT(*) = 0 THEN 'Yes' ELSE 'No' END AS show_warning FROM meeting, meeting_person
WHERE meeting.id = meeting_person.meeting_id
AND meeting.meeting_type = 1
AND (person_type, person_id) NOT IN ( (1,100),(1,101),(2,102) ); -- comment this and uncomment second line for second example to check
--AND (person_type, person_id) NOT IN ( (1,100) );


问:
bash to prompt integers in terminal and get sum when entering =
I'm looking for a rather simple solution to prompt integer numbers (one each line) into a terminal and in return for entering the equity-sign get all of them summed up.
I guess it has to look like this:

```<code>#!/bin/bash
read X
read Y
echo " $ (( X + Y ) ) "
</code>```

somehow I fail to amend it properly.

答:
Please see if below script helps. If you have any questions, please let us know.

```<code>#!/bin/bash
sum=0
number='^[0-9]+$'
equal='='
while :
do
    read input
    if ! [[ $input =~ $number ]] && ! [[ $input =~ $equal ]] ; then
        echo -e "Please provide only numbers!"
    elif [[ $input =~ $equal ]] ; then
        echo -e "Sum : $sum"
        break
    else
        let sum+=$input
    fi
done
</code>```

Sample Output

```<code>10
201
2202
2323
=
Sum : 4736
</code>```

Body:
I'm looking for a rather simple solution to prompt integer numbers (one each line) into a terminal and in return for entering the equity-sign get all of them summed up.
I guess it has to look like this:

#!/bin/bash
read X
read Y
echo " $ (( X + Y ) ) "

somehow I fail to amend it properly.

Body:
Please see if below script helps. If you have any questions, please let us know.

#!/bin/bash
sum=0
number='^[0-9]+$'
equal='='
while :
do
    read input
    if ! [[ $input =~ $number ]] && ! [[ $input =~ $equal ]] ; then
        echo -e "Please provide only numbers!"
    elif [[ $input =~ $equal ]] ; then
        echo -e "Sum : $sum"
        break
    else
        let sum+=$input
    fi
done

Sample Output

10
201
2202
2323
=
Sum : 4736


问:
Any advice for speeding up the compile time in Flex Builder 3?
I run Flex Builder 3 on a mac and as my project grows - the compile time gets longer and longer and longer.  I am using some SWC's and there is a fair amount of code but it shouldn't take minutes to build and crash daily should it?</p>

答:
You want at least 4 gigs on your computer if possible, and make sure to override the default memory settings that eclipse/flexbuilder gives to the application.

If you're not sure how to do this, you can find the flexbuilder app in /Applications, right click and choose "Show Package Contents".  Then go into the contents file and edit the eclipse.ini file.  Edit that file have memory settings of at least:

```<code>-vmargs -Xms768m -Xmx768m -XX:PermSize=128m -XX:MaxPermSize=128m
</code>```

It's also worthwhile to go into the eclipse/flexbuilder preferences and to check the "Show heap status" box under Windows->Preferences->General  (This is in eclipse with the FB plugin, I'm assuming it's also there for standalone FB).

This shows the current memory in the lower right of the window and has a little trash icon so you can force garbage collection.

I'd also suggest turning off automatic building of the project when your files change (you can force a build with cmd-B).

We had a huge project with quite a few modules files and performance in FlexBuilder 3 was decent with these steps.

OwnerDisplayName: onekidney

LastEditorDisplayName: travis

Body:
You want at least 4 gigs on your computer if possible, and make sure to override the default memory settings that eclipse/flexbuilder gives to the application.

If you're not sure how to do this, you can find the flexbuilder app in /Applications, right click and choose "Show Package Contents".  Then go into the contents file and edit the eclipse.ini file.  Edit that file have memory settings of at least:

-vmargs -Xms768m -Xmx768m -XX:PermSize=128m -XX:MaxPermSize=128m

It's also worthwhile to go into the eclipse/flexbuilder preferences and to check the "Show heap status" box under Windows->Preferences->General  (This is in eclipse with the FB plugin, I'm assuming it's also there for standalone FB).

This shows the current memory in the lower right of the window and has a little trash icon so you can force garbage collection.

I'd also suggest turning off automatic building of the project when your files change (you can force a build with cmd-B).

We had a huge project with quite a few modules files and performance in FlexBuilder 3 was decent with these steps.

OwnerDisplayName: Ted Naleid


问:
How can I store and retrieve an image using an SQLite database and a WPF application?
I have to store an image from my WPF application to the SQLite database, and then retrieve the same image and display it in the application. I tried doing this by coverting the image into byte array and storing that byte array to the SQLite database as BLOB, but this is not working. Can someone help me?</p>

答: Why don't you store the path to the image relative to the application's root?</p>


问:
TypeError: trying to access 'property' on undefined
I'm stuck on a strange error: when trying to display a state variable, vuejs warns me:
Error in render function: "TypeError: Cannot read property 'token' of undefined"

My state looks like this (in the vuejs extension):

```<code>room:Object
    details:Object
        game_id:"1"
        id:914527404
        max_users:5
        messages:Array[0]
        token:"ef6464692f4cce187fe129d7"
        user:Array[1]
    messages:Array[0]
    users:Array[1]
</code>```

Despite the error, the HTML is still rendered correctly:

```<code><button id="copySharingLink" type="button" class="btn btn-primary waves-effect waves-light" v-bind:data-token="room.details.token">some text</button>
</code>```

becomes

```<code><button id="copySharingLink" type="button" data-token="ef6464692f4cce187fe129d7" class="btn btn-primary waves-effect waves-light">some text</button>
</code>```

I have no idea how to rid out of this error, since it's working.

答:
There may be a time when room or room.details is not yet set, and that may be when the error is getting thrown.

Try changing the code from this...

```<code>v-bind:data-token="room.details.token"
</code>```

...to this:

```<code>v-bind:data-token="room.hasOwnProperty('details') ? room.details.token : ''"
</code>```

Body:
I'm stuck on a strange error: when trying to display a state variable, vuejs warns me:
Error in render function: "TypeError: Cannot read property 'token' of undefined"

My state looks like this (in the vuejs extension):

room:Object
    details:Object
        game_id:"1"
        id:914527404
        max_users:5
        messages:Array[0]
        token:"ef6464692f4cce187fe129d7"
        user:Array[1]
    messages:Array[0]
    users:Array[1]

Despite the error, the HTML is still rendered correctly:

<button id="copySharingLink" type="button" class="btn btn-primary waves-effect waves-light" v-bind:data-token="room.details.token">some text</button>

becomes

<button id="copySharingLink" type="button" data-token="ef6464692f4cce187fe129d7" class="btn btn-primary waves-effect waves-light">some text</button>

I have no idea how to rid out of this error, since it's working.

Body:
There may be a time when room or room.details is not yet set, and that may be when the error is getting thrown.

Try changing the code from this...

v-bind:data-token="room.details.token"

...to this:

v-bind:data-token="room.hasOwnProperty('details') ? room.details.token : ''"


问:
Drawing Text to the canvas using three.js
To start, I am not the most advanced javascript developer. I have only now started to undertake a more serious study of the subject.

So one of my first forays in this subject is to draw some text to the canvas using the three.js library.But for the life of me, I can't get this sucker to work. I have looked on google and even through the three.js documentation. When I inspect the page in chrome, the page doesn't show any errors either. Here is my code for reference:

```<code>var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth /
window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setClearColor(0xdddddd);

var spotlight = new THREE.SpotLight(0xffffff,);
spotlight.castShadow = true;
spotlight.position.set(30,60,60);

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var loader = new THREE.FontLoader();

loader.load( 'fonts/helvetiker_regular.typeface.json', function ( font ) {

    var textGeo = new THREE.TextGeometry( 'Hello three.js!', {
        font: font,
        size: 80,
        height: 5,
        curveSegments: 12,
        bevelEnabled: true,
        bevelThickness: 10,
        bevelSize: 8,
        bevelSegments: 5
    } );

    var  color = new THREE.Color();
    color.setRGB(255, 250, 250);
    textGeo.computeBoundingBox();
    textGeo.computeVertexNormals();
    var textMaterial = new THREE.MeshBasicMaterial({ color: color });

    var mesh = new THREE.Mesh(textGeo, textMaterial);
    mesh.position.x = textGeo.boundingBox.max.x / 2;
    mesh.position.y = textGeo.boundingBox.max.y / 2;
    mesh.castShadow = true;
    scene.add(mesh);
} );

var render = function (){
requestAnimationFrame(render);
renderer.render(scene, camera);
}
camera.lookAt(scene.position);
render();
</code>```

Also, for some background if it's needed, I am running this in debug mode in an asp.net application.

Thanks everyone.

答: I had my camera directly on the scene, so I couldn't see anything. Thanks prisoner for comment. </p>

Body:
To start, I am not the most advanced javascript developer. I have only now started to undertake a more serious study of the subject.

So one of my first forays in this subject is to draw some text to the canvas using the three.js library.But for the life of me, I can't get this sucker to work. I have looked on google and even through the three.js documentation. When I inspect the page in chrome, the page doesn't show any errors either. Here is my code for reference:

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth /
window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setClearColor(0xdddddd);

var spotlight = new THREE.SpotLight(0xffffff,);
spotlight.castShadow = true;
spotlight.position.set(30,60,60);

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

var loader = new THREE.FontLoader();

loader.load( 'fonts/helvetiker_regular.typeface.json', function ( font ) {

    var textGeo = new THREE.TextGeometry( 'Hello three.js!', {
        font: font,
        size: 80,
        height: 5,
        curveSegments: 12,
        bevelEnabled: true,
        bevelThickness: 10,
        bevelSize: 8,
        bevelSegments: 5
    } );

    var  color = new THREE.Color();
    color.setRGB(255, 250, 250);
    textGeo.computeBoundingBox();
    textGeo.computeVertexNormals();
    var textMaterial = new THREE.MeshBasicMaterial({ color: color });

    var mesh = new THREE.Mesh(textGeo, textMaterial);
    mesh.position.x = textGeo.boundingBox.max.x / 2;
    mesh.position.y = textGeo.boundingBox.max.y / 2;
    mesh.castShadow = true;
    scene.add(mesh);
} );

var render = function (){
requestAnimationFrame(render);
renderer.render(scene, camera);
}
camera.lookAt(scene.position);
render();

Also, for some background if it's needed, I am running this in debug mode in an asp.net application.

Thanks everyone.


问:
Counting lowercase with regex
I am trying to count the number of lower case characters in a string using regex.  I think I am missing something blindingly obvious but can't figure out what!  It is for an old classic ASP page.

```<code><%
Password="abcd123"
Set myRegExp = New RegExp
myRegExp.Pattern = "(.*[a-z].*)"
Response.Write myRegExp.Execute(Password).Count
%>
</code>```

The script returns 1 rather than 4.

答: Your capturing group is wrong, this is enough: ([a-z]). Using the .* you capture all that is around your lowercase character.

Title: Counting lowercase with regex

Body:
I am trying to count the number of lower case characters in a string using regex.  I think I am missing something blindingly obvious but can't figure out what!  It is for an old classic ASP page.

<%
Password="abcd123"
Set myRegExp = New RegExp
myRegExp.Pattern = "(.*[a-z].*)"
Response.Write myRegExp.Execute(Password).Count
%>

The script returns 1 rather than 4.


问:
android studio error- mixing versions can lead to run-time crashes
I get an error after adding 'com.firebaseui:firebase-ui-auth:1.0.0' to the dependency. The error goes away when I delete 'com.firebaseui:firebase-ui-auth:1.0.0' from the gradle. Code and pic included below
Help please

```<code>apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.a.chatapp"
    minSdkVersion 22
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'

compile 'com.firebaseui:firebase-ui:0.3.1'

compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
</code>```

答:
Here exist an error!

```<code>compile 'com.android.support:appcompat-v7:25.3.1'
</code>```

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 25.3.0. Examples include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Seeing this Examples
include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Just add these codes in dependencies, make sure that versions are same.

Just update build.gradle file with this :-

```<code>compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
</code>```

Body:
I get an error after adding 'com.firebaseui:firebase-ui-auth:1.0.0' to the dependency. The error goes away when I delete 'com.firebaseui:firebase-ui-auth:1.0.0' from the gradle. Code and pic included below
Help please

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.a.chatapp"
    minSdkVersion 22
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'

compile 'com.firebaseui:firebase-ui:0.3.1'

compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Body:
Here exist an error!

compile 'com.android.support:appcompat-v7:25.3.1'

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 25.3.0. Examples include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Seeing this Examples
include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Just add these codes in dependencies, make sure that versions are same.

Just update build.gradle file with this :-

compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'


答:
Why you don't just use [a-z] instead, because when you use (.*[a-z].*), it will match all your input like one piece and not character by character?

You can check the difference here:

[a-z] regex

(.*[a-z].*) Your regex

I also suggest reading:

The Dot Matches (Almost) Any Character

Title: Counting lowercase with regex


问:
Fade out character by character in text using jQuery
In the code below I have a line of text "A B C" that I would like to fade out character by character, i.e. C is faded out first, then B and finally A. The code works, but I think that my solution is very clumpsy. If the text has more letters, then the code must be extended for each letter with callback after callback...

Can this be solved in a more neat way? Can the fadeOuts be placed in sequence instead of nested callbacks?

My final goal is to fade out a text character by character and then fade in a new text, character by character... Just like a Powerpoint animation :)

$(document).ready(function() {
  $("button").click(function() {
    $("#C").fadeOut(300, function() {
      $("#B").fadeOut(300, function() {
        $("#A").fadeOut(300);
      });
    });
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body>
  <button>Click to fade out character by character</button><br><br>

  <div>
    <span id="A">A</span>
    <span id="B">B</span>
    <span id="C">C</span>
  </div></code>```

答:
I have mad solution where you don't have to write each character in span inside dom , instead you can just type in the string and fade out each character in reverse order

```<code><div class="text">Phone is great</div>
</code>```

Javscript code:

```<code>var queue = [];
var input = $(".text").text();
for (var i = 0; i < input.length; i++) {

  queue.push("<span class='charToFade'>" + input.charAt(i) + "</span>");

}
$(".text").text("");
while(queue.length>0)
 {
  $(".text").append(queue.shift());
}

$($("span").get().reverse()).each(function(i) {
    $(this).delay(400 * i).fadeOut(300)
 })
</code>```

See the jsfiddle link

Body:
In the code below I have a line of text "A B C" that I would like to fade out character by character, i.e. C is faded out first, then B and finally A. The code works, but I think that my solution is very clumpsy. If the text has more letters, then the code must be extended for each letter with callback after callback...

Can this be solved in a more neat way? Can the fadeOuts be placed in sequence instead of nested callbacks?

My final goal is to fade out a text character by character and then fade in a new text, character by character... Just like a Powerpoint animation :)

$(document).ready(function() {
  $("button").click(function() {
    $("#C").fadeOut(300, function() {
      $("#B").fadeOut(300, function() {
        $("#A").fadeOut(300);
      });
    });
  });
});

  <button>Click to fade out character by character</button>

    A
    B
    C

Body:
I have mad solution where you don't have to write each character in span inside dom , instead you can just type in the string and fade out each character in reverse order

<div class="text">Phone is great</div>

Javscript code:

var queue = [];
var input = $(".text").text();
for (var i = 0; i < input.length; i++) {

  queue.push("<span class='charToFade'>" + input.charAt(i) + "</span>");

}
$(".text").text("");
while(queue.length>0)
 {
  $(".text").append(queue.shift());
}

$($("span").get().reverse()).each(function(i) {
    $(this).delay(400 * i).fadeOut(300)
 })

See the jsfiddle link


问:
How to create a query dynamically for an array of elements?
I have a basic query as follows

```<code>$query = "SELECT * FROM files WHERE (subject_code = '".$subject_code."' )";
</code>```

I have to modify this query to create a query where we have multiple subject codes fetched from an array.

```<code>$query1="SELECT subject_code FROM subject WHERE (sbranch = '".$branch."' )";
$result = mysqli_query($bmysqli, $query1);
</code>```

Now result holds all the required subject_codes say result[0]=SC1,result[1]=SC2 etc....

Now I want to the original query to be modified something as follows

```<code>$query = "SELECT * FROM files WHERE (subject_code = SC1 OR subject_code = SC2 .....)";
</code>```

Note that i don't know what are the values of SC1 SC2 etc.It depends on the branch and is inside $result.

How can i accomplish this?

答:
You can amend your php array to comma delimited string of SubjectCodes.

then:

```<code>$query1="SELECT * FROM files WHERE subject_code in (".$NewString.") ";
</code>```

$NewString will look something like this:

```<code>"'SC1', 'SC2', 'SC3'"
</code>```

Body:
I have a basic query as follows

$query = "SELECT * FROM files WHERE (subject_code = '".$subject_code."' )";

I have to modify this query to create a query where we have multiple subject codes fetched from an array.

$query1="SELECT subject_code FROM subject WHERE (sbranch = '".$branch."' )";
$result = mysqli_query($bmysqli, $query1);

Now result holds all the required subject_codes say result[0]=SC1,result[1]=SC2 etc....

Now I want to the original query to be modified something as follows

$query = "SELECT * FROM files WHERE (subject_code = SC1 OR subject_code = SC2 .....)";

Note that i don't know what are the values of SC1 SC2 etc.It depends on the branch and is inside $result.

How can i accomplish this?

Body:
You can amend your php array to comma delimited string of SubjectCodes.

then:

$query1="SELECT * FROM files WHERE subject_code in (".$NewString.") ";

$NewString will look something like this:

"'SC1', 'SC2', 'SC3'"


问:
how to remove xml namesapce with SAX parser
I need to do xml transformation with SAX parser, for that i need to remove namespace from the xml. Since we are handling with huge xml, i need to use SAX parser.

sample input xml:

```<code><root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
 xmlns:ns2="http://www.google.com/generation/type">
    <ns2:meta>
        <gender xmlns="" xmlns:ns5="http://www.google.com/generation">M</gender>
        <dateOfBirth xmlns="" xmlns:ns5="http://www.google.com/generation">1976-07-19</dateOfBirth>
        <ns2:languageRef>ENG</ns2:languageRef>
    </ns2:meta>
    <root>
</code>```

with the help of SAX parser, i need the below output.

```<code>       <root>
            <meta>
                <gender>M</gender>
                <dateOfBirth>1976-07-19</dateOfBirth>
                <languageRef>ENG</languageRef>
            </ns2:meta>
        <root>
</code>```

Thanks in advance..

The code which i tried,

i tried with XMLFlterImpl,

```<code>XMLReader xr = new XMLFilterImpl(XMLReaderFactory.createXMLReader()) {

  @Override
  public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {

    if (qName.contains(":")) {
      String[] data = data = qName.split(":");

      super.startElement(uri, localName, data[1], atts);
    } else {
      super.startElement(uri, localName, qName, atts);
    }
  }
</code>```

this removes the element name prefix(namespace), but not sure how to remove the namespace attributes

答: Usually attempts to remove namespaces to perform a "transformation" is a sign of lack of understanding of how to handle XML but in general if you use SAX and want to alter the processed XML you can implement a filter https://docs.oracle.com/javase/8/docs/api/org/xml/sax/XMLFilter.html, starting with https://docs.oracle.com/javase/8/docs/api/org/xml/sax/helpers/XMLFilterImpl.html as a base clase and overriding the methods where you expect and want to strip namespaces.</p>

Body:
I need to do xml transformation with SAX parser, for that i need to remove namespace from the xml. Since we are handling with huge xml, i need to use SAX parser.

sample input xml:

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
 xmlns:ns2="http://www.google.com/generation/type">
    <ns2:meta>
        <gender xmlns="" xmlns:ns5="http://www.google.com/generation">M</gender>
        <dateOfBirth xmlns="" xmlns:ns5="http://www.google.com/generation">1976-07-19</dateOfBirth>
        <ns2:languageRef>ENG</ns2:languageRef>
    </ns2:meta>
    <root>

with the help of SAX parser, i need the below output.

       <root>
            <meta>
                <gender>M</gender>
                <dateOfBirth>1976-07-19</dateOfBirth>
                <languageRef>ENG</languageRef>
            </ns2:meta>
        <root>

Thanks in advance..

The code which i tried,

i tried with XMLFlterImpl,

XMLReader xr = new XMLFilterImpl(XMLReaderFactory.createXMLReader()) {

  @Override
  public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {

    if (qName.contains(":")) {
      String[] data = data = qName.split(":");

      super.startElement(uri, localName, data[1], atts);
    } else {
      super.startElement(uri, localName, qName, atts);
    }
  }

this removes the element name prefix(namespace), but not sure how to remove the namespace attributes


问:
How to center the ul in the HTML
I have this html and CSS code on which I have spent the last 3 hrs and I am still not able to figure out how to center align the top menu bar in my code. The code is as follows:

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <ul>
    <li>Student Attendance</li>
    <li>Edit Students</li>
    <li>Profile</li>
    <li>Logout</li>
  </ul>
</div></code>```

答:
Add inline-block to the list and use text-align:center; on the #container

#container {
  text-align: center;
}

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
  display: inline-block;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="container">
  <ul>
    <li>Student Attendance</li>
    <li>Edit Students</li>
    <li>Profile</li>
    <li>Logout</li>
  </ul>
</div></code>```

Title: How to center the ul in the HTML

Body:
I have this html and CSS code on which I have spent the last 3 hrs and I am still not able to figure out how to center align the top menu bar in my code. The code is as follows:

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}

Student Attendance

Edit Students

Profile

Logout

Body:
Add inline-block to the list and use text-align:center; on the #container

#container {
  text-align: center;
}

#container ul {
  list-style: none;
  margin: auto;
  padding: 0;
  display: inline-block;
}

#container ul li a {
  color: #FFFFFF;
}

#container ul li {
  background-color: #6068FF;
  width: 180px;
  border: 1px solid white;
  height: 50px;
  line-height: 50px;
  text-align: center;
  float: left;
  align-items: center;
  color: #FFFFFF;
  font-size: 18;
}

#container ul li:hover {
  background-color: #0BF5F5;
}

<div id="container">
  <ul>
    <li><a style="text-decoration:none;" href="default.asp">Student Attendance</a></li>
    <li><a style="text-decoration:none;" href="news.asp">Edit Students</a></li>
    <li><a style="text-decoration:none;" href="contact.asp">Profile</a></li>
    <li><a style="text-decoration:none;" href="about.asp">Logout</a></li>
  </ul>
</div>


问:
Revoke mysql permissions on database
Im trying to remove all permissions for a user on a database.

```<code>REVOKE ALL PRIVILEGES ON database.* FROM 'user'@'%';
</code>```

This just gives an error saying:

```<code>ERROR 1141 (42000): There is no such grant defined for user 'user' on host '%'
</code>```

I am logged in as root user when running the query. And running show grants for user query shows that the user has permissions on all databases

Output from show grants query:

```<code>GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD 'xxxxxx'
</code>```

答:
Revoke statement has to match the grants issued. If grant is issued to *.*, you can only revoke *.* as well.

since SHOW GRANTS for 'user'@'%' shows a line like:

```<code>GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD 'xxxxxx'
</code>```

You need to revoke that!

This should work:

```<code>REVOKE ALL PRIVILEGES ON *.* FROM 'user'@'%';
</code>```

database.* denotes all tables in the "database" database

*.* denotes all tables in all databases

Title: Revoke mysql permissions on database

Body:
Im trying to remove all permissions for a user on a database.

REVOKE ALL PRIVILEGES ON database.* FROM 'user'@'%';

This just gives an error saying:

ERROR 1141 (42000): There is no such grant defined for user 'user' on host '%'

I am logged in as root user when running the query. And running show grants for user query shows that the user has permissions on all databases

Output from show grants query:

GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD 'xxxxxx'

Body:
Revoke statement has to match the grants issued. If grant is issued to *.*, you can only revoke *.* as well.

since SHOW GRANTS for 'user'@'%' shows a line like:

GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD 'xxxxxx'

You need to revoke that!

This should work:

REVOKE ALL PRIVILEGES ON *.* FROM 'user'@'%';

database.* denotes all tables in the "database" database

*.* denotes all tables in all databases


问:
Is there any method of making local 'defonce'? (Clojure)
Let's say I need to make a simple counter and I want counter to be incremented each time I call this function, but here is one unpleasant thing: defined 'counter' is not local and I can easily change its value from another space, that breaks encapsulation.

```<code>(defn next []
  (defonce counter (atom 0))
  (println @counter)
  (reset! counter (inc @counter)))
</code>```

Many say, it will be correct if I place 'private' meta tag. So function will look like this:

```<code>(defn next []
  (defonce ^:private counter (atom 0))
  (println @counter)
  (reset! counter (inc @counter)))
</code>```

But I still have access to 'counter' from another space.

Is there any way to implement this encapsulation or it's only at the agreement level?

答:
Private works well, you shouldn't have access from other namespace

```<code>user> (ns a)
nil
a> (defonce ^:private counter (atom 0))
#'a/counter
a> (defn next []
     (println @counter)
     (swap! counter inc))
#'a/next
a> (next)
0
1
a> (next)
1
2
a> (next)
2
3
a> (next)
3
4
a> (ns b)
nil
b> (require 'a)
nil
b> (a/next)
4
5
b> (a/next)
5
6
b> a/counter
CompilerException java.lang.IllegalStateException: var: a/counter is not public
b> (ns a)
nil
a> a/counter
#object[clojure.lang.Atom 0x1ec64eb6 {:status :ready, :val 6}]
</code>```

Also some minor issues:

define counter at the top level of ns, not inside the function, both have the same effect, but top level is clearer

change reset! to (swap! counter inc), it will be thread safe

Body:
Let's say I need to make a simple counter and I want counter to be incremented each time I call this function, but here is one unpleasant thing: defined 'counter' is not local and I can easily change its value from another space, that breaks encapsulation.

(defn next []
  (defonce counter (atom 0))
  (println @counter)
  (reset! counter (inc @counter)))

Many say, it will be correct if I place 'private' meta tag. So function will look like this:

(defn next []
  (defonce ^:private counter (atom 0))
  (println @counter)
  (reset! counter (inc @counter)))

But I still have access to 'counter' from another space.

Is there any way to implement this encapsulation or it's only at the agreement level?

Body:
Private works well, you shouldn't have access from other namespace

user> (ns a)
nil
a> (defonce ^:private counter (atom 0))
#'a/counter
a> (defn next []
     (println @counter)
     (swap! counter inc))
#'a/next
a> (next)
0
1
a> (next)
1
2
a> (next)
2
3
a> (next)
3
4
a> (ns b)
nil
b> (require 'a)
nil
b> (a/next)
4
5
b> (a/next)
5
6
b> a/counter
CompilerException java.lang.IllegalStateException: var: a/counter is not public
b> (ns a)
nil
a> a/counter
#object[clojure.lang.Atom 0x1ec64eb6 {:status :ready, :val 6}]

Also some minor issues:

define counter at the top level of ns, not inside the function, both have the same effect, but top level is clearer

change reset! to (swap! counter inc), it will be thread safe


问:
PHP login page using session variable
I am new to php, and trying to create a login page through session without using database, if user successfully logs in, it will be redirected to some page "portfolio.php” and then session will expire after 15 mins but if user randomly types the “portfolio.php” as url it will be redirected to the login page. it should only redirect to that page ("portfolio.php") after the user has login successfully.
here is my "login.php" page code:

```<code> <?php
session_start();
include("functions.php");
$message="";
if(count($_POST)>0) {
    if( $_POST["user_name"] == "admin" and $_POST["password"] == "admin-1") {
        $_SESSION["user_id"] = 1001;
        $_SESSION["user_name"] = $_POST["user_name"];
        $_SESSION['loggedin_time'] = time();

    } else {
        $message = "Invalid Username or Password!";
    }
}
if(isset($_SESSION["user_id"])) {
    if(!isLoginSessionExpired()) {
        header("Location:portfolio.php");
    } else {
        header("Location:logout.php?session_expired=1");
    }
}
if(isset($_GET["session_expired"])) {
    $message = "Login Session is Expired. Please Login Again";
}
?>
</code>```

portfolio.php code:

```<code><?php
session_start();
include("functions.php");
if(isset($_SESSION["user_id"])) {
    if(isLoginSessionExpired()) {
        header("Location:logout.php?session_expired=1");

    }
 }

?>
</code>```

funcation.php code:

```<code><?php
function isLoginSessionExpired() {
    $login_session_duration = 10;
    $current_time = time();
    if(isset($_SESSION['loggedin_time']) and isset($_SESSION["user_id"])){
        if(((time() - $_SESSION['loggedin_time']) > $login_session_duration)){
            return true;
        }
    }
    return false;
}
?>
</code>```

Thanks in advance.

答:
I see you haven't set any check in portfolio.php file.
Try to check if session login is valid for every php page you create. For example add a session helper in your functions.php file:

```<code>function session_helper() {
  if(isset($_SESSION["user_id"])) {
      if(isLoginSessionExpired()) {
        header("Location:logout.php?session_expired=1");
      }
      // check valid user id?
      // session is fine, let the code continue
  } else {
    // no session user_id so redirect to login or
    // any other welcome page

    header("Location:login.php");
  }

}
</code>```

then you could use that method in all your files, including the portfolio.php:

```<code><?php
    session_start();
    // the new functions.php file
    include("functions.php");
    session_helper();

    // more code
?>
</code>```

If you are planning to do a php application, you can consider using a Php Framework which handles a lot of stuff for you and cares about security issues you may not be aware of, as well as providing built-in safer user authentication.

Title: PHP login page using session variable

Body:
I am new to php, and trying to create a login page through session without using database, if user successfully logs in, it will be redirected to some page "portfolio.php” and then session will expire after 15 mins but if user randomly types the “portfolio.php” as url it will be redirected to the login page. it should only redirect to that page ("portfolio.php") after the user has login successfully.
here is my "login.php" page code:

 <?php
session_start();
include("functions.php");
$message="";
if(count($_POST)>0) {
    if( $_POST["user_name"] == "admin" and $_POST["password"] == "admin-1") {
        $_SESSION["user_id"] = 1001;
        $_SESSION["user_name"] = $_POST["user_name"];
        $_SESSION['loggedin_time'] = time();

    } else {
        $message = "Invalid Username or Password!";
    }
}
if(isset($_SESSION["user_id"])) {
    if(!isLoginSessionExpired()) {
        header("Location:portfolio.php");
    } else {
        header("Location:logout.php?session_expired=1");
    }
}
if(isset($_GET["session_expired"])) {
    $message = "Login Session is Expired. Please Login Again";
}
?>

portfolio.php code:

<?php
session_start();
include("functions.php");
if(isset($_SESSION["user_id"])) {
    if(isLoginSessionExpired()) {
        header("Location:logout.php?session_expired=1");

    }
 }

?>

funcation.php code:

<?php
function isLoginSessionExpired() {
    $login_session_duration = 10;
    $current_time = time();
    if(isset($_SESSION['loggedin_time']) and isset($_SESSION["user_id"])){
        if(((time() - $_SESSION['loggedin_time']) > $login_session_duration)){
            return true;
        }
    }
    return false;
}
?>

Thanks in advance.

Body:
I see you haven't set any check in portfolio.php file.
Try to check if session login is valid for every php page you create. For example add a session helper in your functions.php file:

function session_helper() {
  if(isset($_SESSION["user_id"])) {
      if(isLoginSessionExpired()) {
        header("Location:logout.php?session_expired=1");
      }
      // check valid user id?
      // session is fine, let the code continue
  } else {
    // no session user_id so redirect to login or
    // any other welcome page

    header("Location:login.php");
  }

}

then you could use that method in all your files, including the portfolio.php:

<?php
    session_start();
    // the new functions.php file
    include("functions.php");
    session_helper();

    // more code
?>

If you are planning to do a php application, you can consider using a Php Framework which handles a lot of stuff for you and cares about security issues you may not be aware of, as well as providing built-in safer user authentication.


问:
listagg with DISTINCT in redshift
I am struggling to find a good way to do a DISTINCT in listagg in redshift.

All I want to do is list the combination of product, but each row should return a list of distinct products.

Example

Desired output:

```<code>bulb, light
bulb, light, fan
</code>```

instead of:

```<code>bulb, bulb, light
bulb, bulb, light, fan
</code>```

Below is my SQL:

```<code>select
    tit.listagg
from (
    SELECT
        username,
        listagg(node_name, ',')
        WITHIN GROUP (ORDER BY node_name asc)
    FROM table
    Where node_type not like '%bla bla%'
    GROUP BY username
) as tit
group by listagg;
</code>```

答:
You can enumerate the rows and then select the first one:

```<code>select username,
       listagg(case when seqnum = 1 then node_name end, ',') within group (order by node_name asc)
from (select t.*,
             row_number() over (partition by username, node_name order by node_name) as seqnum
      from table t
      where node_type not like '%bla bla%'
     ) t
group by username;
</code>```

This uses the feature that listagg() ignores NULL values.

Title: listagg with DISTINCT in redshift

Body:
I am struggling to find a good way to do a DISTINCT in listagg in redshift.

All I want to do is list the combination of product, but each row should return a list of distinct products.

Example

Desired output:

bulb, light
bulb, light, fan

instead of:

bulb, bulb, light
bulb, bulb, light, fan

Below is my SQL:

select
    tit.listagg
from (
    SELECT
        username,
        listagg(node_name, ',')
        WITHIN GROUP (ORDER BY node_name asc)
    FROM table
    Where node_type not like '%bla bla%'
    GROUP BY username
) as tit
group by listagg;

Body:
You can enumerate the rows and then select the first one:

select username,
       listagg(case when seqnum = 1 then node_name end, ',') within group (order by node_name asc)
from (select t.*,
             row_number() over (partition by username, node_name order by node_name) as seqnum
      from table t
      where node_type not like '%bla bla%'
     ) t
group by username;

This uses the feature that listagg() ignores NULL values.


问:
VB.Net SQL DataAdapter Not updating on first run
I am working with a SQL DataAdapter (sqlDa) and on the click of a checkbox event the sqlDa should run an update command.

The code is called, but the update event doesnt actually fire and I am unsure why.

I have stepped through and there are no errors,
I have run SQL Profiler and it shows there is no SQL Event fired
Originally there was no Initializer so created one and the binding events are on the checkbox I am working with

So, I am a little stumped and need some help.

The code I am working with is

```<code>Public Sub New()

    InitializeComponent()

End Sub

Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged
    ControlSettingsBindingSource.EndEdit()
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings)
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only
End Sub

 Public Overloads Overridable Function Update(ByVal dataTable As boundTestDataSet.controlSettingsDataTable) As Integer
        Return Me.Adapter.Update(dataTable)
    End Function
</code>```

In the initializer this is the control that I am working with

```<code> 'boundCheckBox
    '
    Me.boundCheckBox.AutoSize = True
    Me.boundCheckBox.DataBindings.Add(New System.Windows.Forms.Binding("Checked", Me.ControlSettingsBindingSource, "checkBoxSetting", True))
    Me.boundCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.boundCheckBox.Location = New System.Drawing.Point(10, 62)
    Me.boundCheckBox.Margin = New System.Windows.Forms.Padding(4, 3, 4, 3)
    Me.boundCheckBox.Name = "boundCheckBox"
    Me.boundCheckBox.Size = New System.Drawing.Size(590, 40)
    Me.boundCheckBox.TabIndex = 0
    Me.boundCheckBox.Text = "CheckBox Bound To 'checkBoxSetting'"
    Me.boundCheckBox.UseVisualStyleBackColor = True
    '
</code>```

Any and all help much appreciated

Simon

答:
Found the issue

needed to add ControlSettingsBindingSource.ResetBindings(False)

```<code>Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged
    ControlSettingsBindingSource.EndEdit()
    ControlSettingsBindingSource.ResetBindings(False)
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings)
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only
End Sub
</code>```

Body:
I am working with a SQL DataAdapter (sqlDa) and on the click of a checkbox event the sqlDa should run an update command.

The code is called, but the update event doesnt actually fire and I am unsure why.

I have stepped through and there are no errors,
I have run SQL Profiler and it shows there is no SQL Event fired
Originally there was no Initializer so created one and the binding events are on the checkbox I am working with

So, I am a little stumped and need some help.

The code I am working with is

Public Sub New()

    InitializeComponent()

End Sub

Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged
    ControlSettingsBindingSource.EndEdit()
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings)
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only
End Sub

 Public Overloads Overridable Function Update(ByVal dataTable As boundTestDataSet.controlSettingsDataTable) As Integer
        Return Me.Adapter.Update(dataTable)
    End Function

In the initializer this is the control that I am working with

 'boundCheckBox
    '
    Me.boundCheckBox.AutoSize = True
    Me.boundCheckBox.DataBindings.Add(New System.Windows.Forms.Binding("Checked", Me.ControlSettingsBindingSource, "checkBoxSetting", True))
    Me.boundCheckBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.boundCheckBox.Location = New System.Drawing.Point(10, 62)
    Me.boundCheckBox.Margin = New System.Windows.Forms.Padding(4, 3, 4, 3)
    Me.boundCheckBox.Name = "boundCheckBox"
    Me.boundCheckBox.Size = New System.Drawing.Size(590, 40)
    Me.boundCheckBox.TabIndex = 0
    Me.boundCheckBox.Text = "CheckBox Bound To 'checkBoxSetting'"
    Me.boundCheckBox.UseVisualStyleBackColor = True
    '

Any and all help much appreciated

Simon

Body:
Found the issue

needed to add ControlSettingsBindingSource.ResetBindings(False)

Private Sub boundCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles boundCheckBox.CheckedChanged
    ControlSettingsBindingSource.EndEdit()
    ControlSettingsBindingSource.ResetBindings(False)
    Me.ControlSettingsTableAdapter.Update(Me.BoundTestDataSet.controlSettings)
    Call diagnosticCheck(boundCheckBox.Checked) ' this is for diagnostic purposes only
End Sub


问:
How to replicate a HTML table code when clicked on a button using angular js?
I have whole table created in a Html but I want to implement the functionality where if I click on a text I need to replicate the same table (Html) code in my application.

My HTML:

```<code>  <th class="bx--table-header bx--table-sort" data-event="sort" ng-click="vm.addTowerTable()">
    <a class="text-decoration-none"><i class="fa fa-plus-circle" aria-hidden="true" style="padding-right:10px;"></i>Add Tower</a>
</th>
</code>```

I have a ADD TOWER as my text when I click on it I need to add a whole table... How can I implement it using angularjs?

答:
You could use ng-repeat to loop over a dummy array whose length is the number of tables you need:

```<code><table ng-repeat="table in vm.tables">
    ...
    <th ng-click="vm.addTowerTable()">
        ...
    </th>
</table>
</code>```

And then in your controller:

```<code>// Right now I am just pushing null since we need something in the
// array. You could push some data about each table.
vm.tables = [null];

vm.addTowerTable = function() {
    vm.tables.push(null);
};
</code>```

If you don't like using a dummy array, check out some other solutions people have come up with to make it look a little nicer.

Body:
I have whole table created in a Html but I want to implement the functionality where if I click on a text I need to replicate the same table (Html) code in my application.

My HTML:

    Add Tower

I have a ADD TOWER as my text when I click on it I need to add a whole table... How can I implement it using angularjs?

Body:
You could use ng-repeat to loop over a dummy array whose length is the number of tables you need:

<table ng-repeat="table in vm.tables">
    ...
    <th ng-click="vm.addTowerTable()">
        ...
    </th>
</table>

And then in your controller:

// Right now I am just pushing null since we need something in the
// array. You could push some data about each table.
vm.tables = [null];

vm.addTowerTable = function() {
    vm.tables.push(null);
};

If you don't like using a dummy array, check out some other solutions people have come up with to make it look a little nicer.


问:
transfer a number from one module to another
I have 2 modules: A and B. A uses B. A reads in two numbers, then calls a subroutine in B that needs these numbers. How do I make these two numbers, read in in A, available in the subroutine in B without having them to add to the call to the subroutine?</p>

答:
There are two possibilities that I'm aware of:

Add them to the call.

Move the two numbers into a third module C and use these in both A and B.

You've said you don't want option 1 but, option 2 might be ok for you.

An (untested) example is

```<code>module A
 contains
    subroutine readNumbers()
        use C, only: a1, a2
        use B, only: theFinalRoutine
        !code to set a1 and a2
        call theFinalRoutine
    end subroutine readNumbers
 end module A

module B
 contains
    subroutine theFinalRoutine()
        use C, only: a1, a2
        !do some things with a1 and a2
    end subroutine theFinalRoutine
 end module B

module C
   real :: a1, a2
end module C

program test
   use A, only: readNumbers
   call readNumbers()
end program test
</code>```

This isn't always a good idea, but it does help avoid circular dependencies in the case of data (rather than dependencies between routines).

Body:
There are two possibilities that I'm aware of:

Add them to the call.

Move the two numbers into a third module C and use these in both A and B.

You've said you don't want option 1 but, option 2 might be ok for you.

An (untested) example is

module A
 contains
    subroutine readNumbers()
        use C, only: a1, a2
        use B, only: theFinalRoutine
        !code to set a1 and a2
        call theFinalRoutine
    end subroutine readNumbers
 end module A

module B
 contains
    subroutine theFinalRoutine()
        use C, only: a1, a2
        !do some things with a1 and a2
    end subroutine theFinalRoutine
 end module B

module C
   real :: a1, a2
end module C

program test
   use A, only: readNumbers
   call readNumbers()
end program test

This isn't always a good idea, but it does help avoid circular dependencies in the case of data (rather than dependencies between routines).


问:
Scala Option[Future[T]] to Future[Option[T]]
How can I convert Option[Future[T]] to Future[Option[T]] in scala?

I want to use it in:

```<code>val customerAddresses = for {
  a <- addressDAO.insert(ca.address) // Future[Address]
  ia <- ca.invoiceAddress.map(addressDAO.insert) // Option[Future[Address]]
} yield (a, ia) // Invalid value have to be two futures
</code>```

Here signature insert method

```<code>def insert(address: Address): Future[Address]
</code>```

ca is a CustomerData

```<code>case class CustomerData(address: Address, invoiceAddress: Option[Address])
</code>```

答:
The standard library does provide the methods to use Future.sequence on an Option, unfortunately you have to plumb them together.

Either as a quick method:

```<code>def swap[M](x: Option[Future[M]]): Future[Option[M]] =
    Future.sequence(Option.option2Iterable(x)).map(_.headOption)
</code>```

Note I found the implicit Option.option2Iterable was already in scope for me. So you may not need to provide it, reducing the code down to Future.sequence(x).map(_.headOption)

Or you may prefer an extension method:

```<code>implicit class OptionSwitch[A](f: Option[Future[A]]) {
    import scala.concurrent.Future

    def switch: Future[Option[A]] = Future.sequence(Option.option2Iterable(f))
      .map(_.headOption)
  }

val myOpt = Option(Future(3))
myOpt.switch
</code>```

Body:
How can I convert Option[Future[T]] to Future[Option[T]] in scala?

I want to use it in:

val customerAddresses = for {
  a <- addressDAO.insert(ca.address) // Future[Address]
  ia <- ca.invoiceAddress.map(addressDAO.insert) // Option[Future[Address]]
} yield (a, ia) // Invalid value have to be two futures

Here signature insert method

def insert(address: Address): Future[Address]

ca is a CustomerData

case class CustomerData(address: Address, invoiceAddress: Option[Address])

Body:
The standard library does provide the methods to use Future.sequence on an Option, unfortunately you have to plumb them together.

Either as a quick method:

def swap[M](x: Option[Future[M]]): Future[Option[M]] =
    Future.sequence(Option.option2Iterable(x)).map(_.headOption)

Note I found the implicit Option.option2Iterable was already in scope for me. So you may not need to provide it, reducing the code down to Future.sequence(x).map(_.headOption)

Or you may prefer an extension method:

implicit class OptionSwitch[A](f: Option[Future[A]]) {
    import scala.concurrent.Future

    def switch: Future[Option[A]] = Future.sequence(Option.option2Iterable(f))
      .map(_.headOption)
  }

val myOpt = Option(Future(3))
myOpt.switch


问:
How do I resize high-res photos to thumbnails?
I have a site where a user can upload a photo. I have no idea how to handle photos. To make a thumbnail out of a large res photo, do I just resize the width and the height? Or is there  a better way to do this?

If you could point me to any resources or give me any tips, that would be great.

I'm using Ruby on Rails, if that matters. I don't really want gems for this because I want to learn how to do it myself.

答:
David answered the question well, but I thought I might be able to provide some more specific information regarding your question.

Use the Paperclip gem, combined with RMagick, an ImageMagick wrapper for Ruby. You can set post-processing options and create multiple resizings.

If you really want to do it yourself, checkout the actual gem at https://github.com/thoughtbot/paperclip and you'll see how that author does it.  Part of the thought behind Ruby on Rails is DRTW (Don't Reinvent the Wheel). Utilize what's out there and build on it. It will save you time, and enable you to do more in the longrun.


问:
LocalStorage TextBox's in JSON
Weave: https://codepen.io/anon/pen/BZVdaM?editors=0010

I'm using LocalStorage to remember the states of input[type=text] elements. I was able to push to a JSON fine

```<code>{"website": "value","behance": "value","dribbble": "value"}
</code>```

However, my problem now is I'm having difficulty populating the saved data on back in the inputs for page load.

On first run the string returned shouldn't have the quote outside of it; in addition, I noticed after 2nd run it wouldn't show any of the saved data.

Here's the result from Chrome Dev Tools (this is after the 2nd run adding text to another textbox)

Thus what am I doing wrong?

var arr = localStorage.getItem("socialValues") || {};
if ( localStorage.getItem("socialValues")) {
  var savedArrData = JSON.parse(arr);
  $.each(savedArrData, function(key, value) {
    $("[data-social=links] input#" + key).val(value);
  });
}
$("[data-social=links] input").on("change keyup", function() {
  var id = this.id;
  arr[id] = (this.value ? '"' + this.value + '"' : "");
  localStorage.removeItem("socialValues");
  localStorage.setItem("socialValues", JSON.stringify(arr));
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<ul class="uk-nav uk-nav-default" data-social="links">
  <li>

      <span class="uk-margin-small-right" uk-icon="icon: world"></span>
      <input id="website" class="socialbox" type="text" placeholder="http://yoursite.com/" value="hello world">

  </li>
  <li>

      <span class="uk-margin-small-right" uk-icon="icon: behance"></span>
      <input id="behance" class="socialbox" type="text" placeholder="Your behance page">

  </li>
  <li>

      <span class="uk-margin-small-right" uk-icon="icon: dribbble"></span>
      <input id="dribbble" class="socialbox" type="text" placeholder="Your dribbble page">

  </li>
</ul></code>```

Title: LocalStorage TextBox's in JSON

Body:
Weave: https://codepen.io/anon/pen/BZVdaM?editors=0010

I'm using LocalStorage to remember the states of input[type=text] elements. I was able to push to a JSON fine

{"website": "value","behance": "value","dribbble": "value"}

However, my problem now is I'm having difficulty populating the saved data on back in the inputs for page load.

On first run the string returned shouldn't have the quote outside of it; in addition, I noticed after 2nd run it wouldn't show any of the saved data.

Here's the result from Chrome Dev Tools (this is after the 2nd run adding text to another textbox)

Thus what am I doing wrong?

var arr = localStorage.getItem("socialValues") || {};
if ( localStorage.getItem("socialValues")) {
  var savedArrData = JSON.parse(arr);
  $.each(savedArrData, function(key, value) {
    $("[data-social=links] input#" + key).val(value);
  });
}
$("[data-social=links] input").on("change keyup", function() {
  var id = this.id;
  arr[id] = (this.value ? '"' + this.value + '"' : "");
  localStorage.removeItem("socialValues");
  localStorage.setItem("socialValues", JSON.stringify(arr));
});

      <input id="website" class="socialbox" type="text" placeholder="http://yoursite.com/" value="hello world">

      <input id="behance" class="socialbox" type="text" placeholder="Your behance page">

      <input id="dribbble" class="socialbox" type="text" placeholder="Your dribbble page">

Body:
var arr = localStorage.getItem("socialValues") || {};
if ( localStorage.getItem("socialValues")) {
  var savedArrData = JSON.parse(arr);
  $.each(savedArrData, function(key, value) {
    $("[data-social=links] input#" + key).val(value);
  });
}
$("[data-social=links] input").on("change keyup", function() {
  var id = this.id;
  arr[id] = (this.value ? '"' + this.value + '"' : "");
  localStorage.removeItem("socialValues");
  localStorage.setItem("socialValues", JSON.stringify(arr));
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<ul class="uk-nav uk-nav-default" data-social="links">
  <li>
    <a href="#">
      <span class="uk-margin-small-right" uk-icon="icon: world"></span>
      <input id="website" class="socialbox" type="text" placeholder="http://yoursite.com/" value="hello world">
    </a>
  </li>
  <li>
    <a href="#">
      <span class="uk-margin-small-right" uk-icon="icon: behance"></span>
      <input id="behance" class="socialbox" type="text" placeholder="Your behance page">
    </a>
  </li>
  <li>
    <a href="#">
      <span class="uk-margin-small-right" uk-icon="icon: dribbble"></span>
      <input id="dribbble" class="socialbox" type="text" placeholder="Your dribbble page">
    </a>
  </li>
</ul>


问:
Append a Parent to a Child Element using Jquery
I need Help for append a Child element to a parent Element. This is my code.I need to put the $input inside the $temp.

Thanks

```<code>function CaixaPin(){

  var $temp;
  $temp = $("<div></div>");
  $temp.addClass("caixa");

  var $input;
  for(var i=0; i<4; i++){
    $input = $("<div></div>");
    $input.addClass("caixaPin");
    $("body").append($input);
  }

  $("body").append($temp);

}

CaixaPin();
</code>```

答:
are you looking for something like this

https://jsfiddle.net/zyjje3r8/1

```<code><div class='parent'>
parent div - click to add child
</div>
<div class='parent'>
parent div - click to add child
</div>
</code>```

SCRIPT

```<code>$(".parent").on("click",function(){
$(this).append("<p>child element</p>")
})
</code>```

Body:
I need Help for append a Child element to a parent Element. This is my code.I need to put the $input inside the $temp.

Thanks

function CaixaPin(){

  var $temp;
  $temp = $("

");
  $temp.addClass("caixa");

  var $input;
  for(var i=0; i<4; i++){
    $input = $("

");
    $input.addClass("caixaPin");
    $("body").append($input);
  }

  $("body").append($temp);

}

CaixaPin();

Body:
are you looking for something like this

https://jsfiddle.net/zyjje3r8/1

<div class='parent'>
parent div - click to add child
</div>
<div class='parent'>
parent div - click to add child
</div>

SCRIPT

$(".parent").on("click",function(){
$(this).append("<p>child element</p>")
})