Skip to content

Instantly share code, notes, and snippets.

View fspacek's full-sized avatar
🏠
Working from home

František Špaček fspacek

🏠
Working from home
View GitHub Profile
@fspacek
fspacek / sshtunnel.go
Created November 22, 2016 08:03 — forked from iamralch/sshtunnel.go
SSH tunnelling in Golang
package main
import (
"log"
"bufio"
"time"
"os"
"fmt"
"io"
"net"
@fspacek
fspacek / nechapem.go
Created June 29, 2018 17:51
nechapem
func download(id string, db *sql.DB) {
fmt.Printf("Downloading %s\n", id)
//nejde pretoze namiesto $ sa da null alebo nejaky shit pretoze nic nematchuje
rows, err := db.Query(`select post_id || '.html', structured_text from post_translation pt
join post_translation_structured_text t on t.id = pt.id
where post_id = $1 and language_key = 'en'`, id)
//ale toto ide, ked je tam pasnuta konstanta...
rows, err := db.Query(`select post_id || '.html', structured_text from post_translation pt
join post_translation_structured_text t on t.id = pt.id
@fspacek
fspacek / TokenAuthDynamicFeature.java
Created February 13, 2019 09:40
Eclipse MicroProfile JWT Authentication extension to allow token based authentication without roles. Code based on Payara microprofile JWT authentication implementation.
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.container.DynamicFeature;
import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.FeatureContext;
import javax.ws.rs.ext.Provider;
import java.lang.reflect.Method;
/**
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
DROP TABLE IF EXISTS pgbench_generic_log;
CREATE TABLE pgbench_generic_log (
mtime timestamptz not null default now(),
action char not null check (action in ('I', 'U', 'D')),
username text not null,
table_name text not null,
row_data jsonb not null
);
CREATE INDEX ON pgbench_generic_log USING brin (mtime);
@fspacek
fspacek / topics.java
Last active October 14, 2022 17:21
List kafka topics without members
try (final var client = AdminClient.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"))) {
final var groupIds = client.listConsumerGroups().all().get().
stream().map(ConsumerGroupListing::groupId).collect(Collectors.toList());
//get groups
final var groups = client.
describeConsumerGroups(groupIds).all().get();
//search for topics with members
final var topicsWithMembers = new HashSet<String>();