Skip to content

Instantly share code, notes, and snippets.

Hello, Erlang

Hello, world

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
@elainenaomi
elainenaomi / log.rb
Last active August 11, 2020 23:45
redirecting log
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
  • Por que fazer testes?
    • saber se o software está funcionando de maneira automatizada
      • não elimina os testes exploratórios feito de forma manual
    • manter custos de desenvolvimento em níveis saudáveis
    • ajuda na qualidade interna do código (design e arquitetura do código)
  • Como avaliar a qualidade dos testes (se estão bem feitos)?
    • corretude - se o teste não está gerando um falso positivo
  • adequação do tipo de teste - se o teste é o mais adequado para a situação
@elainenaomi
elainenaomi / status_object.md
Last active December 18, 2018 15:35
Status Object (from Confident Ruby)

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
@elainenaomi
elainenaomi / timezone_rails.md
Created May 15, 2018 13:25
Working with time zone on Rails

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:

  • Usar 30.days em uma constante é ok, pois, no fundo, é um inteiro.
  • Se usar 30.days.from_now em uma constante não funciona pois é um timestamp e será cacheado no momento em que a app subir.
@elainenaomi
elainenaomi / time_vs_datatime.md
Created March 27, 2018 14:02 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

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
@elainenaomi
elainenaomi / Ruby_Rails_Naming_Conventions.md
Created December 28, 2017 01:53 — forked from alexpchin/Ruby_Rails_Naming_Conventions.md
Ruby & Rails Naming Conventions

Alex's Rails Cheat Sheet

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...