Skip to content

Instantly share code, notes, and snippets.

View acfreitas's full-sized avatar

Antônio Carlos acfreitas

View GitHub Profile
@acfreitas
acfreitas / 000-default.conf
Last active November 20, 2017 23:58
Enable mod_rewrite
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
@acfreitas
acfreitas / Popup.php
Last active January 10, 2018 11:18 — forked from blazarecki/PopupDictionary.php
Working with popup and Behat/Mink
<?php
use Behat\Behat\Context\BehatContext;
/**
* Add Popup in Context
*/
class Popup extends BehatContext
{
/**
@acfreitas
acfreitas / imeiRandom.php
Last active August 29, 2015 14:10
Generator of aleatory IMEI code
/**
* Generates IMEI code valid and random
* Generates 14 aleatory digits. These 14, multiplies the multiples of 2 by 2 and sum the result
* The result Must be divisible by 10,
* Then get the diference and genaretes the last digit
*
* @return int $imei
*/
public function imeiRandom() {
$code = $this->intRandom(14);
@acfreitas
acfreitas / cpfCnpjRandom.php
Last active March 7, 2024 13:54
Gerador de CPF e CNPJ aleatório
/**
* Método para gerar CNPJ válido, com máscara ou não
* @example cnpjRandom(0)
* para retornar CNPJ sem máscar
* @param int $mascara
* @return string
*/
public static function cnpjRandom($mascara = "1") {
$n1 = rand(0, 9);
$n2 = rand(0, 9);
@acfreitas
acfreitas / intRandom.php
Last active August 29, 2015 14:10
Int Random
/**
* @param int $size
* @return interger
*/
public function intRandom($size) {
$validCharacters = utf8_decode("0123456789");
$validCharNumber = strlen($validCharacters);
$int = '';
while (strlen($int) < $size) {
$index = mt_rand(0, $validCharNumber - 1);
@acfreitas
acfreitas / stringRandom.php
Last active August 29, 2015 14:10
String Random
/**
* @param int $size
* @return string
*/
public function stringRandom($size) {
$validCharacters = utf8_decode("abcdefghijklmnopqrstuvxwzABCDFGHIJKLMNOPQRSTUVXWZ");
$validCharNumber = strlen($validCharacters);
$string = '';
while (strlen($string) < $size) {
$index = mt_rand(0, $validCharNumber - 1);
@acfreitas
acfreitas / isValidDate.php
Last active August 29, 2015 14:10
Check Date is valid
/**
* @param string $date
* @param string $format
* @return boolean
*/
public function isValidDate($date, $format = 'dd.mm.yyyy') {
if (strlen($date) >= 6 && strlen($format) == 10) {
// find separator. Remove all other characters from $format
$separator_only = str_replace(array('m', 'd', 'y'), '', $format);