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 / redis_queue.rb
Created September 30, 2016 03:15
redis queue
# encoding: utf-8
require 'redis'
require 'redis/connection/hiredis'
class RedisQueue
attr_reader :redis, :queue, :buffer, :timeout
attr_accessor :buffer_max
def initialize(queue_name, options = {})
@xuanyu-h
xuanyu-h / ChainedList.rb
Last active December 12, 2016 08:03
ChainedList
# a project have many steps
class Step
module ChainedList
extend ActiveSupport::Concern
included do
# DNode
field :prior_step_id, type: BSON::ObjectId
field :next_step_id, type: BSON::ObjectId
end
@xuanyu-h
xuanyu-h / git-branch.md
Created March 23, 2017 03:07 — forked from yisibl/git-branch.md
在Mac、Linux 终端显示 Git 当前所在分支

在Mac、Linux 终端显示 Git 当前所在分支

  1. 进入你的home目录
cd ~
  1. 编辑.bashrc文件
@xuanyu-h
xuanyu-h / redis_persistence.rb
Last active March 24, 2017 15:32
a simple redis orm
# encoding: utf-8
require 'redis'
require 'thread'
begin
require "active_model/model/validations"
rescue LoadError
end
@xuanyu-h
xuanyu-h / deployment.js
Created November 3, 2017 07:06
deployment
$(function(){
var refresh_id;
var scrollToBottom = function(){
$("html, body").animate({ scrollTop: $(document).height() }, 1000);
}
var refreshDeploymentTrace = function(){
var deployment_id = $('.deployment-show-page').data('id')
@xuanyu-h
xuanyu-h / singleton.py
Created December 20, 2017 07:31
Python 单例模式
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)
@xuanyu-h
xuanyu-h / config.py
Last active December 22, 2017 02:41
python context??
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
@xuanyu-h
xuanyu-h / Vagrantfile
Created January 3, 2018 03:19
Vagrantfile
# -*- 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 = {
@xuanyu-h
xuanyu-h / haproxy.conf
Created April 8, 2018 08:24 — forked from thpham/haproxy.conf
test config haproxy for gRPC loadbalancing
global
tune.ssl.default-dh-param 1024
defaults
timeout connect 10000ms
timeout client 60000ms
timeout server 60000ms
frontend fe_http
mode http
@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