Skip to content

Instantly share code, notes, and snippets.

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

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
@kivanio
kivanio / audit_table.sql
Created October 19, 2022 19:59 — forked from djheru/audit_table.sql
Example audit table and trigger function for Postgresql
CREATE TABLE audit_log (
username text, -- who did the change
event_time_utc timestamp, -- when the event was recorded
table_name text, -- contains schema-qualified table name
operation text, -- INSERT, UPDATE, DELETE or TRUNCATE
before_value json, -- the OLD tuple value
after_value json -- the NEW tuple value
);
CREATE OR REPLACE FUNCTION audit_trigger()
@kivanio
kivanio / unused_routes.rb
Created May 23, 2022 12:24 — forked from strzibny/unused_routes.rb
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
@kivanio
kivanio / README.md
Created April 4, 2022 12:45 — forked from NikiforovAll/README.md
Postgres + RabbitMQ + Seq

Developer Setup

This repository is intended for bootstrapping developer environment.

@kivanio
kivanio / alert-manager.md
Created April 4, 2022 12:43 — forked from nicosingh/alert-manager.md
A small and local configuration for Prometheus + AlertManager + Slack notifications + Unsee

TL;DR

Clone this repo:

git clone https://gist.github.com/08be6d6e7605a43fe52d1f201c2b47d8.git
cd 08be6d6e7605a43fe52d1f201c2b47d8

Start the docker stack:

@kivanio
kivanio / all-indexes.sql
Created June 9, 2021 13:41 — forked from robertrossmann/all-indexes.sql
Postgres diagnostics
-- List all existing indexes and include some useful info about them (incl. the index's definition)
SELECT
schemaname AS schemaname,
t.relname AS tablename,
ix.relname AS indexname,
regexp_replace(pg_get_indexdef(i.indexrelid), '^[^\(]*\((.*)\)$', '\1') AS columns,
regexp_replace(pg_get_indexdef(i.indexrelid), '.* USING ([^ ]*) \(.*', '\1') AS algorithm,
indisunique AS UNIQUE,
indisprimary AS PRIMARY,
import { Controller } from "stimulus"
import Inputmask from 'inputmask';
export default class extends Controller {
static targets = ['employees', 'amount', 'fullresult', 'result', 'economy', 'resultContent', 'calculator', 'id', 'emailBtn', 'leadBtn']
connect(){
this.params = ['employees', 'amount', 'fullresult', 'result', 'economy', 'id']
var _component = this
this.state = 'valid'
var im = new Inputmask('999,99')
@kivanio
kivanio / base_validator.js
Created July 12, 2020 00:33 — forked from mariochavez/base_validator.js
Stimulus validations
export default class BaseValidator {
constructor(value, options, errorMessages) {
this.value = value
this.options = options
this.errorMessages = errorMessages
}
validate() {
return { valid: false, message: 'Implement me!'}
}
@kivanio
kivanio / index.html.slim
Created July 12, 2020 00:31 — forked from ryenski/index.html.slim
Tabbed interface with Stimulus.js
div data-controller='tabs' data-tabs-index='1'
.tabs.is-boxed.is-marginless
ul
li data-target='tabs.tab'
a data={action: "tabs#change"} Tab 1
li data-target='tabs.tab'
a data={action: "tabs#change"} Tab 2
.tab.box data={target: 'tabs.tabPanel'} Tab panel 1
.tab.box data={target: 'tabs.tabPanel'} Tab panel 2
@kivanio
kivanio / currency_controller.js
Created July 12, 2020 00:31 — forked from psergi/currency_controller.js
Stimulus controller to handle dollar based user input when the backend is expecting cents
import { Controller } from 'stimulus';
export default class extends Controller {
onInput = (e) => this.updateHiddenInput(e.target.value);
connect() {
this.element.addEventListener('input', this.onInput);
this.initializeHiddenInput();
this.initializeInput();
}
import UploadAdapter from './upload_adapter';
function CustomUploadAdapterPlugin( editor ) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = ( loader ) => {
// Configure the URL to the upload script in your back-end here!
return new UploadAdapter( loader, editor );
};
}
import { Controller } from "stimulus"