Skip to content

Instantly share code, notes, and snippets.

View bayareawebpro's full-sized avatar
✔️
Available for Consulting

Dan Alvidrez bayareawebpro

✔️
Available for Consulting
View GitHub Profile
abandoned
able
absolute
adorable
adventurous
academic
acceptable
acclaimed
accomplished
accurate
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@chasecmiller
chasecmiller / Plugin.php
Last active February 6, 2018 00:08
Wordpress - Materialized Path for Custom Post Types ( CPT ) and Built In Post Types
<?php
/*
Plugin Name: Materialized Paths
Plugin URI: http://crumbls.com
Description: Implement materialized paths for WordPress to enable simple searching for child and parent paths.
Author: Chase C. Miller
Version: 2.0.1a
Author URI: http://crumbls.com
Text Domain: Crumbls\Plugins\Materialized
*/
@chronon
chronon / ext.txt
Created February 18, 2017 15:38
List of docker-php-ext-install extension names
Possible values for ext-name:
bcmath
bz2
calendar
ctype
curl
dba
dom
enchant
@yajra
yajra / axios-401-response-interceptor.js
Last active September 20, 2023 06:24
Axios 401 response interceptor.
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@nasrulhazim
nasrulhazim / AppServiceProvider.php
Last active October 1, 2023 15:47
Laravel Base64 and Base64 Image Validator
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
@Paradoxis
Paradoxis / findReplace.php
Last active March 14, 2022 13:30
Find and replace double curly braces in PHP, example: findReplace("Hello, {{ name }}", "name", "John"); // "Hello, John" Raw
<?php
/**
* Parses a template argument to the specified value
* Template variables are defined using double curly brackets: {{ [a-zA-Z] }}
* Returns the query back once the instances has been replaced
* @param string $string
* @param string $find
* @param string $replace
* @return string
@ebramanti
ebramanti / uncle_bob_scribe_oath.md
Last active December 20, 2022 14:54
Uncle Bob Scribe's Oath

Uncle Bob - Scribe's Oath

  1. I will not produce harmful code.
    • I will not intentionally write code with bugs.
    • This means: Do your best.
  2. I will not produce code that's not my best.
  3. I will provide with each release a quick, testable & repeatable proof that the code works.
  4. I will not avoid release that will impede progress.
    • Short term rapid releases
  5. I will fearlessly and relentlessly improve the quality of code.
  • I will never make the code worse.
@djonsson
djonsson / install_elasticsearch_osx.md
Last active November 11, 2022 21:10
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@eduwass
eduwass / aux-functions.php
Last active August 11, 2022 05:21
Programmatically adding a Page item to a Wordpress nav menu
<?php
/**
* Adds Page to a WordPress navmenu
* @param [int] $page_id The ID of the page you want to add
* @param [str] $page_title Title of menu item
* @param [int] $menu_id NavMenu ID
* @param [int] $parent (Optional) Menu item Parent ID
*/
function add_page_to_menu($page_id, $page_title, $menu_id, $parent = 0){