Skip to content

Instantly share code, notes, and snippets.

@josefaidt
josefaidt / amplify-init.sh
Last active December 8, 2022 22:31
Minimal Amplify CLI headless init script
#!/bin/bash
set -e
IFS='|'
AMPLIFY_ENVIRONMENT='dev'
AWS_REGION='us-east-1'
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
@ljharb
ljharb / array_iteration_thoughts.md
Last active October 2, 2025 14:17
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@superKalo
superKalo / Sortable.jsx
Last active August 9, 2022 09:31
How to use jQuery UI with React JS? You can use this approach to integrate almost any jQuery plugin! Full details and explanation here: http://stackoverflow.com/a/40350880/1333836
class Sortable extends React.Component {
componentDidMount() {
// Every React component has a function that exposes the
// underlying DOM node that it is wrapping. We can use that
// DOM node, pass it to jQuery and initialize the plugin.
// You'll find that many jQuery plugins follow this same pattern
// and you'll be able to pass the component DOM node to jQuery
// and call the plugin function.
@reesscot
reesscot / Full_Width_Row.js
Created August 29, 2016 16:39
Add full width row to an element inside a fixed grid container. This is useful when you can't change the parent page's html structure to add a full width container, such as when the entire page is already inside of a B.S. Container div. Ideally you would solve this without JS, but sometimes that isn't possible or practical.
/**
* Add full width row to an element inside a fixed grid container
* Note: This is useful when you can't change the parent page's html structure to add a full width container,
* such as when the entire page is already inside of a B.S. Container div. Ideally you would solve this without JS,
* but sometimes that isn't possible.
*/
function renderFullWidthRow(size) {
let parentElement = document.querySelector('.parent-element');
let childElement = document.querySelector('.child-element');
let elStyles = window.getComputedStyle(parentElement);
@helderco
helderco / db-open
Created October 6, 2015 14:51
Script to open a mysql database in Sequel Pro from a service in docker-compose.
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.