Skip to content

Instantly share code, notes, and snippets.

View didyhu's full-sized avatar

Didy HU didyhu

View GitHub Profile

Systemd service

sudo vi /etc/systemd/system/foo.service
#/etc/systemd/system/foo.service
[Unit]
Description=DESCRIPTION

Linux Swap

# 1. generate an empty file
$ dd if=/dev/zero of=/var/swapfile bs=1M count=1024
# 2. format it as swap
$ mkswap /var/swapfile 
# 3. turn on it
$ swapon /var/swapfile
# 4. make it works after boot
@didyhu
didyhu / windows-pyopencl.md
Last active January 23, 2019 07:59
Windows 环境下搭建 PyOpenCL
  1. 下载驱动 Nvidia
https://developer.nvidia.com/opencl
  1. 安装 pybind11
py -3 -m pip install pybind11
  1. 安装 pyopencl
@didyhu
didyhu / tech-route.md
Last active July 14, 2016 05:34
Tech Route
  • Version Control
    • Git
    • GitHub
    • OsChina
      • Issue
  • Language
    • Java SE
      • Functional Programming
      • Stream
  • Date
@didyhu
didyhu / java-executors.md
Created May 27, 2016 08:42
Java Executors
        Callable r = () -> {
            try {
                log.debug("TryLock");
                readLock.tryLock(5, TimeUnit.SECONDS);
                Thread.sleep(1000);
                log.debug("Read");
                readLock.unlock();
            } catch (InterruptedException e) {
                e.printStackTrace();
@didyhu
didyhu / logging-best-practices.md
Created May 23, 2016 13:54
Logging best practices

#Logging Best Practices

Always log, and always log in right place, on right level.

Error Unexcepted exceptions happened, should write down the error message and the call stacks.

log.error(ex.getMessage(),ex);
@didyhu
didyhu / gist:a2c8f6359a015c018f50943304a34ffc
Created May 23, 2016 10:03
Passing env arguments using maven with spring boot
java -jar xxx.jar --server.port=80
mvn spring-boot:run -Drun.jvmArguments="-Dserver.port=80"
@didyhu
didyhu / handling-exceptions-in-java-projects.md
Last active May 23, 2016 14:09
Handling exceptions in java projects

There are two types of exceptions in java language.

  • Checked Exceptions
  • Runtime Exceptions

A Checked Exception is a part of the method signature, with the method name, arguments and returns. So if a method throws a checked exception, then the caller should have the knowlege about the exception, the deal with it. Thus we say a checked exception is a Exposing of the inner logic of a method.

And anothor way to classify the exceptions:

@didyhu
didyhu / my.ini
Created May 23, 2016 09:40
MySQL settings
default_tmp_storage_engine = MyISAM
default-storage-engine = MyISAM
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
#!/bash
targethost='root@targethost'
# eg. 'root@dev.csdra.net'
targetpath='/var/www'
# eg. '/var/www'
targetname=TARGETNAME
# eg. 'SomeProject'
targetport=TARGETPORT
# eg. 8080