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-6725d40decd528930[……]

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 wallGot it,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...