Skip to content

Instantly share code, notes, and snippets.

@Quar
Quar / compare_systemd_systemv_list.py
Created November 10, 2017 19:26
Compare List-Serice-Status difference between SystemV and SystemD
#!/usr/bin/env python3
import subprocess as sp
import shlex
CMD_SYSTEMV_LIST="""
service --status-all | cut -d']' -f2 | xargs -n 1
"""
CMD_SYSTEMD_LIST="""
systemctl list-units --type=service | cut -d' ' -f1
@Quar
Quar / jq_snippet.yaml
Last active November 18, 2017 01:05
post-process gooleapi nearby returns using jq
Snippets:
- description: get distinct types of location
url: https://jqplay.org/s/Od6lj5qjwm
filter: |
[ ..|.types? | arrays ] | flatten | unique
- description: select places are typeof resturant
url: https://jqplay.org/s/_BAt2M6bkZ
filter: |
.results[] | select( .types[] | contains("restaurant") )
@Quar
Quar / t_understand_chan.go
Last active December 7, 2017 00:58
understand go channel
package main
import (
"fmt"
"time"
)
/* Note that both "sending to" and "retrieving from" a channel can block.
* - sending to a channel will block until it is closed and all sent
* elements get retrieved.
@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:

@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 / 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 / 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 / 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 / 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) #