Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠

Rod Elias chapeupreto

🤠
View GitHub Profile
View getRawSql.php
<?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;
@chapeupreto
chapeupreto / instalacao.md
Created Feb 2, 2017
Instalação MongoDB com PHP5.6 no Ubuntu 14
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
@chapeupreto
chapeupreto / formata.sh
Last active Dec 17, 2016
formata data do padrao EUA para BR
View formata.sh
#!/bin/bash
function formata()
{
local data="$1"
local dia="${data:(-2)}"
local mes="${data:5:2}"
local ano="${data:0:4}"
View documento.txt
https://github.com/andrewpuch/code-commit-setup
View h.sh
# 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 / pool.sql
Created Nov 6, 2015
SQL query that shows the number of total and allocated IPs for each pool that exists in radippool table
View pool.sql
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