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
@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
@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 / 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 / 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 / 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
*/
/**
* 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 / class_method_exists.php
Last active June 24, 2021 23:22
Checks if the class has been defined and Checks if the class method exists
/**
* Checks if the class has been defined and Checks if the class method exists
* @param $class_object
* @param $method_name
* @return bool
*/
function class_method_exists($class_object, $method_name)
{
return class_exists($class_object) && method_exists($class_object, $method_name);
}

# Loading Gifs for Buttons and Pages


Name View
Loading Bar loading_bar.gif
Loading Bar 2 loading_bar-2.gif
Loading Square loading_square.gif
Loading Spiner spinner.gif
@medeirosinacio
medeirosinacio / get_all_commits_count_from_user.js
Last active August 5, 2021 19:29
Easy way to calculate all commits count from one user
const base_url = 'https://api.github.com';
function httpGet(theUrl, return_headers) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
if (return_headers) {
return xmlHttp
}
return xmlHttp.responseText;
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=https://example.com.br">
<script type="text/javascript">
window.location.href = "https://example.com.br"
</script>
<title>Page Redirection</title>
</head>