This file contains hidden or 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 HorizonSite(Site): | |
| _instance = None # 静态私有变量是关键 | |
| def __new__(cls, *args, **kwargs): | |
| if not _instance: | |
| cls._instance = super(Site).__new__(cls, *args, **kwargs) | |
| return cls._instance |
This file contains hidden or 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
| >>> '.'.join('suo.piao.xxx'.split('.')[:-1]) | |
| >>> 'suo.piao' | |
| 先按“点”分隔开,得到list,舍去最后一个,再用join将这个list连接起来,用到类中,就是这样的: | |
| >>> '.'.join(self.__module__.split('.')[:-1]) |
This file contains hidden or 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 __future__ import with_statement # Required in 2.5 | |
| import signal | |
| from contextlib import contextmanager | |
| class TimeoutException(Exception): pass | |
| @contextmanager | |
| def time_limit(seconds): | |
| def signal_handler(signum, frame): | |
| raise TimeoutException, "Timed out!" |
This file contains hidden or 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 jenkins:latest | |
| USER root | |
| RUN apt-get update | |
| RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && apt-get install -yq nodejs build-essential | |
| RUN npm install -g hexo-cli | |
| RUN echo "Host *\n\tStrictHostKeyChecking no\n" >> /etc/ssh/ssh_config |
This file contains hidden or 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
| if [ -d hackerain.me ]; then | |
| cd hackerain.me | |
| git pull && git submodule foreach git pull origin master | |
| if [ ! -d node_modules ]; then | |
| npm install --save; | |
| fi | |
| else | |
| git clone git@git.oschina.net:yugsuo/hackerain.me.git --recursive | |
| cd hackerain.me | |
| npm install --save |
This file contains hidden or 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 python:2 | |
| WORKDIR /usr/src/app | |
| COPY requirements.txt ./ | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY . . | |
| CMD [ "uwsgi", "--http", ":8001", "--wsgi-file", "deploy_blog.py" ] |
This file contains hidden or 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/bash | |
| PORT=22 | |
| USER='root' | |
| if [ $# = 1 ]; then | |
| case $1 in | |
| "sss") | |
| IP="54.238.233.187" | |
| USER="ubuntu" |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import pika | |
| import time | |
| channel = None | |
| def on_connected(connection): | |
| connection.channel(on_channel_open) | |
| def on_channel_open(new_channel): |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://sdk.amazonaws.com/js/aws-sdk-2.283.1.min.js"></script> | |
| <script> | |
| var s3 = new AWS.S3({ | |
| endpoint: "https://console.tfcloud.com:13808", | |
| accessKeyId: "accesskeyid", | |
| secretAccessKey: "secretaccesskey", |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| import json | |
| import requests | |
| import datetime | |
| import subprocess | |
| import xml.etree.ElementTree as ET | |
| from keystoneauth1.identity import v3 | |
| from keystoneauth1 import session as keystone_session |