text Throttling Searchbar ios swift

Throttling Searchbar ios swift

SearchViewController
class SearchViewController: UIViewController, UISearchBarDelegate {
    // We keep track of the pending work item as a property
    private var pendingRequestWorkItem: DispatchWorkItem?

    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
        // Cancel the currently pending item
        pendingRequestWorkItem?.cancel()

        // Wrap our request in a work item
        let requestWorkItem = DispatchWorkItem { [weak self] in
            self?.resultsLoader.loadResults(forQuery: searchText)
        }

        // Save the new work item and execute it after 250 ms
        pendingRequestWorkItem = requestWorkItem
        DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(250),
                                      execute: requestWorkItem)
    }
}

// Written by John sundell https://www.swiftbysundell.com/posts/a-deep-dive-into-grand-central-dispatch-in-swift

text gistfile1.txt

gistfile1.txt
import React, { Component } from 'react';
import './App.css';

class App extends Component {

  state = {
    contacts: [],
    firstName: '',
    lastName: '',
    phoneNumber: '',
    email: ''
  };

  synchronizeContacts = this.componentDidMount();

  getContacts = () => {
    fetch(`http://localhost:3000/contacts`)
      .then(results => {
        return results.json()
      })
      .then(data => {
        const contactList = data.map(contact => contact);
        this.setState({
          contacts: contactList
        });
      });
  };

  componentDidMount() {
    this.getContacts()
  }

  addContact = (event) => {
    event.preventDefault();
    const newContact = {
      firstName: this.state.firstName,
      lastName: this.state.lastName,
      phoneNumber: this.state.phoneNumber,
      email: this.state.email
    };
    fetch(
      'http://localhost:3000/contacts', {
        method: 'POST',
        body: JSON.stringify(newContact),
        headers: {
          'Content-type': 'application/json'
        }
      }
    ).then(this.getContacts)
  };

  removeContact = id => {
    fetch(
      `http://localhost:3000/contacts/` + id, {
        method: 'DELETE',
        headers: {
          'Content-Type': 'application/json'
        }
      }
    );
    this.getContacts()
  };

  render() {
    return (
      <div className="App">
        <h1>Contact App</h1>
          <form className="newContactPanel" onSubmit={this.addContact}>
            <input
              type="text"
              placeholder="First Name"
              value={this.state.firstName}
              onChange={(event) => this.setState({
                firstName: event.target.value
              })}
              />

            <input
              type="text"
              placeholder="Last Name"
              value={this.state.lastName}
              onChange={(event) => this.setState({
                lastName: event.target.value
              })}
            />

            <input
              type="number"
              placeholder="Phone Number"
              value={this.state.phoneNumber}
              onChange={(event) => this.setState({
                phoneNumber: event.target.value
              })}
            />

            <input
              type="mail"
              placeholder="Email"
              value={this.state.email}
              onChange={(event) => this.setState({
                email: event.target.value
              })}
            />

            <button>Add contact</button>
          </form>
        <ul>
          {this.state.contacts.map(contact => {
            return (
              <div>
                <li key={contact.id}>
                  <p>{contact.firstName} {contact.lastName}</p>
                  <p>{contact.phoneNumber}</p>
                  <p>{contact.email}</p>
                  <button onClick={() => this.removeContact(contact.id)}>Remove</button>
                </li>
              </div>
            )
          })}
        </ul>
      </div>
    );
  }
}

export default App;

text Atom + Docker + XDebug

配置Atom,Docker,XDebug

atom_docker_xdebug.txt
I'll use port 9005 instead standard 9000 to avoid conflicts with other applications.

Client Side (Host with Atom):

1) Download php-debug
2) Configure php-debug : Server: 10.254.254.254 - Port: 9005 - Pathmaps : add "/" at the end of path to include all subfolders
3) Enable php-debug panel inside Atom with CTRL+ALT+D (or clicking bottom left button "PHP Debug"
4) Make lo0 alias: ifconfig lo0 alias 10.254.254.254


Server Side (Server inside Docker):

Xdebug configuration:

;zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.remove_host=10.254.254.254
xdebug.remote_port=9005
xdebug.remote_log=/tmp/xdebug.log

text 由Native JS触发输入

1
var ev = new Event("input", { bubbles: true });
ev.simulated = true;
debugger;
document.activeElement.value = data;
document.activeElement.dispatchEvent(ev);
document.activeElement.style.border = "2px solid red";

text cmd代理

cmd proxy
alias proxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unproxy="unset ALL_PROXY"
alias ip="curl -i http://ip.cn"

text git代理

git proxy
git config --global http.proxy 'socks5://127.0.0.1:1080'

git config --global https.proxy 'socks5://127.0.0.1:1080'

text 允许ony数字和小数

number_decimal_only
http://jsfiddle.net/ecDmn/1/


$("#txtQty").keyup(function() {
    var $this = $(this);
    $this.val($this.val().replace(/[^\d.]/g, ''));        
});​

text Bootstrap顶部,底部,左侧和右侧标签

bootstrap_tabs_all_sides

https://www.bootply.com/74926

Newer method: https://github.com/dbtek/bootstrap-vertical-tabs

<div class="container">
  <div class="row">
    <div class="col-md-6">
      <h3>Tabs</h3>
        <!-- tabs -->
        <div class="tabbable">
          <ul class="nav nav-tabs">
            <li class="active"><a href="#one" data-toggle="tab">One</a></li>
            <li><a href="#two" data-toggle="tab">Two</a></li>
            <li><a href="#twee" data-toggle="tab">Twee</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="one">Lorem ipsum dolor sit amet, charetra varius quam sit amet vulputate. 
            Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero.</div>
            <div class="tab-pane" id="two">Secondo sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan. 
            Aliquam in felis sit amet augue.</div>
            <div class="tab-pane" id="twee">Thirdamuno, ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate. 
            Quisque mauris augue, molestie tincidunt condimentum vitae.</div>
           </div>
        </div>
        <!-- /tabs -->

    </div>
    <div class="col-md-6"><h3>Tabs -below</h3>
    
          	
      <!-- tabs bottom -->
      <div class="tabbable tabs-below">
        <div class="tab-content">
         <div class="tab-pane active" id="one_">Lorem ipsum dolor sit amet, charetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero.</div>
         <div class="tab-pane" id="two_">Secondo sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan. 
         Aliquam in felis sit amet augue.</div>
         <div class="tab-pane" id="twee_">Thirdamuno, ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae. </div>
        </div>
        <ul class="nav nav-tabs">
          <li><a href="#one_" data-toggle="tab">One</a></li>
          <li><a href="#two_" data-toggle="tab">Two</a></li>
          <li><a href="#twee_" data-toggle="tab">Twee</a></li>
        </ul>
      </div>
      <!-- /tabs -->
      
    
    </div>
  </div><!-- /row -->
  <div class="row">
    
    <div class="col-md-6"><h3>Tabs -left</h3>
          	
      <!-- tabs left -->
      <div class="tabbable tabs-left">
        <ul class="nav nav-tabs">
          <li><a href="#a" data-toggle="tab">One</a></li>
          <li class="active"><a href="#b" data-toggle="tab">Two</a></li>
          <li><a href="#c" data-toggle="tab">Twee</a></li>
        </ul>
        <div class="tab-content">
         <div class="tab-pane active" id="a">Lorem ipsum dolor sit amet, charetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero.</div>
         <div class="tab-pane" id="b">Secondo sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan. 
         Aliquam in felis sit amet augue.</div>
         <div class="tab-pane" id="c">Thirdamuno, ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae. </div>
        </div>
      </div>
      <!-- /tabs -->
      
    </div>
    
     <div class="col-md-6"><h3>Tabs -right</h3>
          	
      <!-- tabs right -->
      <div class="tabbable tabs-right">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#1" data-toggle="tab">One</a></li>
          <li><a href="#2" data-toggle="tab">Two</a></li>
          <li><a href="#3" data-toggle="tab">Twee</a></li>
        </ul>
        <div class="tab-content">
         <div class="tab-pane active" id="1">Lorem ipsum dolor sit amet, charetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae, gravida a libero.</div>
         <div class="tab-pane" id="2">Secondo sed ac orci quis tortor imperdiet venenatis. Duis elementum auctor accumsan. 
         Aliquam in felis sit amet augue.</div>
         <div class="tab-pane" id="3">Thirdamuno, ipsum dolor sit amet, consectetur adipiscing elit. Duis pharetra varius quam sit amet vulputate. 
         Quisque mauris augue, molestie tincidunt condimentum vitae. </div>
        </div>
      </div>
      <!-- /tabs -->
      
    </div>
    
  </div><!-- /row -->
</div>
  
  
  

<hr>


CSS;

/* custom inclusion of right, left and below tabs */

.tabs-below > .nav-tabs,
.tabs-right > .nav-tabs,
.tabs-left > .nav-tabs {
  border-bottom: 0;
}

.tab-content > .tab-pane,
.pill-content > .pill-pane {
  display: none;
}

.tab-content > .active,
.pill-content > .active {
  display: block;
}

.tabs-below > .nav-tabs {
  border-top: 1px solid #ddd;
}

.tabs-below > .nav-tabs > li {
  margin-top: -1px;
  margin-bottom: 0;
}

.tabs-below > .nav-tabs > li > a {
  -webkit-border-radius: 0 0 4px 4px;
     -moz-border-radius: 0 0 4px 4px;
          border-radius: 0 0 4px 4px;
}

.tabs-below > .nav-tabs > li > a:hover,
.tabs-below > .nav-tabs > li > a:focus {
  border-top-color: #ddd;
  border-bottom-color: transparent;
}

.tabs-below > .nav-tabs > .active > a,
.tabs-below > .nav-tabs > .active > a:hover,
.tabs-below > .nav-tabs > .active > a:focus {
  border-color: transparent #ddd #ddd #ddd;
}

.tabs-left > .nav-tabs > li,
.tabs-right > .nav-tabs > li {
  float: none;
}

.tabs-left > .nav-tabs > li > a,
.tabs-right > .nav-tabs > li > a {
  min-width: 74px;
  margin-right: 0;
  margin-bottom: 3px;
}

.tabs-left > .nav-tabs {
  float: left;
  margin-right: 19px;
  border-right: 1px solid #ddd;
}

.tabs-left > .nav-tabs > li > a {
  margin-right: -1px;
  -webkit-border-radius: 4px 0 0 4px;
     -moz-border-radius: 4px 0 0 4px;
          border-radius: 4px 0 0 4px;
}

.tabs-left > .nav-tabs > li > a:hover,
.tabs-left > .nav-tabs > li > a:focus {
  border-color: #eeeeee #dddddd #eeeeee #eeeeee;
}

.tabs-left > .nav-tabs .active > a,
.tabs-left > .nav-tabs .active > a:hover,
.tabs-left > .nav-tabs .active > a:focus {
  border-color: #ddd transparent #ddd #ddd;
  *border-right-color: #ffffff;
}

.tabs-right > .nav-tabs {
  float: right;
  margin-left: 19px;
  border-left: 1px solid #ddd;
}

.tabs-right > .nav-tabs > li > a {
  margin-left: -1px;
  -webkit-border-radius: 0 4px 4px 0;
     -moz-border-radius: 0 4px 4px 0;
          border-radius: 0 4px 4px 0;
}

.tabs-right > .nav-tabs > li > a:hover,
.tabs-right > .nav-tabs > li > a:focus {
  border-color: #eeeeee #eeeeee #eeeeee #dddddd;
}

.tabs-right > .nav-tabs .active > a,
.tabs-right > .nav-tabs .active > a:hover,
.tabs-right > .nav-tabs .active > a:focus {
  border-color: #ddd #ddd #ddd transparent;
  *border-left-color: #ffffff;
}


text 在CSS上留下位置

left
The value of the left posiont is the Px size form the beginning of the margin on the current element to 
the beginning of the padding on the parent element.

the property returns the left position(includes the margin) relative to the left side(at the beginning of the padding)
of the parent element

text 请参阅UNIX中的开放端口

请参阅UNIX中的开放端口

unix.txt
# Show all ports where the current host is listening
netstat -l