Skip to content

Instantly share code, notes, and snippets.

@groundnuty
groundnuty / check.md
Created September 7, 2018 10:41
premium mobile analyse

Compare data prices

pdftotext -layout -enc ASCII7 FV-017240-18-09-1-022909-biling.pdf - | sed -n -e '/Data poczenia/,$p' | sed -n -e '2,$p' | grep -v " 0,00 " | sed 's/[[:space:]]\{15\}/\tX\t/g' | sed   -e '/.*(Rozliczenie pakietu:$/{n;d}' | sed 's/[[:space:]][[:space:]]\+/\t/g' | grep "Transmisja danych" | sed 's/\o14//g'  |  cut -d $'\t' -f 4,5 | while read size price ; do msize=$(echo "$size/1024/1024" | bc ) ; mprice=$( echo "$msize*0.02" | bc) ; echo "$size [B], $price [zl] | $msize [MB] $mprice [zl] | rate 0.02/MB [Germany]" ; done  | column -t

Sum up all the costs

pdftotext -layout -enc ASCII7 FV-017240-18-09-1-022909-biling.pdf - | sed -n -e '/Data poczenia/,$p' | sed -n -e '2,$p' | grep -v " 0,00 " | sed 's/[[:space:]]\{15\}/\tX\t/g' | sed   -e '/.*(Rozliczenie pakietu:$/{n;d}' | sed 's/[[:space:]][[:space:]]\+/\t/g' | cut -d $'\t' -f 5 | sed -n -e '0,/Lcznie/p' | sed \$d | tr ',' . | paste -s -d+ - | bc
@groundnuty
groundnuty / gantt.md
Created July 30, 2018 21:05
Gantt for k8s pods

Data from pods

Script:

JSONPATH='{range .items[*]};{@.metadata.name}:{@.status.conditions[?(@.type=="PodScheduled")].lastTransitionTime},{@.status.conditions[?(@.type=="Ready")].lastTransitionTime}{end}'; kubectl get pods -o jsonpath="$JSONPATH" | tr ';' '\n'

Example:

gantt
        dateFormat  YYYY-MM-DDTHH:mm:ssZ
@groundnuty
groundnuty / check_sum.sh
Created May 11, 2018 12:03
Premium Mobile Pdf Invoice Check
cat ~/Downloads/FV-018195-18-05-1-022909-biling.txt | sed -n -e '/Data polczenia/,$p' | sed -n -e '2,$p' | grep -v " 0,00 " | sed 's/[[:space:]]\{15\}/\tX\t/g' | sed -e '/.*(Rozliczenie pakietu:$/{n;d}' | sed 's/[[:space:]][[:space:]]\+/\t/g' | cut -d $'\t' -f 5 | sed -n -e '0,/Lcznie/p' | sed \$d | tr ',' . | paste -s -d+ - | bc
@groundnuty
groundnuty / umountl.sh
Created April 3, 2018 14:21
Umount stale file handles
while read -r mountp ; do if ! timeout 3s ls "$mountp" 1>/dev/null ; then echo "umounting $mountp" ; umount -l $mountp ; fi ; done < <(mount | cut -d ' ' -f 3)
@groundnuty
groundnuty / filter_logs.sh
Created March 12, 2018 11:04
flitering logs
cat *.log* | perl -ne'print unless m{Unable to check space strategies due to\: \{badmatch,\{error\,not_found\}\}}..m{storage_sync_monitoring}' | grep -v -e exometer_report_lager -e 'started ranch_acceptor:start_link' -e 'started couchbase_pool_worker:start_link' -e 'started wpool_process:start_link' | perl -ne'print unless m{wpool_worker\:handle_cast/2 line 76}..m{storage_id => <<"}' | perl -ne'print unless m{Stacktrace:}..m{0~enotdir\}\}}' > ../f
@groundnuty
groundnuty / insert_error.sh
Created March 5, 2018 20:27
error reporting sed in place
config_edit() {
config_edit_file="$1"
config_edit_tmp_file=$(mktemp "${TMPDIR:-/tmp/}$(basename $0).XXXXXXXXXXXX")
cp "$config_edit_file" "$config_edit_tmp_file"
errors=""
for var in $config_parameters; do
eval tmp_val="\$config_$var"
eval tmp_label="\$display_$var"
@groundnuty
groundnuty / redis_barrier.sh
Last active February 19, 2018 13:54
bash redis barrier
# exec 3<>/dev/tcp/j-redis/6379
# printf %b "*2\r\n\$4\r\nINCR\r\n\$25\r\noneclients_ready_count\r\n" >&3
# read -r oneclients_ready_count <&3
# msg_in=$(printf %b "$oneclients_ready_count" | cut -f2 -d$ | tr -d '\r')
# echo "oneclients_ready_count: <${oneclients_ready_count}>"
# exec 3<>/dev/tcp/j-redis/6379
# printf %b "*2\r\n\$3\r\nGET\r\n\$23\r\noneclients_ready_count\r\n" >&3
# read -r oneclients_ready_count <&3
# read -r oneclients_ready_count <&3
@groundnuty
groundnuty / onedata_replication_cheatsheet.md
Last active February 27, 2018 10:33
Onedata replications cheatsheet

Envs we will need

OZ_HOST="90.147.170.26"

TOKEN='MDAxNWxvY2F00aW9uIG9uZXpvbmUKMDAzYmlkZW500aWZpZXIga3c00QXExOTJQUXd4SHRyalBxcXlFS1NWWldSeVM3bHFaSWVDTHVQQVZaNAowMDFhY2lkIHRpbWUgPCAxNTM3NDUwNjkzCjAwMmZzaWduYXR1cmUgIh2n5CILKKXUbtEZC01tmQzQEgcq27gnTWV0102J6WMzegK'

SPACEID="S-HHji1RCFgGlGsTJ4kZ23Jiu6vhvVI74PRaGLuJSVg"

HOST="oneprovider.cesnet.cz"
@groundnuty
groundnuty / calico.yaml
Last active December 11, 2018 07:30
canal network with subnets changed
# This ConfigMap is used to configure a self-hosted Calico installation.
kind: ConfigMap
apiVersion: v1
metadata:
name: calico-config
namespace: kube-system
data:
# The location of your etcd cluster. This uses the Service clusterIP
# defined below.
etcd_endpoints: "http://10.96.232.136:6666"
@groundnuty
groundnuty / iperf_tcpprobe.yml
Created August 15, 2017 21:43
tcpprobe for debuging kubernetes networking
# tcpprobe https://wiki.linuxfoundation.org/networking/tcpprobe
# use: apt install module-init-tools
# to install modprobe
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels: