Skip to content

Instantly share code, notes, and snippets.

View ajvillegas's full-sized avatar

Alexis J. Villegas ajvillegas

View GitHub Profile
@kadamwhite
kadamwhite / annotate-page
Last active July 17, 2024 17:54
Bookmarklet: Annotate or circle things on the webpage
javascript:'use strict'%3B(()%3D>%7Bfunction l(%7Bx%3Ae%2Cy%3Af%7D)%7Bconst a%3Ddocument.createElement("div")%3Ba.style.position%3D"absolute"%3Ba.style.display%3D"none"%3Ba.style.border%3D"7px dotted hotpink"%3Ba.style.borderRadius%3D"1rem"%3Ba.style.display%3D"block"%3Ba.style.height%3D0%3Ba.style.left%3D%60%24%7Be%7Dpx%60%3Ba.style.top%3D%60%24%7Bf%7Dpx%60%3Ba.style.width%3D0%3Bconst b%3Ddocument.createElement("DIV")%3Bb.classList.add("annotation-label")%3Bb.contentEditable%3D!0%3Bb.style.background%3D"rgba(255%2C255%2C255%2C0.9)"%3Bb.style.transform%3D"translateY(-60%25)"%3Bb.style.color%3D"hotpink"%3Bb.style.display%3D"inline-block"%3Bb.style.minWidth%3D"100px"%3Bb.style.padding%3D"0.25rem 0.5rem"%3Bb.style.marginLeft%3D"0.75rem"%3Bb.style.fontWeight%3D800%3Bb.style.fontSize%3D"24px"%3Bb.style.whiteSpace%3D"nowrap"%3Ba.appendChild(b)%3Bb.addEventListener("pointerdown"%2Cc%3D>%7Bc.stopPropagation()%7D)%3Ba.addEventListener("contextmenu"%2Cc%3D>%7Bc.preventDefault()%3Ba.remove()%7D)%3Bconst g%3Dc%3D>%7Ba.st
@lennardv2
lennardv2 / 1. Building PHP-MAMP on Apple Silicon M1.md
Last active October 3, 2024 20:29
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@cferdinandi
cferdinandi / middle-man.js
Last active July 17, 2021 15:29
A middleman API boilerplate for Cloudflare Workers. https://workers.cloudflare.com/
addEventListener('fetch', function (event) {
event.respondWith(handleRequest(event.request));
});
// Allowed domain origins
var allowed = ['http://localhost:8000', 'https://your-website.com'];
/**
* Respond to the request
* @param {Request} request
@pbearne
pbearne / block.js
Last active March 15, 2024 11:42
code to force server-side Gutenberg block to reload on a change to a Tax
/**
* BLOCK: serverside block that changes on page tax
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './editor.scss';
import './style.scss';
@lizheming
lizheming / svg-allowed-tags.json
Created June 29, 2019 08:09
SVG allowed tags
[
"br",
"div",
"span",
"font",
"b",
"a",
"altglyph",
"altglyphdef",
"altglyphitem",
@pento
pento / php-block.js
Last active September 5, 2024 01:58
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@seothemes
seothemes / customizer-additional-js.php
Last active July 20, 2018 03:19
Adds an Additional JS control to the Customizer and outputs the JS in the site footer.
<?php
/**
* Additional JS Customizer Control
*
* @author Lee Anthony
* @link https://seothemes.com
* @copyright Copyright © 2018 SEO Themes
* @license GPL-2.0-or-later
*/
@bph
bph / psl-theme-test.txt
Last active October 19, 2023 15:21
Blocks for Themes Test
<!-- wp:paragraph -->
<p><a href="https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e">https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e</a></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"className":"eplus-oOhLNH"} -->
<h2 class="eplus-oOhLNH">Common Blocks / Formatting / Layout Elements / Widgets and Embeds</h2>
<!-- /wp:heading -->
<!-- wp:list {"className":"eplus-eI3gin"} -->
<ul class="eplus-eI3gin"><li><a href="#images">Images</a> (Single image, cover image, gallery </li><li><a href="#quotes">Pull Quote / Quote</a></li><li><a href="#verse">Verse</a></li><li><a href="#buttons">Buttons</a></li><li><a href="#socialicons" data-type="internal" data-id="#socialicons">Social Icons</a></li><li><a href="#columns">Columns </a> Text (only) columns / Columns experimental</li><li><a href="#cover" data-type="internal" data-id="#cover">Cover</a> with CAT + button</li><li><a href="#paragraphs">Paragraph</a> </li><li><a href="#audio">Audio</a> </li><li><a href="#video">Video</a></li><li><a href="#w
@Shelob9
Shelob9 / serve-side-block.js
Last active February 4, 2024 20:38
Example Gutenberg block with server-side rendering. Gutenberg edit() block creates interface. Gutenberg saves settings automatically, the PHP function passed as `render_callback` to `register_block_type` is used to create HTML for front-end rendering of block.
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const el = wp.element.createElement;
registerBlockType( 'hiRoy/serverSide', {
title: __( 'Server Side Block', 'text-domain' ),
icon: 'networking',
category: 'common',
attributes: {
@westonruter
westonruter / add-customize-changeset-locked-notification-dismiss-button.js
Last active November 21, 2017 05:03
Add button to dismiss changeset locked notification in Customizer without taking over the lock from the other user
wp.customize.notifications.bind( 'add', function( notification ) {
if ( 'changeset_locked' === notification.code ) {
notification.render = (function( render ) {
return function() {
var li = render.call( notification ), button;
button = jQuery( '<button type="button" class="button button-secondary">Dismiss</button>' );
button.on( 'click', function() {
notification.parent.remove( notification.code );
} );
li.find( '.action-buttons' ).append( button );