Skip to content

Instantly share code, notes, and snippets.

View seLain's full-sized avatar
😭
life is tough

Victor Hu seLain

😭
life is tough
  • Backend@TripPlus.cc
  • New Taipei City, Taiwan
View GitHub Profile
@seLain
seLain / gist:30fc906706997fec64a1a54c0b00c893
Created January 27, 2018 15:39
prevent java.lang.String.split() from creating leading or trailing empty string
/*
example delimiters : [ !,?._'@] (including space)
*/
String[] tokens = s.replaceFirst("^[ !,?._'@]+", "").split("[ !,?._'@]+");
// to keep leading empty string
String[] tokens = s.split("[ !,?._'@]+");
// to keep trailing empty string
@seLain
seLain / openproject.conf
Last active November 9, 2023 19:30
nginx config for openproject
# assume :
# - openproject installed in /opt/openproject
# - local port: 6000
# - external port: 6020
server {
listen 6020;
server_name SERVER_DOMAIN_NAME;
root /opt/openproject/public;
@seLain
seLain / gist:2d6c234b93e3d4a8398f15a3a89327f2
Created November 14, 2017 09:09
manual openproject mysql db backup
# applied when back up through 'sudo openproject run backup' not working due to access denied 1045 issue
# using mysqldump instead. be sure to replace 'BACKUP_PATH/backup.sql' with desired baclup file location.
sudo mysqldump --single-transaction --add-drop-table --add-locks --result-file=BACKUP_PATH/backup.sql --host=localhost --user=openproject --password openproject
@seLain
seLain / AESCipher.py
Last active October 7, 2017 13:35 — forked from mguezuraga/AESCipher.py
Encrypt & Decrypt using PyCrypto AES 256From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
import hashlib
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)