Skip to content

Instantly share code, notes, and snippets.

View januszm's full-sized avatar

Janusz Mordarski januszm

View GitHub Profile
@januszm
januszm / mysql_table_size.sql
Created September 25, 2023 21:24
MySQL tables size
SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "mydatabase"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
```ruby
record = Model.where("data->'$.somearray[0].email' = ?", email).first
```
@januszm
januszm / hash_array_to_csv.rb
Created March 19, 2024 21:37 — forked from christiangenco/hash_array_to_csv.rb
Ruby hash array to CSV
class Array
def to_csv(csv_filename="hash.csv")
require 'csv'
CSV.open(csv_filename, "wb") do |csv|
csv << first.keys # adds the attributes name on the first line
self.each do |hash|
csv << hash.values
end
end
end