Skip to content

Instantly share code, notes, and snippets.

View CoryDuncan's full-sized avatar
🖤

Cory Duncan CoryDuncan

🖤
View GitHub Profile
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active April 26, 2024 13:33
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@trepmal
trepmal / resize-original-upload.php
Last active September 30, 2020 10:38
resize new uploads to fit max dimensions
<?php
/*
Plugin Name: Resize Original Upload
*/
add_filter('wp_handle_upload', 'max_dims_for_new_uploads', 10, 2 );
function max_dims_for_new_uploads( $array, $context ) {
// $array = array( 'file' => $new_file, 'url' => $url, 'type' => $type )
// $context = 'upload' || 'sideload'
@stuntbox
stuntbox / gist:4557917
Last active March 23, 2023 03:32
Slightly smarter filtering to remove hard-coded width and height attributes from *all* images in WordPress (post thumbnails, images inserted into posts, and gravatars). Handy for responsive designs. Add the code below to the functions.php file in your theme's folder (/wp-content/themes/theme-name/ ). Remember to rename the function as needed to …
/**
* Filter out hard-coded width, height attributes on all images in WordPress.
* https://gist.github.com/4557917
*
* This version applies the function as a filter to the_content rather than send_to_editor.
* Changes made by filtering send_to_editor will be lost if you update the image or associated post
* and you will slowly lose your grip on sanity if you don't know to keep an eye out for it.
* the_content applies to the content of a post after it is retrieved from the database and is "theme-safe".
* (i.e., Your changes will not be stored permanently or impact the HTML output in other themes.)
*
@RichardBronosky
RichardBronosky / jquery.selectOptgroup.js
Created May 12, 2011 05:07 — forked from SmileyChris/jquery.selectOptgroup.js
Convert select boxes with optgroup elements into multiple select boxes. Registers itself as an onReady handler.
(function(jQuery) {
// adapted from the work of Chris Beaven https://gist.github.com/967775
jQuery.fn.selectOptgroup = function(options) {
var settings = jQuery.extend({
optSelect: '_options',
inBetween: '',
optBlank: null,
selectBlank: null,
keepOrphans: true,
showSpeed: 200
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')