This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArrayBlockingQueue | |
attr_reader :capacity, :queue | |
def initialize(capacity = 5) | |
@capacity = capacity | |
@lock = Mutex.new | |
@empty = ConditionVariable.new | |
@full = ConditionVariable.new | |
@queue = [] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################################################################################### | |
# Tecmint_monitor.sh # | |
# Written for Tecmint.com for the post www.tecmint.com/linux-server-health-monitoring-script/ # | |
# If any bug, report us in the link below # | |
# Free to use/edit/distribute the code below by # | |
# giving proper credit to Tecmint.com and Author # | |
# # | |
#################################################################################################### | |
#! /bin/bash | |
# unset any variable which system may be using |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Script for automatic setup of an IPsec VPN server on CentOS/RHEL 6 and 7. | |
# Works on any dedicated server or virtual private server (VPS) except OpenVZ. | |
# | |
# DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! | |
# | |
# The latest version of this script is available at: | |
# https://github.com/hwdsl2/setup-ipsec-vpn | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Shadowsocks | |
[Service] | |
TimeoutStartSec=0 | |
ExecStart=/usr/local/bin/ssserver -c /usr/etc/shadowsocks.json | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Port 2202 | |
Protocol 2 | |
HostKey /etc/ssh/ssh_host_rsa_key | |
HostKey /etc/ssh/ssh_host_dsa_key | |
HostKey /etc/ssh/ssh_host_ecdsa_key | |
HostKey /etc/ssh/ssh_host_ed25519_key | |
UsePrivilegeSeparation yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
tune.ssl.default-dh-param 1024 | |
defaults | |
timeout connect 10000ms | |
timeout client 60000ms | |
timeout server 60000ms | |
frontend fe_http | |
mode http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
BOX_NAME = ENV['BOX_NAME'] || "centos/7" | |
VAGRANTFILE_API_VERSION = "2" | |
CONSUL_ENCRYPT = "eEZJ2MTe0keJc2EkvZ+l3Q==" | |
CONSUL_DATACENTER = "nyc" | |
CONSUL_DATA_DIR = "/var/consul" | |
CONSUL_NODE_IP = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Spirit | |
* @date 2017/12/14 | |
*/ | |
/** | |
* Twitter 雪花算法 | |
* | |
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 | |
* 1 位标识 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def print_method_name(f): | |
@wraps(f) | |
def decorated(*args, **kwargs): | |
print("enter function: {0}, {1}, {2}".format(f.__name__, args, kwargs)) | |
return f(*args, **kwargs) | |
return decorated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthManager(object): | |
"""Authentication Manager.""" | |
def __new__(cls): | |
singleton = cls.__dict__.get('__singleton__') | |
if singleton is not None: | |
return singleton | |
cls.__singleton__ = singleton = object.__new__(cls) |