Skip to content

Instantly share code, notes, and snippets.

View medeirosinacio's full-sized avatar
🤙
Stackoverflow Oriented Programming

Douglas Medeiros medeirosinacio

🤙
Stackoverflow Oriented Programming
View GitHub Profile
/**
* Simple multi-bytes ucfirst()
* @param $str
* @return string
*/
function mb_ucfirst_fix($str)
{
return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr(mb_strtolower($str), 1);
}
@medeirosinacio
medeirosinacio / get_contents.php
Created June 24, 2021 21:22
PHP If file_get_contents fails, do this instead
/**
* It's a modified file_get_contents()
* get_contents(filename, use_include_path, context, offset, maxlen)
* @param $url
* @param bool $u
* @param null $c
* @param null $o
* @return bool|string
* @package https://stackoverflow.com/questions/8673272/php-if-file-get-contents-fails-do-this-instead
*/
@medeirosinacio
medeirosinacio / filter_input_fix.php
Created June 24, 2021 21:21
FIX_BUG: filter_input() doesn't work with INPUT_SERVER or INPUT_ENV when you use FASTCGI
/**
* FIX_BUG: filter_input() doesn't work with INPUT_SERVER or INPUT_ENV when you use FASTCGI
* @param $type
* @param $variable_name
* @param int $filter
* @param null $options
* @return mixed|null
* @package https://stackoverflow.com/questions/25232975/php-filter-inputinput-server-request-method-returns-null/25385553
*/
function filter_input_fix($type, $variable_name, $filter = FILTER_DEFAULT, $options = null)
@medeirosinacio
medeirosinacio / true_scandir.php
Last active June 24, 2021 21:00
List true files and true directories inside the specified path in PHP
/**
* List true files and true directories inside the specified path
* @param $directory
* @return array
*/
function true_scandir($directory)
{
$result = [];
$cdir = scandir($directory);
foreach ($cdir as $key => $value) {
@medeirosinacio
medeirosinacio / regex.md
Last active June 9, 2022 14:20
Expressões Regulares | Regex de diversos tipos para agilizar o desenvolvimento

☎️ ​Telefone

Tipo Regex Testar
(12) 3456-7891 ou (12) 3456-78910 /^\(\d{2}\) \d{4}-\d{4,5}$/gi 🔍
1234567891 ou 12345678910 /^\d{10,11}$/gi 🔍



@medeirosinacio
medeirosinacio / hosts.rb
Created February 6, 2020 13:40 — forked from mangar/hosts.rb
ruby script to update hosts file
#!/usr/bin/env ruby
HOSTS_FILE = "hosts"
MY_HOSTS_FILE = "hosts.marciog"
ENTRY_MARK = "########## STARTING PERSONAL CONFIGURATION ##########\n"
def contains_entry?
contains = false