Skip to content

Instantly share code, notes, and snippets.

@pmckee11
pmckee11 / GoogleButton.tsx
Last active February 13, 2023 14:21
New (Aug 2021) Google Sign In Button in React
import React, { FunctionComponent, useEffect, useState } from 'react';
import { Helmet, HelmetProvider, HelmetTags } from 'react-helmet-async';
const googleUrl = 'https://accounts.google.com/gsi/client';
export interface GoogleCredentialResponse {
credential: string;
}
interface GoogleButtonParams {
@bradtraversy
bradtraversy / mongodb_cheat_sheet.md
Last active April 25, 2024 22:38
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@nathanrice
nathanrice / modular-stylesheets.php
Last active April 11, 2020 14:36
A simple proof-of-concept for modularizing the CSS for each block, and linking it "just in time".
<?php
// this snippet requires PHP 5.3+
add_action( 'wp_enqueue_scripts', function() {
wp_register_style( 'atomic-blocks/ab-cta', '/path/to/atomic-blocks/css/ab-cta.css', array(), 1.0.0 );
} );
add_filter( 'render_block', function( $block_content, $block ) {
if ( 'atomic-blocks/ab-cta' === $block['blockName'] ) {
ob_start();
wp_print_styles( $block['blockName'] );
@roborourke
roborourke / wp-react-dev.php
Last active May 17, 2020 13:50
Get the development version of react in WordPress without needing a dev version of WP
<?php
/**
* Enable dev mode vendor packages.
*/
if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) {
return;
}
add_action( 'init', function () {
@wpscholar
wpscholar / .eslintignore
Last active March 14, 2022 10:21
Webpack 4 Config for WordPress plugin, theme, and block development
**/*.min.js
**/*.build.js
**/node_modules/**
**/vendor/**
build
coverage
cypress
node_modules
vendor
@ezirmusitua
ezirmusitua / group-same-image.py
Last active November 30, 2022 21:41
[Group similar images] Group similar images using phash algorithm #python #image #algorithm #tools
"""
This script use to group similiar images from source folder
and save to the same output folder, base on the perceptual hash algorithm.
Work on Python3.6 and win10-build-17074
Prerequest: Pillow
Author: jferroal@gmail.com
"""
import hashlib
import mimetypes
@JohannesDeml
JohannesDeml / README.md
Last active April 22, 2024 22:14
Batch convert images with inkscape on windows

Batch convert svg|pdf|eps|emf|wmf|ai|ps|cdr to eps|pdf|png|jpg|tiff|svg|ps|emf|wmf

Screenshot Batch converter for Windows using Inkscape with the command line
InkscapeBatchConvert is an easy to use solution to quickly convert all files of a folder to another type without the need to open Inkscape. The program uses Windows Batch scripting and will only work on Windows.
Tested with Inkscape 1.0.x - 1.3.x ✅ (The last version that supports Inkscape 0.9.x can be found here)

Usage

  1. Download _InkscapeBatchConvert.bat
  2. Put it in the folder where you have files you wish to convert (will also scan on all subfolders for files of input type).
  3. Then double click the file to start it.
@paulirish
paulirish / what-forces-layout.md
Last active April 25, 2024 21:49
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
// iMacro CheatSheet - Command Reference
// http://wiki.imacros.net/Command_Reference
// iMacros supports 3 types of variables:
// * The macro variables !VAR0 thru !VAR9. They can be used with the SET and ADD command inside a macro.
// * Built-in variables. They contain certain values set by iMacros.
// * User-defined variables. They are defined in-macro using the SET command.
@derekconjar
derekconjar / wordpress-firebase.php
Last active April 25, 2024 15:21
An example of using Firebase and WordPress together. The idea is to use WP's custom post types and metaboxes to make content management easy, and sync with Firebase so that your websites have access to a real-time JSON feed of your custom data.
<?php
/**
* All custom functions should be defined in this class
* and tied to WP hooks/filters w/in the constructor method
*/
class Custom_Functions {
// Custom metaboxes and fields configuration