This file contains 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
# frozen_string_literal: true | |
require "benchmark_driver" | |
source = <<~RUBY | |
class Hash | |
def symbolize_keys | |
transform_keys { |key| key.to_sym rescue key } | |
end |
This file contains 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 Array | |
def deconstruct | |
self | |
end | |
end | |
class Hash | |
def deconstruct_keys(_) | |
self | |
end |
This file contains 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
-- 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 |
This file contains 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 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] } |
This file contains 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(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(). |