Skip to content

Instantly share code, notes, and snippets.

View skorasaurus's full-sized avatar

Will Skora skorasaurus

View GitHub Profile

This gist is a simple no-brainer description of the 3 ways (actually 2.5) the Web handle events.

<tag onclick />

The declarative inline HTML event listener is mostly an indirection of DOM Level 0 events, meaning this simply uses the equivalent of tag.onclick = listener behind the scene.

Example

click me
@TylerB24890
TylerB24890 / disable-variations.js
Created May 3, 2022 19:00
Disable Gutenberg Embed Block Variations
const { getBlockVariations, unregisterBlockVariation } = wp.blocks;
wp.domReady(() => {
const allowedEmbedBlocks = ['vimeo', 'youtube'];
getBlockVariations('core/embed').forEach(function (blockVariation) {
if (allowedEmbedBlocks.indexOf(blockVariation.name) === -1) {
unregisterBlockVariation('core/embed', blockVariation.name);
}
});
@ryanwelcher
ryanwelcher / theme.json
Created February 8, 2022 17:30
When adding theme.json to an existing Classic Theme, these settings will stop the default color and typography controls from being enabled.
{
"$schema": "http://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"layout": {
"contentSize": "750px"
},
"color": {
"background": false,
"custom": false,
@JasonTheAdams
JasonTheAdams / DynamicProperties.php
Last active November 15, 2021 19:02
A backwards-compatible trait for deprecated dynamic properties in 8.2
<?php
/**
* This is a very simple and basic trait for overcoming the deprectation of dynamic properties in 8.2, and broken in 9.0.
*
* If using a 8.2 or later, use the #[AllowDynamicProperties] attribute instead of this.
*
* I suggest this is better than traditional dynamic properties for the simple fact that it's excplicit and therefore
* intentional. If your class already has magic methods then you don't need this. This will work in 8.2 or later and as far
* back as 5.4, so it should cover most sensible cases.
@begroff
begroff / call-to-action.js
Created March 4, 2021 02:54
WordPress Editor Color Picker Style Issue
const { __ } = wp.i18n;
const { MediaUpload,
MediaUploadCheck,
RichText,
InspectorControls,
ColorPalette,
BlockControls,
AlignmentToolbar,
BlockAlignmentToolbar,
@Te-k
Te-k / pdf_metadata.md
Created November 26, 2020 10:31
How to remove metadata from PDFs

Many tools do not fully remove metadata, but just remove the link with in the metadata table. The data are thus still available in the PDF file itself.

While a lot of people rely on Exiftool to remove metadata, it actually does the same in PDFs. If you remove metadata with exiftool -all= some.pdf, you can always restore the data with exiftool -pdf-update:all= some.pdf.

There are several options to remove PDF metadata safely:

Option 1 : Exiftool with qpdf

  • Remove metadata with exiftool : exiftool -all= some.pdf
  • Then remove ununsed objects with qpdf : qpdf --linearize some.pdf - &gt; some.cleaned.pdf
@chriswhong
chriswhong / README.md
Created February 28, 2020 17:55
Using ogr2ogr to load a CSV into Postgres

The absolute easiest way to get a CSV into a postgresql table is to use ogr2ogr with AUTODETECT_TYPE=YES.

I learned a while back that this is what cartoDB uses to import your CSV into postgis (with a lot of other parameters added)

ogr2ogr -f PostgreSQL PG:"host=localhost user=postgres dbname=postgres password=password"  docs.csv -oo AUTODETECT_TYPE=YES
@rajinwonderland
rajinwonderland / stadiums.geojson
Created June 6, 2019 22:01
NFL Stadiums – GeoJson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 15, 2024 20:11
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@davewarfel
davewarfel / default-wordpress-blocks-sass.scss
Last active November 8, 2023 11:31
WordPress Blocks Styles - Cleaned Up, Commented & Sassified
/**
* WordPress Blocks
*
* Default block styling included with WordPress core.
* Provides a better starting point for WordPress theme developers,
* especially when using Sass.
*
* @link https://github.com/WordPress/WordPress/blob/master/wp-includes/css/dist/block-library/style.css
*
* Most styles from the above file are included.