Solving MySQL suddenly occupy all memory problems

Pocketed a while ago on migrating from virtual host to an independent VPS,Maintenance of this all is my own。For performance,If your environment,Nature does not use the old configuration。

I use Ubuntu Server 16.04 + PHP 7.0 + Nginx + MySQL 5.7 In short,Stepped on a lot of holes。

Now,To record

Why MySQL is suddenly filling up memory

At first I thought it was a VPS under attack,But not only this traffic View Card[……]

Click link to continue reading...

Ubuntu 16.04 Adding memcached and redis extended PHP7

Switch to PHP 7 after that,Site speed boost,But usually just one of extension may not yet support PHP7.

Memcached

For example, I now use the latest Ubuntu 16.04,Although it built in PHP 7 source,But it has not memcached,Fortunately, however,,It has supported PHP 7 ,Not just the source of it,We compile it manually。

To install memcached,You need to install the dependent libraries libmemcached

fromHereturn up[……]

Click link to continue reading...

Swift in the single mode

In the process of writing the code,We will meet when the need to ensure that only one instance of the global,This time use the singleton pattern。

Single mode--this ensures that only one instance of a class,And provide a global point of access to。

What about how to implement the singleton pattern? We take a look at the classic Java code,How to implement the singleton pattern。

Our online search for "Java singleton pattern" will be able to find plenty of readily available code snippets,Here are random excerpts of a report:
[crayon-69048ab33fa463203[……]

Click link to continue reading...

Rollover to the Ubuntu Server 16.04

We vps,In general, Ubuntu is still easy to use,On the one hand it is more friendly to novice,On the other hand are some common service configuration can be a key installation。Plus Niubi ufw,Really perfect。

but,Now not all vps service providers are able to provide the latest Ubuntu Server 16.04,what a pity。It has so many benefits of,For example, the native library is php7,No additional compiler ......

So since it is linux,Will be able to directly upgrade to the new version - I remember Ubu[……]

Click link to continue reading...

Please use caution in the C # var

we all know,For example, Swift 、 Python,,You do not need to declare a special variable type - although they are type-safe languages,But it can help you to dynamically infer the type of a variable in context。

Python do what you do,Write a name is the default declare a variable;And Swift,It is more close to our topic,It also uses where

If you have had experience in the use Swift,Again using C #[……]

Click link to continue reading...

Let's Encrypt using the VPS configure SSL for Nginx

Before we have talked about how to siteOpen Full Site SSL Now we take a look at how the vps to Nginx open Let's Encrypt certificate and automatically update。

The contents of this article older,About letsencrypt configuration article,I wrote a new,Perhaps you can refer to a look:letsencrypt tool renamed certbot

Set the environment

First of all,We should prepare the installation environment,This time I am using CentOS 6.7[……]

Click link to continue reading...

Using python write a domain whitelist reptiles

Some time ago I wrote an article,SayIt is time to use the whitelist to the wallIt's,But that has expired long whitelist,It is not so smooth with the,Then I say boasted:I want to implement your own a reptile,Come crawling China's domain,Good update whitelist。

Ok,All in all this crawler is written on the line and then climb took more than ten thousand,But in the end I found the former to do a better solution,So the project was abandoned reptile。In short,White List more powerful,Just do not use it this reptile。

Crawler is written in Python,Not used by[……]

Click link to continue reading...

Minecraft server set up in Ubuntu and mount Mod

Recently roommate Ubuntu On the run MC,I helped take a moment,However, due to his own packageTo turn over,It may not be a specific process running GM,But the overall environment configuration is quite common。

Prepare the environment

MC is running in the first java Environment,To make it run more smoothly,We still have to be installed on UbuntuOracleThe java environment:

verification

Installed after,You can use this command to verify your j[……]

Click link to continue reading...

Python strings and arrays of bytes

When using Python to do network programming will inevitably encounter convert a string to the byte stream,Here we record the following commonly used methods:

First byte array to a string,That is str:

Then the string to a byte array:

Either the above two methods are possible。[……]

Click link to continue reading...

Use fail2ban Bind9 be used to prevent DNS amplification attacks

Foreword

Ali cloud I built for personal use dnsmasq server,DNS is used to make pollution-free,The recent disclosure of the IP,Sure enough, it was attacked - is actually being used DNS amplification attacks。

Since dnsmasq itself is not designed to provide external DNS service,So it is for security profile is not a lot (no!),But it's very easy to configure Resolution Policy (DNS resolution, such as Chinese white list),So I had the basis of,Plus a front-end to do security Bind9。[……]

Click link to continue reading...

Mac version of Thunder quietly collect user BT seeds

Just today,Small waiting six months for Mac version of Thunder finally updated again,A new version - although no new features,But finally dragged fixes a bug when running around the window。

but,Also encountered the problem can not be downloaded offline。With the help of the test while debugging,I found some other things:I accordance with the requirementsThunderComes debug tool to generate statistical information archive altogether 70M large!

At all events,So many log files - Well,Apple had a year Mail.app Log bug experience for me G[……]

Click link to continue reading...

Let TextWrangler key to optimize XML file format

TextWrangler Mac is the indispensable multi-purpose text editor,Excellent built-in code highlighting,Also supports regular expression searches ...... summary,For developers,It is necessary manpower。

but,TextWrangler for XML Not so smart - and often long after the opening line!

In short,The solution is simple,We can write a script to TextWrangler。

First of all

Open a new blank document TextWrangler ([……]

Click link to continue reading...

Optimization of WordPress comment reply notifications

in most cases,We are accustomed to using Wordpress comes with the comment system,Although it's not intended to make people - after all,,Third-party commenting system it is difficult to accept。

Relatively good third party to say it is disgusting;The foreign system several good reviews and very inconvenient to use China,In general,Wordpress comment system still comes with the best。

Then,Speaking of this commenting system that comes with Wordpress,E-mail notification may be its most important characteristic of the。Although externally Wordpress does not[……]

Click link to continue reading...

Strongly typed programming language、Weakly typed

in most cases,People use the programming language is implicitly convert data types to determine whether a languageWeakly typedLanguage,For example, C。

In fact,For in addition to the more classic foreign language,Most other common languages ​​Strong、Weak type could not tell - or,yesInconsistentof。So it will always be someone to argue。If we take as the basis for the concept of opening,Then the conflicts will appear:

Pascal had planned such as a strongly typed language,But on the whole gave the type of system introduces a vulnerability,So technically speaking it is weakly typed。[……]

Click link to continue reading...

Let go Homebrew Update Agent

Before we said,As the domestic network was further bad,use brew AlsoReplace domestic universities mirror source,But this method palliatives,An update is faster,But still the same download。

The result was the most updates need to download the source code and compiled locally,Luck almost altogether also download the source code is not down,Cancel every time and try again,Constantly repeated manual。

- If we can go proxy terminal command like。

Yes,You might think of what such proxychains-ng Such software,In fact, do not,Because b[……]

Click link to continue reading...

A complete picture - keeping a complete program

Write a program is never an easy thing,You often feel very satisfied with the work,Users say your program is simply a semi-finished products。You scratching,But always wondered。

Long before I was in college,I was an art student,Studied painting in Beijing。Time,Every day a lot of painting paintings,There have someone like gouache color sketch,Every time I drew strong three hours do not go,To sit and rest play phone。The teacher will come for:Only three hours,You have not yet unfinished,Continue to draw。

I did not understand the,Very puzzled,Obviously the others have,Why can not I simply said[……]

Click link to continue reading...

Armed your QuickLook - I used several QuickLook plugin

Use OSX friends for this system will not be unfamiliar among QuickLook,no matter where,Almost all the local operating system,For this image,You can select it,Then press the space bar to quickly see what this picture without the need to open the plug-in software or image editor;Or documents and other video and audio some text - it is so convenient。

but,This is not so omnipotent QuickLook,For example, it can only support the Apple preset several common formats (plain text documents,MP4 format video,[……]

Click link to continue reading...

Future of Virtual Reality

When a person from the real world into the virtual world,Why immersion,What is it based on,It is a virtual world charm,And people are born not resist,Burst out from the virtual game virtual reality,There are more powerful attraction。It lets us into the more unpredictable space,People feel like being one of the happy people shouted authenticity,Especially the game of virtual reality technology,People simply want the blood sprayed sheets。However, for practical applications of the technology most people still know little about,Maybe you think virtual reality is put on a "virtual glasses" to go twice in a virtual environment,However, the function to be worse than you think。

similar[……]

Click link to continue reading...