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 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
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
>>> '.'.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
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
通过availability_zone参数可以将虚拟机强制调度到指定的计算节点,但是默认的该参数只能由admin使用,若要普通用户使用,在nova的policy.json中,将"compute:create:forced_host": "is_admin:True",这条规则改为"compute:create:forced_host": "" | |
命令行: | |
nova boot --image c796de54-25f8-405e-afdd-e03003a9e62a --nic net-id=ba05e057-1eb8-4cb2-af58-9b99a72df5ed --flavor 2 --availability_zone nova:server-76 vm | |
API: |
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
SCREEN_NAME=${SCREEN_NAME:-gring} | |
SCREEN=$(which screen) | |
if [[ -n "$SCREEN" ]]; then | |
SESSION=$(screen -ls | awk '/[0-9].'$SCREEN_NAME'/ { print $1 }') | |
if [[ -n "$SESSION" ]]; then | |
screen -X -S $SESSION quit | |
fi | |
fi |
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
SCREEN_NAME=${SCREEN_NAME:-gring} | |
USE_SCREEN=${USE_SCREEN:-True} | |
CONFIG_FILE=${CONFIG_FILE:-/etc/gringotts/gringotts.conf} | |
function screen_it { | |
echo "staring $1" | |
if [[ "$USE_SCREEN" = "True" ]]; then | |
screen -S $SCREEN_NAME -X screen -t $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
import wsme | |
from pecan import rest | |
from wsmeext.pecan import wsexpose | |
class RootController(rest.RestController): | |
@wsexpose(wsme.types.File) | |
def get(self): | |
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 | |
# -*- coding: utf-8 -*- | |
import sched | |
import sys,time | |
# action function, and add another event to queue. | |
def event(action_time): | |
print "action_time:%s" % (action_time) | |
scheduler.enterabs(action_time + 5, 1, event, (action_time + 5,)) |