Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
Bacon//Pickle

Rob robacarp

🐢
Bacon//Pickle
View GitHub Profile
@robacarp
robacarp / fan-out-in.cr
Created May 7, 2023 02:11
Mosquito Fan-out-in example
View fan-out-in.cr
class FanOutInJob < Mosquito::QueuedJob
params(
root : String,
fan_state : String = "starting",
parent_job_id : String = "",
branch : String = ""
)
def perform
case fan_state
View builder.js
export default class Builder {
static tag(name, text) {
const tag = document.createElement(name)
tag.textContent = text
return tag
}
static link(href, text) {
const link = Builder.tag("a", text)
link.href = href
@robacarp
robacarp / crystal_lucky.md
Created October 6, 2021 01:52
Crystal+Lucky on M1
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 January 30, 2022 07:22
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 August 2, 2018 21:37
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"