Skip to content

Instantly share code, notes, and snippets.

View sombriks's full-sized avatar
🎧
discover new life, new galaxies, new civilizations -- [RUNNING]

Leonardo Silveira sombriks

🎧
discover new life, new galaxies, new civilizations -- [RUNNING]
View GitHub Profile
@sombriks
sombriks / App.spec.ts
Created August 22, 2024 19:25
working version of testcase passing on github CI or: the importance of await vi.waitFor
import {describe, expect, it, afterAll, afterEach, beforeAll, vi} from 'vitest'
import {render, screen, fireEvent} from '@testing-library/vue'
import {http, HttpResponse} from 'msw'
import {setupServer} from 'msw/node'
import {router} from "./services/route-config.ts";
import App from './App.vue'
describe('Basic tests', () => {
@sombriks
sombriks / index.mjs
Created August 11, 2024 20:37
drizzle issue
import Database from 'better-sqlite3';
import { desc, sql } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import { text, sqliteTable } from "drizzle-orm/sqlite-core";
const sqlite = new Database('sqlite.db');
const schema = {
UserTable: sqliteTable('user', {
name: text('name').notNull()
@sombriks
sombriks / .bashrc
Created August 1, 2024 21:29
completion scripts for your .bashrc
# completion tools to add into .bashrc
source <(k0s completion bash)
source <(kind completion bash)
source <(helm completion bash)
source <(argocd completion bash)
source <(kubectl completion bash)
source <(npm completion)
source <(gh completion -s bash)
@sombriks
sombriks / cassandra-init.sh
Created July 16, 2024 20:37
cassandra and init script via init-image strategy
#!/usr/bin/env bash
export RESULT=-1
until [ $RESULT -eq 0 ]; do
sleep 3;
echo "attempt to create keyspace"
cqlsh cassandra-local \
-u cassandra \
-p cassandra \
-e "create keyspace if not exists my_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};"
RESULT=$?
@sombriks
sombriks / no_rollback_from_here.js
Last active July 13, 2024 23:36
single function database migrations solution for small tests and for people who doesn't want an entire migration system
import { readFileSync } from 'node:fs';
import { logger } from './logging.js';
const log = logger.scope('no-rollback.js');
/**
* Apply database migrations
*
* @param {import('@electric-sql/pglite')} database database connection instance
*/
@sombriks
sombriks / create-cluster.sh
Created June 28, 2024 16:58
docker compose for testing redis cluster
#!/bin/sh
# need to run this to have a proper local cluster
sleep 5 ; echo yes | redis-cli --cluster create redis-7003:7003 redis-7001:7001 redis-7002:7002 --cluster-replicas 0
@sombriks
sombriks / example.html
Created June 15, 2024 20:01
hx-dataset-include - keep your application state in the loop using this hacky, fast and simple extension.
<!--
Since the markup IS the application state, using data-* attributes to keep track of some specifics would be handy.
Luckily, HTMX is brutally easy to extend, so we can do that in no time!
-->
<article class="message task"
th:id="'task'+${task.id}"
th:data-task="${task.id}"
th:data-status="${task.status.id}"
th:hx-put="@{/task/{id}(id=${task.id})}"
hx-ext="hx-dataset-include"
@sombriks
sombriks / TCApplicationTests.kt
Created May 18, 2024 00:06
sample testconfiguration for spring
package sample.example
import org.hamcrest.CoreMatchers
import org.hamcrest.MatcherAssert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Import
import org.springframework.data.domain.PageRequest
@sombriks
sombriks / docker-compose-elasticsearch.yml
Created February 20, 2024 21:29
running pelias elastic search standalone for testing purposes
version: "3.8"
services:
elasticsearch:
image: pelias/elasticsearch:7.16.1
restart: always
ports: [ "127.0.0.1:9200:9200", "127.0.0.1:9300:9300" ]
ulimits:
memlock:
soft: -1
hard: -1
@sombriks
sombriks / Logging.mjs
Created December 15, 2023 01:46
a genenral logger for koa
export class Logging {
static async generalLogger (ctx, next) {
try {
await next()
} catch (err) {
console.log(err)
ctx.throw(err)
}
}
}