Mix.install([
{:phoenix_playground, "~> 0.1.6"}
])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Debug do | |
defmacro dbg_m(ast, options \\ []) do | |
options = Keyword.put_new(options, :header, format_dbg_m_header(__CALLER__)) | |
ast | |
|> Macro.expand(__CALLER__) | |
|> write_ast(options) | |
ast | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Myapp.URI | |
@doc """ | |
Builds a URL or path with the given query parameters. | |
Accepts a URL or path and a keyword list or map of parameters. Handles merging, overriding, and removing | |
parameters, including support for complex values (lists, maps and keyword lists as supported by `Plug.Conn.Query/2`). | |
If a value of `[value: v, default: d]` option is given, the parameter is omitted if `v == d`. In this format, | |
`:value` must come first, otherwise it is treated as a list. If you must provide a list with `{:value, _something}`, | |
then either make sure it's not first, or pass it as: `foo: [value: [value: "bar"]]`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/myapp_web/user_auth.ex b/lib/myapp_web/user_auth.ex | |
index 37dfa43..fa1fa74 100644 | |
--- a/lib/myapp_web/user_auth.ex | |
+++ b/lib/myapp_web/user_auth.ex | |
@@ -13,6 +13,10 @@ defmodule MyappWeb.UserAuth do | |
@remember_me_cookie "_myapp_web_user_remember_me" | |
@remember_me_options [sign: true, max_age: @max_age, same_site: "Lax"] | |
+ # Refresh the user_token and remember-me cookie every hour, so an active | |
+ # user will have their login credentials refreshed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_event("import", _params, socket) do | |
results = | |
consume_uploaded_entries(socket, :import, fn %{path: path}, _entry -> | |
temp_dir = Briefly.create!(type: :directory) | |
csv_file = Path.join(temp_dir, "import.csv") | |
# Attempt to create a new hard link to the file | |
case File.ln(path, csv_file) do | |
:ok -> | |
{:ok, csv_file} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Default1710Web.FormModalLive do | |
use Default1710Web, :live_view | |
def render(assigns) do | |
~H""" | |
<.live_component module={Default1710Web.InnerForm} id="form" /> | |
<button phx-click="open_modal">Open Modal</button> | |
<.modal :if={@show_modal} id="modal" show on_cancel={JS.push("close_modal")}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 1, | |
"address": "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts", | |
"enabled": 1, | |
"date_added": 1589393137, | |
"date_modified": 1678635720, | |
"comment": "Migrated from /etc/pihole/adlists.list", | |
"date_updated": 1696765562, | |
"number": 137890, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aapas | |
abaht | |
abeat | |
abeer | |
abeng | |
abeys | |
abius | |
abjad | |
abjud | |
abnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extend the `workon` command to include just random directories to CD into without activating | |
# a virtualenv. | |
# | |
# Source into .bashrc or .bash_profile | |
# | |
# source ~/custom_workon.sh | |
declare -A projects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.sessions.models import Session | |
class SessionAdmin(admin.ModelAdmin): | |
list_display = ('session_key', 'decoded_session_data', 'expire_date') | |
readonly_fields = ('decoded_session_data',) | |
exclude = ('session_data',) | |
ordering = ('expire_date',) | |
search_fields = ('session_key',) | |
def decoded_session_data(self, obj): |