Linux Swap 启停及swappiness设置
可以通过磁盘分区和文件两种方式进行操作
可以通过磁盘分区和文件两种方式进行操作
原文链接 The XY Problem
cybersecurity: 网络空间安全涉及旨在保护设备,网络,程序和数据免受攻击和未经授权的访问的一系列实践,流程和技术; 网络安全不仅可以保护数据,还可以保护存储数据的资源和技术。
题目: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 1 2 3 4 5 3 / \ 9 20 / \ 15 7 return its level order traversal as: 1 2 3 4 5 [ [3], [9,20], [15,7] ] 解题: 两种方式处理, 广度优先搜索借助队列,一层一层处理,并放入二维数组; 深度优先搜索借助栈, 一个一个处理, 将每一个元素方式所属层对应的一维数组中。 ...
这篇文章 Timers and time management in the Linux kernel. Part 7. 是出自 linux-insides
/proc/buddyinfo 文件可以查看Linux机器上可用的内存页, 可以查看每个节点,不同区域的每个order大小的块的可用数量, 下面是我们虚拟机的信息:
题目: Given a binary tree, return the postorder traversal of its nodes’ values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [3,2,1] Follow up: Recursive solution is trivial, could you do it iteratively? 解题: 遍历顺序“根-左-右” 实现: 使用栈实现 从根节点开始,先将根节点压入栈,保存结果值,然后移动到右节点, 保证“根-右边”顺序, 为空后出栈,取其左节点入栈中。这样入栈就保证了访问顺序为“根-右-左”, 出栈实现“左-右-根”。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public: vector<int> postorderTraversal(TreeNode* root) { vector<int> res; stack<TreeNode*> ss; TreeNode *p= root, *t; while(!ss.empty()||p){ if (p){ ss.push(p); res.insert(res.begin(), p->val); p = p->right; } else { p=ss.top(); ss.pop(); p= p->left; } } return res; } }; 实现: 递归实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class Solution { public: vector<int> postorderTraversal(TreeNode* root) { vector <int> res; postorder(root, res); return res; } void postorder(TreeNode *root, vector<int> &res){ if (!root) { return; } if (root->left) { postorder(root->left, res); } if (root->right){ postorder(root->right, res); } res.push_back(root->val); } }; 参考: [LeetCode] 145. Binary Tree Postorder Traversal 二叉树的后序遍历
由于工作需要,需要在项目立项前都需要进行功能点估算, 为后续计算项目组的的工作效率做准备。目前做了几次估算,在这里整理和总结一下。 我们目前使用的评估的标准参考 IFPUG: ISO/IEC 20926:2009 概述 定义: 1 2 3 The function point is a "unit of measurement" to express the amount of business functionality an information system (as a product) provides to a user. 功能点是业务功能的单位, 也就是从用户视角的进行评估, 是可以和用户交流的。对于我现在实施的外包项目来说就是用一种方法和甲方达成共识。相比较与之前的根据经验评估更有依据些。 步骤 1. 功能点应用的分类 开发项目: 从无到有 升级项目: 功能升级 应用项目: 基线评估 2. 识别应用边界 被测应用与用户间的边界。 3. 确认功能点 被测应用与用户间的边界。 数据功能 ILF: 容纳本应用维护的一组业务数据, 控制数据 ELF: 容纳外部应用维护的数据, 对于外部数据来说是他的ILF 处理功能 EI: 处理来自应用外部的的数据, 主要实现ILF的维护, 应用的控制 EO: 通过ILF生成新数据, 已报表,数据流形式送到应用以外 EQ: 请求来自应用外部, 处理过程包含输入,输出, 但输入不进行ILF文件的维护 复杂度 1. 复杂度评估涉及三种元素 RET & DET & FTR DET :用户可识别的,非重复的域 RET :用户可识别的数据的子集合 FTR: 引用文件类型 2. ILF & EIF 的复杂度 ILF & EIF 1 to 19 DET 20 to 50 DET 51 or more DET 1 RET Low Low Average 2 to 5 RET Low Average High 6 or more RET Average High High ILF: Functional Complexity Rating Unadjusted Function Points Low 7 Average 10 High 15 EIF: Functional Complexity Rating Unadjusted Function Points Low 5 Average 7 High 10 3. EI & EO & EQ 的复杂度 EI: 1 to 4 DET 5 to 15 DET 16 or more DET 0 to 1 FTR Low Low Average 2 FTRs Low Average High 3 or more FTRs Average High High EO & EQ 1 to 5 DET 6 to 19 DET 20 or more DET 0 to 1 FTR Low Low Average 2 to 3 FTRs Low Average High 4 or more FTRs Average High High EI & EQ: Functional Complexity Rating Unadjusted Function Points Low 3 Average 4 High 6 EO: Functional Complexity Rating Unadjusted Function Points Low 4 Average 5 High 7 关于复杂度我们实际场景中目前取的都是平均数, 没有对功能点负责度进一步分析,后续会对数据进行统计, 折算出应用的固定的权重。 ...
概述 wiki上的定义: The buddy memory allocation technique is a memory allocation algorithm that divides memory into partitions to try to satisfy a memory request as suitably as possible. This system makes use of splitting memory into halves to try to give a best fit. 伙伴内存分配技术是一种内存分配算法,它将内存划分为多个分区,以尝试尽可能适当地满足内存请求。 该系统利用将内存分成两半来尝试提供最佳匹配。 算法 伙伴系统有多种形式; 将每个块细分为两个较小块的块是最简单,最常见的一种。 选定块的大小要根据实际情况选取,太小则需要更多的内存记录跟踪内存分配, 太大又容易产生空间浪费,另外,就是如果选择2的次幂单位的话, 最大的块有可能不会覆盖整个内存. 例子 同样是wiki的例子,申请的内存调整了下 Step 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 1 24 2.1 23 23 2.2 22 22 23 2.3 21 21 22 23 2.4 20 20 21 22 23 2.5 A:20 20 21 22 23 3 A:20 20 B: 21 22 23 4 A:20 C:20 B: 21 22 23 5.1 A:20 C:20 B: 21 21 21 23 5.2 A:20 C:20 B: 21 D: 21 21 23 6 A:20 C:20 21 D: 21 21 23 7.1 A:20 C:20 21 21 21 23 7.2 A:20 C:20 21 22 23 8 20 C:20 21 22 23 9.1 20 20 21 22 23 9.2 21 21 22 23 9.3 22 22 23 9.4 23 23 9.5 24 初始化状态,每块64K, 最大的块包含 24 个块, 一个4阶块. ...
python根据excel内容生成文件夹 工作需要根据excel数据信息,生成对应的文件夹,用python写了一个脚本处理了一下。 样例中表格内容也进行了调整。 环境: windows10 python3.7 + openpyxl 目标: 以list.xlsx数据为准,抽取指定sheet页中的指定字段信息,生成目录, 并在目录中创建固定的子目录. 表格格式: 表格sheet-A01 序号 项目名称 备注 1 项目1 张三 2 项目2 李四 表格sheet-A02 序号 项目名称 备注 1 项目1 王五 每一个sheet存放一个批次的任务信息, total为批次名称 代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 from openpyxl import load_workbook from openpyxl import Workbook import os import re ## 获取项目清单列表 wb = load_workbook( filename = '.\\test\\list.xlsx') #ws_in = wb_in.active outpath=".\\out\\" ## 名字列表开始结束行号 start_index = 4 ##end_index = ## 目录编号 dir_no = 1 ## 1. 找到指定的sheet页面 sheets_name = ['A01', 'A02'] ## 3. 组成符合要求的目录字符串创建目录 def mkdir(path): try: os.makedirs(path) print("CREATE") except FileExistsError: print("EXIST, NO CREATE") # Get all dirs def mksubdir(path): try: dirnames = [name for name in os.listdir('.\\model') if os.path.isdir(os.path.join('.\\model', name))] for i in dirnames: mkdir(path+"\\"+i) except : print(" CREATE SUB DIR ERROR ") for i in range(len(sheets_name)): print(i) sheet = wb[sheets_name[i]] print(sheet) ## 2. 找到相关的任务信息 for row in range(start_index, sheet.max_row+1): ## 1. 判断内容是否空格 0 or 1? if (str(sheet.cell(row, column=1).value).strip() == "None" ): print(batch_no + " is over") break; ##2. 获取表格内容生成目录 task_no = sheet.cell(row, column=1).value batch_no = sheet.title.split('-')[0] task_context = str(sheet.cell(row, column=2).value).strip() task_manager = re.search(r'张三|李四|王五', sheet.cell(row,column=3).value) task_leader = task_manager.group(0) #(序号)-批次号-批次序号-任务名称(负责人) # mkdir(path) dir_no_str = format(dir_no, '02d') task_no_str = format(task_no, '02d') dirname=dir_no_str+"-"+batch_no+"-"+task_no_str+"-"+task_context+"-"+task_leader mkdir(outpath+dirname) # mksubdir(path) mksubdir(outpath+dirname) dir_no = dir_no+1 运行结果 ├─01-A01-01-项目1-张三 │ ├─01_文档目录1 │ └─02_文档目录2 ├─02-A01-02-项目2-李四 │ ├─01_文档目录1 │ └─02_文档目录2 └─03-A02-01-项目3-王五 ├─01_文档目录1 └─02_文档目录2 ...