突突唧之家

我的疑问 & 我的解决方案

There are two types of variables in batch files. One is for parameters which can be passed when the batch file is called and the other is done via the set command.

Command Line Arguments

Batch scripts support the concept of command line arguments wherein arguments can be passed to the batch file when invoked. The arguments can be called from the batch files through the variables %1, %2, %3, and so on.

The following example shows a batch file which accepts 3 command line arguments and echos them to the command line screen.

@echo off
echo %1
echo %2
echo %3
阅读全文 »

for /l is your friend:

for /l %x in (1, 1, 100) do echo %x

Starts at 1, steps by one, and finishes at 100.

Use two %s if it's in a batch file:

for /l %%x in (1, 1, 100) do echo %%x

If you have multiple commands for each iteration of the loop, do this:

for /l %x in (1, 1, 100) do (
echo %x
copy %x.txt z:\whatever\etc
)

or in a batch file:

for /l %%x in (1, 1, 100) do (
echo %%x
copy %%x.txt z:\whatever\etc
)

Key:

  • /l denotes that the for command will operate in a numerical fashion, rather than operating on a set of files.
  • %x is the loops variable.
  • (starting value, increment of value, end condition[inclusive])

引用文件

首先需要引用 JUnit 库文件。

依次操作 File -> Project Structure… -> Libraies -> 加号 -> Java -> 选择 IDEA 安装路径 lib 文件夹中的 junit-4.12.jarhamcrest-core-1.3.jar

编写测试代码

TestJUnit.java

1
2
3
4
5
6
7
8
9
10
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class TestJUnit {
@Test
public void testAdd() {
String str = "Junit is working fine.";
assertEquals("Junit is working fine.", str);
}
}

TestRunner.java

1
2
3
4
5
6
7
8
9
10
11
12
13
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestJUnit.class);
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
}

期望输出

true

要修改默认的启动内核,可以执行以下操作。

打开文件 /etc/default/grub ,将 GRUB_DEFAULT 的值更改为您希望选择的菜单选项的索引值。

例如,在启动过程中的 GRUB 菜单中有

Ubuntu
Advanced options for Ubuntu
Windows 10 (loader) (on /dev/sda1)
system setup

其中 Advananced options for Ubuntu 子菜单如下所示

1
2
3
4
5
6
Ubuntu, with Linux 4.13.0-26-generic
Ubuntu, with Linux 4.13.0-26-generic (upstart)
Ubuntu, with Linux 4.13.0-26-generic (recovery mode)
Ubuntu, with Linux 4.10.0-42-generic
Ubuntu, with Linux 4.10.0-42-generic (upstart)
Ubuntu, with Linux 4.10.0-42-generic (recovery mode)

现在,第一个选项是索引 0 ,第二个是 1 ,第三个是 2 ,依此类推。

例如现在想选择 Advanced options for Ubuntu 子菜单中的 Ubuntu, with Linux 4.10.0-42-generic ,则将 GRUB_DEFAULT 设为:

GRUB_DEFAULT = "1> 3"

使用 > 符号来指定子菜单(注意符号 > 和数字 3 之间有空格,所以需要双引号)。在这种情况下,主菜单中选择第二个选项(索引 1 ),在子菜单中选择第四个选项(索引 3 )。

菜单选项来自文件 /boot/grub/grub.cfg (不要编辑这个文件)。

一旦对 /etc/default/grub 进行了更改,请保存并运行

update-grub

来更新 GRUB 配置文件(必须,否则不生效)。重新启动,现在应该默认启动旧的内核版本。

首先安装并配置好 adb 工具,并选择以下命令中的一条执行。

PACKAGE 替换为应用包名。

adb shell pm block PACKAGE # Kitkat 可用
adb shell pm hide PACKAGE # Lollipop 可用
adb shell pm uninstall --user 0 PACKAGE # Marshmallow 和 Nougat 可用

注意第三种命令可能会失效,而且在重新安装或恢复出厂设置之前无法找回被删除的软件。

在引导时按住 Shift 键即可进入高级选项菜单。如果想要每次都显示的话可以进行如下修改。

打开 /etc/default/grub ,将 GRUB_TIMEOUT 设置为 -1

运行命令

update-grub

完成修改。

该文章内容已过期不再适用

下载并解压内核源码

首先获取 root 权限方便操作

sudo su

官方网站下载 4.19.1 版本的 Linux 内核源码。此时我们把它放在 ~/linux-4.19.1.tar.xz

移动到 /usr/src

cd /usr/src

将文件解压到此处

tar -xvJf ~/linux-4.19.1.tar.xz

安装相关依赖

运行以下命令安装依赖

apt install g++ make libncurses5-dev libssl-dev build-essential
apt install openssl zlibc minizip libidn11-dev libidn11
apt install bison flex pkg-config libelf-dev

编译内核

复制老的配置文件到目录

cp -vi /boot/config-`uname -r` .config

配置新版本内核新增特性

make oldconfig

然后利用

make menuconfig

编辑配置文件。直接保存退出可以使用默认配置。

然后运行

make -j 4

其中 4 建议设置为 CPU 逻辑核心数 * 2

完成之后运行

make modules_install
make install

安装新内核。之后重启系统即可自动使用新内核启动。

注意事项

内核编译需求的硬盘空间至少为 40GB 。

利用如下路由配置便可以将所有不存在的 URL 请求都引导到同一个页面(例如 404 页面)。

{
path: '*',
redirect: '/404'
}

配置路由属性

可以简单地在路由中设置 meta 属性。

例如在 src/router/index.js

1
2
3
4
5
6
7
8
routes: [
{
path: '...',
name: '...',
meta: { title: '...' },
component: () => import('...')
}
]

使用路由钩子

利用路由的 beforeEach 方法修改网站标题。

router.beforeEach((to, from, next) => {
document.title = to.meta.title
next()
})