Skip to content

Instantly share code, notes, and snippets.

@mittyok
mittyok / ChangeLogLevel.java
Created April 22, 2019 10:07 — forked from nkcoder/ChangeLogLevel.java
change log level at runtime (logback and slf4j)
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* change log level at runtime
* Created by nkcoder on 10/8/16.
func init() {
rand.Seed(time.Now().UnixNano())
}
func retry(attempts int, sleep time.Duration, f func() error) error {
if err := f(); err != nil {
if s, ok := err.(stop); ok {
// Return the original error for later checking
return s.error
}
@mittyok
mittyok / confirm.go
Created August 27, 2018 08:52 — forked from albrow/confirm.go
Go (golang): How to ask for user confirmation via command line
import (
"fmt"
"log"
"os"
"sort"
)
// askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and
// then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as
// confirmations. If the input is not recognized, it will ask again. The function does not return
@mittyok
mittyok / install-multiple-jdk-on-macos-high-sierra.md
Created May 24, 2018 05:42 — forked from ntamvl/install-multiple-jdk-on-macos-high-sierra.md
Install Multiple Java Versions on macOS High Sierra

Install Multiple Java Versions on macOS High Sierra

Install Homebrew Cask

On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.

Install Homebrew Cask first if you haven’t:

brew update
brew tap caskroom/cask
@mittyok
mittyok / git_toturial
Created April 11, 2018 08:15 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@mittyok
mittyok / findParent.sh
Last active January 4, 2018 03:43 — forked from dkirrane/findParent.sh
Find the parent branch of the current branch get parent branch
current_branch=`git rev-parse --abbrev-ref HEAD`
git show-branch -a | grep '*' | grep -v $current_branch | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
@mittyok
mittyok / API.md
Created December 30, 2017 13:25 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@mittyok
mittyok / Dockerfile
Created December 3, 2017 16:22 — forked from renzok/Dockerfile
docker: mapping host uid and gid to user inisde container
FROM debian:jessie
ENV USER=boatswain USER_ID=1000 USER_GID=1000
# now creating user
RUN groupadd --gid "${USER_GID}" "${USER}" && \
useradd \
--uid ${USER_ID} \
--gid ${USER_GID} \
--create-home \
@mittyok
mittyok / tmux.conf
Created August 14, 2017 07:56 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@mittyok
mittyok / AnnotationClassMapBuilder.java
Created December 17, 2016 14:56 — forked from elaatifi/AnnotationClassMapBuilder.java
Example of a class-map builder supporting custom annotations to configure Orika mapper.
/*
AnnotationClassMapBuilder extends the default class map builder and override byDefault method to lookup for more metadata
*/
public class AnnotationClassMapBuilder<A, B> extends ClassMapBuilder<A, B> {
protected AnnotationClassMapBuilder(Type<A> aType, Type<B> bType, PropertyResolverStrategy propertyResolver,
DefaultFieldMapper[] defaults) {
super(aType, bType, propertyResolver, defaults);
}