Skip to content

Instantly share code, notes, and snippets.

@Quar
Quar / getPipeSize.c
Created March 29, 2018 19:46
System IOs
/* SO25411892
*
* Since F_GETPIPE_SZ is Linux-specific, we will have
* to define _GNU_SOURCE to obtain their definitions
*
* Ref: http://man7.org/linux/man-pages/man2/fcntl.2.html#CONFORMING_TO
*/
#define _GNU_SOURCE
@Quar
Quar / ubuntu-install-docker.bash
Last active January 14, 2019 02:17
Docker Install Script
#!/bin/bash
# ref: https://docs.docker.com/install/linux/docker-ce/ubuntu/#supported-storage-drivers
DOCKER_PGP_KEY='9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88'
set -e
autocheckPGP() {
if grep -q "${DOCKER_PGP_KEY}" <(sudo apt-key fingerprint 0EBFCD88 | tr -s ' '); then
echo -e "\e[32mautocheck PGP key PASSED\e[39m"
docker run -it -p 80:80 -v $PWD/fs/gitlabsrv/config:/etc/gitlab -v $PWD/fs/gitlabsrv/logs:/var/log/gitlab -v $PWD/fs/gitlabsrv/data:/var/opt/gitlab --entrypoint=/bin/sh gitlab/gitlab-ce
@Quar
Quar / Makefile
Created March 15, 2018 16:21 — forked from nano-yang/Makefile
spark dependency with Makefile
#### config packages ####
PACKAGES := \
net.liftweb:lift-json:2.0 \
datastax:spark-cassandra-connector:1.6.10-s_2.11 \
#### main part ####
null :=
space := $(null) #
@Quar
Quar / GetRuntimeType.go
Last active February 2, 2018 19:16
Golang Reflection
// a trivial extension on SO6996704
// `fmt.Printf("%T", x)` returns same as `reflect.TypeOf(x).Name()`
// without considering other aspects like impairments on execution time.
package main
import (
"fmt"
"reflect"
)
@Quar
Quar / zsh_scalac_optimise.md
Created January 23, 2018 18:16
zsh use scalac 2.12 with optimise

Since Scala 2.12, -optimise flag of scalac was deprecated.

scalac -help shows:

Deprecated settings: -optimise Compiler flag for the optimizer in Scala 2.11 deprecated: In 2.12, -optimise enables -opt:l:inline -opt-inline-from:**. Check -opt:help for using the Scala 2.12 optimizer.

It works file in bash, while error will throw if you use without asterisks quoted in zsh 5.4.2:

@Quar
Quar / TestForkJoinPool.java
Last active January 18, 2018 02:02
examples of using ForkJoinPool
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class TestForkJoinPool {
static String accumulate(int from, int to, String name) {
int sum = 0;
@Quar
Quar / README.md
Created December 14, 2017 02:57
About locale

About locale

locale will be used by locale-aware programs, likely depends on glibc.

Programs will complain if cannot find used locales (check via locale) within available locales (check via locale -a).

One will have to generate/put used locales into path (find by localedef --help | grep 'locale path') to fix the issue.

Fix:

@Quar
Quar / Makefile
Last active December 19, 2017 00:55
Portable Python
MAIN ?= $(firstword $(wildcard *.py))
CONDA_ENV ?= "$(shell conda info --envs | sed -n 's/^\([^[:space:]]*\).*\*.*/\1/p')"
SHELL = /bin/bash
LD_LIBRARY_PATH := "$(shell conda info --envs | sed -n 's/.*\*[ ]*\(\/.*\)$$/\1/p')/lib/"
SET_CONDA = source activate $(CONDA_ENV)
@Quar
Quar / README.md
Last active December 7, 2017 19:10
Simplify `travis encrypt ... --add` on macOS, use KeyChain

travis-allow-push

Simplify travis encrypt ... --add on macOS, use KeyChain

Install

  1. Get Github Access Token follow the link.

  2. Add link to KeyChain with: