Skip to content

Instantly share code, notes, and snippets.

Mix.install(
[
{:phoenix_playground, "~> 0.1.0"},
{:openai, "~> 0.6.1"}
],
config: [
openai: [
api_key: System.get_env("OPENAI_API_KEY"),
organization_key: System.get_env("OPENAI_ORGANIZATION_KEY")
]
@brainlid
brainlid / .iex.exs
Created April 2, 2024 12:52
My .iex.exs file that lives in my Home directory. Gets loaded and used in every IEx session on my machines. I borrowed and stole all the great ideas from others an tweaked them over the years.
Application.put_env(:elixir, :ansi_enabled, true)
# IEx shell customization for color
# - Added as a comment: https://thinkingelixir.com/course/code-flow/module-1/pipe-operator/
# - Original source: https://samuelmullen.com/articles/customizing_elixirs_iex/
# - Can add to a specific project or can put in the User home folder as a global config.
# Updates from:
# - https://github.com/am-kantox/finitomata/blob/48e1b41b21f878e9720e6562ca34f1ce7238d810/examples/ecto_intergation/.iex.exs
timestamp = fn ->
{_date, {hour, minute, _second}} = :calendar.local_time
@veekaybee
veekaybee / normcore-llm.md
Last active July 3, 2024 15:42
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@LostKobrakai
LostKobrakai / form_live.ex
Last active July 2, 2024 22:58
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
#!/usr/bin/env bash
DATABASE_URL="postgres://MyPostgresUser:MyPostgresPassword@192.168.0.1:5432/MyPostgresDB"
# `cut` is used to cut out the separators (:, @, /) that come matched with the groups.
DATABASE_USER=$(echo $DATABASE_URL | grep -oP "postgres://\K(.+?):" | cut -d: -f1)
DATABASE_PASSWORD=$(echo $DATABASE_URL | grep -oP "postgres://.*:\K(.+?)@" | cut -d@ -f1)
DATABASE_HOST=$(echo $DATABASE_URL | grep -oP "postgres://.*@\K(.+?):" | cut -d: -f1)
DATABASE_PORT=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:\K(\d+)/" | cut -d/ -f1)
@pulkit110
pulkit110 / mock_websocket_server.ex
Last active February 24, 2023 04:21
Supplementary Code for Testing WebSocket Clients in Elixir with a Mock Server
defmodule Commerce.Orders.MockWebsocketServer do
use Plug.Router
plug(:match)
plug(:dispatch)
match _ do
send_resp(conn, 200, "Hello from plug")
end
@saissemet
saissemet / apache_self_signed.sh
Last active April 2, 2024 09:34
Apache website with self signed certificates
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install easy-rsa -y
cd /usr/share/easy-rsa
sudo ./easyrsa init-pki
yes "" | sudo ./easyrsa build-ca nopass
@humpalum
humpalum / exaramel.yml
Last active February 17, 2021 11:42
Ansible playbook to check for files related to Exaramel
---
# Checks if files exists that related to Exaramel Malware
# Ref:https://www.cert.ssi.gouv.fr/uploads/CERTFR-2021-CTI-005.pdf
- name: Setting files to check
set_fact:
maliciousFiles:
- /tmp/.applocktx
- /tmp/.applock
- /usr/local/centreon/www/search.php
import Ecto.Query
...
defmacro store_items_not_exist(store_items_table_name, store_id, item_name) do
args = [
"NOT EXISTS (SELECT * FROM #{store_items_table_name} item WHERE item.store_id = ? AND item.name == ?)",
store_id,
item_name
]
@Hakky54
Hakky54 / openssl_commands.md
Last active July 1, 2024 16:02 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

OpenSSL 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl