Skip to content

Instantly share code, notes, and snippets.

View joshuacerbito's full-sized avatar
🔥
🎸🎛🎛🎚🔊

Joshua Cerbito joshuacerbito

🔥
🎸🎛🎛🎚🔊
View GitHub Profile
@joshuacerbito
joshuacerbito / example_usage.php
Last active January 30, 2024 17:06
How to include PDF in Wordpress Searches
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
if (get_post_mime_type() == 'application/pdf') {
// Customize how you display PDF files
echo '<a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a>';
} else {
@joshuacerbito
joshuacerbito / extend-react-props.tsx
Created September 13, 2023 11:00
Extend or use the props interface/type of any component
// extend basic react component props
// simply replace the type and add your props' types
interface PersonCardProps extends React.ComponentProps<typeof PersonCard> {
name: string;
age: number;
isAdmin: boolean;
}
// in this example we're writing a component named PersonCard
// with props name, age, and isAdmin
@joshuacerbito
joshuacerbito / lazy.css
Created August 30, 2023 11:38
This is a CSS file that I wrote back in 2013 and used on almost all of my FE projects for a couple of years. Does this approach look familiar? 😂 For historical purposes only. DO NOT USE THIS
/*-------------------------------------------------*/
/*----------------- LAZY.CSS v1.0 -----------------*/
/*-------- Joshua Cerbito (@joshuacerbito) --------*/
/*-------------------------------------------------*/
/* RESET ALL CONTAINERS */
html, body, div, table, tbody, tfoot, thead, tr, th, td, fieldset, form, label, legend,
section, article, aside, header, footer, hgroup, nav, audio, video, canvas, figure, figcaption, time, menu, details
{
margin: 0;
@joshuacerbito
joshuacerbito / main.yml
Last active May 5, 2023 11:40
Github Action for Flywheel deployment (via ssh) [2023-05-05]
name: Flywheel SSH Deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: "shivammathur/setup-php@v2"
@joshuacerbito
joshuacerbito / vercel.json
Created March 8, 2023 11:23
Config file for deploying Storybook to Vercel
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "npm run build-storybook",
"devCommand": "npm run storybook",
"installCommand": "npm install",
"framework": null,
"outputDirectory": "./storybook-static"
}
@joshuacerbito
joshuacerbito / awit-ng-bayan-guitar-solo.txt
Last active August 19, 2022 08:43
Awit ng Bayan Guitar Solo (CBAP-SOMA Christmas 2021 version)
E|--------------|------------------------|---------------------------------|-------------------------------|----------------------------------------------------------------|
B|--------------|------------------------|---------------------------------|-------------------------------|----------------12r11----11-12-14-12-11-12r11----11-------------|
G|-----4v-------|-6/8v-6-8v-6-8v-6h8/11v-|---------------------------------|---------------------------11v-|-13/15v-15v-15v-------13----------------------13----13-11----11-|
D|-4/6----6-4-6-|------------------------|-11v~~-13\11\9-11-11/13v-11-9----|-11/13-11-13v-11-13v-11-13-----|----------------------------------------------------------13----|
A|--------------|------------------------|------------------------------11-|-------------------------------|----------------------------------------------------------------|
E|--------------|------------------------|---------------------------------|-------------------------------|---------------------------------------------
@joshuacerbito
joshuacerbito / ensure.ts
Created July 7, 2022 21:18
[TS] ensure function to fix "T | undefined" from Array functions
function ensure<T>(argument: T | undefined | null, message: string = 'This value was promised to be there.'): T {
if (argument === undefined || argument === null) {
throw new TypeError(message);
}
return argument;
}
@joshuacerbito
joshuacerbito / tw-respond.scss
Created October 4, 2021 04:09
Allows shorthand notation for responsive tailwind styles
/**
Allows shorthand notation for responsive styles
USAGE:
.element {
@include tw-respond(
text-px12 leading-px22 font-bold, // First argument is always unnamed, for mobile styles
$md: text-px14 leading-px24, // Succeeding arguments should be named with screen variable
$lg2: text-px16 leading-px26
@joshuacerbito
joshuacerbito / bem-css-loader.js
Created August 16, 2021 12:29
Custom CSS Loader for BEM
const { getOptions } = require("loader-utils");
const camelCased = s => s && s.replace(/-([a-z0-9])/g, g => g[1].toUpperCase());
const localsMatcher = /exports\.locals\s=\s\{([\s\S]+)\};/g;
module.exports = function(source) {
// You can set the prefix used for the modifiers in the webpack config
const { modifierPrefix = "$" } = getOptions(this);
@joshuacerbito
joshuacerbito / getElementOffset.js
Last active May 10, 2022 02:43
Get an Element's Offset relative to the document
const getElementOffset = el => {
const rect = el.getBoundingClientRect(),
scrollLeft = window.scrollX || document.documentElement.scrollLeft,
scrollTop = window.scrollY || document.documentElement.scrollTop;
return {
top: rect.top + scrollTop,
left: rect.left + scrollLeft
}
}