Skip to content

Instantly share code, notes, and snippets.

@estepnv
estepnv / SecurityConfig.java
Last active June 20, 2025 16:00
Spring Boot Security 6.5 Built-in JWT Example Secret Key HS256 Signature
package com.estepnv.hotel_advisor.iam;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.jwk.*;
import com.nimbusds.jose.jwk.source.ImmutableJWKSet;
import com.nimbusds.jose.jwk.source.JWKSource;
import com.nimbusds.jose.proc.SecurityContext;
import org.springframework.beans.factory.annotation.Value;
@estepnv
estepnv / kysely-utils.ts
Created March 13, 2025 05:54
Useful utility functions for kysely
import { Insertable, Kysely, SelectQueryBuilder, Selectable, Updateable } from "kysely"
import { db } from "./db.js"
import { DB } from "./schema.js"
function must<T extends any>(value: T | null | undefined, msg: string = "value must be present"): T {
if (typeof value === "undefined") {
throw new Error(msg)
} else if (value == null) {
throw new Error(msg)
} else {
@estepnv
estepnv / check_rubocop_dept.rb
Created August 22, 2022 14:40
Pre-commit hook to check rubocop dept
#!/usr/bin/env ruby
require 'yaml'
require 'open3'
merge_process_status = nil
Open3.popen3("git merge HEAD &> /dev/null") do |stdin, stdout, stderr, wait_thr|
merge_process_status = wait_thr.value
end
@estepnv
estepnv / opensearch_ddtrace_instrumentation_patch.rb
Created June 29, 2022 13:18
Opensearch Datadog instrumentation patch ddtrace 0.5.4
Datadog.configure do |c|
c.use :elasticsearch, service_name: "opensearch"
end
module OpenSearch
module InstrumentationPatch
DEFAULT_PEER_SERVICE_NAME = 'opensearch'
SPAN_QUERY = 'opensearch.query'
SPAN_TYPE_QUERY = 'opensearch'
sudo apt-get install git
# Setting up rbenv
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc