This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple javascript to explore the React stateState function paradigm | |
node react_state_fn_upd_explore.js | |
Explore the second form of setState() that accepts a function rather than an | |
object. This is needed because React can batch state updates and | |
asynchronous state updates mean you need a function that receives its | |
current value before using values from it to set the next state | |
values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: this a partial copy of some working code from a working Rails app | |
# *However* it hasn't been tested on it's own, shown here as an example of | |
# using ActiveModel::Model as an alternative to ActiveRecord when you don't | |
# need the DB | |
class ContactRequest | |
include ActiveModel::Model | |
def self.define_sanitized_attr(attr) | |
define_method(attr) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController < ApplicationController | |
# ... | |
def search_all | |
return unless (@search_phrase = search_phrase_or_redirect) | |
doc_types = %w[Episode ForumPost Series] | |
notification_payload = { action: "search_all", search_phrase: @search_phrase, | |
doc_types: doc_types, pagy_limit: RESULT_PAGE_SIZE } | |
ActiveSupport::Notifications.instrument('search_render', notification_payload) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "app_name_here", | |
"private": true, | |
"engines": { | |
"yarn": "1.22.10", | |
"node": "14.16" | |
}, | |
"dependencies": { | |
"@rails/actioncable": "^6.0.0", | |
"@rails/activestorage": "^6.0.0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
DEFAULT_FIELD_IDS = <<-'RUBY' | |
<div class="field"> | |
<%= form.label :author_id %> | |
<%= form.text_field :author_id %> | |
</div> | |
<div class="field"> | |
<%= form.label :plot_id %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>RefresherDemo</title> | |
<%= csrf_meta_tags %> | |
<%= csp_meta_tag %> | |
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | |
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "@hotwired/stimulus" | |
import { PlaybackManager } from "../helpers/playback_manager"; | |
export default class MusicController extends Controller { | |
static values = { | |
previewUrl: String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8:37:40 web.1 | started with pid 360745 | |
18:37:40 worker.1 | started with pid 360746 | |
18:37:40 js.1 | started with pid 360747 | |
18:37:40 css.1 | started with pid 360748 | |
18:37:40 css.1 | yarn run v1.22.15 | |
18:37:40 js.1 | yarn run v1.22.15 | |
18:37:40 css.1 | $ sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch | |
18:37:40 js.1 | $ node esbuild.config.js --watch | |
18:37:40 css.1 | Sass is watching for changes. Press Ctrl-C to stop. | |
18:37:40 css.1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem 'open-uri' | |
gem 'async' | |
gem 'async-http' | |
gem 'httparty' | |
gem 'redis' | |
# gem 'net-ssh' | |
gem 'sequel' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BenchIt | |
require 'benchmark' | |
ITERATIONS = 100_000 | |
def self.run_benchmark_multi(methods, arg_arrays, iterations=ITERATIONS, verbose=false) | |
methods.each do |method| | |
puts "\n#{method} iterations:#{iterations}:\n" | |
Benchmark.bm do |x| | |
x.report do | |
iterations.times do |i| |
OlderNewer