Skip to content

Instantly share code, notes, and snippets.

View kwk's full-sized avatar

Konrad Kleine kwk

View GitHub Profile
@ipbastola
ipbastola / jq to filter by value.md
Last active April 25, 2024 17:14
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@bjaglin
bjaglin / remove-orphan-images.sh
Last active March 31, 2024 22:54
Remove orphan layers left by the "file" storage backend of the docker registry, heavily inspired by https://gist.github.com/shepmaster/53939af82a51e3aa0cd6
#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/lib/docker/registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/usr/bin/jq
readonly repository_dir=$base_dir/repositories
#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/local/docker-registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/tmp/jq
readonly repository_dir=$base_dir/repositories
@kwk
kwk / Makefile
Last active March 17, 2024 22:54
Compiling with Address Sanitizer (ASAN) with CLANG and with GCC-4.8
.PHONY: using-gcc using-gcc-static using-clang
using-gcc:
g++-4.8 -o main-gcc -lasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc
using-gcc-static:
g++-4.8 -o main-gcc-static -static-libstdc++ -static-libasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc-static
@kwk
kwk / CMakeLists.txt
Last active February 14, 2024 08:53
Fix for "undefined reference to dlopen" in CMake projects
project(testlink)
add_executable(testlink main.cpp)
target_link_libraries(testlink)
@kwk
kwk / gist:1167959
Created August 24, 2011 12:29
How to install NodeJS and NPM on a host without internet access and without compile tools
# On build host (has internet access): Download and install NodeJS and NPM
wget http://nodejs.org/dist/node-v0.4.10.tar.gz
tar xvzf node-v0.4.10.tar.gz
cd node-v0.4.11
./configure
make
sudo make install
wget http://npmjs.org/install.sh
sudo sh ./install.sh
@pqnelson
pqnelson / filter-uses.py
Created February 25, 2019 15:18
Noweb syntax highlighting
#!/usr/bin/env python
import fileinput
from re import sub
deletemode = False
codemode = False
asmmode = False
breakmode = False
@kwk
kwk / timeular-activity-time.sh
Last active April 16, 2021 19:59
Display amount of time spent in activity tracked by timeular for the current day
#!/bin/bash
set -e
# Go here to create or refresh an API key and API secret and paste them:
# https://profile.timeular.com/#/app/account
# Put this in your ~/.timeular.config
# API_KEY="..."
# API_SECRET="..."
@pop
pop / README.md
Created November 18, 2016 22:03
Buildbot on K8s