Skip to content

Instantly share code, notes, and snippets.

View juanmaguitar's full-sized avatar

JuanMa juanmaguitar

View GitHub Profile
const { getBlockTypes, getBlockVariations } = wp.data.select('core/blocks');
getBlockTypes()
.filter(({ name }) => getBlockVariations(name).length)
.map(({ name }) => ({ [name]: getBlockVariations(name) }));
wp.data
.select('core/blocks')
.getBlockTypes()
.filter(({ name }) => !name.includes('core/'));
⬢  wp shell

wp> foreach ( wp_get_abilities() as $a ) echo $a->get_name() . "\n";

  core/get-site-info
  core/get-environment-info
  site/site-info
  list-all-urls/urls
// Helper: wait for all records of a given post type.
const getTypes = async ( types ) => {
return await Promise.all(
types.map(
( type ) =>
new Promise( ( resolve ) => {
const unsub = wp.data.subscribe( () => {
const items = wp.data
.select( 'core' )
.getEntityRecords( 'postType', type );
@vesse
vesse / express-jwt.js
Last active October 3, 2024 10:52
Two Passport + JWT (JSON Web Token) examples
//
// Implementation using express-jwt middle
//
var express = require('express'),
ejwt = require('express-jwt'),
jwt = require('jsonwebtoken'),
passport = require('passport'),
bodyParser = require('body-parser'),
LocalStrategy = require('passport-local').Strategy,
BearerStrategy = require('passport-http-bearer').Strategy;
@raddeus
raddeus / app.js
Last active February 4, 2025 09:42
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active October 27, 2025 08:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh