Skip to content

Instantly share code, notes, and snippets.

@lubien
lubien / ecto_sqlite.livemd
Created April 5, 2024 12:18
ecto_sqlite livebook

Untitled notebook

Mix.install([
  {:liveview_playground, "~> 0.1.8"},
  {:phoenix_ecto, "~> 4.5"},
  {:ecto, "~> 3.11"},
  {:ecto_sqlite3, "~> 0.13"}
])
@c0m4r
c0m4r / freebsd_hetzner_cloud_vps.md
Last active November 16, 2025 08:23
FreeBSD installation on Hetzner Cloud VPS
@adtac
adtac / Dockerfile
Last active July 13, 2025 20:06
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@cywang117
cywang117 / delete-device-config-var-overrides.js
Last active May 2, 2024 18:41
For large balena fleets, it may be necessary to run this from the Chrome dev console.
// This script may be run in a Chrome dev console, and will delete all the device config variables for each device in a fleet,
// which the exception of *_SUPERVISOR_DELTA or *_SUPERVISOR_DELTA_VERSION.
await (async () => {
// Make sure FLEET_ID is the ID of your fleet.
const FLEET_ID = 12345;
// Get devices in fleet
const devices = await sdk.models.device.getAllByApplication(FLEET_ID, {
$select: 'id',
});
@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active October 9, 2025 12:37
Phoenix + SQLite Deployment tips

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

@cywang117
cywang117 / preload-any-supervisor-version-onto-balena-os.md
Last active September 3, 2024 13:31
Preload any Supervisor onto balenaOS image

Replace loopN with loop number listed with partx command

Download & mount .img

balena os download raspberrypi4-64 -o rpi4.img
losetup -fP --show rpi4.img
mount /dev/loopNp6 $MOUNTPOINT 

If the mount fails with wrong fs type or similar, this is most likely because the image is a flasher image (i.e. for Intel NUC, for example), and you will need to do the following:

@keatz55
keatz55 / index.ex
Last active April 12, 2021 17:49
LiveView Query Helper Module
defmodule ExampleWeb.ArticleLive.Index do
alias Example.{Articles, Tags}
alias ExampleWeb.{ArticleLive, ComponentLive, Query}
use ExampleWeb, :live_view
@impl true
def render(assigns) do
~L"""
<div class="container max-w-screen-md mx-auto pt-6">
@vinicius73
vinicius73 / Dockerfile
Last active August 15, 2019 22:21
Node project with PM2 and Docker
FROM node:10.15-alpine as base
RUN apk --no-cache --virtual build-dependencies add \
python \
make \
g++ \
&& rm -f /var/cache/apk/* \
&& npm config set unsafe-perm true \
&& npm install --quiet node-gyp -g --cache /tmp/empty-cache
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active December 3, 2025 20:57
set -e, -u, -o, -x pipefail explanation
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 28, 2024 00:44
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};