Skip to content

Instantly share code, notes, and snippets.

View reggiegutter's full-sized avatar
🎯
Focusing

Reginaldo Gutter reggiegutter

🎯
Focusing
View GitHub Profile
@emmanuel
emmanuel / file.sql
Created June 2, 2011 07:54
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 / 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';
@erikhenrique
erikhenrique / bin-cc.md
Last active June 30, 2024 22:14
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
@kentoj
kentoj / closure-table-operations.sql
Last active December 31, 2021 07:12 — 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
@a-tokyo
a-tokyo / envFileToJS.js
Created March 12, 2020 17:49
Converts a .env file to a .env.js file
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
/**
* Writes bash env variables to a .env.js file
*/
// const _bashEnvToEnvFileJs = () => {
// /** Destination Env file path */