Skip to content

Instantly share code, notes, and snippets.

@anjia0532
anjia0532 / ip_blacklist.lua
Created May 24, 2017 15:10 — forked from chrisboulton/ip_blacklist.lua
Redis based IP blacklist for Nginx (LUA)
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@anjia0532
anjia0532 / openresty
Last active September 5, 2017 07:36
openresty init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: openresty
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts openresty
# Description: starts openresty using start-stop-daemon
### END INIT INFO
@anjia0532
anjia0532 / nginx
Created September 5, 2017 07:59
nginx init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Stop/start nginx
### END INIT INFO
{
"福建省": {
"南平市": {
"松溪县": {
"code": "350724",
"level": 3,
"parentCode": "350000",
"name": "松溪县",
"lon": 118.765689,
"lat": 27.610704
@anjia0532
anjia0532 / nexus_docker_image_clean.py
Last active July 11, 2019 08:14
auto clean more than 30 unused docker image https://stackoverflow.com/a/46481098/7001350
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# python2.7
from requests import Request, Session
from requests.exceptions import RequestException
from datetime import datetime,timedelta
import base64
import json
import sys
@anjia0532
anjia0532 / nginx.conf
Created December 14, 2017 04:08
nginx proxy_pass add a static parameter
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@anjia0532
anjia0532 / ks.cfg.trusty
Created March 15, 2018 00:43 — forked from chusiang/ks.cfg.trusty
Kickstart script for Ubuntu 14.04
# ====================================================================
# Author: 凍仁翔 / chusiang.lai (at) gmail.com
# Blog: http://note.drx.tw
# Filename: ks.cfg.
# Modified: 2015-02-25 10:20
# Description: Kickstart Configurator for Ubuntu 14.04.1 LTS server (amd64)
# Reference:
#
# 1. 作業系統自動安裝應答 CD 製作 - kickstart | iThome Download
# - http://download.ithome.com.tw/article/index/id/1792
@anjia0532
anjia0532 / Demo.java
Last active April 19, 2023 10:36
@HystrixCommand support dynamic command key
@Component
public class Demo {
@HystrixCommand(commandKey = "#key",groupKey = "#key",fallbackMethod = "fail")
public String exec(String key){
if (RandomUtils.nextBoolean()) {
System.out.println(1 / 0);
}
return key;
}
public String fail(String key){
@anjia0532
anjia0532 / rancher2.1.1.md
Last active October 26, 2018 05:42
rancher2.1.1.md

1. vmware 12 安装 ubuntu x64 16.04.4 LTS(单机安装) 4U16G50G

2. vmware 12 静默安装Ubuntu

3. ## 远程公司电脑,不知道为嘛无法复制。。。。明天再补充

4. 步骤完全按照 https://www.cnrancher.com/docs/rancher/v2.x/cn/installation/basic-environment-configuration/ 走的,包括最佳实践里的步骤

5. 之前在群里反馈过,coreos-etcd一直在restart ,通过logs -f 看,etcdserver/membership: cluster cannot be downgraded (current version: 3.2.24 is lower than determined cluster version: 3.3).k8s集群用了1.12 1.11 1.10都这样

6. 是不是不能在单台上运行?

@anjia0532
anjia0532 / lua-resty-maxminddb.lua
Created December 7, 2018 00:10
lua-resty-maxminddb.lua
-- Copyright (C) Anjia (anjia0532)
local json = require('cjson')
local json_encode = json.encode
local json_decode = json.decode
local ngx_log = ngx.log
local ngx_ERR = ngx.ERR
local ngx_CRIT = ngx.CRIT
local ngx_INFO = ngx.INFO