Skip to content

Instantly share code, notes, and snippets.

@carlosleonam
carlosleonam / Docker with XDebug.md
Created October 25, 2024 01:12 — forked from megahirt/Docker with XDebug.md
Debugging PHP with XDebug v3 inside Docker using VSCode

Debugging PHP with XDebug v3 inside Docker using VSCode

Assumptions / Prerequisites

  • XDebug v3+ inside Docker (e.g. php:7.3-apache Docker image)
  • Running Docker v20.10+
  • VSCode with PHP Debug Extension (Felix Becker)
  • Using Docker Compose for orchestration

Objective

@carlosleonam
carlosleonam / wp-demo-snippet-latest.php
Created December 2, 2023 01:21 — forked from gridphp/wp-demo-snippet-latest.php
Wordpress Grid 4 PHP Framework Integration - Sample Snippet, https://www.gridphp.com
/**
* Grid 4 PHP Framework
*
* @author Abu Ghufran <[email protected]> - https://www.gridphp.com
* @version 2
* @date 20-Oct-2020
* @license: see license.txt included in package
*/
/*
@carlosleonam
carlosleonam / fn_remove_accents.sql
Created May 27, 2023 02:02 — forked from jgdoncel/fn_remove_accents.sql
MySQL Function to remove accents and special characters
DROP FUNCTION IF EXISTS fn_remove_accents;
DELIMITER |
CREATE FUNCTION fn_remove_accents( textvalue VARCHAR(10000) ) RETURNS VARCHAR(10000)
BEGIN
SET @textvalue = textvalue COLLATE utf8_general_ci;;
-- ACCENTS
SET @withaccents = 'ŠšŽžÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝŸÞàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿþƒ';
@carlosleonam
carlosleonam / is_localhost
Created April 22, 2023 11:35 — forked from troutacular/is_localhost
PHP - Check if localhost
// Check if we are in a local environment
function is_localhost() {
// set the array for testing the local environment
$whitelist = array( '127.0.0.1', '::1' );
// check if the server is in the array
if ( in_array( $_SERVER['REMOTE_ADDR'], $whitelist ) ) {
@carlosleonam
carlosleonam / .php
Created April 22, 2023 11:26 — forked from cupertinobr/.php
Add texto no footer - addFooterWidget
<?php
....
//Adicionar um texto ao footer do form
$addText = new TTextDisplay(FormService::getByAndAt($object), 'gray', 10, 'i');
$this->form->addFooterWidget($addText);
#!/usr/bin/env zsh
# -*- coding: UTF8 -*-
# Author: Guillaume Bouvier -- [email protected]
# https://research.pasteur.fr/en/member/guillaume-bouvier/
# 2017-08-25 14:59:30 (UTC+0200)
usage ()
{
echo "Usage"
@carlosleonam
carlosleonam / .php
Created January 25, 2023 15:26 — forked from fayqLs/.php
CLASSE PARA IMPORTAÇÃO DE XML NFe
<?php
class ImportacaoXmlNFe
{
protected $chave;
protected $xml;
protected $versao;
public function __construct($arquivo, $tipo = 'arquivo')
{
@carlosleonam
carlosleonam / get-ip-address-optimized.php
Created November 2, 2022 15:20 — forked from cballou/get-ip-address-optimized.php
PHP - Advanced Method to Retrieve Client IP Address
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
/**
* Returns an string clean of UTF8 characters. It will convert them to a similar ASCII character
* www.unexpectedit.com
*/
function cleanString($text) {
// 1) convert á ô => a o
$text = preg_replace("/[áàâãªä]/u","a",$text);
$text = preg_replace("/[ÁÀÂÃÄ]/u","A",$text);
$text = preg_replace("/[ÍÌÎÏ]/u","I",$text);
$text = preg_replace("/[íìîï]/u","i",$text);
version: '3.7'
# Networks
networks:
# Internal network
internal:
driver: bridge
# Volumes
volumes: