我要出家当和尚去………

我要出家当和尚去
某个大雨倾盆的夜晚
你会偷偷来看我吗
唉,还是别来吧
我会拒绝与你相认

不要在山门静坐
不要和方丈软磨硬泡
不要伪装虔诚的香客
我拒绝与你相认
我在禅房看竖排繁体的肉蒲团

我再也不相信爱情了
猪肉都吃不起
还留在滚滚红尘干啥
如果你非要找我再续前缘
那就——带上一斤绝味鸭脖吧

鸳鸯偎,蝴蝶双飞
小雨在烟雾里盘着腿
你知道在哪里能找到我
女道观的隔壁,墙根下面

——南无阿弥陀佛,在吗?
——急急如律令,快进来!

Django parse a json/dictionary reminder on template

如果想在一个Django template里引入json, 正确的template写法为

python的views.py的写法

# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.http import Http404, HttpResponse

def get_product(request):
    context1 = {}
    context1['env'] = 'production'
    context1['mydict'] = {"key1":"value1", "key2":"value2", "key3":"value3", "key4":"value4"}
    context1['days'] = [1,2,3]

    if request.GET.get("item") == "ec2" or not request.GET.get("item"):
        return render(request, 'main_content.html', context1)
    else:
        raise Http404()

main_content.html使用extends引入index.html

{% extends 'index.html' %}
    {% block content %}
        {% for day in days %}
        <li>day: {{ day }}</li>
        {% endfor %}
    {% endblock %}

index.html使用include引入sidebar.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div class="header">My page</div>
    <div class="content">
        <div class="sidebar">

            <ul>
                {% if env == 'production' %}
                    {% include 'production.sidebar.html' %}
                {% elif env == 'development' %}
                    {% include 'development.sidebar.html' %}
                {% elif env == 'staging' %}
                    {% include 'staging.sidebar.html' %}
                {% elif env == 'legacy' %}
                    {% include 'legacy.sidebar.html' %}
                {% endif %}
            </ul>

        </div>
        <div class="maincontent">

            {% block content %} {% endblock %}

        </div>
    </div>
</body>
</html>

继续阅读

iptables delete some rules form a chain

以下两条命令均可用

iptables -t nat -L PREROUTING --line-numbers | grep RULE_NAME | cut -d" " -f 1 | xargs iptables -t nat -D PREROUTING

for i in $(iptables -t nat -nvL PREROUTING --line-numbers | grep RULE_NAME | grep ^[0-9] | awk '{ print $1 }' | tac); do iptables -t nat -D PREROUTING $i; done

How to run a crontab job every X seconds

如果你有一个job, 需要每隔5秒运行一次.

以下写法是错误的

* * * * * sleep 5; /bin/cmd

如果使用这种写法, 会导致在每分钟的第0秒开始, sleep 5秒以后, 再运行/bin/cmd, 然尔运行完就结束了, 不会每隔5秒运行一次.

正确写法1

* * * * * for i in {1..12}; do /bin/cmd; sleep 5; done

正确写法2

* * * * * REMAIN=60 INC=5 ; while ; do /bin/cmd; sleep $INC; REMAIN=$(($REMAIN - $INC)); done

正确写法3

* * * * * /bin/cmd
* * * * * sleep 5; /bin/cmd
* * * * * sleep 10; /bin/cmd
* * * * * sleep 15; /bin/cmd
......
* * * * * sleep 55; /bin/cmd

可以使用systemctl status cron.service -l命令看看cron服务的状态以及最新日志.

参考: How to run a cronjob every X seconds in cron

docker基础知识(一)

安装docker

$ sudo apt install docker docker.io    #适用ubuntu 16.04

一,images管理
搜索kms相关的image

$ sudo docker search kms
NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
luodaoyi/kms-server                          kms server                                      21                   [OK]
lunker/kms                                   ubuntu image repositoiry for kms                1                    
leon0516/py-kms                              this is beta version!!!                         1                    [OK]
captbrick/py-kms                             Py-KMS                                          1                    [OK]
gkuzet/kms                                   KMS Server written in C                         1                    
openvidu/openvidu-server-kms                 OpenVidu platform service. It includes Ope...   1                    

比如第1个luodaoyi/kms-server,也可以用https://hub.docker.com/r/luodaoyi/kms-server/的方式查看相关信息.

下载想要的image(不必需)

$ sudo docker pull luodaoyi/kms-server

查看本地的images

$ sudo docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
luodaoyi/kms-server   latest              4f86d964ac52        4 months ago        4.09 MB

$ sudo docker image ls
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
luodaoyi/kms-server   latest              4f86d964ac52        4 months ago        4.09 MB

继续阅读

第 3 页,共 152 页123456...102030...最旧 »