Skip to content

Instantly share code, notes, and snippets.

@pch
pch / typeerror.md
Created February 2, 2024 07:51
Rails, Turbo, esbuild: TypeError: map.get is not a function

(This applies to Rails 7.1, Turbo 8.0 with esbuild and propshaft)

If you're getting a "TypeError: map.get is not a function" when navigating between pages:

Uncaught (in promise) TypeError: map.get is not a function
    at fetch (application-df30cd29ded7227ed5c827c81fa4fc9b51db518a.js:6485:20)
    at fetchWithTurboHeaders (application-df30cd29ded7227ed5c827c81fa4fc9b51db518a.js:1153:10)
    at FetchRequest.perform (application-df30cd29ded7227ed5c827c81fa4fc9b51db518a.js:1263:25)
fetch @ application-df30cd29ded7227ed5c827c81fa4fc9b51db518a.js:6485
@JoshCheek
JoshCheek / bad_ideas.rb
Created November 1, 2022 11:28
bad ideas
# https://twitter.com/josh_cheek/status/1587406334839889921
$**?$ # => ""
$**%$*$ # => ""
$**%** # => ""
$**%$$ # => ""
$_ = {}
alias $*$_
public def *(*) = itself
alias ** *
@JoshCheek
JoshCheek / most_allocated_objects.rb
Last active October 16, 2022 09:31
Finding locations of most allocated objects
require 'objspace'
def self.show_allocations(&block)
_ = ObjectSpace.trace_object_allocations &block
ObjectSpace
.each_object
.to_a
.filter_map do |obj|
file = ObjectSpace.allocation_sourcefile obj
line = ObjectSpace.allocation_sourceline obj
@alfg
alfg / README.md
Last active February 16, 2024 08:34
MP4 Parser example in Go.

Minimal MP4 Parser Example

  • Download MP4: https://github.com/alfg/mp4/blob/master/test/tears-of-steel.mp4?raw=true
  • Run
go run mp4_example.go tears-of-steel.mp4

go run mp4_example_2.go tears-of-steel.mp4
@aperture147
aperture147 / ffmpeg.go
Last active November 13, 2024 16:30
fix make buffer
package main
import (
"bytes"
"io/ioutil"
"log"
"os"
"os/exec"
)
@kany
kany / rails6-actioncable-stimulus.md
Last active May 28, 2024 09:26
Rails 6 + ActionCable + Stimulus example for pushing updates to the view.

Rails 6 + ActionCable + Stimulus example for pushing updates to the view.

This example will show how to push updates to the view for a Model instance that has changed without the user having to refresh the page.

This example focuses more on getting ActionCable working with Stimulus. If you don't already have stimulus setup in your app, here's a great write up on how to set it up: https://medium.com/better-programming/how-to-add-stimulus-js-to-a-rails-6-application-4201837785f9

Example scenario

  • You have a Scan model with attributes.
  • You have a ScanController#show action.
  • A user is viewing a Scan through the show.html.slim|haml|erb view template.
@kirillshevch
kirillshevch / rails_new_options_help.md
Last active October 31, 2024 14:00
List of "rails new" options to generate a new Rails 7 application

Run rails new --help to see all of the options you can use to create a new Rails application:

Output for Rails 7+

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated engines)
@NullVoxPopuli
NullVoxPopuli / deserialization.md
Last active October 9, 2019 20:30
ActiveModelSerializers vs jsonapi-rb Benchmarks
@przbadu
przbadu / react-on-docker.md
Last active May 12, 2024 15:34
Setup Docker for React development

STEP 2: setup docker to run react app (dev and production) configuration: https://gist.github.com/przbadu/929fc2b0d5d4cd78a5efe76d37f891b6

Setup Docker for React development

Because we are using Docker, we are not going to install node, npm, create-react-app in our development machine, not even for generating create-react-app scaffold.

For this purpose I am using 2-step docker configuration:

  • In first step, we will create a simple docker container, that does only one thing, install create-react-app

How to disable page caching with create-react-app

If you currently not using a service worker resulting in old production caches being used and users not getting new versions of the app.

src/index.js

Use:

import { unregister as unregisterServiceWorker } from './registerServiceWorker'