Skip to content

Instantly share code, notes, and snippets.

View natanfelles's full-sized avatar
💥
Hunting bugs!

Natan Felles natanfelles

💥
Hunting bugs!
View GitHub Profile
@natanfelles
natanfelles / Compress HTML output.md
Last active May 29, 2025 23:27
Editing Compress HTML output

Source: https://github.com/bcit-ci/CodeIgniter/wiki/Compress-HTML-output

To remove useless whitespace from generated HTML, except for Javascript see [Regex Source] or just replace the $re value:

$re = '%# Collapse ws everywhere but in blacklisted elements.
        (?>             # Match all whitespaces other than single space.
          [^\S ]\s*     # Either one [\t\r\n\f\v] and zero or more ws,
        | \s{2,}        # or two or more consecutive-any-whitespace.
        ) # Note: The remaining regex consumes no text at all...
@natanfelles
natanfelles / parse_link_header.md
Last active January 31, 2025 14:31
Parse Link Header
@natanfelles
natanfelles / Access.php
Created December 14, 2016 19:51
CodeIgniter Strong Password Validation
<?php
/**
* @author Natan Felles <natanfelles@gmail.com>
*/
defined('BASEPATH') or exit('No direct script access allowed');
/**
* Class Access
*/
class Access extends CI_Controller {
@natanfelles
natanfelles / Install-xdebug-php7.1.md
Created January 11, 2018 20:59 — forked from asanikovich/Install-xdebug-php7.1.md
Installing xdebug for php7.1 on Ubuntu 14.04

Install xdebug extension

# Download stable release of xdebug from https://xdebug.org/download.php
wget -c "https://xdebug.org/files/xdebug-2.5.3.tgz"
# Extract archive
tar -xf xdebug-2.5.3.tgz

cd xdebug-2.5.3/
@natanfelles
natanfelles / theme_darcula.xml
Created June 13, 2016 14:48
gedit darcula theme
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme id="darcula" _name="Darcula" version="1.0">
<author>Sash0k</author>
<_description>Dark color scheme using IntelliJ IDEA colors</_description>
<!-- Scribe Theme Generator 1.3 -->
<!-- COLORS -->
<color name="comment_color" value="#629755"/>
@natanfelles
natanfelles / domain.tld.conf
Last active May 12, 2024 03:51
Nginx Virtual Host example to work on localhost
# Location: /etc/nginx/sites-available/domain.tld.conf
server {
listen 80;
# listen 443 ssl;
# include snippets/snakeoil.conf;
root /var/www/domain.tld/public;
index index.html index.php;
@natanfelles
natanfelles / text_helper.php
Created February 20, 2020 23:12
HTML Purifier Helper for TinyMCE
<?php
/**
* @param string $content
*
* @return string
*/
function purify(string $content) : string
{
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.AllowedElements', [
@natanfelles
natanfelles / atom-php.md
Last active January 25, 2024 03:48
Atom PHP Environment + CodeIgniter 3 & 4

Atom PHP Environment + CodeIgniter 3 & 4

Atom Editor

Install

Download and install Atom Editor:

cd ~/Downloads
@natanfelles
natanfelles / db_helper.php
Last active August 18, 2023 03:15
CodeIgniter Database Helper to Add and Drop Foreign Keys and Triggers
<?php
/**
* @author Natan Felles <natanfelles@gmail.com>
*/
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('add_foreign_key'))
{
/**
* @param string $table Table name