Skip to content

Instantly share code, notes, and snippets.

View iintothewind's full-sized avatar
:octocat:
coding

Chen Yinghua iintothewind

:octocat:
coding
View GitHub Profile
@iintothewind
iintothewind / config.java
Created June 24, 2020 13:27
load config entries as Map
static Seq<Tuple2<String, Integer>> loadWeightEntries(final String path) {
Preconditions.checkArgument(Objects.nonNull(path) && path.endsWith("weight"), "invalid path");
final Config weight = CfgUtil.cfg.getConfig(path);
final Map<String, Integer> map = weight.root().keySet().stream().collect(Collectors.toMap(k -> k, weight::getInt));
return List.ofAll(map.entrySet().stream().map(e -> Tuple.of(e.getKey(), e.getValue()))).sortBy(t -> t._1);
}
@iintothewind
iintothewind / DataSourceConfig.java
Last active February 29, 2024 02:08
jooq dbutil
package com.wise.powerhub.util;
import javax.sql.DataSource;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultConfiguration;
import org.jooq.impl.DefaultDSLContext;
import org.jooq.impl.DefaultExecuteListenerProvider;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.autoconfigure.jooq.JooqExceptionTranslator;
@iintothewind
iintothewind / command.bash
Created June 19, 2019 16:34
shell commands
docker images | tail -n +5 | head -n -1 | awk '{print $3}' | xargs docker rmi
@iintothewind
iintothewind / firewalld.md
Last active September 3, 2019 13:11
firewalld cheat sheet

启动一个服务:

systemctl start firewalld.service

关闭一个服务:

systemctl stop firewalld.service
@iintothewind
iintothewind / curl_bash_wrapper.bash
Last active March 27, 2018 04:23
curl bash wrapper, provide convenient functions for sending restful requests
#!/usr/bin/env bash
export REQ_BASE=""
export REQ_USER=""
export REQ_PWD=""
export REQ_METHOD=""
function cf_lower() {
echo "${1:-`cat`}" | tr '[:upper:]' '[:lower:]'
}
@iintothewind
iintothewind / util.sh
Last active June 27, 2024 06:51
util.sh
# from: http://hongjiang.info/common-bash-functions/
# check current os is linux
function cf_is_linux() {
[[ "$OSTYPE" = *linux* ]] && echo "true" && return 0
echo "false" && return 1
}
# check current os is mac/darwin
function cf_is_darwin() {
@iintothewind
iintothewind / Vagrantfile
Created March 19, 2018 01:49
fedora25.Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "fedora" do |fdr|
fdr.vm.box = "fedora25"
fdr.vm.box_version = "0"
fdr.vm.box_check_update = false
fdr.vm.network "private_network", ip: "192.168.2.10"
#fdr.vm.network "forwarded_port", guest: 80, host:10080
fdr.vm.provider "virtualbox" do |vb|
@iintothewind
iintothewind / bosh.sh
Created October 13, 2017 06:17
bosh.sh
#!/usr/bin/env bash
set -e
set -u
if [[ $director_name == "" ]]; then
export director_name = "Bosh Lite Director"
fi
if [[ $internal_ip == "" ]]; then
export internal_ip = "192.168.50.6"
@iintothewind
iintothewind / random.sql
Last active June 4, 2017 14:57
random sql
CREATE OR REPLACE FUNCTION get_random_number(INTEGER, INTEGER) RETURNS INTEGER AS $$
DECLARE
start_int ALIAS FOR $1;
end_int ALIAS FOR $2;
BEGIN
RETURN trunc(random() * (end_int-start_int) + start_int);
END;
$$ LANGUAGE 'plpgsql' STRICT;