Skip to content

Instantly share code, notes, and snippets.

View fgilio's full-sized avatar

Franco Gilio fgilio

View GitHub Profile
@fgilio
fgilio / axios-catch-error.js
Last active February 11, 2026 16:18
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@fgilio
fgilio / SsPrechecks.php
Created January 14, 2026 13:54
ss-prechecks: SingleStore database metrics report for migration evaluation (like PlanetScale ps-prechecks)
<?php
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* SingleStore pre-checks command for migration evaluation.
@fgilio
fgilio / agently.php
Created June 2, 2025 18:54
Untested DRAFT of a basic coding agent built in PHP
<?php
declare(strict_types=1); // enforce strict typing so PHP catches bad stuff early
// Simple coding agent in a single PHP 8.4 file inspired by Radan Skorić's 94‑line Ruby agent.
// https://radanskoric.com/articles/coding-agent-in-ruby
// Gives OpenAI‑backed chat plus four tools: read_file, list_files, edit_file, run_shell_command.
// Every line is commented with the "why" to align with your preference.
$apiKey = getenv('OPENAI_API_KEY'); // Pull the API key from env vars for security and portability
if (!$apiKey) { // Fail fast if we can't talk to the model
@fgilio
fgilio / script.js
Created September 9, 2024 11:31
Bulk delete AWS DynamoDB items from AWS console
// Define a function that performs the desired actions
function executeActions() {
console.log("Executing actions...");
document.querySelector('[aria-label="Items selection"] input').click();
document.querySelector('button[id^=awsui-button-dropdown__trigger]').click();
document.querySelector('[data-testid="DELETE_ITEM_BUTTON_ID"]').click();
document.querySelector('[data-testid="submit-form"]').click();
console.log("Actions executed.");
}
@fgilio
fgilio / gitlab-mr-expand-and-collapse-all.css
Created September 2, 2024 11:41
GitLab MR "Expand and Collapse all"
.gitlab-mreca-top-0 {
top: 0 !important;
}
.gitlab-mreca-mr-version-controls-sticky {
position: sticky;
top: 72px;
z-index: 999;
padding-bottom: 3px;
background-color: white;
@fgilio
fgilio / wp-update_post-on-save_post.php
Last active April 17, 2024 22:34
WordPress - Update post programmatically when a post is saved
<?php
function update_on_post_saved( $post_id ) {
if ( wp_is_post_revision( $post_id ) ) return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
// if ('NNN' !== $_POST['post_type']) return; return if post type is not NNN
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'update_on_post_saved');
@fgilio
fgilio / remove-onclick.js
Created September 29, 2016 16:01
Remove onclick attribute from DOM element
document.getElementById('remove-onclick').removeAttribute("onclick");
@fgilio
fgilio / language-select-with-native-name.html
Created February 26, 2017 16:22
Language select with native names
<form class="languages go" method="get" action="#">
<label for="language">Other languages:</label>
<select id="language" class="autosubmit" name="lang">
<option title="English (US)" value="en-US">
English (US) (en-US)
</option>
<option title="Afrikaans" value="af">
Afrikaans (af)
</option>
<option title="Arabic" value="ar">
@fgilio
fgilio / .gitlab-ci.yml
Last active February 20, 2023 17:25
Override Laravel Vapor's Secrets management
stages:
- deploy
.setup_staging_env_file: &setup_staging_env_file |
echo "$STAGING_SECRETS" > staging_secrets.php
.setup_production_env_file: &setup_production_env_file |
echo "$PRODUCTION_SECRETS" > production_secrets.php
staging:
@fgilio
fgilio / .env.example
Last active July 7, 2022 20:04
Roots Bedrock variable webroot folder name
DB_NAME=database_name
DB_USER=database_user
DB_PASSWORD=database_password
DB_HOST=database_host
WP_ENV=development
WEBROOT_FOLDER_NAME=if_necessary
WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp