作者归档:Neo

最强日期正则表达式

简单的日期判断(YYYY/MM/DD)

^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$

演化的日期判断(YYYY/MM/DD| YY/MM/DD)

^(^(\d{4}|\d{2})(\-|\/|\.)\d{1,2}\3\d{1,2}$)|(^\d{4}年\d{1,2}月\d{1,2}日$)$

加入闰年的判断

^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$

继续阅读

macOS 下的包管理器 Homebrew

介绍

之前使用 Ubuntu 和 CentOS 的时候,它们都各自拥有便捷的包管理器 APTYUM,使用它们安装卸载软件,自动解决依赖问题,非常方便。最近在换用 macOS 系统之后,却没有了类似的管理器,安装软件又回到了和 Windows 一样的体验。虽说 App Store 拥有一些很优秀的软件,但是作为一个未来的码农,需要的很多软件并没有 App Store 版,如果手动下载安装,以后软件更新了还需要再下载安装一次,这些无意义的重复劳动需要解决掉。
继续阅读

修复 Ubuntu 下拼音输入法崩溃问题

最近在使用 Ubuntu 18.04 的过程中,遇到了一个拼音输入法总是在选字的时候崩溃的问题。

崩溃表现

crashed with SIGABRT in __assert_fail_base()

具体表现为:在打字时,无法使用数字键选择字词,鼠标点选也无效,只能按空格打出第一个字词。当按数字键选择字词时,输入法会崩溃,并输出字母和数字,例如我想打出“谷歌”,“谷歌”在候选列表第二个位置,按下 2,输入法崩溃,输出 guge2

我搜索了一下,并没有找到解决办法,只好退而求其次,使用 fcitx 代替了 ibus,就这么过了半个月。然而我今天再次搜索的时候竟然找到了解决办法:Selecting a number does not always return a Chinese character with ibus pinyin

解决办法

直接删除输入法的缓存就好:

rm ~/.cache/ibus/libpinyin/*

又一次更换了评论系统

去年暑期的时候 HyperComments 开始收费,并且不给钱就不给看历史数据,一声不吭就直接进入收费模式,这也太狗了。去他妈的 HyperComments 吧,不用就不用了。于是在那个时候换了 Disqus 这个经典的评论系统。 继续阅读

COM6506

Week 02

public class Person {
    String name;
    double weight;
    double height;

    public Person(String name, double weight, double height) {
        this.name = name;
        this.weight = weight;
        this.height = height;
    }

    public String getName() {
        return name;
    }

    public double getWeight() {
        return weight;
    }

    public double getHeight() {
        return height;
    }

    public static void main(String[] args) {
        Person jeff = new Person("Jeff", 72.4, 2.2);
        Person jim = new Person("Jim", 65, 1.7);
        System.out.println("Jeff is " + jeff.getHeight() + "m tall.");
        System.out.println("Jim is " + jim.getHeight() + "m tall.");
    }
}

继续阅读

COM6516

Week01-02

/*
 * HelloWorld.java
 * A traditional Hello World program!
 */

// In Java, all programs reside in a class. This class is called HelloWorld, 
// and should be saved in a file called HelloWorld.java. This class has a single
// method called main, which is the entry point to the program.
//
// Compiling the class with javac HelloWorld.java will produce a bytecode file
// called HelloWorld.class if compilation is successful. This bytecode can then
// be run on any machine with a java bytecode interpreter. You can run the
// bytecode in a console by typing java HelloWorld.

public class HelloWorld {
    public static void main(String[] arg) {

        String helloString = "Hello";
        String worldString = "World!";

        // In Java the System.out.println command displays the argument to the 
        // console. However the command below doesn't work, because helloWorldAString
        // has not been declared. Try compiling this file to see what happens, 
        // and take a careful look at the error message that is produced.

        System.out.println(helloString + " " + worldString);

        // In Java, we can use the '+' operator to concatenate strings, 
        // so to fix this problem, either change the argument passed to the
        // System.out.println method from (helloWorldString) to 
        // (helloString + " " + worldString)
        // or declare the variable helloWorldString before it is used by 
        // System.out.println by inserting 
        // String helloWorldString = helloString + " " + worldString;

        // In Java a variable can be declared anywhere in the code, so it is
        // possible to declare a variable just before it is used, which makes for
        // code that is easier to read and understand.

        // It is conventional to use mixed case for variable names and method 
        // names in Java, with with the first letter lower case, and then the 
        // first letter of each internal word in upper case -- e.g. helloString.
        // Class names start with a capital letter -- e.g. HelloWorld.java

        // details at: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html

    }
}

继续阅读

更换评论系统

最近一直在忙着毕业的事情,没有打理博客。等到基本事情都做完回来看博客的时候发现,原来使用的 HyperComments 评论系统已经开始收费了,并且只有在订阅之后才可以进入管理页面。

这样一来,原本的评论想要找回来就只能强制被收费了,那只好对 HyperComments 说再见了,重新投入 Disqus 的怀抱。

然而 Disqus 在国内被屏蔽,这也是没办法的事情,所以……以后网站的评论就只能是随缘评论了……