Skip to content

Instantly share code, notes, and snippets.

View crystal_lucky.md

Mac+M1+Crystal+Lucky

This is the series of steps I followed to get Crystal and Lucky running on a Mac M1 from scratch, as of Oct. 2021.

Prerequisites

  • Ensure ~/bin and /opt both exist.
  • /opt will have to be created with sudo but should be owned by your user.
  • Make sure your $PATH includes ~/bin. Doing so is up to you and will vary a bit depending on your shell.
@robacarp
robacarp / .gitignore.diff
Last active Jan 19, 2021
Lucky with Parcel Bundler
View .gitignore.diff
+public/_entrypoint.html
+public/*.js
+public/*.css
+public/*.map
View lucky_crystal.dockerfile
FROM crystallang/crystal:0.27.2
WORKDIR /opt/src
# Install nodejs
COPY bin ./bin
RUN bin/nodesource_11.x
RUN apt-get update && apt-get install -y nodejs
# npm install
View browser_action.cr
# src/actions/browser_action.cr
abstract class BrowserAction < Lucky::Action
include Lucky::ProtectFromForgery
include Auth::SessionManagement
include Auth::SessionEnforcement
require_logged_in!
expose current_user
View actions_auth_redirect_if_signed_in.cr
module Auth::RedirectIfSignedIn
macro included
include Auth::SkipRequireSignIn
before redirect_if_signed_in
# Most notably, this is removed everywhere. All actions now depend on a current_user.
# unexpose current_user
end
# ...
@robacarp
robacarp / stdin.cr
Created Aug 2, 2018
crystal single character read from stdin
View stdin.cr
print "Type something: "
entered_chars = [] of Char
STDIN.raw do
loop do
char = STDIN.read_char
next if char.nil?
View migrate_migrations.cr
##########################
# CONFIG
##########################
# select and require the appropriate database driver here:
require "pg"
# require "sqlite"
# require "mysql"
TABLE_NAME = "schema_version"
View db.cr
require "pg"
require "migrate"
require "../config/application"
command = ARGV[0]?
case command
when "migrate"
MigrationRunner.new.migrate
when "rollback"
View amber_build_test.sh
#!/usr/bin/env bash
set -e
cd amber
make install
cd ..
hr() {
text=${1:-}
@robacarp
robacarp / aa_rails_logs.txt
Last active Feb 9, 2018
Undoctored logs for Rails vs Amber speed comparison
View aa_rails_logs.txt
Started GET "/bookmarks" for 127.0.0.1 at 2018-01-11 10:48:37 -0700
Processing by BookmarksController#index as HTML
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Rendering bookmarks/index.html.haml within layouts/application
Rendered bookmarks/_navbar.html.haml (3.7ms)
Bookmark Exists (0.4ms) SELECT 1 AS one FROM "bookmarks" LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 0]]
Bookmark Load (0.4ms) SELECT "bookmarks".* FROM "bookmarks" ORDER BY "bookmarks"."created_at" ASC LIMIT $1 OFFSET $2 [["LIMIT", 25], ["OFFSET", 0]]
Webpage Load (0.4ms) SELECT "webpages".* FROM "webpages" WHERE "webpages"."id" IN ($1, $2, $3, $4, $5, $6) [["id", 1], ["id", 4], ["id", 5], ["id", 6], ["id", 7], ["id", 8]]
Tag Load (6.6ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 5]]
Rendered bookmarks/_bookmark_list_item.html.haml (49.5ms)