Skip to content

Instantly share code, notes, and snippets.

View bspaulding's full-sized avatar

Bradley Spaulding bspaulding

View GitHub Profile
@jaredly
jaredly / cors-proxy.js
Created June 4, 2022 03:31
cloudflare worker CORS proxy
/**
* Usage:
* https://worker-name.myusername.workers.dev/?url=http://google.com
*/
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add: