SELECT
queue,
count(1) FILTER (WHERE state = 'available'),
count(1) FILTER (WHERE state IS NULL OR state != 'available')
FROM oban_jobs
GROUP BY queue;
| When writing Elixir code, perfer the following style guidlines: | |
| 1. Elixir developers tend to create many small functions in their modules. I DO NOT LIKE THIS. Instead create functions that fully capture a conceptual task, even if it makes that function longer. A good rule of thumb is, if a private function is only called once within a module, it should've been inlined. | |
| For example: | |
| DON'T DO THIS: | |
| ```elixir |
| server { | |
| listen 80; | |
| server_name ***********; | |
| return 301 https://$server_name$request_uri; | |
| } | |
| server { | |
| # OPTIONAL FOR SSL if you use other port, skip this part. | |
| listen 443 ssl; | |
| server_name ************; |
| Mix.install( | |
| [ | |
| {:phoenix_playground, "~> 0.1.0"}, | |
| {:openai, "~> 0.6.1"}, | |
| {:makeup, "~> 1.1.2"}, | |
| {:makeup_elixir, "~> 0.14"} | |
| ], | |
| config: [ | |
| openai: [ | |
| api_key: System.get_env("OPENAI_API_KEY"), |
Universal Studios API Unofficial Documentation
| // assets/js/app.js | |
| window._lazy_hooks = window._lazy_hooks || {}; | |
| let lazyHook = function(hook) { | |
| return { | |
| mounted() { window._lazy_hooks[hook].mounted(...arguments) }, | |
| beforeUpdate() { window._lazy_hooks[hook].beforeUpdate(...arguments) }, | |
| updated() { window._lazy_hooks[hook].updated(...arguments) }, | |
| destroyed() { window._lazy_hooks[hook].destroyed(...arguments) }, | |
| disconnected() { window._lazy_hooks[hook].disconnected(...arguments) }, |
| defmodule Client do | |
| def main(pid) do | |
| cmd = IO.gets("Enter a command: ") |> String.trim() | |
| case String.split(cmd) do | |
| ["show"] -> | |
| key = self() | |
| Task.async(fn -> | |
| send(pid, {:list, key, self()}) |
| unless File.exists?("~/.todos/"), do: File.mkdir!("~/.todos/") | |
| case System.argv() do | |
| ["all"] -> | |
| if (files = File.ls!("~/.todos/")) == [], | |
| do: IO.puts("No todos."), | |
| else: Enum.each(files, &IO.puts("- #{&1}\n#{File.read!("#{"~/.todos/"}#{&1}")}\n")) | |
| ["create", todo] -> | |
| File.write!("#{"~/.todos/"}#{:os.system_time(:second)}", todo) && IO.puts("📝") |
This code is in dev mode and not yet finished, it probably won't work but I am using it to learn how to create a transformer from scratch
This gist is shared to help with this tweet https://twitter.com/LorenzoSinisi/status/1652756858459881473
Mix.install(
[