This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlowQueryTrackerWorker < ApplicationWorker | |
def perform(payload_sql, payload_name, duration, backtrace) | |
# Use Rails cache to deduplicate within 5 minutes | |
sql_hash = Digest::MD5.hexdigest(payload_sql) | |
cache_key = "slow_query_tracker:#{sql_hash}" | |
# Skip if we've already processed this query recently | |
Rails.cache.fetch(cache_key, expires_in: 5.minutes) do | |
analyze_slow_query(payload_sql, payload_name, duration, backtrace) | |
true # Store something in cache to mark as processed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⏺ Bash(docker exec keycloak_app /opt/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin --password 123) | |
⎿ Logging into http://localhost:8080 as user admin of realm master | |
⏺ Bash(docker exec keycloak_app /opt/keycloak/bin/kcadm.sh update realms/master -s sslRequired=NONE) | |
⎿ (No content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feat(conversations): improve prompt formatting by introducing a `pretty_print_prompt` helper method to display messages in a table format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# ############################### | |
# Script to run PMM 2. | |
# If docker is not installed, this script will try to install it as root user. | |
# | |
# Usage example: | |
# curl -fsSL https://raw.githubusercontent.com/percona/pmm/main/get-pmm.sh -o get-pmm2.sh; chmod +x get-pmm2.sh; ./get-pmm2.sh | |
# | |
################################# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this to your main library file | |
# lib/<engine_name>.rb | |
if ENV['RAILS_ENV'] == 'test' | |
require 'simplecov' | |
SimpleCov.start do | |
load_profile "test_frameworks" | |
add_filter %r{^/config/} | |
add_filter %r{^/db/} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def active_class(link_path) | |
current_path = request.path | |
# Special case for root path | |
return 'active' if current_path == '/' && link_path == '^/$' | |
return '' if current_path != '/' && link_path == '^/$' | |
# Use Regex to match the route or any conditions you need | |
current_path.match(Regexp.new(link_path)) ? 'active' : '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"set termguicolors | |
call plug#begin('~/.local/share/nvim/plugged') | |
Plug 'wakatime/vim-wakatime' | |
Plug 'hashivim/vim-terraform' | |
" Colorscheme | |
Plug('flazz/vim-colorschemes') | |
Plug('arcticicestudio/nord-vim') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_action :prepend_view_paths | |
def prepend_view_paths | |
prepend_view_path "#{Bundler.locked_gems.dependencies['your_gem_name'].source.path}/app/views/" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Compare two Excel sheets | |
Inspired by https://pbpython.com/excel-diff-pandas-update.html | |
For the documentation, download this file and type: | |
python compare.py --help | |
""" | |
import argparse | |
import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Date.toLocaleDateString.js | |
(function(global) { | |
"use strict"; | |
var dateFormatOverride = function(locale) { | |
var formatUS = | |
this.getMonth() + 1 + "/" + this.getDate() + "/" + this.getFullYear(); | |
var formatTH = | |
this.getDate() + | |
"/" + |
NewerOlder