Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / stream_tar.bash
Last active October 20, 2017 22:57
common tools
# view contents inside tar.gz
curl -s https://www.x.org/releases/individual/util/util-macros-1.19.1.tar.gz | tar -tf -
# view file inside tar.gz
curl -s https://www.x.org/releases/individual/util/util-macros-1.19.1.tar.gz | tar --strip-components 1 -xOf - util-macros-1.19.1/README
# search file using glob-pattern tcsh(1)
curl -s https://www.x.org/releases/individual/util/util-macros-1.19.1.tar.gz | tar --strip-components 1 -xOf - '**/README'
@Quar
Quar / NWJT.md
Last active September 21, 2017 18:12
Time reference to clear worries

NWJT (Nothing is Wrong, it Just takes Time)

Without a reference, suspect of something goes wrong may increase with wall time. So here is an archieve: NWJT (Nothing is Wrong, it Just takes Time).

  • brew reinstall graph-tool --with-openmp --with-python3 --without-python
    • takes 50 minutes 9 seconds to build
  • on 2.5GHz i7, 16GB 1600MHz DDR3
@Quar
Quar / # openblas-julia - 2017-06-14_19-37-55.txt
Created June 15, 2017 01:41
openblas-julia (staticfloat/julia/openblas-julia) on macOS 10.12.5 - Homebrew build logs
Homebrew build logs for staticfloat/julia/openblas-julia on macOS 10.12.5
Build date: 2017-06-14 19:37:55
@Quar
Quar / test.R
Created May 19, 2017 15:49
Test R Code to be retrieved
x = 1:10
plot(x)
@Quar
Quar / SelfReferenceExample.scala
Last active May 9, 2017 00:05
Self Reference Example
// continued the original example from
// https://scalerablog.wordpress.com/2015/07/13/traditionally-baked-scala-cake/
import scala.util.Random
trait MyComponent {
def service: MyService
trait MyService {
<keymap version="1" name="Mac OS X WQ" parent="Mac OS X">
<action id="ActivatePythonConsoleToolWindow">
<keyboard-shortcut first-keystroke="ctrl back_quote" />
</action>
<action id="ChooseDebugConfiguration" />
<action id="ChooseRunConfiguration">
<keyboard-shortcut first-keystroke="f10" />
</action>
<action id="CloseActiveTab" />
<action id="CloseContent">
@Quar
Quar / dockingdocker.sh
Last active March 25, 2017 02:20
lazily install Docker
#!/bin/bash
# Docker (Community Edition) Installing Script
# usage:
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/Quar/09c0fd99ec0e5bf58c74f638b3b5bda1/raw)"
# adapted from
# https://store.docker.com/editions/community/docker-ce-server-ubuntu?tab=description
# check version