A collection of commands that change the Arc Browser icon on macOS.
| Theme | Command |
|---|---|
| Candy Arc | defaults write company.thebrowser.Browser currentAppIconName candy |
| import_if_available(Ecto.Query) | |
| # alias MyApp.Repo | |
| defmodule R do | |
| # Old habits die hard. Take a random of something. You don't care which. | |
| # > R.take(SomeSchema) | |
| def take(schema_or_query) do | |
| schema_or_query | |
| |> limit(1) | |
| |> Repo.one() |
You also might wanna just use Whisky which does this automatically
This guide works on macOS 13.4+ using Command Line Tools for XCode 15 Beta!
In the recent WWDC, Apple announced and released the "game porting toolkit", which upon further inspection this is just a modified version of CrossOver's fork of wine which is a "compatibility layer" that allows you to run Windows applications on macOS and Linux.
| require Logger | |
| Logger.configure_backend(:console, format: "$time $metadata[$level] $levelpad$message\n") | |
| # more colores in | |
| # https://hexdocs.pm/elixir/1.12/IO.ANSI.html | |
| Logger.info("colorful log line", ansi_color: :black) | |
| Logger.info("colorful log line", ansi_color: :blue) | |
| Logger.info("colorful log line", ansi_color: :cyan) |
Background: это было написано для "фронт-энд" сервиса, который должен был проксировать HTTP и WebSocket-запросы на несколько внутренних сервисов.
Для того, чтобы переопределить то, как Phoenix обрабатывает вебсокеты, надо поменять настройки HTTP сервера (Cowboy), а именно настройки роутинга (:dispatch) — см. config.exs. Тут мы указываем, что для любого хоста: а) для пути "/aaa/websocket" вызывается хендлер API.Gateway.WSReverseProxy, б) для любого другого пути вызывается дефолтный хэндлер Phoenix.
API.Gateway.WSReverseProxy — это хэндлер Cowboy, для подробной информации о р
| defmodule Map.Helpers do | |
| @moduledoc """ | |
| Functions to transform maps | |
| """ | |
| @doc """ | |
| Convert map string camelCase keys to underscore_keys | |
| """ | |
| def underscore_keys(nil), do: nil |
| defmodule Randomizer do | |
| @moduledoc """ | |
| Random string generator module. | |
| """ | |
| @doc """ | |
| Generate random string based on the given legth. It is also possible to generate certain type of randomise string using the options below: | |
| * :all - generate alphanumeric random string | |
| * :alpha - generate nom-numeric random string |
| #!/bin/bash | |
| set -e | |
| CURRENT_NAME="CurentName" | |
| CURRENT_OTP="current_name" | |
| NEW_NAME="NewName" | |
| NEW_OTP="new_name" |
| Backup: | |
| docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql | |
| Restore: | |
| cat your_dump.sql | docker exec -i your-db-container psql -Upostgres |
| # This demonstrates that, when using async/await, a crash in the task will crash the caller | |
| defmodule Tasker do | |
| def good(message) do | |
| IO.puts message | |
| end | |
| def bad(message) do | |
| IO.puts message | |
| raise "I'm BAD!" | |
| end |