Skip to content

Instantly share code, notes, and snippets.

@mcrumm
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
~H"""
<div>
View LG Smart-TV Blocklist Adlist (for PiHole)
127.0.0.1 us.rdx2.lgtvsdp.com
127.0.0.1 us.info.lgsmartad.com
127.0.0.1 us.ibs.lgappstv.com
# 127.0.0.1 us.lgtvsdp.com
127.0.0.1 ad.lgappstv.com
127.0.0.1 smartshare.lgtvsdp.com
127.0.0.1 ibis.lgappstv.com
# added after fork
# from https://www.reddit.com/r/pihole/comments/6qmpv6/blacklists_for_lg_webos_tvs/ and others
@mcrumm
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)
{:cont,
@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active January 15, 2024 07:49
Phoenix + SQLite Deployment tips
View phx_sqlite_fly_launch.md

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is 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
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 = {
Pickr
}
// ...
@mcrumm
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
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
mcrumm / pipeline.py
Created May 28, 2016 00:30
python collection pipeline example
View pipeline.py
def mapHits(doc):
source = doc['_source']
if len(source['occurrences']) < 1:
return None
occ = source['occurrences'][0]
return {
'name': source['name'],
'place': occ['place']
}
View docker-machine-nfs.sh
#!/bin/sh
#
# The MIT License (MIT)
# Copyright © 2015 Toni Van de Voorde <toni.vdv@gmail.com>
#
# 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
mcrumm / SocketClientCompatibilityTable.md
Last active March 8, 2016 05:38
ReactPHP socket-client version compatibility chart
View SocketClientCompatibilityTable.md

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