Skip to content

Instantly share code, notes, and snippets.

module YieldsMembers
module ClassMethods
def yields_members_for(*method_names)
module_eval do
# method_names.each do |method_name|
binding.pry
define_method :add do |*members, &proc|
puts "IN PREPENDED MODULE"
binding.pry
super members
module YieldsMembers
module ClassMethods
mattr_accessor :method_names
def yields_members_for(*method_names)
self.method_names = method_names
end
end
def initialize(...)
super(...)
@julianrubisch
julianrubisch / content-element-input.js
Created June 24, 2021 07:12
contenteditable lit-element
import { LitElement, html, css } from "lit";
import { property, customElement } from "lit/decorators.js";
@customElement("content-element-input")
class ContentElementInput extends LitElement {
@property({ type: Boolean })
contentEditable = true;
@property({ type: String })
placeholder = "";
URI.open(url) do |uri|
base_uri = uri.base_uri
listable_type = case base_uri.to_s
when /soundcloud.com\/(?<artist>.+)\/tracks/
raise UnparsableTrackUrlError
when /soundcloud.com\/(?<artist>.+)\/sets\/(?<title>.+)/
SoundCloudPlaylist
when /soundcloud.com\/(?<artist>.+)\/(?<title>.+)/
SoundCloudTrack
<!-- app/views/boards/_board.html.erb -->
<ul class="..."
data-controller="board"
data-board-signed-resource-value="<%= board.to_sgid.to_s %>"
id="<%= dom_id(board) %>">
<!-- ... -->
</ul>
<!-- app/views/boards/_board.html.erb -->
<ul class="..."
data-controller="board"
data-board-signed-resource-value="<%= board.to_sgid.to_s %>"
id="<%= dom_id(board) %>">
<!-- ... -->
</ul>
import { Controller } from "stimulus";
import { get } from "@rails/request.js";
import { PageSnapshot } from "@hotwired/turbo";
export default class extends Controller {
static values = { hoverTime: Number };
connect() {
this.element.addEventListener("mouseover", this.prefetch.bind(this));
this.element.addEventListener("touchstart", this.prefetch.bind(this));
}
// useIdle
away(event) {
consumer.subscriptions.add(this.presenceChannel);
}
back(event) {
this.presenceChannel.unsubscribe();
}
class LocaleReflex < ApplicationReflex
def switch
@locale = element.value
end
end
class ApplicationController < ActionController::Base
around_action :switch_locale
def switch_locale(&action)
@julianrubisch
julianrubisch / 0_perf.sc
Last active September 29, 2021 19:23
Supercollider OOP - Part 1: Classes
(
Server.killAll;
~num_buffers = 4;
~num_channels = 12;
~rec_end = ~num_buffers.collect { 0 };
~gtranspose = ~num_buffers.collect { 0 };
~density = ~num_buffers.collect { 0.0 };
~stretch = 1.0;