问:
initialValues works the first time, but after page refresh breaks the page, REACT/REDUX
I can click on edit comment and it will bring me to the comment edit page with the value of that comment. The problem is if I hit refresh it breaks the page and I get error comments undefined. Now I know this is because the state has been wiped, but is there a way around this that I can wait till the state loads in or such?

UPDATE: I have fixed the page from breaking on refresh but I cannot get the initialValues to get the comment value. I am not sure if there is a way to set the state value later on or not. I am getting things like author undefined and _id undefined and I know it is because I am setting the commentValue to {}. My question is there a way that when the state does get correctly updated to get those values?

Here is code for the check:

```<code>function mapStateToProps({ posts, auth, user }, ownProps) {
  let commentValue = {};
  const post = posts[ownProps.match.params.id];

  if(!post){
    return commentValue = {};
  }
  if(!posts.comments[ownProps.match.params.comment_id]) {
    return commentValue = {};
  }
  if(posts.comments[ownProps.match.params.comment_id]){
    return commentValue = posts.comments[ownProps.match.params.comment_id];
  }

  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}
</code>```

Here is the code:

```<code>import React , { Component } from 'react';
import * as actions from '../../actions/comments_actions';
import { bindActionCreators } from 'redux';
import * as actionsPosts from '../../actions/posts_actions';
import * as actionsIndex from '../../actions/index';
import { reduxForm, Field } from 'redux-form';
import {connect} from 'react-redux';
import {Link} from 'react-router-dom';

class EditComment extends Component {
  componentDidMount() {
    const {id, comment_id} = this.props.match.params;
    this.props.getOnePost(id);

    if(this.props.user._id !== this.props.post.comments[comment_id].author.id) {
      this.props.history.replace(`/posts/${id}`);
    }

    if(this.props.auth) {
      this.props.getUser();
    }

  }

  componentWillReceiveProps ({ user: nextUser, history, match, post, auth}) {

    const {user: currentUser} = this.props;
    const { id } = match.params

    if (!currentUser || nextUser !== currentUser) {
    if (nextUser && (nextUser._id !== post.author.id)) {
      history.replace(`/posts/${id}`);
    }
  }
}

  renderField(field) {
    const { meta: {touched, error} } = field;
    const className = `form-group ${touched && error ? 'has-danger' : ''}`;

    return (
      <div className={className}>
        <label><strong>{field.label}:</strong></label>
        <input
          className="form-control"
          type={field.type}
          {...field.input}
        />
        <div className="text-help">
          { touched ? error : ''}
        </div>
      </div>
    )
  }

  onSubmit(values) {
    const {comment_id} = this.props.match.params;

    this.props.editComment(values, comment_id, () => {
      this.props.history.push(`/posts/${id}`);
    });
  }

  render() {
    const {handleSubmit} = this.props;

    const {id} = this.props.match.params;

    return (
      <form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
        <Field
          label="Comment"
          name="text"
          type="text"
          component={this.renderField}
        />
        <button type="submit" className="btn btn-success">Comment</button>
        <Link to={`/posts/${id}`} className="btn btn-danger">Cancel</Link>
      </form>
    );
  }
}

function validate(values) {
  const errors = {};

  if(!values.comment) {
    errors.comment = "Enter a comment!";
  }

  return errors;
}

function mapStateToProps({ posts, auth, user }, ownProps) {
  console.log(posts[ownProps.match.params.id]);
  const commentValue = posts[ownProps.match.params.id].comments[ownProps.match.params.comment_id];
  console.log(commentValue);
  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({...actions, ...actionsIndex, ...actionsPosts}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(reduxForm({
  validate,
  form: 'editform'
})(EditComment));
</code>```

答:
With the help of markerikson I was able to come up with a solution. In the mapStateToProps I did some checks and set some initial values in the case that the state would return undefined. Here is the working code:

```<code>function mapStateToProps({ posts, auth, user }, ownProps) {
  let commentValue = {};
  const {id, comment_id} = ownProps.match.params;

  if(!posts.comments){
    commentValue = null;
  }
  if(posts[id]){
    if(posts[id] && posts[id].comments[comment_id]){
      commentValue = posts[id].comments[comment_id];
    }
  }

  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}
</code>```

Body:
I can click on edit comment and it will bring me to the comment edit page with the value of that comment. The problem is if I hit refresh it breaks the page and I get error comments undefined. Now I know this is because the state has been wiped, but is there a way around this that I can wait till the state loads in or such?

UPDATE: I have fixed the page from breaking on refresh but I cannot get the initialValues to get the comment value. I am not sure if there is a way to set the state value later on or not. I am getting things like author undefined and _id undefined and I know it is because I am setting the commentValue to {}. My question is there a way that when the state does get correctly updated to get those values?

Here is code for the check:

function mapStateToProps({ posts, auth, user }, ownProps) {
  let commentValue = {};
  const post = posts[ownProps.match.params.id];

  if(!post){
    return commentValue = {};
  }
  if(!posts.comments[ownProps.match.params.comment_id]) {
    return commentValue = {};
  }
  if(posts.comments[ownProps.match.params.comment_id]){
    return commentValue = posts.comments[ownProps.match.params.comment_id];
  }

  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}

Here is the code:

import React , { Component } from 'react';
import * as actions from '../../actions/comments_actions';
import { bindActionCreators } from 'redux';
import * as actionsPosts from '../../actions/posts_actions';
import * as actionsIndex from '../../actions/index';
import { reduxForm, Field } from 'redux-form';
import {connect} from 'react-redux';
import {Link} from 'react-router-dom';

class EditComment extends Component {
  componentDidMount() {
    const {id, comment_id} = this.props.match.params;
    this.props.getOnePost(id);

    if(this.props.user._id !== this.props.post.comments[comment_id].author.id) {
      this.props.history.replace(`/posts/${id}`);
    }

    if(this.props.auth) {
      this.props.getUser();
    }

  }

  componentWillReceiveProps ({ user: nextUser, history, match, post, auth}) {

    const {user: currentUser} = this.props;
    const { id } = match.params

    if (!currentUser || nextUser !== currentUser) {
    if (nextUser && (nextUser._id !== post.author.id)) {
      history.replace(`/posts/${id}`);
    }
  }
}

  renderField(field) {
    const { meta: {touched, error} } = field;
    const className = `form-group ${touched && error ? 'has-danger' : ''}`;

    return (

        {field.label}:
        <input
          className="form-control"
          type={field.type}
          {...field.input}
        />

          { touched ? error : ''}

    )
  }

  onSubmit(values) {
    const {comment_id} = this.props.match.params;

    this.props.editComment(values, comment_id, () => {
      this.props.history.push(`/posts/${id}`);
    });
  }

  render() {
    const {handleSubmit} = this.props;

    const {id} = this.props.match.params;

    return (
      <form onSubmit={handleSubmit(this.onSubmit.bind(this))}>
        <Field
          label="Comment"
          name="text"
          type="text"
          component={this.renderField}
        />
        <button type="submit" className="btn btn-success">Comment</button>
        <Link to={`/posts/${id}`} className="btn btn-danger">Cancel</Link>
      </form>
    );
  }
}

function validate(values) {
  const errors = {};

  if(!values.comment) {
    errors.comment = "Enter a comment!";
  }

  return errors;
}

function mapStateToProps({ posts, auth, user }, ownProps) {
  console.log(posts[ownProps.match.params.id]);
  const commentValue = posts[ownProps.match.params.id].comments[ownProps.match.params.comment_id];
  console.log(commentValue);
  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({...actions, ...actionsIndex, ...actionsPosts}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(reduxForm({
  validate,
  form: 'editform'
})(EditComment));

Body:
With the help of markerikson I was able to come up with a solution. In the mapStateToProps I did some checks and set some initial values in the case that the state would return undefined. Here is the working code:

function mapStateToProps({ posts, auth, user }, ownProps) {
  let commentValue = {};
  const {id, comment_id} = ownProps.match.params;

  if(!posts.comments){
    commentValue = null;
  }
  if(posts[id]){
    if(posts[id] && posts[id].comments[comment_id]){
      commentValue = posts[id].comments[comment_id];
    }
  }

  return {
    initialValues: commentValue,
    post: posts[ownProps.match.params.id],
    auth: auth.authenticated,
    user: user
  };
}


来源: stackexchange

问:
Is there a metadata table to check if the table in BigQuery is partitioned?
I have the following requirement.

We have 1400 sharded tables in BQ based on specific functional grouping.
Maximum of these individual sharded tables are also time-partitioned for DAY.

Smaller tables are not time-partitioned.

I am trying to create views dynamically in BigQuery by doing a UNION of all the sharded tables and writing a WHERE filter condition on _partitiontime.

But the problem is there could be smaller tables which are not time-partitioned, the query fails.

There are many more tables created on daily basis and I cant settle for a static exclusion solution since that would require manually maintaining a file with table names etc. (Apache Beam + BQ uses the data that is coming in and creates new sharded tables for newer functional groups without manual intervention.)

I am trying to exclude the non time-partitioned tables by using bq utility to connect to BQ more than 1000 times to check if a table is time-partitioned.

bq show --format=prettyjson
and check the timepartitioning type field.

This is very slow, more than 30 minutes.

I have tried the __TABLES_SUMMARY__, but it does not have the partitioning info.

I have also checked
SELECT partition_id from [mydataset.table1$__PARTITIONS_SUMMARY__];, but this works if the table is already partitioned.

答:
Unfortunately, there is no way to determine this dynamically.

As a workaround, I would suggest keeping your partitioned tables and your non-partitioned tables in distinct datasets OR including information about whether the table is partitioned in its name.

You could also maintain a list of table prefixes that are known to be partitioned (or non-partitioned, if that is easier to maintain).

You can also open a feature request on the public issue tracker for BigQuery: https://issuetracker.google.com/issues/new?component=187149&template=0

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


问:
Reverting Unstaged Changes to Single File in Git
I have about 20 files which have unstaged changes since the last commit. I would like to discard changes in one of these files while keeping the changes to the rest intact. How could I do that?</p>

答: git checkout -- <file-path>

Body: git checkout -- <file-path>


问:
get value from multiple checkbox's selected and append into jtextarea
My current code will only append the last checkbox selected. I need to get all values from selected checkbox and append into jtextarea to later be printed. Maybe an array but not sure how to append an array. Thanks for any help!

EDIT: I solved this! Instead of taking the values to the append method, I took the append method to the values to get my desired output.I posted updated code.

```<code>        private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {
    //declare local variables
    String item = null;
    int quanity = 0;
    double priceEa = 0;
    double total = 0;

    if (jCTiteliestGolfBall.isSelected()) {
        quanity = Integer.parseInt(jQty1.getText());
        item = jCTiteliestGolfBall.getActionCommand();
        priceEa = 1.50;
        total = (priceEa * quanity);
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity = Integer.parseInt(jQty2.getText());
        item = jCTiteliestGolfClubs.getActionCommand();
        priceEa = 150.00;
        total = (priceEa * quanity);
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity = Integer.parseInt(jQty3.getText());
        item = jCGregNormanGolfShirt.getActionCommand();
        priceEa = 15.00;
        total = (priceEa * quanity);
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity = Integer.parseInt(jQty4.getText());
        item = jCGregNormanGolfHat.getActionCommand();
        priceEa = 10.00;
        total = (priceEa * quanity);
    }
    if (jCGolfGlove.isSelected()) {
        quanity = Integer.parseInt(jQty5.getText());
        item = jCGolfGlove.getActionCommand();
        priceEa = 2.00;
        total = (priceEa * quanity);
    }
    if (jCGolfTees.isSelected()) {
        quanity = Integer.parseInt(jQty6.getText());
        item = jCGolfTees.getActionCommand();
        priceEa = .50;
        total = (priceEa * quanity);
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\tFolly Beach Golf:\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total)
            + "\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");
</code>```

UPDATED:
        private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {

        //declare local variables
        String item ="";
        int quanity = 0;
        double priceEa = 0;
        double total = 0;

```<code>    jTextAreaReciept.append("\tFolly Beach Golf:\n");

    if (jCTiteliestGolfBall.isSelected()) {
        quanity = Integer.parseInt(jQty1.getText());
        item = jCTiteliestGolfBall.getActionCommand();
        priceEa = 1.50;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity = Integer.parseInt(jQty2.getText());
        item = jCTiteliestGolfClubs.getActionCommand();
        priceEa = 150.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity = Integer.parseInt(jQty3.getText());
        item = jCGregNormanGolfShirt.getActionCommand();
        priceEa = 15.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity = Integer.parseInt(jQty4.getText());
        item = jCGregNormanGolfHat.getActionCommand();
        priceEa = 10.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGolfGlove.isSelected()) {
        quanity = Integer.parseInt(jQty5.getText());
        item = jCGolfGlove.getActionCommand();
        priceEa = 2.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGolfTees.isSelected()) {
        quanity = Integer.parseInt(jQty6.getText());
        item = jCGolfTees.getActionCommand();
        priceEa = .50;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\n\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");
</code>```

答:
Try this code :</p>

```<code>private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {
    //declare local variables
    String item = "";
    int quanity = 0;
    double priceEa = 0;
    double total = 0;

    if (jCTiteliestGolfBall.isSelected()) {
        quanity += Integer.parseInt(jQty1.getText());
        item += jCTiteliestGolfBall.getActionCommand();
        priceEa += 1.50;
        total += (priceEa * quanity);
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity += Integer.parseInt(jQty2.getText());
        item += jCTiteliestGolfClubs.getActionCommand();
        priceEa += 150.00;
        total += (priceEa * quanity);
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity += Integer.parseInt(jQty3.getText());
        item += jCGregNormanGolfShirt.getActionCommand();
        priceEa += 15.00;
        total += (priceEa * quanity);
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity += Integer.parseInt(jQty4.getText());
        item += jCGregNormanGolfHat.getActionCommand();
        priceEa += 10.00;
        total += (priceEa * quanity);
    }
    if (jCGolfGlove.isSelected()) {
        quanity += Integer.parseInt(jQty5.getText());
        item += jCGolfGlove.getActionCommand();
        priceEa += 2.00;
        total += (priceEa * quanity);
    }
    if (jCGolfTees.isSelected()) {
        quanity += Integer.parseInt(jQty6.getText());
        item += jCGolfTees.getActionCommand();
        priceEa += .50;
        total += (priceEa * quanity);
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\tFolly Beach Golf:\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total)
            + "\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");
</code>```

Body:
My current code will only append the last checkbox selected. I need to get all values from selected checkbox and append into jtextarea to later be printed. Maybe an array but not sure how to append an array. Thanks for any help!

EDIT: I solved this! Instead of taking the values to the append method, I took the append method to the values to get my desired output.I posted updated code.

        private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {
    //declare local variables
    String item = null;
    int quanity = 0;
    double priceEa = 0;
    double total = 0;

    if (jCTiteliestGolfBall.isSelected()) {
        quanity = Integer.parseInt(jQty1.getText());
        item = jCTiteliestGolfBall.getActionCommand();
        priceEa = 1.50;
        total = (priceEa * quanity);
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity = Integer.parseInt(jQty2.getText());
        item = jCTiteliestGolfClubs.getActionCommand();
        priceEa = 150.00;
        total = (priceEa * quanity);
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity = Integer.parseInt(jQty3.getText());
        item = jCGregNormanGolfShirt.getActionCommand();
        priceEa = 15.00;
        total = (priceEa * quanity);
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity = Integer.parseInt(jQty4.getText());
        item = jCGregNormanGolfHat.getActionCommand();
        priceEa = 10.00;
        total = (priceEa * quanity);
    }
    if (jCGolfGlove.isSelected()) {
        quanity = Integer.parseInt(jQty5.getText());
        item = jCGolfGlove.getActionCommand();
        priceEa = 2.00;
        total = (priceEa * quanity);
    }
    if (jCGolfTees.isSelected()) {
        quanity = Integer.parseInt(jQty6.getText());
        item = jCGolfTees.getActionCommand();
        priceEa = .50;
        total = (priceEa * quanity);
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\tFolly Beach Golf:\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total)
            + "\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");

UPDATED:
        private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {

        //declare local variables
        String item ="";
        int quanity = 0;
        double priceEa = 0;
        double total = 0;

    jTextAreaReciept.append("\tFolly Beach Golf:\n");

    if (jCTiteliestGolfBall.isSelected()) {
        quanity = Integer.parseInt(jQty1.getText());
        item = jCTiteliestGolfBall.getActionCommand();
        priceEa = 1.50;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity = Integer.parseInt(jQty2.getText());
        item = jCTiteliestGolfClubs.getActionCommand();
        priceEa = 150.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity = Integer.parseInt(jQty3.getText());
        item = jCGregNormanGolfShirt.getActionCommand();
        priceEa = 15.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity = Integer.parseInt(jQty4.getText());
        item = jCGregNormanGolfHat.getActionCommand();
        priceEa = 10.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGolfGlove.isSelected()) {
        quanity = Integer.parseInt(jQty5.getText());
        item = jCGolfGlove.getActionCommand();
        priceEa = 2.00;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    if (jCGolfTees.isSelected()) {
        quanity = Integer.parseInt(jQty6.getText());
        item = jCGolfTees.getActionCommand();
        priceEa = .50;
        total = (priceEa * quanity);
        jTextAreaReciept.append("\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total));
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\n\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");

Body:
Try this code :

private void jBtnRecieptActionPerformed(java.awt.event.ActionEvent evt) {
    //declare local variables
    String item = "";
    int quanity = 0;
    double priceEa = 0;
    double total = 0;

    if (jCTiteliestGolfBall.isSelected()) {
        quanity += Integer.parseInt(jQty1.getText());
        item += jCTiteliestGolfBall.getActionCommand();
        priceEa += 1.50;
        total += (priceEa * quanity);
    }
    if (jCTiteliestGolfClubs.isSelected()) {
        quanity += Integer.parseInt(jQty2.getText());
        item += jCTiteliestGolfClubs.getActionCommand();
        priceEa += 150.00;
        total += (priceEa * quanity);
    }
    if (jCGregNormanGolfShirt.isSelected()) {
        quanity += Integer.parseInt(jQty3.getText());
        item += jCGregNormanGolfShirt.getActionCommand();
        priceEa += 15.00;
        total += (priceEa * quanity);
    }
    if (jCGregNormanGolfHat.isSelected()) {
        quanity += Integer.parseInt(jQty4.getText());
        item += jCGregNormanGolfHat.getActionCommand();
        priceEa += 10.00;
        total += (priceEa * quanity);
    }
    if (jCGolfGlove.isSelected()) {
        quanity += Integer.parseInt(jQty5.getText());
        item += jCGolfGlove.getActionCommand();
        priceEa += 2.00;
        total += (priceEa * quanity);
    }
    if (jCGolfTees.isSelected()) {
        quanity += Integer.parseInt(jQty6.getText());
        item += jCGolfTees.getActionCommand();
        priceEa += .50;
        total += (priceEa * quanity);
    }
    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd   HH:mm:ss");
    LocalDateTime now = LocalDateTime.now();
    date = (dtf.format(now));

    jTextAreaReciept.append("\tFolly Beach Golf:\n" + item + "   " + quanity + "  @  "
            +   String.format("%.2f", priceEa) + "  =   " + String.format("%.2f", total)
            + "\nSubtotal: " + jTextFieldCostofItems.getText()
            + "\nTax: " + jTextFieldTax.getText()
            + "\nTotal: " + jTextFieldTotal.getText()
            + "\n\nDate/Time:  " + date + "\n\n\tThank you for your business");


问:
Minimum legible font size and internationalization
Is there any way to determine a base minimum font size for a given language or font?

I've been looking for some way to tell programatically if a browser font/glyph size is perceptually equal across different languages? For example, I've seen that Thai fonts are painfully small compared to Latin or Japanese (probably because of Thai's enormous ascenders force everything to scale down to fit in each glyph's bounding box). And I suspect that lots and lots of other languages have very different "minimum legible size" values from Latin fonts.

Here is an example of the problem, first with clearly legible English text (in the blue buttons). Below that is a picture of equivalent Thai text, which has identical styling but is barely legible.

This shows Thai and Latin fonts. When Thai and Latin text have an equal font-size applied to them, Thai is perceptually "too small" (this is more obvious at smaller font sizes). Increasing it by 15% gives something closer to actual Thai presentation:

I can use the CSS Object Model's element.getBoundingClientRect() to find the dimensions of shapes and elements, but I know of no way of measuring inside a font. And CanvasRenderingContext2D.measureText() currently only gives width information.

Is there any method / API (in the browser or not) for determining a sort of "base font size" that perhaps discounts ascenders and descenders or even gives a suggested base font size?

答:
In my opinion it's not the question of i18n, but a11y (that is accessibility). You see, if you set the font too small some people (me included) will not be able to read it.

Of course there are cases like Traditional Chinese where 12 point is an absolute minimum because otherwise some strokes will not be clearly seen. But it's hard to give exact numbers for all languages without actual UI testing.


问:
Call a Form and correct way to release? memory usage
I'm using Delphi 7.

I have two units containing Form1 and Form2. The secondary form will be called many times during some process, and I am very worried about memory usage.

When I start the program, memory usage is around 2.1 MB. When Form2 is called, memory grows to 2.9 MB.  After this process, I close Form2 and call it again to simulate regular usage, and memory grows to 3.1 MB, call again and memory grows to 3.4 MB, 3.6 MB, 3.8 MB, etc.

Memory usage is the main issue.

Form1 is calling Form2 like this:

```<code>uses
  Unit2;

...

private
  { Private declarations }
  FChild : TForm2;
...

FChild := TForm2.Create(nil);
try
  FChild.ShowModal;
finally
  FChild.Free;
end;
</code>```

Inside Unit2:

```<code>procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;
</code>```

Am I doing something wrong? Is there a better solution?

Please, this not a simple question, because this program will be running 24 hours, and the second form will be called many times.  This means that sometimes this program will freeze the computer.

I included FASTMM4 inside project:

```<code>program Project1;

uses
  FastMM4,
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
  FullDebugModeScanMemoryPoolBeforeEveryOperation := True;
  SuppressMessageBoxes:=False;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
</code>```

This program is reading a fingerprint.

Unit1:

```<code>unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Unit2;

type
  TForm1 = class(TForm)
    btnForm2: TButton;
    btnReselease: TButton;
    procedure btnForm2Click(Sender: TObject);
    procedure btnReseleaseClick(Sender: TObject);
  private
    { Private declarations }
    FChild : TForm2;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnForm2Click(Sender: TObject);

begin
  FChild := TForm2.Create(nil);
  try
    FChild.ShowModal;
  finally
    FChild.Free;
  end;
end;

procedure TForm1.btnReseleaseClick(Sender: TObject);
begin
  if FChild <> nil then
  begin
    FreeAndNil(FChild);
  end;
end;

end.
</code>```

Unit2:

```<code>unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, pngimage, ExtCtrls, Grids,  XMLIntf, XMLDoc,
  ComCtrls, CPort;

type
  TForm2 = class(TForm)
    btnSyncFP: TBitBtn;
    btnExitFP: TBitBtn;
    btnDeleteFP: TBitBtn;
    btnCaptureFP: TBitBtn;
    ComImage: TImage;
    FPGrid: TStringGrid;
    prgBar: TProgressBar;
    lblbar: TLabel;
    ComPortA: TComPort;
    ComDataPacket1: TComDataPacket;
    procedure LoadUsers2;
    procedure FormCreate(Sender: TObject);
    procedure ComPortAAfterOpen(Sender: TObject);
    procedure ComPortAAfterClose(Sender: TObject);
    procedure btnExitFPClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
//  Form2: TForm2;
  L1, L2: TStringList;

implementation
{$R *.dfm}

procedure TForm2.LoadUsers2;
var
  XML : IXMLDOCUMENT;
  CurNode, CNode : IXMLNODE;
  i : Integer;
begin
  XML := NewXMLDocument;
  XML.LoadFromFile('usuario.xml');
  XML.Active := True;
  CurNode := XML.DocumentElement.ChildNodes[0]; // users
  FPGrid.RowCount := CurNode.ChildNodes.Count+1;
  prgBar.Min := 0;
  prgBar.Max := CurNode.ChildNodes.Count-1;
  lblBar.Caption := 'Carregando usuários...';
  for i := 0 to CurNode.ChildNodes.Count-1 do
  begin
    CNode := CurNode.ChildNodes[i]; // groups
    with CNode do
    begin
      FPGrid.Cells[2,i+1] := Attributes['group'];
      FPGrid.Cells[1,i+1] := Attributes['id'];
      FPGrid.Cells[0,i+1] := Attributes['name'];
      FPGrid.Cells[3,i+1] := Attributes['fingerID'];
      FPGrid.Cells[4,i+1] := Attributes['level'];
      FPGrid.Cells[5,i+1] := Attributes['status'];
    end;
    if FPGrid.Cells[3,i+1]<>'' then L1.Add(FPGrid.Cells[3,i+1]);
    prgBar.Position := i;
  end;
  XML := nil;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  LoadUsers2;
  with FPGrid do
  begin
    Font.Name := 'Tahoma';
    Font.Size := 12;
    ColCount := 4;
    Cells[0,0] := 'Name';  Cells[1,0] := 'ID';
    Cells[2,0] := 'Group'; Cells[3,0] := 'Read ID';
    Cells[4,0] := 'Level'; Cells[5,0] := 'Status';
    ScrollBars := ssVertical;
    Options := Options + [goRowSelect];
  end;
  ComPortA.Open;
end;

procedure TForm2.ComPortAAfterOpen(Sender: TObject);
begin
  ComImage.Picture.LoadFromFile('conn_on.png');
end;

procedure TForm2.ComPortAAfterClose(Sender: TObject);
begin
  ComImage.Picture.LoadFromFile('conn_off.png');
end;

procedure TForm2.btnExitFPClick(Sender: TObject);
begin
  ComPortA.Close;
  Close;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

end.
</code>```

I know that Task Manager is the best to verify leak memory, but after few hours, the program is growing faster and not realeasing memory.

I let the program running all night and memory is backing, but there is a long time not enough as user usage.

答:
Use FastMM. See article and add FastMM.

If you can, create separated build configuration with fully enabled FastMM diagnostics and run it i. e. before merging to master git branch. I use this strategy and greatly increase quality of my code, without any drawbacks (FastMM diagnostics are kinda heavy  for compiler, but I run them not often, so it's ok).

Body:
I'm using Delphi 7.

I have two units containing Form1 and Form2. The secondary form will be called many times during some process, and I am very worried about memory usage.

When I start the program, memory usage is around 2.1 MB. When Form2 is called, memory grows to 2.9 MB.  After this process, I close Form2 and call it again to simulate regular usage, and memory grows to 3.1 MB, call again and memory grows to 3.4 MB, 3.6 MB, 3.8 MB, etc.

Memory usage is the main issue.

Form1 is calling Form2 like this:

uses
  Unit2;

...

private
  { Private declarations }
  FChild : TForm2;
...

FChild := TForm2.Create(nil);
try
  FChild.ShowModal;
finally
  FChild.Free;
end;

Inside Unit2:

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

Am I doing something wrong? Is there a better solution?

Please, this not a simple question, because this program will be running 24 hours, and the second form will be called many times.  This means that sometimes this program will freeze the computer.

I included FASTMM4 inside project:

program Project1;

uses
  FastMM4,
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
  FullDebugModeScanMemoryPoolBeforeEveryOperation := True;
  SuppressMessageBoxes:=False;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

This program is reading a fingerprint.

Unit1:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Unit2;

type
  TForm1 = class(TForm)
    btnForm2: TButton;
    btnReselease: TButton;
    procedure btnForm2Click(Sender: TObject);
    procedure btnReseleaseClick(Sender: TObject);
  private
    { Private declarations }
    FChild : TForm2;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnForm2Click(Sender: TObject);

begin
  FChild := TForm2.Create(nil);
  try
    FChild.ShowModal;
  finally
    FChild.Free;
  end;
end;

procedure TForm1.btnReseleaseClick(Sender: TObject);
begin
  if FChild <> nil then
  begin
    FreeAndNil(FChild);
  end;
end;

end.

Unit2:

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, pngimage, ExtCtrls, Grids,  XMLIntf, XMLDoc,
  ComCtrls, CPort;

type
  TForm2 = class(TForm)
    btnSyncFP: TBitBtn;
    btnExitFP: TBitBtn;
    btnDeleteFP: TBitBtn;
    btnCaptureFP: TBitBtn;
    ComImage: TImage;
    FPGrid: TStringGrid;
    prgBar: TProgressBar;
    lblbar: TLabel;
    ComPortA: TComPort;
    ComDataPacket1: TComDataPacket;
    procedure LoadUsers2;
    procedure FormCreate(Sender: TObject);
    procedure ComPortAAfterOpen(Sender: TObject);
    procedure ComPortAAfterClose(Sender: TObject);
    procedure btnExitFPClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
//  Form2: TForm2;
  L1, L2: TStringList;

implementation
{$R *.dfm}

procedure TForm2.LoadUsers2;
var
  XML : IXMLDOCUMENT;
  CurNode, CNode : IXMLNODE;
  i : Integer;
begin
  XML := NewXMLDocument;
  XML.LoadFromFile('usuario.xml');
  XML.Active := True;
  CurNode := XML.DocumentElement.ChildNodes[0]; // users
  FPGrid.RowCount := CurNode.ChildNodes.Count+1;
  prgBar.Min := 0;
  prgBar.Max := CurNode.ChildNodes.Count-1;
  lblBar.Caption := 'Carregando usuários...';
  for i := 0 to CurNode.ChildNodes.Count-1 do
  begin
    CNode := CurNode.ChildNodes[i]; // groups
    with CNode do
    begin
      FPGrid.Cells[2,i+1] := Attributes['group'];
      FPGrid.Cells[1,i+1] := Attributes['id'];
      FPGrid.Cells[0,i+1] := Attributes['name'];
      FPGrid.Cells[3,i+1] := Attributes['fingerID'];
      FPGrid.Cells[4,i+1] := Attributes['level'];
      FPGrid.Cells[5,i+1] := Attributes['status'];
    end;
    if FPGrid.Cells[3,i+1]<>'' then L1.Add(FPGrid.Cells[3,i+1]);
    prgBar.Position := i;
  end;
  XML := nil;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  LoadUsers2;
  with FPGrid do
  begin
    Font.Name := 'Tahoma';
    Font.Size := 12;
    ColCount := 4;
    Cells[0,0] := 'Name';  Cells[1,0] := 'ID';
    Cells[2,0] := 'Group'; Cells[3,0] := 'Read ID';
    Cells[4,0] := 'Level'; Cells[5,0] := 'Status';
    ScrollBars := ssVertical;
    Options := Options + [goRowSelect];
  end;
  ComPortA.Open;
end;

procedure TForm2.ComPortAAfterOpen(Sender: TObject);
begin
  ComImage.Picture.LoadFromFile('conn_on.png');
end;

procedure TForm2.ComPortAAfterClose(Sender: TObject);
begin
  ComImage.Picture.LoadFromFile('conn_off.png');
end;

procedure TForm2.btnExitFPClick(Sender: TObject);
begin
  ComPortA.Close;
  Close;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

end.

I know that Task Manager is the best to verify leak memory, but after few hours, the program is growing faster and not realeasing memory.

I let the program running all night and memory is backing, but there is a long time not enough as user usage.


问:
Has Many Nested form not saving to database
Still learning rails and have been stuck on this for a while, I have a feeling it's a simple fix and I'm just not getting it.

I'm trying to use a separate model to populate a dropdown in another model's form. So a nested form. It is the type of activity done in a workout.

Here's what I have set up.

Workout Model

```<code>class Workout < ActiveRecord::Base
  belongs_to :user
  has_many :activities
  accepts_nested_attributes_for :activities
  validates :activity, presence: true
end
</code>```

Workout Controller Params

```<code>def workout_params
      params.require(:workout).permit(:rating, :activity, :workout_date, :activity_id, activity_params:[:id, :title])
end
</code>```

Activity Model

```<code>class Activity < ActiveRecord::Base
  belongs_to :workout
end
</code>```

Activity Controller Params

```<code>def activity_params
   params.require(:activities).permit(:title, :rating, workout_params:[:id])
end
</code>```

View

```<code><%= form_for(@workout) do |f| %>
     <div class="control-group">
       <%= f. label :activity, class: 'control-label' %>
     </div>
     <div class="checkbox">
       <%= collection_select( :activity, :workout_id, Activity.all, :id, :title, {},
     {:multiple => false }) %>
     </div>
     <div class="actions">
       <%= f.submit %>
     </div>
<% end %>
</code>```

Thanks in advance

答:
Fixed it. Error was in the view > collection_select. The order was wrong and i changed :activity_id to :activity</p>

```<code> <%= collection_select :workout, :activity, Activity.all, :id, :title, {}, {:multiple => false } %>
</code>```

Body:
Still learning rails and have been stuck on this for a while, I have a feeling it's a simple fix and I'm just not getting it.

I'm trying to use a separate model to populate a dropdown in another model's form. So a nested form. It is the type of activity done in a workout.

Here's what I have set up.

Workout Model

class Workout < ActiveRecord::Base
  belongs_to :user
  has_many :activities
  accepts_nested_attributes_for :activities
  validates :activity, presence: true
end

Workout Controller Params

def workout_params
      params.require(:workout).permit(:rating, :activity, :workout_date, :activity_id, activity_params:[:id, :title])
end

Activity Model

class Activity < ActiveRecord::Base
  belongs_to :workout
end

Activity Controller Params

def activity_params
   params.require(:activities).permit(:title, :rating, workout_params:[:id])
end

View

<%= form_for(@workout) do |f| %>

       <%= f. label :activity, class: 'control-label' %>

       <%= collection_select( :activity, :workout_id, Activity.all, :id, :title, {},
     {:multiple => false }) %>

       <%= f.submit %>

<% end %>

Thanks in advance

Body:
Fixed it. Error was in the view > collection_select. The order was wrong and i changed :activity_id to :activity

 <%= collection_select :workout, :activity, Activity.all, :id, :title, {}, {:multiple => false } %>


问:
Best approach for (cross-platform) real-time data streaming in PHP?
I've been wondering how to do "true" (semi) real-time data streaming with PHP.

Possible applications: chat rooms, auctions, games, etc.

By "true", I mean the data is not just written somewhere and polled continuously, but actually streaming to the client somehow.

By "semi", I mean it's okay if only the stream from the server to the client is real-time, and messages from the client to the server are not.

For the communication between the client and server, I'd like to stick with plain HTTP (AJAX) rather than some other protocol.

Streaming to the client with HTTP is possible by manually flushing the output buffer.

The question is what to connect that script to on the server-side?

And once it's connected, to do a blocking read, rather than polling for changes.

The shared memory (shmop) extension would work, but it's not cross-platform.

Perhaps memcached would work? But I'm not sure if there's a way to do a blocking read, so it comes down to polling again - although I'm sure memcached is pretty fast, I just don't like the idea of continuous polling.

Any ideas?

答:
If you want to communicate between PHP and another language (for instance a C++ application) you might want to look into Apache Thrift (http://thrift.apache.org/). Apache Thrift is widely used at Facebook for "scalable cross-language services development".

Edit: I would probably use Apache Thrift to communicate with a Twisted application listening on port 80 and have the browsers connect to the Twisted application using either long polling or a websocket. You might want to also look into Socket.IO, it's a cross-browser web socket implementation which is made for realtime applications.

Basically you would have your application push to your Twisted web server using Thrift and you would then pass the message to any open connections.

Christian

ContentLicense: CC BY-SA 2.5


问:
Retrieve list of PCs that are not running a specific process
How do I get a list of PCs that don't have a process running with this script that I wrote?</p>

```<code><#
Searches AD for all computers that can ping and checks to see if a process
is running
#>

Import-Module active*

$PingTest = $null
$Clist = @()

Get-ADComputer -Filter *  -Properties * | ? {$_.operatingsystem -like  "*windows 7*"} |
    ForEach-Object {

        # test to see if the computer is on the network
        $PingTest = Test-Connection -ComputerName $_.name -Count 1 -BufferSize 16 -Quiet

        # If test is $true adds each computer to the array $Clist
        If ($PingTest) {$Clist += $_.name}
        Else {}

}#ForEach

#check for process running on each computer in the array $Clist

Invoke-Command -ComputerName $Clist -ScriptBlock {Get-Process -Name mcshield}
</code>```

答:
Use Get-Process inside an If statement. If a process is returned it will evaluate to true. You could then export the list out as a spreadsheet using Export-Csv

```<code>$Computers = Get-ADComputer -Filter "OperatingSystem -like '*Windows 7*'"
$ProcessRunning =  $Computers |
    ForEach-Object {
        If ( Test-Connection -ComputerName $_.name -Count 1 -BufferSize 16 -Quiet ) {
            If (Get-Process -ComputerName $_.name -Name mcshield -ErrorAction SilentlyContinue) {
                [pscustomobject]@{
                    'ComputerName' = $_.name
                    'Process Running' = $True
                }
            } Else {
                [pscustomobject]@{
                    'ComputerName' = $_.name
                    'Process Running' = $False
                }
            }
        }
    }

$ProcessRunning | Export-Csv C:\example\path.csv -NoTypeInformation
</code>```

Body:
How do I get a list of PCs that don't have a process running with this script that I wrote?

<#
Searches AD for all computers that can ping and checks to see if a process
is running
#>

Import-Module active*

$PingTest = $null
$Clist = @()

Get-ADComputer -Filter *  -Properties * | ? {$_.operatingsystem -like  "*windows 7*"} |
    ForEach-Object {

        # test to see if the computer is on the network
        $PingTest = Test-Connection -ComputerName $_.name -Count 1 -BufferSize 16 -Quiet

        # If test is $true adds each computer to the array $Clist
        If ($PingTest) {$Clist += $_.name}
        Else {}

}#ForEach

#check for process running on each computer in the array $Clist

Invoke-Command -ComputerName $Clist -ScriptBlock {Get-Process -Name mcshield}

Body:
Use Get-Process inside an If statement. If a process is returned it will evaluate to true. You could then export the list out as a spreadsheet using Export-Csv

$Computers = Get-ADComputer -Filter "OperatingSystem -like '*Windows 7*'"
$ProcessRunning =  $Computers |
    ForEach-Object {
        If ( Test-Connection -ComputerName $_.name -Count 1 -BufferSize 16 -Quiet ) {
            If (Get-Process -ComputerName $_.name -Name mcshield -ErrorAction SilentlyContinue) {
                [pscustomobject]@{
                    'ComputerName' = $_.name
                    'Process Running' = $True
                }
            } Else {
                [pscustomobject]@{
                    'ComputerName' = $_.name
                    'Process Running' = $False
                }
            }
        }
    }

$ProcessRunning | Export-Csv C:\example\path.csv -NoTypeInformation


问:
How to change font-size dynamically so that it always fits into its parent container
In my blog, the title of the posts are shown on a div where a video plays in the background. Sometimes the title of the blog is 2 words, sometimes it is more than 20 words. And in the latter case, the text may overflow from its parent container where the video plays.

I do not want to hide the overflown material or use a scrollbar or any "...". The solution I am looking for is resizing the font dynamically if the text overflows so that it fits exactly to its parent div in any viewport.

Here is the code: https://codepen.io/anon/pen/QgBZqd

```<code><!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>SINEMACERA</title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="styles.css">
  <link href="https://fonts.googleapis.com/css?family=Anton|Cabin" rel="stylesheet">
</head>
<body>

<!--NAVBAR STARTS-->

<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">SINEMACERA</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">

        <li class="active"><a href="#">Anasayfa</a></li>

      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Hakkımda</a></li>
        <li><a href="#">İletişim</a></li>

      </ul>
    </div><!-- /.navbar-collapse -->
    </div>
</nav>

<!--NAVBAR ENDS-->

<div id="COVERPHOTO">

    <div id="COVER">
      <h1 id="COVERTEXT">A TEXT SO LONG THAT IT CAN NOT FIT INTO THE PARENT DIV CONTAINER AND MIXES UP WITH THE BLOG, HENCE IT BECOMES UNAESTHETIC. THIS TEXT COULD HAVE BEEN EVEN LONGER AND LONGER</h1>
      <video autoplay loop id="video-background" muted plays-inline>
        <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
      </video>
      </div>
  </div>

<div class="container">
    <div class="row">
    <div id="MAJORCONTENT">

        <div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

        <div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

<div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

</div>
    </div>
</div>

  <script
    src="https://code.jquery.com/jquery-3.2.1.js"
    integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
    crossorigin="anonymous"></script>

  <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="sinemacera.js"></script>
</body>
</html>
</code>```

CSS

```<code>body {
    background: black;
    color:white;
    font-family: Cabin;
}

.wide-button {
    width:100%;
}

h1 {
    text-align: center;
    text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4)

}

.row {
    float:left;
}

.readmore {
    display:none;
}

#COVERPHOTO {
    margin-top: 50px;
}

#COVER {
    opacity:0;
    position: relative;
    font-size: 40px;
    text-align: center;
}

#COVERTEXT {
    opacity: 0;
    margin:0;
    font-family: Anton;
        font-size: 10vw;

    text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
             0px 8px 13px rgba(0, 0, 0, 0.3),
             0px 18px 23px rgba(0, 0, 0,0.3);
    position: absolute;
    top:50%;
    left:0;
    right: 0;

    transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    -o-transform: translateY(-50%);
    transform: -moz-translateY(-50%);
                }

#MAJORCONTENT {
text-align: justify;
font-size: 1.5em;
margin-bottom: 5%;
}

video {
    width:100%;
    height: auto;
}

.container:nth-of-type(2) {
    padding-bottom: 1%;
}
</code>```

JS

```<code>$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
    thisBTN.toggleClass("btn-info")
    if(thisBTN.text()==="Küçült") {
        thisBTN.text("Devamını oku");
    }
    else {
        thisBTN.text("Küçült")
    }
});
});

    $("#COVER").fadeTo(400,1);
    $("#COVERTEXT").delay(600).fadeTo(500,0.5);
</code>```

答:
You can use in css the vh unit:

```<code>font-size: 20vh;
</code>```

Body:
In my blog, the title of the posts are shown on a div where a video plays in the background. Sometimes the title of the blog is 2 words, sometimes it is more than 20 words. And in the latter case, the text may overflow from its parent container where the video plays.

I do not want to hide the overflown material or use a scrollbar or any "...". The solution I am looking for is resizing the font dynamically if the text overflows so that it fits exactly to its parent div in any viewport.

Here is the code: https://codepen.io/anon/pen/QgBZqd

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>SINEMACERA</title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="styles.css">
  <link href="https://fonts.googleapis.com/css?family=Anton|Cabin" rel="stylesheet">

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

      </button>
      SINEMACERA

Anasayfa

Hakkımda

İletişim

A TEXT SO LONG THAT IT CAN NOT FIT INTO THE PARENT DIV CONTAINER AND MIXES UP WITH THE BLOG, HENCE IT BECOMES UNAESTHETIC. THIS TEXT COULD HAVE BEEN EVEN LONGER AND LONGER

      <video autoplay loop id="video-background" muted plays-inline>
        <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
      </video>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

CSS

body {
    background: black;
    color:white;
    font-family: Cabin;
}

.wide-button {
    width:100%;
}

h1 {
    text-align: center;
    text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4)

}

.row {
    float:left;
}

.readmore {
    display:none;
}

#COVERPHOTO {
    margin-top: 50px;
}

#COVER {
    opacity:0;
    position: relative;
    font-size: 40px;
    text-align: center;
}

#COVERTEXT {
    opacity: 0;
    margin:0;
    font-family: Anton;
        font-size: 10vw;

    text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
             0px 8px 13px rgba(0, 0, 0, 0.3),
             0px 18px 23px rgba(0, 0, 0,0.3);
    position: absolute;
    top:50%;
    left:0;
    right: 0;

    transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    -o-transform: translateY(-50%);
    transform: -moz-translateY(-50%);
                }

#MAJORCONTENT {
text-align: justify;
font-size: 1.5em;
margin-bottom: 5%;
}

video {
    width:100%;
    height: auto;
}

.container:nth-of-type(2) {
    padding-bottom: 1%;
}

JS

$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
    thisBTN.toggleClass("btn-info")
    if(thisBTN.text()==="Küçült") {
        thisBTN.text("Devamını oku");
    }
    else {
        thisBTN.text("Küçült")
    }
});
});

    $("#COVER").fadeTo(400,1);
    $("#COVERTEXT").delay(600).fadeTo(500,0.5);

Body:
You can use in css the vh unit:

font-size: 20vh;


问:
Why did boost regex run out of stack space?
```<code>#include <boost/regex.hpp>
#include <string>
#include <iostream>

using namespace boost;
static const regex regexp(
        "std::vector<"
            "(std::map<"
                   "(std::pair<((\\w+)(::)?)+, (\\w+)>,?)+"
             ">,?)+"
        ">");

std::string errorMsg =
"std::vector<"
        "std::map<"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>"
        ">,"
        "std::map<"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>"
        ">"
">";
int main()
{
    smatch result;
    if(regex_match(errorMsg, result, regexp))
    {
        for (unsigned i = 0; i < result.size(); ++i)
        {
            std::cout << result[i] << std::endl;
        }
    }

//    std::cout << errorMsg << std::endl;

    return 0;
}
</code>```

this produces:

```<code>terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error>
>'   what():  Ran out of stack space trying to match the regular expression.
</code>```

compiled with

```<code>g++ regex.cc -lboost_regex
</code>```

EDIT

my platform:

```<code>g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
libboost-regex1.42
Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz
So the latest Ubuntu 64 bit
</code>```

答:
Tested it locally and it worked fine, my guess is your compiler is doing something weird.

What version of gcc? what platform? which version of boost?

```<code> -> ./regex
std::vector<std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>,std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>>
std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>
std::pair<Test::Test, int>
Test
Test
::
int
</code>```

Body:
#include <boost/regex.hpp>
#include <string>
#include <iostream>

using namespace boost;
static const regex regexp(
        "std::vector<"
            "(std::map<"
                   "(std::pair<((\\w+)(::)?)+, (\\w+)>,?)+"
             ">,?)+"
        ">");

std::string errorMsg =
"std::vector<"
        "std::map<"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>"
        ">,"
        "std::map<"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>,"
                "std::pair<Test::Test, int>"
        ">"
">";
int main()
{
    smatch result;
    if(regex_match(errorMsg, result, regexp))
    {
        for (unsigned i = 0; i < result.size(); ++i)
        {
            std::cout << result[i] << std::endl;
        }
    }

//    std::cout << errorMsg << std::endl;

    return 0;
}

this produces:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error>
>'   what():  Ran out of stack space trying to match the regular expression.

compiled with

g++ regex.cc -lboost_regex

EDIT

my platform:

g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
libboost-regex1.42
Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz
So the latest Ubuntu 64 bit

Body:
Tested it locally and it worked fine, my guess is your compiler is doing something weird.

What version of gcc? what platform? which version of boost?

 -> ./regex
std::vector<std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>,std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>>
std::map<std::pair<Test::Test, int>,std::pair<Test::Test, int>,std::pair<Test::Test, int>>
std::pair<Test::Test, int>
Test
Test
::
int


问:
ShellFolderView
I'm trying to capture an instance of the Shell32.ShellFolderView class that is embedded in a another application window.

Something like:

```<code>var folderView = Shell32.ShellFolderView.FromHwnd (hwnd);
</code>```

I need to perform operations like browsing and etc ...

It's possible?

答:
There is no generic interface for everything that hosts a shell view.

Explorer, Internet Explorer and some 3rd-party applications register themselves so you can interact with them using the IShellWindows interface. It is accessible by everything from C++, C# to basic scripts.

Title: ShellFolderView

Body:
I'm trying to capture an instance of the Shell32.ShellFolderView class that is embedded in a another application window.

Something like:

var folderView = Shell32.ShellFolderView.FromHwnd (hwnd);

I need to perform operations like browsing and etc ...

It's possible?


问:
How can i allow access to a specific url on my AWS Beanstalk site by certain ip
I have a site hosted on AWS Beanstalk.
I need to allow all users to access https://my-web-page.com
But only allow certain ip addresses to access https://my-web-page.com/admin</p>

答:
I would add a ebextension script(s) to modify the configuration of the proxy that's sitting in front your app server.

```<code>container_commands:
  replace_httpd_conf:
    command: cp .ebextensions/httpd.conf /etc/httpd/conf/httpd.conf
</code>```

You're going to have either httpd and nginx sitting in front depending on what app server you're using.  Tomcat and Django both have httpd,  I believe node uses nginx.  Not sure about the others.

Here's the page on access restriction for httpd 2.2.  You config would look something like

```<code><Location /admin>
    Require ip 1.1.1.1
</Location>
</code>```

Body:
I would add a ebextension script(s) to modify the configuration of the proxy that's sitting in front your app server.

container_commands:
  replace_httpd_conf:
    command: cp .ebextensions/httpd.conf /etc/httpd/conf/httpd.conf

You're going to have either httpd and nginx sitting in front depending on what app server you're using.  Tomcat and Django both have httpd,  I believe node uses nginx.  Not sure about the others.

Here's the page on access restriction for httpd 2.2.  You config would look something like

<Location /admin>
    Require ip 1.1.1.1
</Location>


问:
How do I get child elements from class list object?
think I have some class of same content

```<code> <div class="parentclass">

         <div class="childClass">
         </div>
         <div class="childClass">
         </div>
         <div class="childClass">
         </div>
    </div>

  <div class="parentclass">

         <div class="childClass">
         </div>
         <div class="childClass">
         </div>
         <div class="childClass">
         </div>
    </div>
</code>```

I can get all the parent class object in an array by

```<code>var pClassList= document.getElementsByClassName("parentclass");
</code>```

My question is how can I access the child classes "childClass" from pClassList array calling it index like

```<code>var childClassList1= pClassList[0].getElementsByClassName("childClass");
var childClassList2= pClassList[1].getElementsByClassName("childClass");
</code>```

答:
Simply loop over the initial collection and use index of each iteration to access individual elements </p>

```<code>var pClassList= document.getElementsByClassName("parentclass");

for(var i=0; i < pClassList.length; i++){

  var parentElement = pClassList[i];
  // do something to each parent as needed
  // access children of parent element
  var childClassList= parentElement.getElementsByClassName("childClass");
  // do something with `childClassList`
  for (var j= 0; j < childClassList.length; j++){
    var child = childClassList[j];
    // do something with each child here
  }
}
</code>```

Body:
think I have some class of same content

I can get all the parent class object in an array by

var pClassList= document.getElementsByClassName("parentclass");

My question is how can I access the child classes "childClass" from pClassList array calling it index like

var childClassList1= pClassList[0].getElementsByClassName("childClass");
var childClassList2= pClassList[1].getElementsByClassName("childClass");

Body:
Simply loop over the initial collection and use index of each iteration to access individual elements

var pClassList= document.getElementsByClassName("parentclass");

for(var i=0; i < pClassList.length; i++){

  var parentElement = pClassList[i];
  // do something to each parent as needed
  // access children of parent element
  var childClassList= parentElement.getElementsByClassName("childClass");
  // do something with `childClassList`
  for (var j= 0; j < childClassList.length; j++){
    var child = childClassList[j];
    // do something with each child here
  }
}


问:
Setting $_SESSION doesn't work on localhost using XAMPP
I set my session like so in my PHP code : $_SESSION['user_id'] = $login; and this seems to work fine whilst uploaded to my server and carries across different pages, however when I am testing the website on my local machine the session seems to become immediately unset after leaving the script where it is set.

I am testing on my local machine using XAMPP and exactly the same code.

I am not sure why this problem is occurring and would greatly appreciate any helpful answer.

Example that is not working:

```<code>$_SESSION['user_id'] = $login;
echo '<META HTTP-EQUIV="refresh" content="0;URL=../home.php">';
</code>```

EDIT 1:

Here is my entire function in which I log in (it's part of the class):

```<code>public function loggingIn(){
    session_start();

    $db = new Database('localhost','root','','userdata');
    $userFunctions = new Users($db);

    $username = $_POST['usernameInput'];
    $password = $_POST['passwordInput'];

    if(empty($username) || empty($password)){
        $this->errors['u&p'] = 'Please Enter Your Username AND Password';
        $this->printE();
    } elseif($userFunctions->user_exists($username)===false){
        $this->errors['nm'] = 'That Username/Password Combination Is Not Valid';
        $this->printE();
    } else {
            $login = $userFunctions->login($username, $password);

    if($login === false){
            $this->errors['nm'] = 'That Username/Password Combination Is Not Valid';
            echo 'Login Failed!';
        } else  {
           if(!$userFunctions->economyTableExistsForUser($login)){
               $userFunctions->createEconomyTableForUser($login);
           }
           if(!$userFunctions->schoolTableExistsForUser($login)) {
               $userFunctions->createSchoolTableForUser($login);
           }

               $_SESSION['user_id'] = $login;

               echo $_SESSION['user_id'];  // working fine

               header('Location: ../home.php');
        }
    }
}
</code>```

答:
```<code>Session Issue Fixed in Xampp 7.1.6 with following Changes in php.ini
Line #1403 set:
session.auto_start = 1
</code>```

Body:
I set my session like so in my PHP code : $_SESSION['user_id'] = $login; and this seems to work fine whilst uploaded to my server and carries across different pages, however when I am testing the website on my local machine the session seems to become immediately unset after leaving the script where it is set.

I am testing on my local machine using XAMPP and exactly the same code.

I am not sure why this problem is occurring and would greatly appreciate any helpful answer.

Example that is not working:

$_SESSION['user_id'] = $login;
echo '<META HTTP-EQUIV="refresh" content="0;URL=../home.php">';

EDIT 1:

Here is my entire function in which I log in (it's part of the class):

public function loggingIn(){
    session_start();

    $db = new Database('localhost','root','','userdata');
    $userFunctions = new Users($db);

    $username = $_POST['usernameInput'];
    $password = $_POST['passwordInput'];

    if(empty($username) || empty($password)){
        $this->errors['u&p'] = 'Please Enter Your Username AND Password';
        $this->printE();
    } elseif($userFunctions->user_exists($username)===false){
        $this->errors['nm'] = 'That Username/Password Combination Is Not Valid';
        $this->printE();
    } else {
            $login = $userFunctions->login($username, $password);

    if($login === false){
            $this->errors['nm'] = 'That Username/Password Combination Is Not Valid';
            echo 'Login Failed!';
        } else  {
           if(!$userFunctions->economyTableExistsForUser($login)){
               $userFunctions->createEconomyTableForUser($login);
           }
           if(!$userFunctions->schoolTableExistsForUser($login)) {
               $userFunctions->createSchoolTableForUser($login);
           }

               $_SESSION['user_id'] = $login;

               echo $_SESSION['user_id'];  // working fine

               header('Location: ../home.php');
        }
    }
}


问:
How to get duration a video - laravel
I want to get the duration of my videos when I upload them.
To do this, I upload my videos like this:

```<code>$video = Carbon::now()->timestamp . '_' .
            $request->file('video')->getClientOriginalName();

        $request->file('video')->move(
            $this->getCorrectPathOnServerAndLocal('/assets/videos/videos'), $video
        );
</code>```

My movie is uploaded well.
now I want to get the duration of this video.
I'm using PHP-FFMpeg:

```<code>composer require php-ffmpeg/php-ffmpeg
</code>```

```<code>$ffprobe = FFProbe::create(); //error
        dd("test");
        $duration = $ffprobe
            ->format($this->getCorrectPathOnServerAndLocal('/assets/videos/videos').$video) // extracts file informations
            ->get('duration');
</code>```

but I got this error:

```<code>  (2/2) ExecutableNotFoundException

Unable to load FFProbe
in FFProbeDriver.php (line 50)
at FFProbeDriver::create(array(), null)in FFProbe.php (line 207)
</code>```

答:
I personally created a Video CMS and found the easiest way to be using ID3 as follows:

```<code>public function getDuration($full_video_path)
{
    $getID3 = new \getID3;
    $file = $getID3->analyze($full_video_path);
    $playtime_seconds = $file['playtime_seconds'];
    $duration = date('H:i:s.v', $playtime_seconds);

    return $duration;
}
</code>```

Before I used ffmpeg like this:

```<code>// Get the video duration
$parameters = "2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//";
$cmd_duration_ffmpeg = "$ffmpeg_path -i $full_video_path $parameters";
$duration = shell_exec($cmd_duration_ffmpeg);
</code>```

Both options will work perfectly, choose whichever works best for you.

Title: How to get duration a video - laravel

Body:
I want to get the duration of my videos when I upload them.
To do this, I upload my videos like this:

$video = Carbon::now()->timestamp . '_' .
            $request->file('video')->getClientOriginalName();

        $request->file('video')->move(
            $this->getCorrectPathOnServerAndLocal('/assets/videos/videos'), $video
        );

My movie is uploaded well.
now I want to get the duration of this video.
I'm using PHP-FFMpeg:

composer require php-ffmpeg/php-ffmpeg

$ffprobe = FFProbe::create(); //error
        dd("test");
        $duration = $ffprobe
            ->format($this->getCorrectPathOnServerAndLocal('/assets/videos/videos').$video) // extracts file informations
            ->get('duration');

but I got this error:

  (2/2) ExecutableNotFoundException

Unable to load FFProbe
in FFProbeDriver.php (line 50)
at FFProbeDriver::create(array(), null)in FFProbe.php (line 207)

Body:
I personally created a Video CMS and found the easiest way to be using ID3 as follows:

public function getDuration($full_video_path)
{
    $getID3 = new \getID3;
    $file = $getID3->analyze($full_video_path);
    $playtime_seconds = $file['playtime_seconds'];
    $duration = date('H:i:s.v', $playtime_seconds);

    return $duration;
}

Before I used ffmpeg like this:

// Get the video duration
$parameters = "2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//";
$cmd_duration_ffmpeg = "$ffmpeg_path -i $full_video_path $parameters";
$duration = shell_exec($cmd_duration_ffmpeg);

Both options will work perfectly, choose whichever works best for you.


问:
get s3 object expiration in golang
There seems to be a way to set expiration days in an upload by attaching a Metadata with an "expdays" key to the PutObjectInput but there doesn't appear to be any way to then get this metadata from an object in like a "ListObjects" call. ListObjectOutput returns "Contents" which is a list of s3.Objects but that object doesn't have a metadata field and I don't see any other way to get it either.</p>

答: The ListObjects calls return a []Object for the actual object list in the result, and Object does not include the expiration. However, GetObject returns GetObjectOutput which does have an Expiration field. So you could iterate your returned Objects and get the expiration for each, though this could be time-consuming if there are many of them.

Title: get s3 object expiration in golang


问:
Vertically Scrolling a

I have a few nested  and I want to allow my deepest  to scroll vertically.

in CSS I have tried adding:

```<code>overflow-x: hidden; /* horizontal */
overflow-y: auto;  /* vertical */
</code>```

to the class I am assigning to the  but that does not seem to do it. Changing overflow-y: yes; does not work either.

How does one accomplish this. I want this  to scroll because it gets populated with MySQL data where the other div's just present selectable criteria to create the query and run it.

thoughts are appreciated.

Example:

```<code><div id="content">
    <div id="slidingDivKeynotePresentations">
        <!-- content here -->
    </div>
</div>
</code>```

My CSS:

```<code>#content {
    position: absolute;
    top: 0;
    left: 21%;
    margin: 26% 31% 1% 21%; /* Cater for Mac IE5 */
    /*\*/ margin: 0; /* Put back for all the rest */
    /*\*/ overflow: auto; /* no need for Mac IE5 to see this */
    overflow-x: hidden; /* horizontal */
    overflow-y: yes;  /* vertical */
}

#slidingDivKeynotePresentations {
    display: none;
    height: 600px;
    width: 600px;
    background-image: url('images/transwhite.png');
    border: 1px solid #3F4933;
    position: fixed;
    top: 100px;
    left: 290px; /*Set left value to WidthOfFrameDiv*/
    padding: 12px;
    overflow-x: hidden; /* horizontal */
    overflow-y: auto;  /* vertical */
 }
</code>```

答: Take out the overflow-y and overflow-x.  You should'nt need to specify overflow-x: hidden, as that is default anyway.  Simply setting overlow: auto; on the #slidingDivKeynotePresentations should do the trick, shouldn't it?  As long as there's a height specified.</p>

Title: Vertically Scrolling a <DIV>

Body:
I have a few nested  and I want to allow my deepest  to scroll vertically.

in CSS I have tried adding:

overflow-x: hidden; /* horizontal */
overflow-y: auto;  /* vertical */

to the class I am assigning to the  but that does not seem to do it. Changing overflow-y: yes; does not work either.

How does one accomplish this. I want this  to scroll because it gets populated with MySQL data where the other div's just present selectable criteria to create the query and run it.

thoughts are appreciated.

Example:

My CSS:

#content {
    position: absolute;
    top: 0;
    left: 21%;
    margin: 26% 31% 1% 21%; /* Cater for Mac IE5 */
    /*\*/ margin: 0; /* Put back for all the rest */
    /*\*/ overflow: auto; /* no need for Mac IE5 to see this */
    overflow-x: hidden; /* horizontal */
    overflow-y: yes;  /* vertical */
}

#slidingDivKeynotePresentations {
    display: none;
    height: 600px;
    width: 600px;
    background-image: url('images/transwhite.png');
    border: 1px solid #3F4933;
    position: fixed;
    top: 100px;
    left: 290px; /*Set left value to WidthOfFrameDiv*/
    padding: 12px;
    overflow-x: hidden; /* horizontal */
    overflow-y: auto;  /* vertical */
 }


问:
How to erase last char in console using backspace, without using space char?
I'm trying to implement a console program that has backspace functionality. The console accepts a number of valid commands I've defined. Example:

Input:

Output:

I'm using a switch statement, which checks the current char returned by getchar().

```<code>    switch (inChar)
    {
        case '\r':
        case '\n':
        {
            ...
        }

        case 0x18:                      // ^x
        {
            ...
        }

        case 0x08:                     // backspace
        {
            printf("\b \b");
            break;
        }

        default:
        {
            inBuffer[inBufIndx++] = inChar;
            inBuffer[inBufIndx] = 0;
            printf("%c", inChar);       // echo character
        }
    }
</code>```

The code above gives the appearance of erasing the character, but places a space char. This works for most instances, such as erasing the o off of helo but does not work when erasing the o off helpo. My shell can no longer interpret the command due to the space char that is printed in the place of the o

How can I implement backspace for chars at the end of the inputthat need to be erased?

EDIT: rici is exactly right. I was not removing the char I erased in the console from my inBuffer. The code below gave the desired functionality.

```<code>        case 0x08:
        {
            printf("\b \b");
            inBuffer[inBufIndx--] = NULL;
            break;
        }
</code>```

答:
Presumably, you need to remove the character from inBuffer (by decrementing inBufIdx and overwriting the old character with a 0). What the screen shows should be irrelevant.

By the way, the backspace-space-backspace sequence won't work at the right margin

Body:
I'm trying to implement a console program that has backspace functionality. The console accepts a number of valid commands I've defined. Example:

Input:

Output:

I'm using a switch statement, which checks the current char returned by getchar().

    switch (inChar)
    {
        case '\r':
        case '\n':
        {
            ...
        }

        case 0x18:                      // ^x
        {
            ...
        }

        case 0x08:                     // backspace
        {
            printf("\b \b");
            break;
        }

        default:
        {
            inBuffer[inBufIndx++] = inChar;
            inBuffer[inBufIndx] = 0;
            printf("%c", inChar);       // echo character
        }
    }

The code above gives the appearance of erasing the character, but places a space char. This works for most instances, such as erasing the o off of helo but does not work when erasing the o off helpo. My shell can no longer interpret the command due to the space char that is printed in the place of the o

How can I implement backspace for chars at the end of the inputthat need to be erased?

EDIT: rici is exactly right. I was not removing the char I erased in the console from my inBuffer. The code below gave the desired functionality.

        case 0x08:
        {
            printf("\b \b");
            inBuffer[inBufIndx--] = NULL;
            break;
        }