问:
Local website lost after trying to set up virtualhosts
I am not a programmer, I'm using a CMS called DIVI to build WordPress sites for myself and other members of our music collective.

I followed some tutorial on setting up multiple virtual hosts and now the site I was building locally, the localhost and phpadmin will not load!

Only 1 of 2 wampserver services running.

I have no idea what I did wrong and was too stupid to backup the GD file before I saved it! I'll paste the files I altered here.

C:\wamp\bin\apache\apache2.4.23\conf\extra\vhosts:

```<code># Virtual Hosts
#

 <VirtualHost *:80>
   DocumentRoot c:/wamp/www/
   ServerName localhost
   ServerAlias localhost
   DocumentRoot c:/wamp/www/wordpress
 </VirtualHost>
</code>```

C:\wamp\bin\apache\apache2.4.23\conf/httpd:

```#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
#
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.
ServerSignature On
ServerTokens Full

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#

# Apache variable names used by Apache conf files:
# The names and contents of variables:
# APACHE24, VERSION_APACHE, INSTALL_DIR, APACHE_DIR
# should never be changed.
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.23
Define INSTALL_DIR c:/wamp
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}

ServerRoot "${APACHE_DIR}"

#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_core_module modules/mod_authn_core.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule buffer_module modules/mod_buffer.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule data_module modules/mod_data.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule http2_module modules/mod_http2.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule lua_module modules/mod_lua.so
#LoadModule macro_module modules/mod_macro.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_http2_module modules/mod_proxy_http2.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule request_module modules/mod_request.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so

LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.25/php5apache2_4.dll"

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin wampserver@wampserver.invalid

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
HostnameLookups Off

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
#ErrorLog "logs/error.log"
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "${INSTALL_DIR}/logs/access.log" common
    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access.log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock cgisock
</IfModule>

#
# "c:/Apache24/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "${INSTALL_DIR}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile off

# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and
# will not recycle sockets between connections. This is useful for network
# adapters with broken driver support, as well as some virtual network
# providers such as vpn drivers, or spam, virus or spyware filters.
AcceptFilter http none
AcceptFilter https none

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include "${INSTALL_DIR}/alias/*"
```

<p>C:\Windows\System32\drivers\etc\hosts:</p>

```# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 na1r.services.adobe.com
127.0.0.1 hlrcv.stage.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 activate.adobe.com

0.0.0.1 mssplus.mcafee.com

#LOCAL
127.0.0.1       localhost
```

Can anyone help?

答:
Your httpd installation can't find the existing apps; they're still on your disk, but now you're purely using virtual hosts.

Do a quick find and figure out where on your machine they are; you can then either repoint your webserver to those locations with a new virtualhost, or attempt to roll back to something resembling your old config.

You'll need to restart httpd to pick up any config changes.

Body:
I am not a programmer, I'm using a CMS called DIVI to build WordPress sites for myself and other members of our music collective.

I followed some tutorial on setting up multiple virtual hosts and now the site I was building locally, the localhost and phpadmin will not load!

Only 1 of 2 wampserver services running.

I have no idea what I did wrong and was too stupid to backup the GD file before I saved it! I'll paste the files I altered here.

C:\wamp\bin\apache\apache2.4.23\conf\extra\vhosts:

# Virtual Hosts
#

 <VirtualHost *:80>
   DocumentRoot c:/wamp/www/
   ServerName localhost
   ServerAlias localhost
   DocumentRoot c:/wamp/www/wordpress
 </VirtualHost>

C:\wamp\bin\apache\apache2.4.23\conf/httpd:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
#
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.
ServerSignature On
ServerTokens Full

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#

# Apache variable names used by Apache conf files:
# The names and contents of variables:
# APACHE24, VERSION_APACHE, INSTALL_DIR, APACHE_DIR
# should never be changed.
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.23
Define INSTALL_DIR c:/wamp
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}

ServerRoot "${APACHE_DIR}"

#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_core_module modules/mod_authn_core.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule authz_core_module modules/mod_authz_core.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule buffer_module modules/mod_buffer.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule data_module modules/mod_data.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule http2_module modules/mod_http2.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule heartbeat_module modules/mod_heartbeat.so
#LoadModule heartmonitor_module modules/mod_heartmonitor.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule lua_module modules/mod_lua.so
#LoadModule macro_module modules/mod_macro.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_html_module modules/mod_proxy_html.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_http2_module modules/mod_proxy_http2.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
#LoadModule reflector_module modules/mod_reflector.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule request_module modules/mod_request.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_crypto_module modules/mod_session_crypto.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
#LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule watchdog_module modules/mod_watchdog.so
#LoadModule xml2enc_module modules/mod_xml2enc.so

LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.25/php5apache2_4.dll"

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin wampserver@wampserver.invalid

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
HostnameLookups Off

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
#ErrorLog "logs/error.log"
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "${INSTALL_DIR}/logs/access.log" common
    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access.log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock cgisock
</IfModule>

#
# "c:/Apache24/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "${INSTALL_DIR}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile off

# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and
# will not recycle sockets between connections. This is useful for network
# adapters with broken driver support, as well as some virtual network
# providers such as vpn drivers, or spam, virus or spyware filters.
AcceptFilter http none
AcceptFilter https none

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include "${INSTALL_DIR}/alias/*"

C:\Windows\System32\drivers\etc\hosts:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 na1r.services.adobe.com
127.0.0.1 hlrcv.stage.adobe.com
127.0.0.1 practivate.adobe.com
127.0.0.1 activate.adobe.com

0.0.0.1 mssplus.mcafee.com

#LOCAL
127.0.0.1       localhost

Can anyone help?


来源: stackexchange

问:
TableView sections don't seem to work Objective - C
The problem I am encountering is that I don't know how to code my tableViewController properly, so it displays 2 sections, one with Items (object type) which value is higher than 50, and second section for Items valued less than 50. My code looks like this:

```<code>@implementation ItemsViewController

- (instancetype)init
{
    self = [super initWithStyle:UITableViewStylePlain];

    if(self)
    {
        for (int i = 0; i < 5; i++)
        {
            [[ItemStore sharedStore] createItem];
        }
    }
    return self;
}

- (instancetype)initWithStyle:(UITableViewStyle)style
{
    return [super initWithStyle:UITableViewStylePlain];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;
{
    return @[@">50", @"<=50"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return [[[ItemStore sharedStore] itemsValuedOver50] count];
    }
    else
    {
        return [[[ItemStore sharedStore] itemsValuedBelowOrEqual50] count];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];

    if (indexPath.section == 0)
    {
        NSArray *items = [[ItemStore sharedStore] itemsValuedOver50];

        NSArray *item = items[indexPath.row];

        cell.textLabel.text = [item description];

    }
    else
    {
        NSArray *items = [[ItemStore sharedStore] itemsValuedBelowOrEqual50];

        NSArray *item = items[indexPath.row];

        cell.textLabel.text = [item description];
    }

    return cell;
}

@end
</code>```

Section names (">50" and <=50) appear in the middle of the right side of the screen(looks like it is out of the table view), and the table view still behaves as it had only one section. These 5 items are not sorted in any way and I have no idea why.

Here is the link to screenshot of the application: http://imgur.com/3MoHmmn

I've been looking for answer for some time, but to be fair i don't know how to describe my problem well enough to find any solution online, thats why I'm creating a new topic.

Thanks for your help in advance.

EDIT: I've figured out the problem. It took me few days and it was preety stupid. I used wrong method. Instead of using sectionIndexTitlesForTableView: i should have used titleForHeaderInSection:. Now everything works as i wanted it to work.

答:
Try setting the section height via the delegate</p>

```<code>- (CGFloat)tableView:(UITableView *)tableView heightForSection:(NSUInteger)section;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
The problem I am encountering is that I don't know how to code my tableViewController properly, so it displays 2 sections, one with Items (object type) which value is higher than 50, and second section for Items valued less than 50. My code looks like this:

@implementation ItemsViewController

- (instancetype)init
{
    self = [super initWithStyle:UITableViewStylePlain];

    if(self)
    {
        for (int i = 0; i < 5; i++)
        {
            [[ItemStore sharedStore] createItem];
        }
    }
    return self;
}

- (instancetype)initWithStyle:(UITableViewStyle)style
{
    return [super initWithStyle:UITableViewStylePlain];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView;
{
    return @[@">50", @"<=50"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return [[[ItemStore sharedStore] itemsValuedOver50] count];
    }
    else
    {
        return [[[ItemStore sharedStore] itemsValuedBelowOrEqual50] count];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];

    if (indexPath.section == 0)
    {
        NSArray *items = [[ItemStore sharedStore] itemsValuedOver50];

        NSArray *item = items[indexPath.row];

        cell.textLabel.text = [item description];

    }
    else
    {
        NSArray *items = [[ItemStore sharedStore] itemsValuedBelowOrEqual50];

        NSArray *item = items[indexPath.row];

        cell.textLabel.text = [item description];
    }

    return cell;
}

@end

Section names (">50" and <=50) appear in the middle of the right side of the screen(looks like it is out of the table view), and the table view still behaves as it had only one section. These 5 items are not sorted in any way and I have no idea why.

Here is the link to screenshot of the application: http://imgur.com/3MoHmmn

I've been looking for answer for some time, but to be fair i don't know how to describe my problem well enough to find any solution online, thats why I'm creating a new topic.

Thanks for your help in advance.

EDIT: I've figured out the problem. It took me few days and it was preety stupid. I used wrong method. Instead of using sectionIndexTitlesForTableView: i should have used titleForHeaderInSection:. Now everything works as i wanted it to work.

Body:
Try setting the section height via the delegate

- (CGFloat)tableView:(UITableView *)tableView heightForSection:(NSUInteger)section;


问:
Determine what a link's pathname would be if followed?
I have a link like this:

This link goes to some page.
```

<p>I have a variable containing the <code>pathname</code> of the page <em>after</em> visiting that page. It looks like so:</p>

<pre class="lang-none prettyprint-override"><code>/C:/work/so/test/somepage.html
</code>```

I'm currently comparing them by doing this:

```<code>curLocation = window.location.pathname;
pathname = curLocation.substring(0, curLocation.lastIndexOf('/') + 1) + elements[i].getAttribute('href');
var oldPathname = '/C:/work/so/test/somepage.html'; //pretend this variable is already set, and not hardcoded
if(pathname == oldPathname) {
    //do stuff
}
</code>```

However that won't work, because pathname will equal this:

/C:/work/so/test/./somepage.html
```

<p>...but <code>oldPathname</code> (the actual resulting path after navigating that link) will look like this:</p>

```/C:/work/so/test/somepage.html
```

How can I reliably check if those two links are the same? Is there a way to "simulate" clicking through a link, and find what the resulting window.location.pathname would be?

答:
Just use .href rather than getAttribute('href')

document.querySelectorAll('a').forEach(a => console.log(a.href))```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Link 1
Link 2
Link 3</code>```

Body:
I have a link like this:

This link goes to some page.

I have a variable containing the pathname of the page after visiting that page. It looks like so:

/C:/work/so/test/somepage.html

I'm currently comparing them by doing this:

curLocation = window.location.pathname;
pathname = curLocation.substring(0, curLocation.lastIndexOf('/') + 1) + elements[i].getAttribute('href');
var oldPathname = '/C:/work/so/test/somepage.html'; //pretend this variable is already set, and not hardcoded
if(pathname == oldPathname) {
    //do stuff
}

However that won't work, because pathname will equal this:

/C:/work/so/test/./somepage.html

...but oldPathname (the actual resulting path after navigating that link) will look like this:

/C:/work/so/test/somepage.html

How can I reliably check if those two links are the same? Is there a way to "simulate" clicking through a link, and find what the resulting window.location.pathname would be?

Body:
Just use .href rather than getAttribute('href')

document.querySelectorAll('a').forEach(a => console.log(a.href))

<a href="./link1.html">Link 1</a>
<a href="../link2.html">Link 2</a>
<a href="../folder/link3.html">Link 3</a>


问:
Unable to generate a Nuget Package in VSTS Build
I have a dotnet core library that I'm trying to publish to my VSTS hosted Nuget feed. I have a problem in that it doesn't seem to be doing anything. The build is completing without errors but the nupkg file seems to be neither created nor pushed. The build log below contains an error as I am trying to publish the output as a build asset but there is no output to publish...

(log start cut off for brevity)

```
******************************************************************************
Starting: NuGet pack
******************************************************************************
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
==============================================================================
Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
Caching tool: NuGet 4.0.0 x64
Using version: 4.0.0
Found tool in cache: NuGet 4.0.0 x64
C:\Windows\system32\chcp.com 65001
Active code page: 65001
******************************************************************************
Finishing: NuGet pack
******************************************************************************
******************************************************************************
Starting: NuGet push
******************************************************************************
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
******************************************************************************
Finishing: NuGet push
******************************************************************************
******************************************************************************
Starting: Publish Artifact: Nuget Packages
******************************************************************************
==============================================================================
Task         : Publish Build Artifacts
Description  : Publish Build artifacts to the server or a file share
Version      : 1.0.42
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=708390)
==============================================================================
Publish build artifacts failed with error: Not found PathtoPublish: d:\a\1\a\*.nupkg
******************************************************************************
Finishing: Publish Artifact: Nuget Packages
******************************************************************************
******************************************************************************
Starting: Post Job Cleanup
******************************************************************************
Cleaning any cached credential from repository: Esoterix (Git)
git remote set-url origin https://esoterix.visualstudio.com/_git/Esoterix
git remote set-url --push origin https://esoterix.visualstudio.com/_git/Esoterix
******************************************************************************
Finishing: Post Job Cleanup
******************************************************************************
******************************************************************************
Finishing: Build
******************************************************************************
```

The library is a .net core library using .NetCoreApp 1.1

The build definition follows a successful dotnet test run with...

NUGET PACK

Path to files to pack: **/src/*.csproj

Config: $(BuildConfiguration)

Package Folder: $(Build.ArtifactStagingDirectory)

NUGET PUSH

Path to packages to push: $(Build.ArtifactStagingDirectory)/*.nupkg

Target Feed: local (my VSTS Package Feed)

This seems rather odd...

```<code>C:\Windows\system32\chcp.com 65001
Active code page: 65001
</code>```

答:
For .NET core library project, and .csproj file usually exist in **/src/ProjectName/ProjectName.csproj.

So please check the Path to csproj or nuspec file(s) to pack in Nuget pack step, it mainly should be **/src/ProjectName/*.csproj or **/src/*/*.csproj. Or if you only have one project, you can use **/*.csproj directly.

Body:
I have a dotnet core library that I'm trying to publish to my VSTS hosted Nuget feed. I have a problem in that it doesn't seem to be doing anything. The build is completing without errors but the nupkg file seems to be neither created nor pushed. The build log below contains an error as I am trying to publish the output as a build asset but there is no output to publish...

(log start cut off for brevity)

******************************************************************************
Starting: NuGet pack
******************************************************************************
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
==============================================================================
Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
Caching tool: NuGet 4.0.0 x64
Using version: 4.0.0
Found tool in cache: NuGet 4.0.0 x64
C:\Windows\system32\chcp.com 65001
Active code page: 65001
******************************************************************************
Finishing: NuGet pack
******************************************************************************
******************************************************************************
Starting: NuGet push
******************************************************************************
==============================================================================
Task         : NuGet
Description  : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.0.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
******************************************************************************
Finishing: NuGet push
******************************************************************************
******************************************************************************
Starting: Publish Artifact: Nuget Packages
******************************************************************************
==============================================================================
Task         : Publish Build Artifacts
Description  : Publish Build artifacts to the server or a file share
Version      : 1.0.42
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=708390)
==============================================================================
Publish build artifacts failed with error: Not found PathtoPublish: d:\a\1\a\*.nupkg
******************************************************************************
Finishing: Publish Artifact: Nuget Packages
******************************************************************************
******************************************************************************
Starting: Post Job Cleanup
******************************************************************************
Cleaning any cached credential from repository: Esoterix (Git)
git remote set-url origin https://esoterix.visualstudio.com/_git/Esoterix
git remote set-url --push origin https://esoterix.visualstudio.com/_git/Esoterix
******************************************************************************
Finishing: Post Job Cleanup
******************************************************************************
******************************************************************************
Finishing: Build
******************************************************************************

The library is a .net core library using .NetCoreApp 1.1

The build definition follows a successful dotnet test run with...

NUGET PACK

Path to files to pack: **/src/*.csproj

Config: $(BuildConfiguration)

Package Folder: $(Build.ArtifactStagingDirectory)

NUGET PUSH

Path to packages to push: $(Build.ArtifactStagingDirectory)/*.nupkg

Target Feed: local (my VSTS Package Feed)

This seems rather odd...

C:\Windows\system32\chcp.com 65001
Active code page: 65001


问:
Rolling mean of correlation matrix
I have to calculate the rolling mean of the correlation matrix. I did this

```<code>df_corr = df.rolling(window=3).corr()
</code>```

but now I want to have

```<code>    2017-06-05 00:00:00+02:00 NaN

    2017-06-06 00:00:00+02:00 NaN

    2017-06-07 00:00:00+02:00 0.86
...
</code>```

Where I evaluate the mean of the upper-right matrix (excluding diagonal).

答:
What you need here is to apply a mask to the correlation matrix at each date, like below:

You can use numpy.triu_indices with the parameter k=1.  This returns the indices for the upper-triangle of an (n, m) array; setting k=1 ignores the diagonal.  So, to create a mask:

```<code>import numpy as np
mask = np.triu_indices(df_corr.shape[1], k=1)
    # .shape[1] = 4; each correl. matrix is 4x4
</code>```

Now compute an average, ignoring masked values, for each period:

```<code>import pandas as pd
dates = df_corr.index.get_level_values(0)
avgs = [df_corr.loc[date].values[mask].mean()
        for date in dates]
s = pd.Series(avgs, index=dates) # may want to dropna

print(s.tail())
Date
2017-07-03    0.72991
2017-07-04    0.73963
2017-07-04    0.73963
2017-07-04    0.73963
2017-07-04    0.73963
dtype: float64
</code>```

To manually confirm the above you could inspect with:

```<code>df_corr.loc['2017-07-04'].values[mask]
Out[108]:
array([ 0.72585007,  0.93792149,  0.79828102,  0.4422102 ,  0.99371595,
        0.53982374])

df_corr.loc['2017-07-04'].values[mask].mean()
Out[109]: 0.73963374659063508
</code>```

Title: Rolling mean of correlation matrix

Body:
I have to calculate the rolling mean of the correlation matrix. I did this

df_corr = df.rolling(window=3).corr()

but now I want to have

    2017-06-05 00:00:00+02:00 NaN

    2017-06-06 00:00:00+02:00 NaN

    2017-06-07 00:00:00+02:00 0.86
...

Where I evaluate the mean of the upper-right matrix (excluding diagonal).

Body:
What you need here is to apply a mask to the correlation matrix at each date, like below:

You can use numpy.triu_indices with the parameter k=1.  This returns the indices for the upper-triangle of an (n, m) array; setting k=1 ignores the diagonal.  So, to create a mask:

import numpy as np
mask = np.triu_indices(df_corr.shape[1], k=1)
    # .shape[1] = 4; each correl. matrix is 4x4

Now compute an average, ignoring masked values, for each period:

import pandas as pd
dates = df_corr.index.get_level_values(0)
avgs = [df_corr.loc[date].values[mask].mean()
        for date in dates]
s = pd.Series(avgs, index=dates) # may want to dropna

print(s.tail())
Date
2017-07-03    0.72991
2017-07-04    0.73963
2017-07-04    0.73963
2017-07-04    0.73963
2017-07-04    0.73963
dtype: float64

To manually confirm the above you could inspect with:

df_corr.loc['2017-07-04'].values[mask]
Out[108]:
array([ 0.72585007,  0.93792149,  0.79828102,  0.4422102 ,  0.99371595,
        0.53982374])

df_corr.loc['2017-07-04'].values[mask].mean()
Out[109]: 0.73963374659063508


问:
Cookie is not saved if system power is interrupted
On Raspberry Pi Raspbian Chromium Kiosk-Mode, I am saving a cookie:

```<code>document.cookie = "currentImage=" + currentImage + ";expires=2038-01-19, 03:14:08 UTC; path=/"
</code>```

Then after a while the power to the Pi is cut. When the system is restored, the cookie cannot be read. Is there a way to persist the cookie in JS?

答:
It seems that you have misconfigured profile (Your profile that saves all data inside including the cookies). Check this blog post for bare config.

Also, make sure there is a directory with this path ~/.config/chromium (This is the default directory for your profile data). And, you can also this option to set user data dir explicitly

```<code>chromium-browser --user-data-dir=DIR
</code>```

--user-data-dir=DIR

Specifies the directory that user data (your "profile") is kept in.  Defaults to ~/.config/chromium  . Separate instances of Chromium must  use separate  user data  directories; repeated invocations of chromium-browser will reuse an existing process for a given user data directory.

Personally, I didn't face this problem before but I tried to give you some insights and keys to the solution. Therefore, I highly recommend if you still face the problem to check this list for chromium different options

Body:
On Raspberry Pi Raspbian Chromium Kiosk-Mode, I am saving a cookie:

document.cookie = "currentImage=" + currentImage + ";expires=2038-01-19, 03:14:08 UTC; path=/"

Then after a while the power to the Pi is cut. When the system is restored, the cookie cannot be read. Is there a way to persist the cookie in JS?

Body:
It seems that you have misconfigured profile (Your profile that saves all data inside including the cookies). Check this blog post for bare config.

Also, make sure there is a directory with this path ~/.config/chromium (This is the default directory for your profile data). And, you can also this option to set user data dir explicitly

chromium-browser --user-data-dir=DIR

--user-data-dir=DIR

Specifies the directory that user data (your "profile") is kept in.  Defaults to ~/.config/chromium  . Separate instances of Chromium must  use separate  user data  directories; repeated invocations of chromium-browser will reuse an existing process for a given user data directory.

Personally, I didn't face this problem before but I tried to give you some insights and keys to the solution. Therefore, I highly recommend if you still face the problem to check this list for chromium different options


问:
How to correctly update SNMP4j agent MIB values correctly
I'm trying to create an SNMP4j agent and am finding it difficult to understand the process correctly. I have successfully created an agent that can be queried from the command line using snmpwalk. What I am having difficulty with is understanding how I am meant to update the values stored in my implemented MIB.

The following shows the relevant code I use for creating the MIB (I implement Host-Resources-MIB)

```<code>        agent = new Agent("0.0.0.0/" + port);
        agent.start();
        agent.unregisterManagedObject(agent.getSnmpv2MIB());
        modules = new Modules(DefaultMOFactory.getInstance());
        HrSWRunEntryRow thisRow = modules.getHostResourcesMib().getHrSWRunEntry()
                .createRow(oidHrSWRunEntry);

        final OID ashEnterpriseMIB = new OID(".1.3.6.1.4.1.49266.0");

        thisRow.setHrSWRunIndex(new Integer32(1));
        thisRow.setHrSWRunName(new OctetString("RunnableAgent"));
        thisRow.setHrSWRunID(ashEnterpriseMIB);
        thisRow.setHrSWRunPath(new OctetString("All is good in the world")); // Max 128 characters
        thisRow.setHrSWRunParameters(new OctetString("Everything is working")); // Max 128 characters
        thisRow.setHrSWRunType(new Integer32(HrSWRunTypeEnum.application));
        thisRow.setHrSWRunStatus(new Integer32(HrSWRunStatusEnum.running));

        modules.getHostResourcesMib().getHrSWRunEntry().addRow(thisRow);

        agent.registerManagedObject(modules.getHostResourcesMib());
</code>```

This appears to be sufficient to create a runnable agent. What I do not understand is how I am meant to change the values stored in the MIB (how do I, for example, change the value of HrSWRunStatus). There seem to be a few kludge ways but they don't seem to fit with the way the library is written.

I have come across numerous references to using/overriding the methods

prepare

commit

undo

cleanup

But cannot find any examples where this is done. Any help would be gratefully received.

答: In protected void registerManagedObjects(), you need to do something like new MOMutableColumn(columnId, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_WRITE, null); for your HrSWRunStatus. Take a look at the TestAgent.java example of SNMP4J-agent source.

Body:
I'm trying to create an SNMP4j agent and am finding it difficult to understand the process correctly. I have successfully created an agent that can be queried from the command line using snmpwalk. What I am having difficulty with is understanding how I am meant to update the values stored in my implemented MIB.

The following shows the relevant code I use for creating the MIB (I implement Host-Resources-MIB)

        agent = new Agent("0.0.0.0/" + port);
        agent.start();
        agent.unregisterManagedObject(agent.getSnmpv2MIB());
        modules = new Modules(DefaultMOFactory.getInstance());
        HrSWRunEntryRow thisRow = modules.getHostResourcesMib().getHrSWRunEntry()
                .createRow(oidHrSWRunEntry);

        final OID ashEnterpriseMIB = new OID(".1.3.6.1.4.1.49266.0");

        thisRow.setHrSWRunIndex(new Integer32(1));
        thisRow.setHrSWRunName(new OctetString("RunnableAgent"));
        thisRow.setHrSWRunID(ashEnterpriseMIB);
        thisRow.setHrSWRunPath(new OctetString("All is good in the world")); // Max 128 characters
        thisRow.setHrSWRunParameters(new OctetString("Everything is working")); // Max 128 characters
        thisRow.setHrSWRunType(new Integer32(HrSWRunTypeEnum.application));
        thisRow.setHrSWRunStatus(new Integer32(HrSWRunStatusEnum.running));

        modules.getHostResourcesMib().getHrSWRunEntry().addRow(thisRow);

        agent.registerManagedObject(modules.getHostResourcesMib());

This appears to be sufficient to create a runnable agent. What I do not understand is how I am meant to change the values stored in the MIB (how do I, for example, change the value of HrSWRunStatus). There seem to be a few kludge ways but they don't seem to fit with the way the library is written.

I have come across numerous references to using/overriding the methods

prepare

commit

undo

cleanup

But cannot find any examples where this is done. Any help would be gratefully received.


问:
Using case statement getting error as incorrect syntax
In store procedure I am placing code as

```<code>SELECT *
FROM [Order] O
INNER JOIN Users U ON O.UserId=U.UserId
INNER JOIN State S ON S.StateId=O.Billing_StateId
INNER JOIN OrderStatus OS ON O.OrderStatusId=OS.OrderStatusId
WHERE (CASE WHEN ISNULL(@Name,'')='' THEN 0=0  ELSE O.Billing_FirstName LIKE '%' + @Name + '%' OR O.Billing_LastName LIKE'%' + @Name + '%' END)
AND (CASE WHEN ISNULL(@Email,'')='' THEN 0=0  ELSE O.Billing_Email LIKE '%' + @Email + '%' END)
</code>```

but it is giving error as Incorrect syntax near =

I dont know what I am doing wrong in placing THEN 0=0 ?

If it is wrong what should I wrote over there and is my query ok?

If @Name parameter is not there then it will not check 1st condition and will check for next condition

答:
your CASE statement is wrong

in case condition you must define new parameter that will replace the condition.

see this (i dont know if its work or not)

```<code>WHERE
(CASE
    WHEN ISNULL(@Name,'')='' THEN 0
    WHEN O.Billing_FirstName LIKE '%' + @Name + '%' OR O.Billing_LastName LIKE'%' + @Name + '%' THEN 1
 END as cond1) = 0 (*or 1, i dont know what you need)
 AND ........
</code>```

Body:
In store procedure I am placing code as

SELECT *
FROM [Order] O
INNER JOIN Users U ON O.UserId=U.UserId
INNER JOIN State S ON S.StateId=O.Billing_StateId
INNER JOIN OrderStatus OS ON O.OrderStatusId=OS.OrderStatusId
WHERE (CASE WHEN ISNULL(@Name,'')='' THEN 0=0  ELSE O.Billing_FirstName LIKE '%' + @Name + '%' OR O.Billing_LastName LIKE'%' + @Name + '%' END)
AND (CASE WHEN ISNULL(@Email,'')='' THEN 0=0  ELSE O.Billing_Email LIKE '%' + @Email + '%' END)

but it is giving error as Incorrect syntax near =

I dont know what I am doing wrong in placing THEN 0=0 ?

If it is wrong what should I wrote over there and is my query ok?

If @Name parameter is not there then it will not check 1st condition and will check for next condition

Body:
your CASE statement is wrong

in case condition you must define new parameter that will replace the condition.

see this (i dont know if its work or not)

WHERE
(CASE
    WHEN ISNULL(@Name,'')='' THEN 0
    WHEN O.Billing_FirstName LIKE '%' + @Name + '%' OR O.Billing_LastName LIKE'%' + @Name + '%' THEN 1
 END as cond1) = 0 (*or 1, i dont know what you need)
 AND ........


问:
Implementations of local regression and local likelihood methods
I am looking for an efficient implementation of local regression (LOESS) and local likelihood methods such as local logistic regression (local likelihood methods are discussed, for example, in section 6.5 of Elements of Statistical Learning by Hastie et. al.).

I would prefer a C++ or Python implementation, but pointers to R (where I know that LOESS is implemented, but I can't find a local likelihood method) or Java would also be appreciated.

Many thanks!

答: Can't you essentially get a python version of LOESS by using sk.learn's RadiusNeighborsRegressor function and specifying a custom tricube weighting function for the weights parameter?


问:
How to pass a form value to another view
How to get a form value form one view to another.
for example i would like to get the 'web_input' value from  InputWebView() and pass it into DisplayWebView()</p>

```<code><form method="POST" action="">
  {% csrf_token %}
    {{ form.non_field_errors }}
    {{ form.web_input }}
    <input type="submit">
</form/>

def InputWebView(requests)
    form = WebInputForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            return redirect('add_web', web_url=request.POST['web_input'])

def DisplayWebView(request, web_url):
    url = web_url
</code>```

答:
You can use sessions to pass data from one view to another. In InputWebView:

```<code>def InputWebView(requests)
    form = WebInputForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            request.session['web_input'] = request.POST['web_input']
            return redirect('add_web')
</code>```

In DisplayWebView:

```<code>def DisplayWebView(request):
    url = request.session.get('web_input')
</code>```

Body:
How to get a form value form one view to another.
for example i would like to get the 'web_input' value from  InputWebView() and pass it into DisplayWebView()

<form method="POST" action="">
  {% csrf_token %}
    {{ form.non_field_errors }}
    {{ form.web_input }}
    <input type="submit">
</form/>

def InputWebView(requests)
    form = WebInputForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            return redirect('add_web', web_url=request.POST['web_input'])

def DisplayWebView(request, web_url):
    url = web_url

Body:
You can use sessions to pass data from one view to another. In InputWebView:

def InputWebView(requests)
    form = WebInputForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            request.session['web_input'] = request.POST['web_input']
            return redirect('add_web')

In DisplayWebView:

def DisplayWebView(request):
    url = request.session.get('web_input')


问:
How to set an observer for a url change in Polymer?
Very simple question, I want to execute something when the url changes inside a custom element.

Currently I have:

```<code>Polymer({
    is: 'my-element',
    properties: {
        ...
    },
    listeners: {
        'playbutton.tap': 'playbuttonTap'
    },
    playbuttonTap: function(e) {
        document.getElementById('playbutton').style.display = "none";
    },
    observers: [
        '_routePageChanged()'
    ],
    _routePageChanged: function() {
        console.log('STOP MOVIE')
    }
});
</code>```

But this doesn't work.

答:
Your _routePageChanged observer isn't actually observing a property...

I suggest adding an element to watch the address bar, like <app-route>:

```<code><app-location route="{{route}}"></app-location>
</code>```

Then you can watch for any changes to the route.path property like so:

```<code>observers: [
  '_routeChanged(route.path)'
]
</code>```

Body:
Very simple question, I want to execute something when the url changes inside a custom element.

Currently I have:

Polymer({
    is: 'my-element',
    properties: {
        ...
    },
    listeners: {
        'playbutton.tap': 'playbuttonTap'
    },
    playbuttonTap: function(e) {
        document.getElementById('playbutton').style.display = "none";
    },
    observers: [
        '_routePageChanged()'
    ],
    _routePageChanged: function() {
        console.log('STOP MOVIE')
    }
});

But this doesn't work.

Body:
Your _routePageChanged observer isn't actually observing a property...

I suggest adding an element to watch the address bar, like <app-route>:

<app-location route="{{route}}"></app-location>

Then you can watch for any changes to the route.path property like so:

observers: [
  '_routeChanged(route.path)'
]


问:
c# string to class from which I can call functions
on initialize a class by string variable in c#? I already found out how to create an class using a string

so what I already have is:

```<code>Type type = Type.GetType("project.start");
var class = Activator.CreateInstance(type);
</code>```

what I want to do is call a function on this class for example:

```<code>class.foo();
</code>```

is this possible? and if it is how?

答:
Activator.CreateInstance returns a type of object.  If you know the type at compile time, you can use the generic CreateInstance.

```<code>Type type = Type.GetType("project.start");
var class = Activator.CreateInstance<project.start>(type);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
on initialize a class by string variable in c#? I already found out how to create an class using a string

so what I already have is:

Type type = Type.GetType("project.start");
var class = Activator.CreateInstance(type);

what I want to do is call a function on this class for example:

class.foo();

is this possible? and if it is how?

Body:
Activator.CreateInstance returns a type of object.  If you know the type at compile time, you can use the generic CreateInstance.

Type type = Type.GetType("project.start");
var class = Activator.CreateInstance<project.start>(type);

ContentLicense: CC BY-SA 2.5


问:
SnakeYAML saves incorrectly
I've been working on setting up my configuration to use SnakeYAML.  I want my configuration to look like this:

```<code>connection:
    bind-ip: 0.0.0.0
    plugin-port: 2011
    rtk-port: 2012
    passphrase: abcde12345
updates:
    auto-update: true
    channel: recommended
    build: -1
</code>```

but instead it turns out as

```<code>connection: {bind-ip: 0.0.0.0, connection.passphrase: abcde12345, connection.pluginPort: 2011,
  connection.rtkPort: 2012}
updates: {updates.auto-update: true, updates.channel: Recommended, updates.build: -1}
</code>```

I have a LinkedHashMap that I save to with like so:

```<code>private LinkedHashMap<String, Map> values;
public void set(String key, Map<String, Object> value) {
        values.put(key, value);
    }
</code>```

And here is the method I use to populate/load the configuration

```<code>private void init() {
        Map<String, Object> connection = new LinkedHashMap<String, Object>();

       if (exists("connection.bind-ip"))  {
            bindIp = (String) get("connection.bind-ip");
        }  else {
            connection.put("bind-ip", bindIp);
        }

        if (exists("connection.passphrase"))  {
            passphrase = (String) get("connection.passphrase");
        }  else {
            connection.put("connection.passphrase", passphrase);
        }

        if (exists("connection.pluginPort"))  {
            pluginPort = (Integer) get("connection.rtkPort");
        }  else {
            connection.put("connection.pluginPort", pluginPort);
        }

        if (exists("connection.rtkPort"))  {
            rtkPort = (Integer) get("connection.rtkPort");
        }  else {
            connection.put("connection.rtkPort", rtkPort);
        }

        if (!(connection.isEmpty())) {
            set("connection", connection);
        }

        Map<String, Object> updates = new LinkedHashMap<String, Object>();

        if (exists("updates.auto-update")) {
            autoUpdate = (Boolean) get("updates.auto-update");
        }  else {
            updates.put("updates.auto-update", autoUpdate);
        }

        if (exists("updates.channel")) {
            channel = (String) get("updates.channel");
        }  else {
            updates.put("updates.channel", channel);
        }

        if (exists("updates.build")) {
            build = (Integer) get("updates.build");
        }  else {
            updates.put("updates.build", build);
        }

        if (!(updates.isEmpty())) {
            set("updates", updates);
        }
    }
</code>```

Any help would be greatly appreciated!  Sorry it's a little long

答:
As of org.yaml:snakeyaml:1.17:

```<code>DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
new Yaml(options).dump(data, writer)
</code>```

Just wonder why this isn't by default.

Title: SnakeYAML saves incorrectly

Body:
I've been working on setting up my configuration to use SnakeYAML.  I want my configuration to look like this:

connection:
    bind-ip: 0.0.0.0
    plugin-port: 2011
    rtk-port: 2012
    passphrase: abcde12345
updates:
    auto-update: true
    channel: recommended
    build: -1

but instead it turns out as

connection: {bind-ip: 0.0.0.0, connection.passphrase: abcde12345, connection.pluginPort: 2011,
  connection.rtkPort: 2012}
updates: {updates.auto-update: true, updates.channel: Recommended, updates.build: -1}

I have a LinkedHashMap that I save to with like so:

private LinkedHashMap<String, Map> values;
public void set(String key, Map<String, Object> value) {
        values.put(key, value);
    }

And here is the method I use to populate/load the configuration

private void init() {
        Map<String, Object> connection = new LinkedHashMap<String, Object>();

       if (exists("connection.bind-ip"))  {
            bindIp = (String) get("connection.bind-ip");
        }  else {
            connection.put("bind-ip", bindIp);
        }

        if (exists("connection.passphrase"))  {
            passphrase = (String) get("connection.passphrase");
        }  else {
            connection.put("connection.passphrase", passphrase);
        }

        if (exists("connection.pluginPort"))  {
            pluginPort = (Integer) get("connection.rtkPort");
        }  else {
            connection.put("connection.pluginPort", pluginPort);
        }

        if (exists("connection.rtkPort"))  {
            rtkPort = (Integer) get("connection.rtkPort");
        }  else {
            connection.put("connection.rtkPort", rtkPort);
        }

        if (!(connection.isEmpty())) {
            set("connection", connection);
        }

        Map<String, Object> updates = new LinkedHashMap<String, Object>();

        if (exists("updates.auto-update")) {
            autoUpdate = (Boolean) get("updates.auto-update");
        }  else {
            updates.put("updates.auto-update", autoUpdate);
        }

        if (exists("updates.channel")) {
            channel = (String) get("updates.channel");
        }  else {
            updates.put("updates.channel", channel);
        }

        if (exists("updates.build")) {
            build = (Integer) get("updates.build");
        }  else {
            updates.put("updates.build", build);
        }

        if (!(updates.isEmpty())) {
            set("updates", updates);
        }
    }

Any help would be greatly appreciated!  Sorry it's a little long

Body:
As of org.yaml:snakeyaml:1.17:

DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
new Yaml(options).dump(data, writer)

Just wonder why this isn't by default.


问:
Requests + Proxy Servers, IP address won't change
I am using the python shell to test requests together with proxy servers.
After reading documentation (http://docs.python-requests.org/en/master/user/advanced/) and a few stackoverflow threads I am doing the following:

```<code>import requests

s = requests.session()
proxies = {'http': 'http://90.178.216.202:3128'}
s.proxies.update(proxies)
req = s.get('http://jsonip.com')
</code>```

After this, if I print req.text, I get this:
u'{"ip":"my current IP (not the proxy server IP I have inserted before)","about":"/about", ......}'

Can you please explain why I'm getting my computer's IP address and not the proxy server's IP address?
Did I go wrong somewhere or am I expecting the wrong thing to happen here?
I am new to requests + proxy servers so I would like to make sure I am understanding this.

UPDATE
I also have this in my code:

```<code>headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'}
s.headers.update(headers)
</code>```

Thanks
Vittorio

答:
The site ( http://jsonip.com ) broadcasts an 'Upgrade-Insecure-Requests' header. This means that your request gets redirected to https://jsonip.com, so requests doesn't use a proxy because you don't have an https proxy in your proxies dict.

So, all you have to do is add an https proxy in proxies , eg:

```<code>proxies = {'http':'http://90.178.216.202:3128', 'https':'https://90.178.216.202:3128'}
</code>```

Body:
I am using the python shell to test requests together with proxy servers.
After reading documentation (http://docs.python-requests.org/en/master/user/advanced/) and a few stackoverflow threads I am doing the following:

import requests

s = requests.session()
proxies = {'http': 'http://90.178.216.202:3128'}
s.proxies.update(proxies)
req = s.get('http://jsonip.com')

After this, if I print req.text, I get this:
u'{"ip":"my current IP (not the proxy server IP I have inserted before)","about":"/about", ......}'

Can you please explain why I'm getting my computer's IP address and not the proxy server's IP address?
Did I go wrong somewhere or am I expecting the wrong thing to happen here?
I am new to requests + proxy servers so I would like to make sure I am understanding this.

UPDATE
I also have this in my code:

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0'}
s.headers.update(headers)

Thanks
Vittorio

Body:
The site ( http://jsonip.com ) broadcasts an 'Upgrade-Insecure-Requests' header. This means that your request gets redirected to https://jsonip.com, so requests doesn't use a proxy because you don't have an https proxy in your proxies dict.

So, all you have to do is add an https proxy in proxies , eg:

proxies = {'http':'http://90.178.216.202:3128', 'https':'https://90.178.216.202:3128'}


问:
Incorrect ruby version when installing bundle in rails project
I have a problem when running bundle install in the root of sharetribe rails's project. It shows me this error message:

Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1

I tried installing rvm and installing the 2.3.1 version required to run this project but nothing changes and it still throwing this output.

Have anyone faced this problem before ?

答:
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1

Steps to resolve this issue

```<code>1)rvm install ruby-2.3.1

2)gem install bundler

3)rvm use ruby-2.3.1

4)Bundle install
</code>```

Body:
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1

Steps to resolve this issue

1)rvm install ruby-2.3.1

2)gem install bundler

3)rvm use ruby-2.3.1

4)Bundle install


问:
How do i display data in front-end in descending order for year born given in a single row of mysql
I am trying to array year in descending order associated with some other data which is fetched from mysql database in php

```<code>My Table
username   familyperson1     yearofbirth1     cityname1     familyperson2     yearofbirth2     cityname2      familyperson3   yearofbirth3   cityname3 ...
ptbarn     John              1985             New York      Smit              2001             San Fransisco  Kate            1966           Houston   ...
</code>```

My mysql fetch query:

```<code>require("connect.php");
$srno = $_SESSION['username'];
$query = "SELECT * FROM my_table_name WHERE username='" . $srno . "'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$username = $row['username'];
$familyperson1 = $row['familyperson1'];
$yearofbirth1 = $row['yearofbirth1'];
$cityname1 = $row['cityname1'];
$familyperson2 = $row['familyperson2'];
$yearofbirth2 = $row['yearofbirth2'];
$cityname2 = $row['cityname2'];
$familyperson3 = $row['familyperson2'];
$yearofbirth3 = $row['yearofbirth2'];
$cityname3 = $row['cityname2'];
...
}
</code>```

I request you to please not comment on mysqli on this, that i intent to change later.

Below is the query i fetch from mysql database

```<code>echo 'Family members of' . $username . ':<br>';
echo $familyperson1 . 'is born in the year' . $yearofbirth1 . 'and stays in the city' . $cityname1 . '<br>';
echo $familyperson2 . 'is born in the year' . $yearofbirth2 . 'and stays in the city' . $cityname2 . '<br>';
echo $familyperson3 . 'is born in the year' . $yearofbirth3 . 'and stays in the city' . $cityname3 . '<br>';
echo $familyperson4 . 'is born in the year' . $yearofbirth4 . 'and stays in the city' . $cityname4 . '<br>';
echo $familyperson5 . 'is born in the year' . $yearofbirth5 . 'and stays in the city' . $cityname5 . '<br>';
</code>```

Now i want that if $yearofbirth4 is youngest it should echo on top and descents and so on and so forth.

Although, the result is:

```<code>Family members of ptbarn:
John is born in the year 1985 and stays in city New York.
Smit is born in the year 2001 and stays in city San Fransisco.
Kate is born in the year 1966 and stays in city Houston.
Papa is born in the year 2005 and stays in city Las Vegas.
Rony is born in the year 2002 and stays in city San Diego.
</code>```

The result i want is:

```<code>Family members of ptbarn:
Papa is born in the year 2005 and stays in city Las Vegas.
Rony is born in the year 2002 and stays in city San Diego.
Smit is born in the year 2001 and stays in city San Fransisco.
John is born in the year 1985 and stays in city New York.
Kate is born in the year 1966 and stays in city Houston.
</code>```

I tried this code (from w3schools):

```<code>echo 'Family members of' . $username . ':<br>';
$numbers = array($yearofbirth1, $yearofbirth2, $yearofbirth3, $yearofbirth4, $yearofbirth5);
rsort($numbers);

$arrlength = count($numbers);
for($x = 0; $x < $arrlength; $x++) {
    echo $familyperson1 . 'is born in the year' . $numbers[$x] . 'and stays in the city' . $cityname1;
    echo "<br>";
}
</code>```

And the result i got was:

```<code>Family members of ptbarn:
John is born in the year 2005 and stays in city New York.
John is born in the year 2002 and stays in city New York.
John is born in the year 2001 and stays in city New York.
John is born in the year 1985 and stays in city New York.
John is born in the year 1966 and stays in city New York.
</code>```

It's logical that I am doing it wrong above, request help.

Added info: The limit of data is only 5 per user in this in mysql row.

答:
this rsort() is sorted in only your variable but your mysql result is in asc order so you can use</p>

```<code>SELECT name, birth FROM pet ORDER BY birth DESC;
</code>```

Body:
I am trying to array year in descending order associated with some other data which is fetched from mysql database in php

My Table
username   familyperson1     yearofbirth1     cityname1     familyperson2     yearofbirth2     cityname2      familyperson3   yearofbirth3   cityname3 ...
ptbarn     John              1985             New York      Smit              2001             San Fransisco  Kate            1966           Houston   ...

My mysql fetch query:

require("connect.php");
$srno = $_SESSION['username'];
$query = "SELECT * FROM my_table_name WHERE username='" . $srno . "'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$username = $row['username'];
$familyperson1 = $row['familyperson1'];
$yearofbirth1 = $row['yearofbirth1'];
$cityname1 = $row['cityname1'];
$familyperson2 = $row['familyperson2'];
$yearofbirth2 = $row['yearofbirth2'];
$cityname2 = $row['cityname2'];
$familyperson3 = $row['familyperson2'];
$yearofbirth3 = $row['yearofbirth2'];
$cityname3 = $row['cityname2'];
...
}

I request you to please not comment on mysqli on this, that i intent to change later.

Below is the query i fetch from mysql database

echo 'Family members of' . $username . ':
';
echo $familyperson1 . 'is born in the year' . $yearofbirth1 . 'and stays in the city' . $cityname1 . '
';
echo $familyperson2 . 'is born in the year' . $yearofbirth2 . 'and stays in the city' . $cityname2 . '
';
echo $familyperson3 . 'is born in the year' . $yearofbirth3 . 'and stays in the city' . $cityname3 . '
';
echo $familyperson4 . 'is born in the year' . $yearofbirth4 . 'and stays in the city' . $cityname4 . '
';
echo $familyperson5 . 'is born in the year' . $yearofbirth5 . 'and stays in the city' . $cityname5 . '
';

Now i want that if $yearofbirth4 is youngest it should echo on top and descents and so on and so forth.

Although, the result is:

Family members of ptbarn:
John is born in the year 1985 and stays in city New York.
Smit is born in the year 2001 and stays in city San Fransisco.
Kate is born in the year 1966 and stays in city Houston.
Papa is born in the year 2005 and stays in city Las Vegas.
Rony is born in the year 2002 and stays in city San Diego.

The result i want is:

Family members of ptbarn:
Papa is born in the year 2005 and stays in city Las Vegas.
Rony is born in the year 2002 and stays in city San Diego.
Smit is born in the year 2001 and stays in city San Fransisco.
John is born in the year 1985 and stays in city New York.
Kate is born in the year 1966 and stays in city Houston.

I tried this code (from w3schools):

echo 'Family members of' . $username . ':
';
$numbers = array($yearofbirth1, $yearofbirth2, $yearofbirth3, $yearofbirth4, $yearofbirth5);
rsort($numbers);

$arrlength = count($numbers);
for($x = 0; $x < $arrlength; $x++) {
    echo $familyperson1 . 'is born in the year' . $numbers[$x] . 'and stays in the city' . $cityname1;
    echo "
";
}

And the result i got was:

Family members of ptbarn:
John is born in the year 2005 and stays in city New York.
John is born in the year 2002 and stays in city New York.
John is born in the year 2001 and stays in city New York.
John is born in the year 1985 and stays in city New York.
John is born in the year 1966 and stays in city New York.

It's logical that I am doing it wrong above, request help.

Added info: The limit of data is only 5 per user in this in mysql row.

Body:
this rsort() is sorted in only your variable but your mysql result is in asc order so you can use

SELECT name, birth FROM pet ORDER BY birth DESC;


问:
Is there a simple function to change the values rows of an array to columns in another array?
Okay, I have an array that has 5 rows and one column.  I have another array with 5 columns, and 1 row.  Is there a way that I can change the values of the array with the rows to the columns in a simpler way.  I know that I can do this:

```<code> import numpy as np
 x = np.ones(5)
 y = np.zeros([5,1])
 y[:,0] = x
</code>```

Is there a easier way of doing this.  I will be flipping many values in rows to columns, and this may get messy in my actual code.

答:
You are looking for reshape.

```<code>y = x.reshape((5,1))
</code>```

Body:
Okay, I have an array that has 5 rows and one column.  I have another array with 5 columns, and 1 row.  Is there a way that I can change the values of the array with the rows to the columns in a simpler way.  I know that I can do this:

 import numpy as np
 x = np.ones(5)
 y = np.zeros([5,1])
 y[:,0] = x

Is there a easier way of doing this.  I will be flipping many values in rows to columns, and this may get messy in my actual code.

Body:
You are looking for reshape.

y = x.reshape((5,1))