Tag Archives: solution

How to Solve Error: Cannot find the declaration of element ‘beans’.

Question: org.xml.sax .SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.

Solution: first, if the exception is encountered in the project, it is usually the problem that the project cannot download to the spring-beans-2.5.xsd file. The version number here varies with the project version.

Here you need to configure the local XSD file as follows:

Find the core package of spring referenced in your project, spring.jar

Open it with a compressed file and find the path

org/springframework/beans/factory/xml/

And configure the XSD file in this path to applicationContext.xml If there are more than one configuration file, all of them will be replaced

That is to say,
is the best choice

classpath:/org/springframework/beans/factory/xml/spring-beans-2.5.xsd

Instead of

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

Enables the configuration file to be read directly from the local

Reprint address: http://blog.csdn.net/wengang285/article/details/7587264

Method 2:

Modify spring applicationContext.xml Change the name space of the XML file to the following code:

<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN 2.0//EN” ” http://www.springframework.org/dtd/spring-beans-2.0.dtd “>
<beans>

Problem solving address: http://www.myexception.cn/vc-mfc/627052.html

 

The first method seems to have no effect, so I use the second method to solve the problem

Twitter’s distributed self increasing ID algorithm snowflake (Java version)

summary

In distributed systems, there are some scenarios where a globally unique ID is needed. In this case, in order to prevent ID conflicts, a 36 bit UUID can be used. However, UUID has some disadvantages. First, it is relatively long. In addition, UUID is generally unordered.

Sometimes we want to use a simpler ID, and we want the ID to be generated in time order.

Twitter’s snowflake solved this problem. At first, twitter migrated the storage system from Mysql to Cassandra. Because Cassandra had no sequential ID generation mechanism, it developed such a global unique ID generation service.

structure

The structure of each part is as follows:

0 – 0000000000 0000000000 0000000000 0000000000 0 – 00000 – 00000 – 000000000000

The first bit is unused, the next 41 bits are milliseconds (the length of 41 bits can be used for 69 years), then 5-bit datacenterid and 5-bit workerid (the length of 10 bits can support deployment of 1024 nodes at most), and the last 12 bits are counts within milliseconds (the 12 bit counting sequence number supports 4096 ID serial numbers per millisecond for each node)

A total of 64 bits, a long type. (length of converted string is 18)

The IDs generated by snowflake are sorted according to the time increment, and there is no ID collision (distinguished by datacenter and workerid) in the whole distributed system, and the efficiency is high. It is said that snowflake can generate 260000 IDS per second.

Source code

(Java version of the source)

/**
 * Twitter_Snowflake<br>
 * The structure of SnowFlake is as follows (each part is separated by -):<br>
 * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
 * 1-bit identifier, as the long basic type is signed in Java, the highest bit is the sign bit, positive numbers are 0, negative numbers are 1, so the id is generally positive, the highest bit is 0 <br>
 * 41-bit time intercept (milliseconds), note that the 41-bit time intercept is not a time intercept to store the current time, but the difference between the time intercept (current time intercept - start time intercept)
 * the value obtained), where the start time intercept, generally our id generator to start using the time specified by our program (the following program IdWorker class startTime property). 41-bit time intercept, you can use 69 years, year T = (1L << 41)/(1000L * 60 * 60 * 24 * 365) = 69<br>
 * 10-bit data machine bits that can be deployed in 1024 nodes, including 5-bit datacenterId and 5-bit workerId<br>
 * 12-bit sequential, millisecond counting, 12-bit counting sequence number supports 4096 ID sequential numbers per node per millisecond (same machine, same time cutoff)<br>
 * Add up to exactly 64 bits for a Long type. <br>
 * The advantage of SnowFlake is that the overall self-increasing sorting by time and no ID collision within the whole distributed system (distinguished by data center ID and machine ID), and high efficiency, tested, SnowFlake can generate about 260,000 IDs per second.
 */
public class SnowflakeIdWorker {

    // ==============================Fields===========================================
    /** Start time cutoff (2015-01-01) */
    private final long twepoch = 1420041600000L;

    /* The number of bits occupied by the machine id */
    private final long workerIdBits = 5L;

    /* The number of bits occupied by the data identifier id */
    private final long datacenterIdBits = 5L;

    /* The maximum machine id supported, resulting in 31 (this shift algorithm can quickly calculate the maximum number of decimal digits that can be represented by a few binary digits) */
    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);

    /* The maximum supported data identifier id, resulting in 31 */
    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);

    /** The number of bits in the id that the sequence occupies */.
    private final long sequenceBits = 12L;

    /** The machine ID is shifted 12 bits to the left */.
    private final long workerIdShift = sequenceBits;

    /** The data identifier id is shifted to the left by 17 bits (12+5)*/.
    Private final long datacenterIdShift = sequenceBits + workerIdBits。

    /** The time truncation is shifted to the left by 22 bits (5+5+12) */.
    private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits。

    /** Generate the mask for the sequence, here 4095. (0b111111111111=0xfff=4095) */
    private final long sequenceMask = -1L ^ (-1L << sequenceBits);

    /** Work machine ID(0~31) */
    private long workerId;

    /** Work machine ID(0~31) */
    private long datacenterId;

    /** Intra-millisecond sequence (0~4095) */
    private long sequence = 0L;

    /** Time cutoff of the last generated ID */
    private long lastTimestamp = -1L;

    //==============================Constructors=====================================
    /**
     * Constructor
     * @param workerId Job ID (0~31)
     * @param datacenterId datacenterId (0~31)
     */
    public SnowflakeIdWorker(long workerId, long datacenterId) {
        if (workerId > maxWorkerId || workerId < 0) {
            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
        }
        if (datacenterId > maxDatacenterId || datacenterId < 0) {
            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
        }
        this.workerId = workerId;
        this.datacenterId = datacenterId;
    }

    // ==============================Methods==========================================
    /**
     * Get the next ID (this method is thread-safe)
     * @return SnowflakeId
     */
    public synchronized long nextId() {
        long timestamp = timeGen();

        //If the current time is less than the timestamp of the last ID generation, it means that the system clock is backed off and an exception should be thrown at this time
        if (timestamp < lastTimestamp) {
            throw new RuntimeException(
                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
        }

        //If it was generated at the same time, then perform a sequence within milliseconds
        if (lastTimestamp == timestamp) {
            sequence = (sequence + 1) & sequenceMask;
            // sequence overflow in milliseconds
            if (sequence == 0) {
                //Block until the next millisecond, get the new timestamp
                timestamp = tilNextMillis(lastTimestamp);
            }
        }
        //Timestamp change, sequence reset in milliseconds
        else {
            sequence = 0L;
        }

        //Time cutoff of the last generated ID
        lastTimestamp = timestamp;

        //Shifted and put together by orthogonal operations to form a 64-bit ID
        return ((timestamp - twepoch) << timestampLeftShift) //
                | (datacenterId << datacenterIdShift) //
                | (workerId << workerIdShift) //
                | sequence;
    }

    /**
     * Block to the next millisecond until the new timestamp is obtained
     * @param lastTimestamp Time cutoff of the last generated ID
     * @return currentTimestamp
     */
    protected long tilNextMillis(long lastTimestamp) {
        long timestamp = timeGen();
        while (timestamp <= lastTimestamp) {
            timestamp = timeGen();
        }
        return timestamp;
    }

    /**
     * Returns the current time in milliseconds
     * @return current time in milliseconds
     */
    protected long timeGen() {
        return System.currentTimeMillis();
    }

    //==============================Test=============================================
    /** TEST */
    public static void main(String[] args) {
        SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
        for (int i = 0; i < 1000; i++) {
            long id = idWorker.nextId();
            System.out.println(Long.toBinaryString(id));
            System.out.println(id);
        }
    }
}

“21442;” 32771;

Tensorflow C++:You must define TF_LIB_GTL_ALIGNED_CHAR_ARRAY for your compiler

When using the tensorflow C++ API, the error You must define TF_LIB_GTL_ALIGNED_CHAR_ARRAY for your compiler.
The reason is as follows (see reference).

 

If you omit the COMPILER_MSVC definition, you will run into an error saying “You must define TF_LIB_GTL_ALIGNED_CHAR_ARRAY for your compiler.” If you omit the NOMINMAX definition, you will run into a number of errors saying “’(‘: illegal token on right side of ‘::’”. (The reason for this is that <Windows.h> gets included somewhere, and Windows has macros that redefine min and max. These macros are disabled with NOMINMAX.)

Solution 1:
Add at the beginning of the code

#pragma once

#define COMPILER_MSVC
#define NOMINMAX

Solution 2:

Take vs2017 as an example: attribute Manager — > C/C + + –> preprocessor definition

Paste in the following

COMPILER_ MSVC
NOMINMAX

put things right once and for all!

ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_power:0 incompatib

Exception encountered while importing optimized frozen graph.

# read pb into graph_def
with tf.gfile.GFile(pb_file, "rb") as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())

# import graph_def
with tf.Graph().as_default() as graph:
    tf.import_graph_def(graph_def)

Get exception in this line:

tf.import_ graph_ def(graph_ def)

ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_ power:0 incompatible with expected float_ ref.

The solution: make sure your_ The file format is correct (similar to this), and try to_ graph_ Set some values in the ‘name’ parameter of def() to try to override the default value of ‘import’, as follows:

import tensorflow as tf

from tensorflow.python.platform import gfile
model_path="/tmp/frozen/dcgan.pb"

# read graph definition
f = gfile.FastGFile(model_path, "rb")
gd = graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())

# fix nodes
for node in graph_def.node:
    if node.op == 'RefSwitch':
        node.op = 'Switch'
        for index in xrange(len(node.input)):
            if 'moving_' in node.input[index]:
                node.input[index] = node.input[index] + '/read'
    elif node.op == 'AssignSub':
        node.op = 'Sub'
        if 'use_locking' in node.attr: del node.attr['use_locking']

# import graph into session
tf.import_graph_def(graph_def, name='')
tf.train.write_graph(graph_def, './', 'good_frozen.pb', as_text=False)
tf.train.write_graph(graph_def, './', 'good_frozen.pbtxt', as_text=True)

fatal error LNK2019[UNK]fatalerror LNK1120

The reason for the error is as follows:

① You use other people’s libraries, such as opencv library, OpenGL library and other third-party libraries. The common situation is that you only include the header file, but there is no import file

② You don’t use other people’s libraries. Some of Microsoft’s own libraries may also have such problems. At this time, the common situation is that the header file of the failed function is in the included directory of the project property, but the corresponding library file is not in the default library directory of the project property. For example, create view glcontext (struct HDC) in FAQ style__ *) function is such a case. This function is defined in the header file wingdi. H. This header file is in the default included directory in the project properties, but the corresponding library file opengl32. Lib is not in the library directory

③ You use your own library file. I haven’t tried this situation. I’ve seen some comments on the Internet

Fatal error lnk1120 cause:

① . contains only the header file, only the declaration of this function, but not the implementation of this function (the implementation is generally placed in the cpp file). So it can only be compiled, and the connection is not successful.

② Another reason is that the declaration and implementation of the function are put in the header file. Generally, the declaration should be put in the header file and the implementation in the cpp file. In this way, each file that contains the header file will have an implementation of the function. When connecting, the connector does not know which implementation to connect, so an error is reported.

 

 

Photoshop CS6 detailed installation of graphic tutorial

catalog

Step 0: preparation

Step 1: install Photoshop CS61

Step 2: Activate

 


Step 0: preparation

First, go to Baidu cloud link: https://pan.baidu.com/s/1kXchn07 Password: dslu; download PS CS6 compressed package, Download do not want to unzip, put well do not move.

Then enter Baidu cloud link: https://pan.baidu.com/s/1htn2zoK Password: hpq7; download cracking tools, after downloading the computer unplug the cable, disconnect the wireless

Step 1: install Photoshop CS61

Unzip the downloaded Photoshop CS6 compressed file, and double-click to open the“ Setup.exe ”[location: Photoshop_ 13_ LS3\Adobe CS6];

Select ignore;

3. After initializing the installation program, the Photoshop CS6 installation program will pop up. To install it by trial, select trial;

4 [acceptance];

5 prompt us to log in, click [log in] (I have logged in here, this interface may be different from your interface, but it does not affect the installation);

If you don’t have an adobe ID account, you can click the button in the yellow box indicated by the yellow arrow to register. It’s as simple as registering a forum account. Just fill in some information;

7 after the login operation, click the button in the box indicated by the arrow to customize Photoshop The directory where CS6 needs to be installed can also be left unchanged by default (remember your installation location and use it later); then click [install] (if you are a 64 bit system friend, there will be Photoshop CS6 and Photoshop CS6 (64bit) installation contents, you can choose to install both or only one);

8. During the installation, it needs to wait about 10 minutes;

9. After installation, click close.

END

Step 2: Activate

Note: after the installation, you must run Photoshop CS6 for the first time, and click the [start trial] button in the trial interface (if you don’t go through this step, the cracked Photoshop CS6 is the ordinary version, not the extended version.) , and then close Photoshop CS6;

Decompress the downloaded crack file, Xiaobian here is the 32-bit operating system, so we need to copy the 32-bit crack patch“ amtlib.dll ”[location: under the “32-bit cracking patch” folder] (if you are a 64 bit student, select the “64 bit cracking patch” folder“ amtlib.dll ”);

Open the installation directory: find “Adobe Photoshop CS6” in all programs in the start menu, right-click it, and then click properties;

Click Find target in the pop-up attribute box;

After clicking find target, a folder will pop up. Right click in a blank place and select paste to overlay the source file;

Prompt “Confirm File replacement” and select [yes];

Installation completed, the following is the software interface, come to try it!

 

PIP3 upgrade tutorial of Python 3.5.2 under ubantu16

You are using pip version 8.1.1, however version 10.0.1 is available. You should consider upgrading via the ‘pip install –upgrade pip’ install。

Upgrade PIP3

1. Input upgrade command

sudo pip3 install –upgrade pip

Note: if you only do this step, an error will still be reported in the next installation. The error is about: cannot import name ‘main’. So you need to modify the/usr/bin/PIP3 file, see Step 2.  

2. Modify the configuration file

sudo gedit /usr/bin/pip3

Change to read as follows (last line and penultimate line)

#!/usr/bin/python3
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__.main())

 
 

The Ubuntu status bar shows the network speed, memory and CPU utilization ratio

Install indicator sysmonitor

1. Add source

sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor

2. Update source

sudo apt update

3. Installation

sudo apt install indicator-sysmonitor

Start monitor-4

nohup indicator-sysmonitor &

Note: when starting with nohup, the indicator sysmonitor will not exit when closing the terminal.

Chrome setting — Disable web security to solve cross domain problems

We can change the Chrome browser settings by using the chrome command line startup parameters. Please refer to this article for the specific startup parameters. https://code.google.com/p/xiaody/wiki/ChromiumCommandLineSwitches

Here is the – disable web security parameter. This parameter can reduce the security of Chrome browser, disable the homology policy, and facilitate the local debugging of developers.

The steps are as follows:

1. Close all chrome browsers.

2. Create a new chrome shortcut, right-click properties, select target in Shortcut tab, and add – args – disable web security – user data dir

3. Then start chrome

Win10 installation git click git bash flash back problem solution

Git is an open source distributed version control system, which can effectively and quickly handle the project version management from very small to very large. Through git, you can upload the code to GitHub, and control the version through GitHub iteration. And the use of every software, always inseparable from the installation, the original git installation is very fast, belongs to the “fool type” installation type. But Xiaobian found that there was no problem when installing it in Xiaobian’s notebook, but when it came to the desktop, it was found that there was a problem. The same win10 system, why the effect is not the same?
After Xiaobian asked Du Niang, someone said C/window/system32/drivers on Du Niang/ null.sysnull.sys This system file is corrupted. So I copied one from other computers, and it still didn’t solve the problem after I covered it. So, Xiaobian continued to ask Du Niang, and found a real solution. Xiaobian’s personal test was effective, so I’d like to introduce it to you.
1. In Windows/system32/ cmd.exe Open CMD, run SC query null

2. Start the service manually, and run SC start null
to find that the small blackboard reported an error:
[SC] startservice failed 577:
Windows cannot verify the digital signature of this file. Some software or hardware has been changed recently. It is possible that the wrong signature or damaged file has been installed, or the installed file may be malicious software of unknown origin.
After that, copy one from another system null.sys And cover the original C: windows, system32, drivers\ null.sys File, and then start the null service. If you want to test null.sys Whether it is normal or not, run SC start null. If the display is similar to the following, it indicates that the startup is successful.
SERVICE_ NAME: null
TYPE : 1 KERNEL_ DRIVER
STATE : 4 RUNNING
(STOPPABLE, NOT_ PAUSABLE, IGNORES_ SHUTDOWN)
WIN32_ EXIT_ CODE : 0 (0x0)
SERVICE_ EXIT_ CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_ Hit: 0x0
PID: 0
flags:
after that, right-click git bash here to find that there is no flash back.
It’s useful to make a personal test null.sys File address:
link: https://pan.baidu.com/s/1UtcZizm-iFcVk4OKrnFJVg Password: 1q4d

Reprinted:
1 http://www.cnblogs.com/ricklz/p/9216395.html