Skip to content

Instantly share code, notes, and snippets.

@on2air
on2air / same-table-backlinks.js
Last active May 20, 2023 08:49
Same Table Backlinks
@lucidBrot
lucidBrot / bookmarklet_image_dwl.js
Last active June 4, 2023 13:43
Bookmarklet to download all images on a page
// as one-liner for bookmarklet
javascript:;(function(){var images=[].slice.call(document.querySelectorAll('img'));try{images.forEach(function(img){downloadResource(img.src)})}catch(e){alert("Download failed.");console.log('Download failed.',e)}function forceDownload(blob,filename){var a=document.createElement('a');a.download=filename;a.href=blob;a.click()}function downloadResource(url,filename){if(!filename)filename=url.split('\\').pop().split('/').pop();fetch(url,{headers:new Headers({'Origin':location.origin}),mode:'cors'}).then(response=>response.blob()).then(blob=>{let blobUrl=window.URL.createObjectURL(blob);forceDownload(blobUrl,filename)}).catch(e=>console.error(e))}}).call(window);
@chrismccoy
chrismccoy / gutenberg.txt
Last active April 4, 2024 20:34
Gutenberg Resources
How to parse Gutenberg content for headless WordPress
https://kinsta.com/blog/headless-wordpress-gutenberg/
Adding wrapper to Gutenberg’s Table block
https://helloadmin.com/adding-wrapper-to-gutenbergs-table-block/
Display specific Gutenberg blocks of a post outside of the post content in the theme
https://florianbrinkmann.com/en/display-specific-gutenberg-blocks-of-a-post-outside-of-the-post-content-in-the-theme-5620/
Modifying the Markup of a Core Block
@jalcantarab
jalcantarab / _jsonPuller.md
Last active March 31, 2024 04:52 — forked from crstamps2/jsonPuller
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

@maugelves
maugelves / polylang.php
Last active June 11, 2021 05:56
This functions returns a WordPress page permalink for the current language by its slug.
<?php
/**
* This function returns a page permalink
* for the current website language.
*
* @author Mauricio Gelves <mg@maugelves.com>
* @param $page_slug string WordPress page slug
* @return string|false Page Permalink or false if the page is not found
*/
@philipnewcomer
philipnewcomer / generate-unique-username.php
Last active February 11, 2023 19:05
Generate a unique username in WordPress
<?php
/**
* Recursive function to generate a unique username.
*
* If the username already exists, will add a numerical suffix which will increase until a unique username is found.
*
* @param string $username
*
* @return string The unique username.
*/
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 16, 2024 12:32
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@donmccurdy
donmccurdy / wildcard-to-regexp.js
Last active February 21, 2024 06:49
Wildcard and glob matching in JavaScript.
/**
* Creates a RegExp from the given string, converting asterisks to .* expressions,
* and escaping all other characters.
*/
function wildcardToRegExp (s) {
return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
/**
* RegExp-escapes all characters in the given string.
const header = document.querySelector('.header');
const pageWrap = document.querySelector('.wrapper');
var lastScrollTop = 0;
function debounce(func, wait) {
let timeout;
return function(...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
@0xjac
0xjac / private_fork.md
Last active April 16, 2024 16:21
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git