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
-- Create a group | |
CREATE ROLE readaccess; | |
-- Grant access to existing tables #sidenote: please switch to DB for which you want to give access | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
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
# Create file config/initializers/find_in_batches_with_order.rb with follwing code. | |
ActiveRecord::Batches.class_eval do | |
## Only flat order structure is supported now | |
## example: [:forename, :surname] is supported but [:forename, {surname: :asc}] is not supported | |
def find_in_batches_with_order(ids: nil, order: [], batch_size: 1000) | |
relation = self | |
arrangement = order.dup | |
index = order.find_index(:id) | |
unless index |
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
# Linux Echo colours | |
red='\033[0;31m' | |
nc='\033[0m' | |
black='\033[0;30m' | |
dark_grey='\033[1;30m' | |
light_red='\033[1;31m' | |
green='\033[0;32m' | |
lgreen='\033[1;32m' | |
orange='\033[0;33m' | |
yellow='\033[1;33m' |
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
# .irbrc | |
IRB.conf[:PROMPT_MODE] = :SIMPLE # default is :DEFAULT | |
# Or, invoke irb with the prompt mode by | |
# terminal | |
❱ irb --prompt simple |
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
{ | |
PROMPT_I => "" # Simple prompt | |
PROMPT_S => "" # Prompt for continued strings | |
PROMPT_C => "" # Prompt for continued statement | |
RETURN => "" # Format to return value | |
} |
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
%N # command name which is running | |
%m # to_s of main object (self) | |
%l # type of string(", ', /, ]), `]' is inner %w[...] | |
%NNi # indent level. NN is digits and means as same as printf("%NNd"). | |
%NNn # line number. |
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
# IRB Classic prompt | |
IRB.conf[:PROMPT_MODE][:CLASSIC] = { | |
:PROMPT_I => "%N(%m):%03n:%i> ", # irb(main):001:0> | |
:PROMPT_S => "%N(%m):%03n:%i%l ", # irb(main):003:0" | |
:PROMPT_C => "%N(%m):%03n:%i* ", # irb(main):005:0* | |
:RETURN => "%s\n" # used to printf # | |
} | |
vs | |
# IRB Simple prompt |
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
# .irbrc | |
IRB.conf[:PROMPT_MODE] = :SIMPLE # default is :DEFAULT | |
# Or, invoke irb with the prompt mode by | |
# terminal | |
❱ irb --prompt simple |
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
# We can get application class by | |
>> Rails.application.class.name | |
# => "Meetup::Application" | |
## Since we are only interested in application name, we can get it by | |
>> Rails.application.class.module_parent.name | |
# => "Meetup" |
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
# We can get rails environment by simply calling | |
>> Rails.env | |
# => "development" |
OlderNewer