View getRawSql.php
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
<?php | |
function getRawSql(string $sql, array $inputs) | |
{ | |
foreach ($inputs as $input) { | |
$index = strpos($sql, '?'); | |
$f = substr($sql, 0, $index); | |
$f .= is_string($input) ? "'" . $input . "'" : $input; | |
$t = substr($sql, $index + 1); | |
$sql = $f . $t; |
View instalacao.md
Instalação mongodb (1.1.8) com PHP5.6 (Ubuntu 14.04.5 LTS)
sudo apt-get install -y php5.6-dev
sudo apt-get install -y php-pear
sudo apt-get install -y pkg-config
sudo pecl channel-update pecl.php.net
sudo pecl install mongodb
View formata.sh
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
#!/bin/bash | |
function formata() | |
{ | |
local data="$1" | |
local dia="${data:(-2)}" | |
local mes="${data:5:2}" | |
local ano="${data:0:4}" |
View documento.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
https://github.com/andrewpuch/code-commit-setup |
View h.sh
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
# this should be included in .bashrc or /etc/profile | |
# this function extracts the hostname of a url | |
function h() | |
{ | |
[[ -z $1 ]] && echo "url deve ser fornecida" && return 1 | |
echo "$1" | sed -E 's#(ftp|https?)://## ; s#:[0-9]*##g ; s#/.*##' | |
} |
View pool.sql
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
SELECT | |
pool_name, | |
COUNT(*) AS total, | |
(SELECT | |
COUNT(*) | |
FROM | |
radius.radippool r2 | |
WHERE r1.pool_name = r2.pool_name | |
AND NASIPAddress <> '' | |
GROUP BY pool_name) AS allocated |