Skip to content

Instantly share code, notes, and snippets.

View hackerain's full-sized avatar
😀
I may be slow to respond.

Guangyu Suo hackerain

😀
I may be slow to respond.
View GitHub Profile
@hackerain
hackerain / .tmux.conf
Last active December 25, 2015 06:39
my localhost tmux.conf
#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
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"
},
@hackerain
hackerain / gist:5525906
Last active December 17, 2015 01:09
顺序分配
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;
}
@hackerain
hackerain / C语言产生随机数
Created May 5, 2013 09:54
C语言产生随机数
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>
@hackerain
hackerain / Round up the value to 50 integer time
Last active December 17, 2015 00:19
Round up the value to 50 integer time
a = (a+50-int(a)%50);
For example:
before after
a=1 --> a=50
a=49 --> a=50
a=51 --> a=100