Skip to content

Instantly share code, notes, and snippets.

View chapeupreto's full-sized avatar
🤠

Rod Elias chapeupreto

🤠
View GitHub Profile
@chapeupreto
chapeupreto / pool.sql
Created November 6, 2015 10:59
SQL query that shows the number of total and allocated IPs for each pool that exists in radippool table
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
@chapeupreto
chapeupreto / h.sh
Last active August 22, 2016 16:27
gethost
# 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#/.*##'
}
@chapeupreto
chapeupreto / documento.txt
Created September 20, 2016 12:04
Codecommit x Git
https://github.com/andrewpuch/code-commit-setup
@chapeupreto
chapeupreto / formata.sh
Last active December 17, 2016 00:02
formata data do padrao EUA para BR
#!/bin/bash
function formata()
{
local data="$1"
local dia="${data:(-2)}"
local mes="${data:5:2}"
local ano="${data:0:4}"
@chapeupreto
chapeupreto / instalacao.md
Created February 2, 2017 19:46
Instalação MongoDB com PHP5.6 no Ubuntu 14

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
@chapeupreto
chapeupreto / getRawSql.php
Last active February 27, 2018 15:26
obtem SQL crua
<?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;