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
document.addEventListener("DOMContentLoaded", function(){ | |
var current_sort_by = null; | |
var sort_ascending = true; | |
var sort_table = function(table_el){ | |
var tbody_el = table_el.querySelector("tbody"); | |
var sort_col_index = table_el.querySelectorAll("th").findIndex(function(el){ return el.textContent === current_sort_by }); | |
var sorted_row_elements = tbody_el.querySelectorAll("tr").sort(function(prev_tr_el, next_tr_el){ |
Step 1: Dump your postgresql create_table statements to a file:
pg_dump -s my_db_name > my_db_name_create.sql
- You will need to manually remove all statements except
CREATE TABLE
,CREATE INDEX
,CREATE_UNIQUE INDEX
, etc.- Honestly just do it. It wont take too long, you'll be fine.
- Some statements you will definately need to remove are
SET
,ALTER
,CREATE SEQUENCE
- For
INDEX
statements we need to find-and-removeUSING btree
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
<%= form_for @post do |f| %> | |
<div class="comments-wrapper"> | |
<% f.fields_for :comments do |f2| %> | |
<%= render "comment_fields", f: f2 %> | |
<% end %> | |
</div> | |
<button type="button" class="add-comment">Add Comment</button> | |
<script> |
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 Result | |
def initialize(h={}, **attrs) | |
if !h.is_a?(Hash) | |
raise ArgumentError.new("Non-hash argument provided") | |
end | |
@attrs = h.presence || attrs | |
@attrs.each do |k,v| | |
define_singleton_method(k) do |
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
### BUNDLER | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
ruby '2.4.1' | |
gem "rails" | |
gem "sqlite3" | |
#gem 'responders' |
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
def self.with_fresh_i18n_load_paths(load_paths, &block) | |
prev_load_path = I18n.load_path | |
I18n.load_path = load_paths | |
I18n.backend.reload! | |
block.call | |
ensure | |
I18n.load_path = prev_load_path | |
I18n.backend.reload! |
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
# lib/<project_name>/engine.rb | |
module RailsI18nManager | |
class Engine < ::Rails::Engine | |
isolate_namespace RailsI18nManager | |
initializer "rails_i18n_manager.load_static_assets" do |app| | |
### Expose static assets | |
app.middleware.use ::ActionDispatch::Static, "#{root}/public" | |
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
# lib/<project_name>/engine.rb | |
module RailsI18nManager | |
class Engine < ::Rails::Engine | |
isolate_namespace RailsI18nManager | |
### Automatically load all migrations into main rails app | |
initializer "rails_i18n_manager.append_migrations" do |app| | |
if !app.root.to_s.match?(root.to_s) | |
config.paths["db/migrate"].expanded.each do |expanded_path| |
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
### Article about the BOM: https://estl.tech/of-ruby-and-hidden-csv-characters-ef482c679b35 | |
### Article about other CSV gotchas: https://blog.rubyhero.dev/solving-problems-with-csv-parsing | |
### Remove Blank Rows from end of file | |
### Ideally this would be handled by the controller to sanitize before saving upload however I wasnt able to make that work | |
file_data = file.read.sub(/[,\n\r\t ]*\z/, "") | |
i = -1 |
NewerOlder