ARST第三周打卡

Algorithm : 做一个 leetcode 的算法题

//二位数组查找 题目描述

//在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。

//请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。

bool FindNum(int target, vector<vector<int> > vect)
{
    int iRow = vect.size();
    int iCol = vect[0].size();

    //从左上角开始遍历
    int i = 0, j = iCol - 1;
    while (i <= iRow - 1 && j >= 0) //保证数组不能越界
    {
        if (vect[i][j] > target)
        {
            j--;
        }
        else if (vect[i][j] < target)
        {
            i++;
        }
        else
        {
            return true;
        }
    }

    return false;
}

Review : 阅读并点评一篇英文技术文章

原文地址:http://download.redis.io/redis-stable/redis.conf

################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.

根据给定的每秒多少写操作保存DB;

#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving completely by commenting out all "save" lines.
#
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""

save 900 1
save 300 10
save 60 10000

保存DB到磁盘:

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.

默认情况下:如果开启了RDB快照(至少一个保存点)并且最后一个备份保存失败,那么redis将停止接受写操作;

#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes

但是,如果你设置了对redis服务器和持久性的适当监控,你可能希望禁用这些特性以便即使存在硬盘、权限等问题,Redis也能照常工作!

# Compress string objects using LZF when dump .rdb databases?
# For default that‘s set to ‘yes‘ as it‘s almost always a win.
# If you want to save some CPU in the saving child set it to ‘no‘ but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes

是否采用LZF压缩技术;

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes

RDB在版本5之后在文件末尾加入了CRC64校验和,这使得格式更抗损坏,但是在保存和加载RDB文件时,性能可能会受到影响(大约10%),因此可以禁用它以获得最大性能;

数据库转储文件名

# The filename where to dump the DB
dbfilename dump.rdb

工作目录:

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the ‘dbfilename‘ configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./

Redis快照设置:

1.保存到DB的方式;

2.是否采用LZF压缩技术;

3.数据库存储文件名;

4.数据文件存储文件夹;

Tips : 学习一个技术技巧

通用比较函数,支持比较结构体指定字段,支持Linux和Windows

#ifndef _WIN32
#define TYPEOF  typeof      // linux C98
#else
#define TYPEOF decltype     // windows C++11后支持
#endif

template <int offset, class TYPE>
bool CheckZero(const void* p)
{
    TYPE a = *(*TYPE)((char*)p + offset);
    return (bool)a;
}

template <int offset, typename T>
int CmpOneKey(const void *p1, const void *p2)
{
    T a1 = *(T*)((char*)p1 + offset);
    T a2 = *(T*)((char*)p2 + offset);

    if (a1 < a2)
        return -1;
    else if (a1 > a2)
        return 1;
    return 0;
}

template <int offset, typename T>
int DescCmpOneKey(const void* p1, const void* p2)
{
    return -CmpOneKey<offset, T>(p1, p2);
}

template <int offset1, typename T1, int offset2, typename T2>
int CmpTwoKey(const void* p1, const void* p2)
{
    int diff = CmpOneKey<offset1, T1>(p1, p2);
    if (diff == 0)
    {
        return CmpOneKey<offset2, T2>(p1, p2);
    }
    return diff;
}

template <int offset1, typename T1, int offset2, typename T2>
int DescCmpTwoKey(const void *p1, const void *p2)
{
    return -CmpTwoKey<offset1, T1, offset2, T2>(p1, p2);
}

template <int offset1, typename T1, int offset2, typename T2, int offset3, typename T3>
int CmpThreeKey(const void *p1, const void *p2)
{
    int diff = CmpTwoKey<offset1, T1, offset2, T2>(p1, p2);
    if (diff == 0)
    {
        return CmpOneKey<offset3, T3>(p1, p2);
    }
    return diff;
}

#define CHECK_ZERO(s, m) CheckZero<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_ONE_KEY(s, m) CmpOneKey<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_TWO_KEY(s, m1, m2) CmpTwoKey<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2)>
#define CMP_THREE_KEY(s, m1, m2, m3) CmpThreeKey()<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2), offsetof(s, m3), TYPEOF(((s*)0)->m3>
#define CMP_ONE_KEY_DESC(s, m) DescCmpOneKey<offsetof(s, m), TYPEOF(((s*)0)->m)>
#define CMP_TWO_KEY_DESC(s, m1, m2) DescCmpTwoKey<offsetof(s, m1), TYPEOF(((s*)0)->m1, offsetof(s, m2), TYPEOF(((s*)0)->m2)>

Share : 分享一篇有观点和思考的技术文章

TCP三次握手和SYN攻击:
原文链接:https://mp.weixin.qq.com/s?__biz=MzIwNTc4NTEwOQ==&mid=2247484888&idx=1&sn=aaf4f7f4a0b37c8f823e2665d711dd72&scene=21#wechat_redirect

原文地址:https://www.cnblogs.com/yzdai/p/11145456.html

时间: 2024-08-08 12:46:57

ARST第三周打卡的相关文章

ARTS第三周打卡

1.Algorithm 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转. 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 class Solution { public int reverse(int x) { int rev = 0; while (x != 0) { int pop = x % 10; x /= 10; if (rev > Integer.MAX_VALUE/10 |

第三周作业(一)VS安装及单元测试练习

第三周作业(一) 需求:练习教科书第22~25页单元测试练习,要求自行安装Visual Studio开发平台,版本至少在2010以上,要求把程序安装过程和练习过程写到博客上,越详细越好,要图文并茂,没有书的同学可以向班内助教同学借阅. 1.visual studio 开发平台安装 事实上我对Visual Studio了解不多,只知道支持的编程语言多,用的人也挺多,功能强大.至于到底好在哪里,还是要用上一阵自己体验一下才知道.听同学说VS2015有些卡,所以这里我选择了VS2013. 如图,具体版

第三周活动进度

学习进度表:   第三周内容 时间 周一(4:10-6:00)上课,周二晚上(8:00-9:00),周四晚上(8:00-8:30),周四下午(4:10-6:00)javaweb课程 代码行数 200行 发博客量 3篇 了解到的知识 随机数的产生,四则运算的开发思路(分解),简单的数据库创建表. 周活动详细记录表: 日期/内容 写代码 上网查方法 上课 看书(构建执法) 3.6 2小时(150行)大概完成   2小时   3.7   查询缺失功能的方法   1小时 3.8         3.9

20145207《Java程序设计》第三周学习总结

20145207<Java程序设计>第三周学习总结 教材学习内容总结 这部分可能要扒一些课本而上的东西了.在第三章中,知道了Java可区分为基本类型和类类型两大类型系统,其中类类型也称为参考类型.在这一周主要学习了类类型. 对象(Object):存在的具体实体,具有明确的状态和行为 类(Class):具有相同属性和行为的一组对象的集合,用于组合各个对象所共有操作和属性的一种机制. 简单来说,类是对象的设计图,对象是类的实例. 要深刻理解对象的含义,例如Clothes c1 = new Clot

每周学习进度--第三周

  第三周 所花时间(包括上课) 300min 代码量 258 博客量 2 了解到的知识点 初步了解了如何做软件需求分析

20145326蔡馨熠《信息安全系统设计基础》第三周学习总结

教材学习内容总结 书上有的内容我就不重复赘述了,只需要将部分重要的知识点归纳总结一下. 1.进制 二进制.八进制.十进制.十六进制(转换:以二进制作为中间变量) 2.字 每台计算机都有一个字长,指明整数和指针数据的大小. 虚拟地址是以这样的一个字来编码的,字长决定虚拟地址空间的最大范围. 3.字节顺序 小端法——在存储器中按照从最低有效字节到最高有效字节的顺序存储对象. 大端法——从最高有效字节到最低有效字节的顺序存储. 4.布尔代数 (1)二进制值是计算机编码.存储.操作信息的核心(0.1),

马哥2016全新Linux+Python高端运维班第三周作业作答

                    马哥2016全新Linux+Python高端运维班第三周作业                                           1.列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可.     [[email protected] ~]# who | awk '{print $1 $NF}'| uniq -d     [[email protected] ~]# who     yicx     :0  

第三周学习总结

20145336第三周JAVA实验报告 20145336 <Java程序设计>第三次实验实验报告 北京电子科技学院(BESTI)实验报告 课程:Java程序设计 班级:1453 姓名:张子扬 指导教师:娄嘉鹏 实验日期:2016.04.22 实验名称:Java开发环境的熟悉(Linux + Eclipse) 实验内容: XP基础 XP核心实践 相关工具 实验目的与要求: 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程 完成实验.撰

印度浦那三周感受

本来打算写印度浦那一周感受的,结果一周过去了一个字都没写,然后打算写二周感受,结果第二周也没找到时间来写.第三周是异常繁忙的一周,终于在周末找到了一点时间来编写. 这次去印度浦那是作为ThoughtWorks University的Coach,需要在印度呆3个多月. 2月27日从成都出发到浦那,整个过程非常纠结,需要成都飞上海,然后上海飞德里,最后德里飞浦那.整个行程从周六下午的2点到周日早上的7点才完成.周日早上的7点是浦那的时间.浦那和中国有两个半小时的时差,所以浦那的早上7点是中国的早上9