This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -rl $'\xEF\xBB\xBF' /srv/httpd/suapasta > /tmp/files_with_boms.txt | |
while read l; do sed -i '1 s/^\xef\xbb\xbf//' $l; done < /tmp/files_with_boms.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<?php | |
for ($i = 1; $i <= 10; $i++) | |
{ | |
echo guid() . "<br>"; | |
} | |
function guid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasLetterAndNumber($value) | |
{ | |
$hasLetters = preg_match('/[a-zA-Z]/',$value); | |
$hasNumbers = preg_match('/\d/',$value); | |
return $hasLetters && $hasNumbers; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Save into /usr/local/wtf_top.sh | |
#!/bin/sh | |
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n20 | |
2) Call into a cmdrunner wtfutil config | |
proccess: | |
title: Processos | |
type: cmdrunner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xml2array($xmlstring) | |
{ | |
$xml = simplexml_load_string($xmlstring); | |
$json = json_encode($xml); | |
return json_decode($json,TRUE); | |
} | |
function array2Xml($array, $rootElement = null, $xml = null) | |
{ | |
$_xml = $xml; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//generate a random string and return the substring of N chars at the end | |
var rnd = "ABCDEF23456789".split('').sort(function(){return 0.5-Math.random()}).join('').substring(0, 6); | |
//OUTPUT: | |
//BC3A095 | |
//C3FA295 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Count the access_log , group by ip and hits, sort by desc and cut to 50 top results | |
CC='\033[1;33m' | |
NC='\033[0m' | |
printf "Lista dos top ${CC}50${NC} enderecos IP e visitas na data de hoje\n" | |
echo "Baseado no arquivo /var/log/httpd/access.log" | |
cat /var/log/httpd/access.log | awk '{print $1}' | sort -t":" -k2,2 | uniq -c | sort -fr | head -n50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[abc] A single character: a, b or c | |
[^abc] Any single character but a, b, or c | |
[a-z] Any single character in the range a-z | |
[a-zA-Z] Any single character in the range a-z or A-Z | |
^ Start of line | |
$ End of line | |
\A Start of string | |
\z End of string | |
. Any single character | |
\s Any whitespace character |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Examples : | |
placeholder.php?size=200x100&bg=eee&fg=000&text=Hello | |
placeholder.php?size=200x100&bg=eee&fg=000 | |
placeholder.php?size=200x100 | |
<?php | |
$getsize = isset($_GET['size']) ? $_GET['size'] : '100x100'; | |
$dimensions = explode('x', $getsize); | |
$image = imagecreate($dimensions[0], $dimensions[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Assets | |
{ | |
const ASSETS_BANNER = 'banner'; | |
const ASSETS_BLOG = 'blog'; | |
const ASSETS_TEMPLATE = 'template'; | |
private static $constants; | |
public static function isConstant($value) | |
{ |
NewerOlder