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
a = (a+50-int(a)%50); | |
For example: | |
before after | |
a=1 --> a=50 | |
a=49 --> a=50 | |
a=51 --> a=100 |
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
C语言产生随机数需要调用stdlib.h头文件中的两个函数: | |
int rand(void): 产生一个0到RAND_MAX之间的随机整数。(RAND_MAX定义在stdlib.h, 其值为2147483647) | |
void srand(int seed): 用于初始化种子,便于每次产生不同的随机数。 | |
/* | |
如果要产生其他范围内的整数,可以使用取余运算实现。以下代码为产生0~100之间的随机数: | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> |
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
public void bindCloudletsToVmsSimple(){ | |
int vmNum = vmList.size(); | |
int cloudletNum = cloudletList.size(); | |
int idx = 0; | |
for (int i=0;i<cloudletNum;i++){ | |
cloudletList.get(i).setVmId(vmList.get(idx).getId()); | |
idx = (idx+1)%vmNum; | |
} |
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
suo@ustack:~/devstack$ curl -H "content-type: application/json" -H "x-auth-token:$ADMIN" http://localhost:35357/v3/credentials -d '{"credential": {"user_id": "91f2f916a5714101866ae325fd6d5aec", "project_id" : "473c507eb7e645fda4d7dabb6c7eac03", "blob": {"AccessKey": "AKIAJ5AAFSPWGWH25P3A", "SecertKey": "PzJGRqDLN8uET9ZzhQZ4wy5gTIGFxE1S3FhghwS8"}, "type": "AccessKey"}}' | ./jsontool.py | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 611 100 372 100 239 6223 3998 --:--:-- --:--:-- --:--:-- 6200 | |
{ | |
"credential": { | |
"user_id": "91f2f916a5714101866ae325fd6d5aec", | |
"links": { | |
"self": "http://localhost:5000/v3/credentials/c04f153f34134fb68699c9efb70c50ec" | |
}, |
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
#set -g prefix C-x | |
#unbind C-b | |
#bind-key C-x send-prefix | |
set-option -g status-keys vi | |
set-window-option -g mode-keys vi | |
setw -g mode-mouse on | |
set -g mouse-resize-pane on | |
set -g mouse-select-pane on |
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,)) |
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
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
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
通过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: |
OlderNewer