Skip to content

Instantly share code, notes, and snippets.

View palkan's full-sized avatar

Vladimir Dementyev palkan

View GitHub Profile
# frozen_string_literal: true
require "benchmark_driver"
source = <<~RUBY
class Hash
def symbolize_keys
transform_keys { |key| key.to_sym rescue key }
end
class Array
def deconstruct
self
end
end
class Hash
def deconstruct_keys(_)
self
end
@palkan
palkan / postgres_queries_and_commands.sql
Last active December 5, 2019 13:01 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@palkan
palkan / rubocop_pre_commit_hook
Last active June 19, 2024 10:41 — forked from mpeteuil/rubocop_pre_commit_hook
Rubocop pre-commit hook
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/)
unstaged_files = `git ls-files -m`.split(/\n/)
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED }
changed_files = changed_files.map { |f| f.split(" ")[1] }
-module(file_utils).
-export([recursively_list_dir/1,
recursively_list_dir/2,
recursively_del_dir/1,
dir_traversal/2,
dir_traversal/3]).
% @type name() = string() | atom() | binary().