Skip to content

Instantly share code, notes, and snippets.

#
# Proof of concept - import maps with JSX transpilation. Can trivially
# be extended to TypeScript and all the languages currently supported
# with Sprockets.
#
# There are two parts to this:
# * Have `find_javascript_files_in_tree` in importmap-rails to not only
# find JS files, but also files that can be transpiled to JS.
# * Add sprockets JSX transformer, making use of esbuild
#
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>
const icalgen = require('ical-generator');
const fs = require('fs').promises;
const path = require('path');
const deepEqual = require('deep-equal');
const input = '/home/rubys/svn/www.apachecon.com/acah2020/tracks';
const output = '/home/rubys/svn/www.apachecon.com/acah2020/calendar';
// Configure babel
require('@babel/register')({
rm -rf multisvn
mkdir multisvn
cd multisvn
mkdir repo
svnadmin create repo/r1
# initial setup
svn checkout file://$(pwd)/repo/r1
mkdir -p r1/foo/bar
touch r1/foo/bar/file1
@rubys
rubys / html.diff
Created June 28, 2018 19:42
Instrumenting tools/doc/html.js for performance analysis
diff --git a/tools/doc/html.js b/tools/doc/html.js
index 974eab769c..b4153c4eee 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -53,6 +53,8 @@ function navClasses() {
}
}
+let start = new Date().getTime();
+