Skip to content

Instantly share code, notes, and snippets.

View bbonamin's full-sized avatar
🕶️

Bruno Bonamin bbonamin

🕶️
View GitHub Profile
@machour
machour / remix.patch
Created May 1, 2023 12:05
Fixes compatibility with old devices
diff --git a/node_modules/@remix-run/dev/dist/compiler/compileBrowser.js b/node_modules/@remix-run/dev/dist/compiler/compileBrowser.js
index 517068e..2846c2a 100644
--- a/node_modules/@remix-run/dev/dist/compiler/compileBrowser.js
+++ b/node_modules/@remix-run/dev/dist/compiler/compileBrowser.js
@@ -87,6 +87,7 @@ const createEsbuildConfig = (config, options) => {
entryPoints,
outdir: config.assetsBuildDirectory,
platform: "browser",
+ target: ["safari12.1"] ,
format: "esm",
@mabenson00
mabenson00 / cheatsheet.rb
Last active May 3, 2024 22:40
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
@brandonpittman
brandonpittman / ProgressiveEnhancement.tsx
Created November 17, 2022 02:05
Progress enhancement helpers/components for Remix
import type { FetcherWithComponents, FormProps } from "@remix-run/react";
import type { ReactElement, ReactNode } from "react";
import { Form } from "@remix-run/react";
import { useHydrated } from "remix-utils";
export let NoJS = ({ children }: { children: ReactElement }) => {
let isHydrated = useHydrated();
if (!isHydrated) {
@bholtbholt
bholtbholt / _stimulus-helper.js
Last active May 2, 2024 13:50
Testing Stimulus with Jest in a Rails App. Stimulus isn't mounted before the test runs, so these helpers wrap the calls in async functions to fix race conditions.
// This helper file provides a consistent API for testing Stimulus Controllers
//
// Use:
// import { getHTML, setHTML, startStimulus } from './_stimulus_helper';
// import MyController from '@javascripts/controllers/my_controller';
//
// beforeEach(() => startStimulus('my', MyController));
// test('should do something', async () => {
// await setHTML(`<button data-controller="my" data-action="my#action">click</button>`);
//
@kaspermeyer
kaspermeyer / jquery_event_delegator.coffee
Created December 13, 2018 14:06
Dispatch jQuery events as regular DOM events
# ~ Dispatch jQuery events as regular DOM events ~
#
# Delegated events are given a new name in the format `jquery:<original event name>`.
# If you delegate `ajax:send` you will be able to listen for `jquery:ajax:send`
# on native event listeners such as Stimulus actions and `EventTarget.addEventListener`.
#
# Notes:
# * The first parameter must be called "event".
# * The parameters can be accessed as members on the `event.detail` object.
#
@stevenharman
stevenharman / 00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Last active March 11, 2024 04:11
Heroku Release Phase script for managing Rails DB migrations, and playing nice with Review Apps and postdeploy scripts

Heroku Release Phase + Review Apps + Rails

This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps. Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:

  1. Fail, loudly, if the DB does not yet exist.
  2. Load the DB schema if the current schema version (as determined by bin/rails db:version) is 0.
  3. Run DB migrations otherwise.

For a "normal" app that usually means it will run the DB migrations.

@andrewprogers
andrewprogers / reactRailsTestSetup.md
Last active October 9, 2018 23:26
Setting up A new React on Rails app with webpacker and full test suite

React on Rails with Test Suite (Karma, Jasmine, Enzyme, PhantomJS)

The steps included here detail the steps I followed to get a new React on Rails app set up, with a focus on testing JS components with Karma / Jasmine / Enzyme. A lot of this was liberally borrowed / modified from the Launch Academy curriculum, but there are some additional steps involved to get everything working with webpacker:

Unless otherwise specified, run the code in the terminal

Install Rails with Webpacker configured for React:

rails new project-name
cd project-name
@strzibny
strzibny / unused_routes.rb
Created May 5, 2016 15:21
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
@ramiabraham
ramiabraham / rom_suffix_codes.md
Last active April 27, 2024 13:28
Video game rom suffix codes (decoded)

Video game rom codes

You wouldn't download a car...


Primary rom codes

Probably what you're looking for

  • [a] Alternate (alternate version of the game, usually trying a different output method)
  • [p] Pirate
@dommmel
dommmel / dokku-pg-backup.sh
Last active September 16, 2020 08:03
dokku postgres backup cronjob (using https://github.com/Kloadut/dokku-pg-plugin)
#! /bin/bash
# directory to save backups in, must be rwx by postgres user
BASE_DIR="/var/backups/postgres"
YMD=$(date "+%Y-%m-%d")
DIR="$BASE_DIR/$YMD"
mkdir -p $DIR
cd $DIR
# make database backup