Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justinc1
justinc1 / ssho2o.py
Created February 20, 2024 16:58
VPN over SSH port forward helper. It generates opts for ssh binary.
#!/usr/bin/env python3
import sys
from dataclasses import dataclass
_help_text="""VPN over SSH port forward helper. It generates opts for ssh binary.
Usage1: {sys.argv[0]} -L hostA port1 port2 -R hostB port3
Usage2 - ssh to bastionA to gain "direct" access to hostA ports 8080 and 8443
@justinc1
justinc1 / nestybox-dockerd-fc36
Last active October 1, 2022 20:27
Run docker in FC36 container using nestybox as dind alternative
# https://github.com/nestybox/sysbox/blob/master/docs/developers-guide/build.md
# https://github.com/zaunerc/codesandbox/blob/master/running-systemd-inside-a-docker-container/Dockerfile
#
# docker build -t fc36-dockerd .
# docker run --runtime=sysbox-runc --rm -it --hostname my_cont -d fc36-dockerd
FROM fedora:36
RUN dnf -y install systemd
RUN dnf -y install dnf-plugins-core
@justinc1
justinc1 / keycloak-curl.sh
Last active September 20, 2022 08:07
Get keycloak access token using curl
#!/bin/bash
# based on https://github.com/akoserwal/keycloak-integrations/blob/master/curl-post-request/keycloak-curl.sh
# Usage:
# Start test server (IP 172.17.0.2)
# docker run -it -p 8080:80 -p 8433:443 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:15.0.2 -b 0.0.0.0
# Get token
# PASSWORD=admin ./keycloak-curl.sh https://172.17.0.2:8443 master admin admin-cli 0
# List realms
# curl -H "Authorization: Bearer $(PASSWORD=admin ./keycloak-curl.sh https://172.17.0.2:8443 master admin admin-cli 0)" -k https://172.17.0.2:8443/auth/admin/realms/ | jq
@justinc1
justinc1 / sqlite-cheatsheet.md
Last active July 10, 2019 07:41
sqlite cheatsheet
sqlite3 -readonly db.sqlite3 

.help
.quit
.databases
.dbinfo main
.tables

PRAGMA table_info([auth_user]);
/*----------------------------------------------------------------------------*/
#define LOG_FUNCION_ENTER 1
static int call_depth = 0;
static FILE *dbg_outlog = NULL;
void dbg_open_log(void);
void dbg_open_log(void) {
if (dbg_outlog == NULL) {
dbg_outlog = stdout;
//outlog = fopen("outlog", "a+");
fprintf(dbg_outlog, "/*----------------------------------------*/\n");
@justinc1
justinc1 / ns-bash
Last active April 22, 2018 17:11
Execute bash in net namespace, with informative promt
#!/bin/bash
set -eu
NS=$1
export PS1="[\u@\h \W] ($NS) \$ "
sudo ip netns exec $NS bash
@justinc1
justinc1 / hexdump.cc
Last active May 17, 2018 19:24
hexdump -C in C
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
/*
Implement "hexdump -C" utility.
*/
void hexdump(void* ptr, size_t size, size_t addr0);
#!/bin/bash
# /home/justin_cinkelj/devel/mikelangelo/perf-test/dec-2016/3392.vsbase2.hlrs.de/
IND=./
OUTD=../outdata/
# individual files time span is:
# run1-node0101.pcap 10:45:05.192261 - 10:46:49.561470
# run1-node0102.pcap 10:45:20.754461 - 10:46:16.754582
# run1-node0103.pcap 10:45:02.345936 - 10:46:22.164012
OSV_SRC=../..
CPPLAGS += -std=c++11
## CPPLAGS += -I$(OSV_SRC) -I$(OSV_SRC)/include/ -I$(OSV_SRC)/arch/x64
CPP=c++ $(CPPLAGS) -ggdb
CPPSO=$(CPP) -fPIC -shared
GCC=gcc
GCCSO=$(GCC) -fPIC -shared
all: udp-rec udp-rec.so
@justinc1
justinc1 / autostart-vm.sh
Last active September 15, 2015 07:53
xen-ringwatch scrip, fixed int32/unit32
#!/bin/bash
# justinc, autostart VMs after server reboot
# Only VMs with tag=autostart, or (in) appliance named autostart-vms
LOG=/root/autostart-vm.log
function main() {
# wait on working xapi
echo '************************************************'