Skip to content

Instantly share code, notes, and snippets.

View tallesairan's full-sized avatar
🏠
Working from home

Talles Airan tallesairan

🏠
Working from home
View GitHub Profile
@tallesairan
tallesairan / pagseguro_error.js
Created December 13, 2018 12:19
Tabela de erros pagseguro
function erroPS($eV) {
let $err = '';
switch($eV)
{
case "5003": $err = "Falha de comunicação com a instituição financeira"; break;
case "10000": $err = "Marca de cartão de crédito inválida"; break;
case "10001": $err = "Número do cartão de crédito com comprimento inválido"; break;
case "10002": $err = "Formato da data inválida"; break;
case "10003": $err = "Campo de segurança CVV inválido"; break;
case "10004": $err = "Código de verificação CVV é obrigatório"; break;
@tallesairan
tallesairan / elastic_heartbeat.sh
Created March 10, 2023 15:49
Elasticsearch & Nginx Reverse proxy heartbeat
#!/bin/sh
# Your heartbeat URL here (must be hosted on this server)
URL_TO_CHECK="http://ngb1.ahvideoscdn.net"
# Your temp file to monitor downtime
DOWN_FILE="/root/site_down";
# How long will you tolerate downtime in minutes
DOWN_TIME="+0";
HTTP_STATUS=`curl -s -o /dev/null -w "%{http_code}" "$URL_TO_CHECK"`;
@tallesairan
tallesairan / remove_domains and emails from string.php
Created February 7, 2023 15:30
Remove texts and emails from string
<?php
function removeDomainsFromString($string){
return trim( preg_replace('/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i','',preg_replace('/[^@\s]*@[^@\s]*\.[^@\s]*/', '',$string)));
}
@tallesairan
tallesairan / mobileAndTabletcheck.js
Created October 1, 2018 14:40
check if is mobile and tablet javascript
window.mobileAndTabletcheck = function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01
@tallesairan
tallesairan / TextMinifier.php
Created August 4, 2022 19:52
Simple cache management on php scripts like wordpress super cache structure
<?php
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
\define($n . "\\token_string", '(?:"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\')');
@tallesairan
tallesairan / README.md
Last active August 4, 2022 14:35
Elasticsearch text classification
@tallesairan
tallesairan / README.md
Created August 3, 2022 15:39
OSX Text Tools

Merge files

Cd folder with all files

cat *.csv >combined.csv

Shuffle lines

perl -MList::Util=shuffle -e 'print shuffle();' < myfile > target_file

@tallesairan
tallesairan / jsx.js
Created March 11, 2020 15:11
jsx.js
! function(n) {
var o = null,
e = function() {
var t, e;
try {
t = window.top.document.getElementsByTagName("head")[0]
} catch (e) {
t = document.getElementsByTagName("head")[0]
}
t && ((e = t.getElementsByTagName("title")[0]) && (o = "textContent" in e ? e.textContent : "innerText" in e ? e.innerText : ""))
@tallesairan
tallesairan / pub_backup.sh
Created May 2, 2022 21:21
Create a new public_html wp backup
zip ./public_html/fb.zip ./public_html -r -x '*.html' -x '*.cache' -x '*.jpg' -x '*uploads/*' -x '*.log' -x '*.xml' -x '*.zip' -x '*.gz'
@tallesairan
tallesairan / url_slug.php
Created April 15, 2021 19:52 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.