Create file as hello.erl
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").
Hello, world everyone
Context
I started to learn Elixir recently and I have a lot of simple questions 😅
I’m reading the Elixir in Action
and I finished the first three chapters 🎉
I really enjoyed how Saša explained the basic concepts, for instance, introducing lists and explaining why we should push an element to the top of the list (with illustrations). He also described the big O notation for several basic operations and other aspects related to the compiler and Erlang VM memory allocation.
However, the part of Streams was very compact (compared to the part about lists). I know that it is a lazy enumerable and I understood (I hope) how to use it.
abusaidm.html-snippets
anseki.vscode-color
cliffordfajardo.hightlight-selections-vscode
CoenraadS.bracket-pair-colorizer
dracula-theme.theme-dracula
formulahendry.auto-close-tag
formulahendry.auto-rename-tag
gencer.html-slim-scss-css-class-completion
GitHub.vscode-pull-request-github
Rails.logger.tagged(:tag_name) do | |
logger = Logger.new(STDOUT) | |
# log both to Rails logger and to STDOUT | |
logger.extend(ActiveSupport::Logger.broadcast(Rails.logger)) | |
# my code | |
end |
Status object definition:
class ImportStatus
def self.success() new(:success) end
def self.redundant() new(:redundant) end
def self.failed(error) new(:failed, error) end
attr_reader :error
Se você precisa usar a configuração de timezone no seu app, lembre-se, você pode usar:
Time.current
.from_now
que usa o Time.current
Sobre uso de constantes:
30.days
em uma constante é ok, pois, no fundo, é um inteiro.30.days.from_now
em uma constante não funciona pois é um timestamp e será cacheado no momento em que a app subir.It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time
class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime
steps in:
>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
Sidekiq.redis { |conn| conn.flushdb } # clear everything | |
Sidekiq::Queue.all # get all queues | |
Sidekiq::Queue.new # get the "default" queue | |
Sidekiq::Queue.new("mailer") # get the "mailer" queue | |
Sidekiq::Queue.new.clear # deletes all jobs in a queue, by removing the queue | |
Sidekiq::Queue.all.each(&:clear) # deletes all jobs in all queues | |
ss = Sidekiq::ScheduledSet.new | |
ss.size |
I think the most confusing thing that I have found about Ruby on Rails so far has been the transition from (trying to) write code myself to the use of the fabled "Rails Magic". So, to help my own understanding of a few core Ruby on Rails concepts, I have decided to write something on what I think is a CRITICAL topic... the idea of Convention over Configuration and why (in my mind) it is the most important thing that helps Rails become magic!
(This may be a topic that we cover in more detail in class but as I said, I'm writing this for my own understanding... I hope it helps someone else understand things too... Perhaps you can give me a hand when I'm crying next week!)
##Convention over configuration ###What does this "actually" mean...