Skip to content

Instantly share code, notes, and snippets.

View vcanales's full-sized avatar

Vicente Canales vcanales

View GitHub Profile
@vcanales
vcanales / deploy_theme.yml
Last active November 13, 2023 14:46
deploy_theme.yml
name: Deploy PR to GitHub Pages
on:
pull_request:
types: [opened, synchronize, ready_for_review]
jobs:
build-theme:
permissions:
actions: write
contents: read
@vcanales
vcanales / escape-patterns.js
Created August 28, 2023 19:10
Escape patterns
import { RewritingStream } from 'parse5-html-rewriting-stream';
import fs from 'fs';
import path from 'path';
import { table } from 'table';
function getPatternTable(themeSlug, patterns) {
const tableConfig = {
columnDefault: {
width: 40,
},
@vcanales
vcanales / github-oauth.php
Created July 19, 2023 23:06
WP Plugin + GitHub OAuth app
<?php
/**
* GitHub OAuth code.
*
* @package CreateBlockTheme
*/
add_action( 'init', 'github_oauth_init' );
function github_oauth_init() {
if ( isset( $_GET['github_oauth'] ) && $_GET['github_oauth'] == 'authorize' ) {
$client_id = 'GITHUB_CLIENT_ID'; // Replace with your GitHub Client ID
@vcanales
vcanales / updateGutenberg.sh
Last active July 9, 2023 21:49
Common sequence of commands run when developing for Gutenberg
#!/bin/bash
# Bash script that runs nvm and npm to update the gutenberg plugin
# and then runs the build script to build the plugin
# Usage: ./updateGutenberg.sh [--pull] [--no-build]
# --no-pull: pull from git before running npm
# --no-build: don't run the build script after running npm
PULL="false"
BUILD="true"
@vcanales
vcanales / README.md
Created April 7, 2021 15:05
Fetch provider, and context based request status.

Fetch Provider

A fetch wrapper that provides a function that allows obtaining the request status wherever it is used, through the React context API.

@vcanales
vcanales / .zshrc
Last active November 26, 2020 12:55
zsh PROMPT
export PROMPT="%(?.%F{green}➜.%F{red}➜)%f %n%B%F{#fff}@%m%f%b %F{green}%B%2~ %#%b%f "
version: '3'
services:
db:
image: postgres
ports:
- '5432:5432'
environment:
POSTGRES_USER: project_name
POSTGRES_PASSWORD: project_name
POSTGRES_DB: project_name
Bee Movie Script
According to all known laws
of aviation,
there is no way a bee
should be able to fly.
@vcanales
vcanales / exists.js
Last active January 22, 2020 03:53
Given an array of objects, check if for any member, the pair `key`, `value` exists
const readableExists = (array, key, value) => array.reduce((acc, obj) => {
if (obj[key] && obj[key] === value) {
return true;
}
return acc;
}, false);
const cleverExists = (array, key, value) => array.reduce((acc, obj) => {
return obj[key] && obj[key] === value || acc;
}, false);

Keybase proof

I hereby claim:

  • I am vcanales on github.
  • I am vcanales (https://keybase.io/vcanales) on keybase.
  • I have a public key ASBq2EhLiuptV1C7u7NJQHqzMi4xXpfJn1LPJ9nPqLYLZgo

To claim this, I am signing this object: