Skip to content

Instantly share code, notes, and snippets.

View xuanyu-h's full-sized avatar
🎯
Focusing

xuanyu xuanyu-h

🎯
Focusing
  • Shanghai
View GitHub Profile
@xuanyu-h
xuanyu-h / sshd_config.sh
Created July 4, 2018 14:16
sshd_config.sh
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
@xuanyu-h
xuanyu-h / shadowsocks.service
Created July 4, 2018 14:56
shadowsocks.service
[Unit]
Description=Shadowsocks
[Service]
TimeoutStartSec=0
ExecStart=/usr/local/bin/ssserver -c /usr/etc/shadowsocks.json
[Install]
WantedBy=multi-user.target
@xuanyu-h
xuanyu-h / vpnsetup-centos.sh
Last active July 4, 2018 15:17
vpnsetup-centos
#!/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
#
@xuanyu-h
xuanyu-h / Tecmint_monitor.sh
Created July 25, 2018 06:52
Tecmint_monitor.sh
####################################################################################################
# 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
class ArrayBlockingQueue
attr_reader :capacity, :queue
def initialize(capacity = 5)
@capacity = capacity
@lock = Mutex.new
@empty = ConditionVariable.new
@full = ConditionVariable.new
@queue = []
end
@xuanyu-h
xuanyu-h / synchronize_access_object.rb
Created November 1, 2018 03:30
synchronizing access to an object
# encoding: utf-8
# frozen_string_literal: true
require 'thwait'
class Object
def synchronize
mutex.synchronize { yield self }
end
# Ruby Thread Pool
# ================
# A thread pool is useful when you wish to do some work in a thread, but do
# not know how much work you will be doing in advance. Spawning one thread
# for each task is potentially expensive, as threads are not free.
#
# In this case, it might be more beneficial to start a predefined set of
# threads and then hand off work to them as it becomes available. This is
# the pure essence of what a thread pool is: an array of threads, all just
# waiting to do some work for you!
@xuanyu-h
xuanyu-h / Singleton.java
Last active November 9, 2018 01:22
Java Singleton
// 定义单例模式中需要完成的代码逻辑
public interface MySingleton {
void doSomething();
}
public enum Singleton implements MySingleton {
INSTANCE {
@Override
public void doSomething() {
System.out.println("complete singleton");
@xuanyu-h
xuanyu-h / gist:a3479b39a6e922f8b0f6b105d7a9b85b
Created January 24, 2019 03:09 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@xuanyu-h
xuanyu-h / date.md
Created September 9, 2019 14:51
go date/time format
Go layout Java notation C notation Notes
2016-01-02 yyyy-MM-dd %F ISO 8601
20160102 yyyyMMdd %Y%m%d ISO 8601
January 02, 2006 MMMM dd, yyyyare neat %B %d, %Y
02 January 2006 dd MMMM yyyy %d %B %Y
02-Jan-2006 dd-MMM-yyyy %d-%b-%Y
01/02/06 MM/dd/yy %D US
01/02/2006 MM/dd/yyyy %m/%d/%Y US
010206 MMddyy %m%d%y US