Skip to content

Instantly share code, notes, and snippets.

@rubys
rubys / articles_controller_test.c
Created May 17, 2026 23:33
articles_controller_test.c after spinel 8ca93b4 (regression on iv___session/iv___flash)
/* Generated by Spinel AOT compiler */
#include "sp_runtime.h"
/* sp_sym intern table */
#define SP_SYM_COUNT 112
static const char *const sp_sym_names[112] = {(&("\xff" "OK")[1]),(&("\xff" "ROW")[1]),(&("\xff" "DONE")[1]),(&("\xff" "sqlite3_open")[1]),(&("\xff" "str")[1]),(&("\xff" "ptr")[1]),(&("\xff" "int")[1]),(&("\xff" "sqlite3_close")[1]),(&("\xff" "sqlite3_exec")[1]),(&("\xff" "sqlite3_prepare_v2")[1]),(&("\xff" "sqlite3_step")[1]),(&("\xff" "sqlite3_finalize")[1]),(&("\xff" "sqlite3_column_int")[1]),(&("\xff" "sqlite3_column_text")[1]),(&("\xff" "sqlite3_column_count")[1]),(&("\xff" "sqlite3_column_name")[1]),(&("\xff" "sqlite3_errmsg")[1]),(&("\xff" "sqlite3_last_insert_rowid")[1]),(&("\xff" "long")[1]),(&("\xff" "sqlite3_changes")[1]),(&("\xff" "db_out")[1]),(&("\xff" "stmt_out")[1]),(&("\xff" "read_ptr")[1]),(&("\xff" "record")[1]),(&("\xff" "adapter")[1]),(&("\xff" "id")[1]),(&("\xff" "updated_at")[1]),(&("\xff" "created_at")[1]),(&("\xff" "verb")[1]),(&("\xff" "pattern")[1]),(&("\xff" "controller
@rubys
rubys / comment_test.c
Created May 17, 2026 23:33
comment_test.c after spinel 8ca93b4 (regression on iv___session/iv___flash)
/* Generated by Spinel AOT compiler */
#include "sp_runtime.h"
/* sp_sym intern table */
#define SP_SYM_COUNT 110
static const char *const sp_sym_names[110] = {(&("\xff" "OK")[1]),(&("\xff" "ROW")[1]),(&("\xff" "DONE")[1]),(&("\xff" "sqlite3_open")[1]),(&("\xff" "str")[1]),(&("\xff" "ptr")[1]),(&("\xff" "int")[1]),(&("\xff" "sqlite3_close")[1]),(&("\xff" "sqlite3_exec")[1]),(&("\xff" "sqlite3_prepare_v2")[1]),(&("\xff" "sqlite3_step")[1]),(&("\xff" "sqlite3_finalize")[1]),(&("\xff" "sqlite3_column_int")[1]),(&("\xff" "sqlite3_column_text")[1]),(&("\xff" "sqlite3_column_count")[1]),(&("\xff" "sqlite3_column_name")[1]),(&("\xff" "sqlite3_errmsg")[1]),(&("\xff" "sqlite3_last_insert_rowid")[1]),(&("\xff" "long")[1]),(&("\xff" "sqlite3_changes")[1]),(&("\xff" "db_out")[1]),(&("\xff" "stmt_out")[1]),(&("\xff" "read_ptr")[1]),(&("\xff" "record")[1]),(&("\xff" "adapter")[1]),(&("\xff" "id")[1]),(&("\xff" "updated_at")[1]),(&("\xff" "created_at")[1]),(&("\xff" "verb")[1]),(&("\xff" "pattern")[1]),(&("\xff" "controller
@rubys
rubys / _item.html.erb
Created June 11, 2024 13:43
Active Storage Demo - full files
<div id="<%= dom_id item %>">
<p class="my-5">
<strong class="block font-medium mb-1">Name:</strong>
<%= item.name %>
</p>
<p class="my-5">
<strong class="block font-medium mb-1">Contents:</strong>
<% if item.contents.attached? %>
<% if item.contents.content_type.start_with? 'image/' %>
@rubys
rubys / _item.html.erb.diff
Created June 11, 2024 13:39
Active Storage Demo - diffs
--- a/app/views/items/_item.html.erb
+++ b/app/views/items/_item.html.erb
@@ -6,7 +6,21 @@
<p class="my-5">
<strong class="block font-medium mb-1">Contents:</strong>
- <%= link_to item.contents.filename, item.contents if item.contents.attached? %>
+ <% if item.contents.attached? %>
+ <% if item.contents.content_type.start_with? 'image/' %>
+ <img src=<%= item.contents.url %> alt="<%= item.contents.filename %>">
m -rf drizzle-test
mkdir drizzle-test
cd drizzle-test
echo "{}" > package.json
npm install drizzle-orm pg
npm install -D drizzle-kit @types/pg typescript
echo "import { pgTable } from 'drizzle-orm/pg-core';" > test.ts
npx tsc test.ts
@rubys
rubys / Dockerfile
Created May 12, 2023 03:09
Barebones demo of ejs, express, node, npm, redis, pg, tailwindcss, typescript, and ws
# syntax = docker/dockerfile:1
FROM node:18-slim as base
# Node app lives here
WORKDIR /app
COPY <<-"EOF" package.json
{
"dependencies": {
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=19.7.0
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="Remix/Prisma"
# Remix/Prisma app lives here
WORKDIR /app
@rubys
rubys / live_elements_demo.sh
Last active March 27, 2023 23:10
Live Elements Demo
rails new livedemo --css tailwind
cd livedemo
bin/importmap pin @flydotio/stimulus-live-elements@0.1.0
echo 'export { default } from "@rubys/stimulus-live-elements"' > app/javascript/controllers/live_elements_controller.js
bin/rails generate controller demo
echo 'Rails.application.routes.draw {root "demo#button"; post "demo/click"}' >> config/routes.rb
cat <<-"EOF" > app/views/demo/_header.html.erb
<%= turbo_frame_tag "header", class: "block bg-#{color}-400 mb-4" do %>
<h1 class="font-bold text-4xl">Live button demo</h1>