Skip to content

Instantly share code, notes, and snippets.

View reggiegutter's full-sized avatar
🎯
Focusing

Reginaldo Gutter reggiegutter

🎯
Focusing
View GitHub Profile
@reggiegutter
reggiegutter / regex_celular.php
Created May 4, 2013 05:53
Regular expression (Regex) para validar números de telefones celulares para o Brasil, incluindo os novos números de celulares para São Paulo - que agora possuem o número 9 no início da primeira seção após o DDD (Exemplo: (11) 92222-2222).
<?php
// Função para checar número de telefone
function phone_check($phone)
{
$exp_regular = '/^(\(11\) (9\d{4})-\d{4})|((\(1[2-9]{1}\)|\([2-9]{1}\d{1}\)) [5-9]\d{3}-\d{4})$/';
$ret = preg_match($exp_regular, $phone);
if($ret === 1)
{
@reggiegutter
reggiegutter / check_date.php
Created May 4, 2013 06:19
Regular Expression (Regex) to validate date and the format of the date (dd/mm/yyyy). I use the regex to check if the data provided is in the required format. Then I use the PHP function checkdate($dd, $mm, $yyyy) to check if the values provided are right. For example, the function will return FALSE if the user provide a date like 30/02/2013, or …
<?php
// function to check dates
public function date_check($date)
{
$exp_regular = '/^(\d{2})[\/](\d{2})[\/](\d{4})/';
$ret = preg_match($exp_regular, $date, $matches);
if($ret === 1)
{
$dd = $matches[1];
@reggiegutter
reggiegutter / regex_telefone.php
Created May 4, 2013 06:38
Regular expression (Regex) para validar números de telefones no formato (XX) XXXX-XXXX para o Brasil.
<?php
// Função para checar número de telefone
function phone_check($phone)
{
$exp_regular = '/^\(\d{2}\)\s[2-5]\d{3}\-\d{4}$/';
$ret = preg_match($exp_regular, $phone);
if($ret === 1)
{
echo 'Número de telefone válido';
@reggiegutter
reggiegutter / combo_dinamico.html
Created July 26, 2017 07:31 — forked from ografael/combo_dinamico.html
Carregar combo com JQuery - Cidades e Estados
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.getJSON('estados_cidades.json', function (data) {
@reggiegutter
reggiegutter / closure-table-operations.sql
Created May 9, 2018 04:03 — forked from kentoj/closure-table-operations.sql
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors
@reggiegutter
reggiegutter / file.sql
Created May 9, 2018 04:03 — forked from emmanuel/file.sql
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors
@reggiegutter
reggiegutter / avdmanager.bat
Created September 1, 2021 15:33
Run AVD from terminal in windows machines
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=0
FOR /F "tokens=* USEBACKQ" %%F IN (`%ANDROID_HOME%\emulator\emulator.exe -list-avds`) DO (
SET /a count=!count!+1
SET var!count!=%%F
)
for /l %%i in (1,1,%count%) do echo %%i) !var%%i!
@echo digit number of virtual machine to run or 'q' to quit
set /p choice=""