Skip to content

Instantly share code, notes, and snippets.

View bfintal's full-sized avatar
🎯
Focusing

Benjamin Intal bfintal

🎯
Focusing
View GitHub Profile
@bfintal
bfintal / gist:9c25bf1975359de1a6c62adf259192dd
Last active August 31, 2026 17:36
Philippines National Expenditure Program (NEP) 2027 Budget Development Flags

FY2027 budget flags: will this budget help the country get richer?

Date: 31 August 2026. Figures re-checked against ph-budget on 1 September 2026. Dataset: ph-budget MCP, National Expenditure Program (NEP) FY2027 compared with the FY2026 GAA (the last budget Congress already passed). All amounts are exact Philippine pesos, shown here in billions or trillions. A higher score means Congress should look at that item again sooner.

Premise

The Philippines wants to stop being a poor country and help families live better lives.

@bfintal
bfintal / auto-block-recovery.js
Created September 29, 2021 12:54
Encountering lots of broken blocks / block errors in WordPress Gutenberg? Paste this code in your browser developer console while editing your post to recover all the blocks at once.
var recursivelyRecoverInvalidBlockList = blocks => {
const _blocks = [ ...blocks ]
let recoveryCalled = false
const recursivelyRecoverBlocks = willRecoverBlocks => {
willRecoverBlocks.forEach( _block => {
if ( isInvalid( _block ) ) {
recoveryCalled = true
const newBlock = recoverBlock( _block )
for ( const key in newBlock ) {
_block[ key ] = newBlock[ key ]
@bfintal
bfintal / query.sql
Created February 25, 2020 05:19
Remove duplicate entries in MySQL table when you have no unique IDs. Change `mytable` to the name of your table.
CREATE TABLE `temp` like `mytable`;
INSERT `temp` SELECT DISTINCT * FROM `mytable`;
DROP TABLE `mytable`;
ALTER TABLE `temp` RENAME `mytable`;
import { registerPlugin } from '@wordpress/plugins'
import { useEffect } from '@wordpress/element'
const doSomething = () => {
useEffect( () => {
// Do whatever when the block editor is initialized.
}, [] )
return null
}
import domReady from '@wordpress/dom-ready'
domReady( () => {
if ( window._wpLoadBlockEditor ) {
window._wpLoadBlockEditor.then( function() {
// Do whatever when the block editor is initialized.
} )
}
} )
add_action( 'wp_head', function () { ?>
<script>
window.addEventListener( 'scroll', function() {
const limit = document.body.classList.contains( 'home' ) ? 300 : 50
if ( ( window.pageYOffset || document.body.scrollTop ) > limit ) {
if ( ! document.body.classList.contains( 'is-scrolling' ) ) {
document.body.classList.add( 'is-scrolling' )
}
} else {
if ( document.body.classList.contains( 'is-scrolling' ) ) {
@bfintal
bfintal / functions.php
Created November 12, 2019 02:44
Stackable child theme
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-style' ),
wp_get_theme()->get( 'Version' )
);
}
@bfintal
bfintal / functions.php
Created September 30, 2019 09:51
Add this in your theme's functions.php to disable blog post image size generation in Stackable
<?php
// Disable blog post image size generation in Stackable.
remove_action( 'after_setup_theme', 'stackable_blog_posts_image_sizes' );
?>
.ugb-image-upload-has-placeholder[data-is-placeholder-visible="true"] {
display: flex !important;
}
setTimeout( function() {
var ttes = document.querySelectorAll( '.tte_wrapper' );
Array.prototype.forEach.call( ttes, function( el ) {
var typeAttr = el.getAttribute( 'data-effect' );
// Make the element visible and remove original text.
// Original text is for SEO.
var mid = el.querySelector( '.tte_mid' );
mid.innerHTML = '';
mid.style.opacity = '';