Skip to content

Instantly share code, notes, and snippets.

View qtopie's full-sized avatar

qtopie.rw qtopie

  • GuangZhou, China
View GitHub Profile
@qtopie
qtopie / drone-ci.md
Last active June 9, 2019 16:07
Drone CI deployment with docker
@qtopie
qtopie / docker-compose.yml
Created January 14, 2019 16:02
gogs docker compose
version: '3'
services:
postgres:
image: postgres:11
restart: always
environment:
- "POSTGRES_USER=postgres"
- "POSTGRES_PASSWORD=postgres1234"
- "POSTGRES_DB=gogs"
@qtopie
qtopie / ubuntu-18.04-xrdp-config.md
Created January 14, 2019 15:19
Ubuntu 18.04 Xrdp Configuration

Installation

sudo apt install xorgxrdp tigervnc-standalone-server xrdp

Configuration

I prefer vnc over xorg, so set autorun=Xvnc.

@qtopie
qtopie / DualPivotQuickSort.go
Last active December 31, 2018 05:11
Classic sorting algorithms implemented in Go.
func dualPivotQuickSort(arr []int, start, end int) {
if start < end {
lp, rp := partition(arr, start, end)
dualPivotQuickSort(arr, start, lp-1)
dualPivotQuickSort(arr, lp+1, rp-1)
dualPivotQuickSort(arr, rp+1, end)
}
}
// partition split the slice into three parts with two pivots:
@qtopie
qtopie / get-commit-ids.sh
Last active November 5, 2018 09:52
Script to get added commit ids of pull request
#!/bin/bash
REPO_DIR=/tmp/my-git-repo
git clone -b $SOURCE_BRANCH $SOURCE_REPO_URL $REPO_DIR && cd $REPO_DIR || exit 1
git remote add upstream $TARGET_REPO_URL && git fetch upstream $TARGET_REPO_BRANCH
commit_ids=$(git cherry upstream/$TARGET_REPO_BRANCH | awk '{print $2}')
cd -
@qtopie
qtopie / main.go
Created October 25, 2018 14:58
Read-Write Lock in Go
package main
// Just a sample code for learning mutex. Don't use this code for prodution.
import (
"fmt"
"sync"
"time"
)
@qtopie
qtopie / migrating-sonarqube.md
Last active November 17, 2019 21:32
Migrating sonarqube to docker container. (DB: mysql)

Back up database sonar

mysqldump -v -h 127.0.0.1 -P 3306 -u root -p --default-character-set=utf8 sonar > sonar_backup.sql

Database recovery

mysql -u username -p database_name < backup_name.sql
@qtopie
qtopie / gist:6c908af1ef9a994463e33678d2b3e27e
Last active November 4, 2018 09:57
Find file contains specific string
grep -rnwH ./ -e WIN32 | sed -e 's/\(.*\):[0-9+].*/\1/' | sort | uniq | grep -v Binary | xargs vim
@qtopie
qtopie / App.java
Last active May 17, 2018 14:55
Handling Plurals in java (i18n) sample code. Reference: https://docs.oracle.com/javase/tutorial/i18n/format/choiceFormat.html
import java.io.IOException;
import java.text.ChoiceFormat;
import java.text.Format;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.ResourceBundle;
public class App {