Skip to content

Instantly share code, notes, and snippets.

View juliancheal's full-sized avatar

Julian Cheal juliancheal

View GitHub Profile
@amirrajan
amirrajan / main.rb
Created May 28, 2024 20:58
DragonRuby Game Toolkit - Scene Management With Fade To Black
class RootScene < Scene
attr :game
def initialize
@game = Game.new
$game = @game
@world_scene = WorldScene.new
@embark_scene = EmbarkScene.new
@world_event_scene = WorldEventScene.new
@battle_scene = BattleScene.new
@tcannonfodder
tcannonfodder / tiptap_document.rb
Created January 7, 2024 00:06
Tiptap document renderer using Phlex
# prototype extracted from the Practical Framework
class PracticalFramework::Components::TiptapDocument < Phlex::HTML
class UnknownNodeTypeError < StandardError; end
class UnknownMarkupTypeError < StandardError; end
module NodeRendering
def render_node(node:)
case node[:type].to_sym
when :text
import {Controller} from '@hotwired/stimulus'
import {Editor} from "@tiptap/core"
import {Mention} from "@tiptap/extension-mention";
import StarterKit from "@tiptap/starter-kit"
export default class extends Controller {
static targets = ['input', 'suggestions']
connect() {
this.editor = new Editor({
@julianrubisch
julianrubisch / turbo_frame_history_controller.js
Last active May 8, 2021 02:39
Tabbed navigation with turbo
import { navigator } from "@hotwired/turbo";
import { Controller } from "stimulus";
import { useMutation } from "stimulus-use";
export default class extends Controller {
connect() {
useMutation(this, { attributes: true, childList: true, subtree: true });
}
mutate(entries) {
@quietsamurai98
quietsamurai98 / main.rb
Created September 23, 2020 05:09
DragonRuby Boids
# l to toggle lines
# space to reset
# left click to attract
# right click to repel
$TIME_FACTOR = 1.0
$X_WRAP = true
$Y_WRAP = true
# @param [GTK::Args] args
def tick(args)
require "app/strings.rb"
def undo_last_stroke(args)
args.state.counts.pop
stroke = args.state.counts.pop
args.state.commands.slice!(0 - stroke, stroke) if stroke
end
def tick(args)
args.state.help_layer ||= :shown
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@gimiki
gimiki / traefik_tcp_mqtt_mosquitto_docker_compose.md
Last active July 21, 2024 20:38
Traefik Reverse Proxy - Mosquitto MQTT Broker - Docker Container

This gist is to configure a Mosquitto MQTT Broker behind a Traefik reverse-proxy, both in a docker container. Mosquitto will be configuread as a TCP Service.

This is a simple configuration used on the same single server. Probably to be adapted for other cases. Having mosquitto behind a reverse proxy enables you to configure TLS on Traefik (likely you already do that for other applications as well) and to load balance different MQTT instances, but that goes beyond this gist.

As noted in Traefik docs, in the router you must use the rule HostSNI(`*`) when using non-TLS routers like in this example. Ref. https://docs.traefik.io/routing/routers/#rule_1

docker-compose.yml

@ftes
ftes / _error_messages.html.haml
Last active April 27, 2022 20:42
Rails bulma form builder with errors
-# layouts/_error_messages.html.haml
- if f.object.errors.any?
.notification.is-danger Please review the problems below:
- if f.object.errors[:base].present?
.notification.is-danger= f.object.errors[:base].join(', ')