Skip to content

Instantly share code, notes, and snippets.

mcrumm / component_under_test.ex
Last active February 26, 2024 13:20
Testing Phoenix.LiveComponent in Isolation
View component_under_test.ex
# lib/party_web/components/example_component.ex
defmodule PartyWeb.ExampleComponent do
@moduledoc """
An example LiveComponent under test.
use Phoenix.LiveComponent
def render(assigns) do
View LG Smart-TV Blocklist Adlist (for PiHole)
# added after fork
# from and others
mcrumm / intl.ex
Created July 11, 2022 21:41
Intl data via LiveView connect params
View intl.ex
defmodule MyAppWeb.Intl do
@moduledoc """
Loads internationalization info from socket.
import Phoenix.LiveView
def on_mount(:default, _params, _session, socket) do
cparams = get_connect_params(socket)
mcrumm /
Last active January 15, 2024 07:49
Phoenix + SQLite Deployment tips

Deploying to with SQLite

Deploying a Phoenix app to is a what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

mcrumm / app.js
Last active April 28, 2023 09:48
flatpickr + LiveView example
View app.js
// assets/js/app.js
// ...
import Pickr from "./pickr"
const hooks = {
// ...
mcrumm / page_live_test.exs
Created February 8, 2021 22:10
LiveView artifacts
View page_live_test.exs
defmodule MyAppWeb.PageLiveTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
@tag :tmp_dir
test "disconnected and connected render", %{conn: conn, tmp_dir: tmp_dir} do
{:ok, page_live, disconnected_html} = live(conn, "/")
assert disconnected_html =~ "Welcome to Phoenix!"
mcrumm / space.ex
Last active October 22, 2023 13:42
Get astronauts in space right now
View space.ex
defmodule Space do
@moduledoc """
Documentation for Space.
@doc """
Hello world.
## Examples
mcrumm /
Created May 28, 2016 00:30
python collection pipeline example
def mapHits(doc):
source = doc['_source']
if len(source['occurrences']) < 1:
return None
occ = source['occurrences'][0]
return {
'name': source['name'],
'place': occ['place']
# The MIT License (MIT)
# Copyright © 2015 Toni Van de Voorde <>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
mcrumm /
Last active March 8, 2016 05:38
ReactPHP socket-client version compatibility chart

These results are based on test connections to the Slack Realtime Messaging API, using PHP versions compiled from source on Mac OSX 10.11.2.

PHP Version wrapSecure ON wrapSecure OFF
5.5.0 👍 SSL Buffer Bug
5.5.19 👍 👍
5.5.23 😬 No connection! 😬 No connection!
5.5.25 👍 👍
5.5.30 👍 👍
5.6.3 👍 SSL Buffer Bug