嗚嗚喔學習筆記: 12月 2022

搜尋此網誌

2022年12月19日 星期一

2022年12月14日 星期三

GIT .gitignore 刷新方式


我们用GIT提交版本的时候,忽略文件有可能并不是不变的。但是对于后来加入到.gitignore中的文件,GIT默认还是不理睬它们的。因为GIT有一个缓存的机制。



下面是解决办法:

1、使用命令工具Git Bash,进入需要修改的工作目录。如C:/est

则输入

cd c:/test



2、重置所有缓存(注意后面有个.)

git rm -r --cached .



3、重新添加(注意后面有个.)

git add .



4、提交

git commit -m ".gitignore is now working"




如需转载请标明出处:http://blog.csdn.net/itas109
————————————————
版权声明:本文为CSDN博主「itas109」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/itas109/article/details/48156805

2022年12月13日 星期二

C# Byte To 4 Bit 用4bit儲存資料 可以節省一半空間


public static class HalfByteArray
{
    public static byte HalfByteAyGet(byte[] bAy, int idx)
    {
        int bIndex = idx / 2;
        if (idx % 2 == 0)
        {
            return (byte)(bAy[bIndex] >> 4);
        }
        else
        {
            return (byte)(bAy[bIndex] & 0b0000_1111);
        }
    }

    public static byte[] Byte2Half(byte[] og)
    {
        byte[] bAry = new byte[og.Length / 2];
        for (int i = 0; i < og.Length; i += 2)
        {
            byte HLv0 = og[i];
            byte HLv1 = og[i + 1];

            byte b = (byte)((HLv0 << 4) + HLv1);
            bAry[i / 2] = b;
        }
        return bAry;
    }

    public static void TestCase()
    {
        byte[] og = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
        byte[] halfB = Byte2Half(og);

        for (int i = 0; i < og.Length; i++)
        {
            byte back = HalfByteAyGet(halfB, i);
            UnityEngine.Assertions.Assert.AreEqual(back, og[i]);
        }
    }
}