Skip to content

Instantly share code, notes, and snippets.

View RodrigoPauletti's full-sized avatar
💻
Coding

Rodrigo Pauletti RodrigoPauletti

💻
Coding
View GitHub Profile
@ahmeti
ahmeti / only-number.directive.md
Last active September 18, 2024 02:44
Angular 5 - Only Number Input, Only Number Decimal
ngOnInit() {
this.form = this.fb.group({
'Xs': this.fb.array([
this.initX()
])
});
this.form.valueChanges.subscribe(data => this.validateForm());
this.validateForm();
}
<form [formGroup]="form">
<!-- X -->
<div formArrayName="Xs">
<div *ngFor="let X of form['controls'].Xs['controls']; let ix=index">
<div formGroupName="{{ix}}" class="Xs">
<input type="text" formControlName="X">
<p>{{ formErrors.Xs[ix].X }}</p>
<!-- Y -->
<div formArrayName="Ys">
<div *ngFor="let Y of X['controls'].Ys['controls']; let iy=index">
@rafael-neri
rafael-neri / validar_cpf.php
Last active March 6, 2025 11:02
Validar CPF em PHP (Completo)
<?php
function validaCPF($cpf) {
// Extrai somente os números
$cpf = preg_replace( '/[^0-9]/is', '', $cpf );
// Verifica se foi informado todos os digitos corretamente
if (strlen($cpf) != 11) {
return false;
@fgilio
fgilio / axios-catch-error.js
Last active February 27, 2025 05:50
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@davidalves1
davidalves1 / formatar_cnpj_cpf.md
Last active May 24, 2025 17:01
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $CPF_LENGTH = 11;
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === $CPF_LENGTH) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
@digitalkreativ
digitalkreativ / lumen-5-2-storage-facade-and-s3-storage.md
Last active May 15, 2022 07:21
Lumen 5.2 Storage facade and s3 storage #lumen

Lumen 5.2 Storage facade

To enable the Storage facade in Lumen 5.2 you need to modify a few things.

Filesystem configuration file

First of all you need to create a filesystems.php in a config folder.

The config folder needs to be at the same level as your app and bootstrap folder. If it's not there yet just create it.

@krambertech
krambertech / Component.jsx
Created July 2, 2016 10:44
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active November 11, 2020 17:26
Frete grátis por região (faixa de cep) - Woocommerce
<?php
//Testa uma faixa de cep
function checkCpfRange($valor, $intervalos) {
$v = (int) preg_replace("/\D+/", "", $valor);
foreach ($intervalos as $range):
list($min, $max) = $range;
if ($v >= $min && $v <= $max)
return true;
endforeach;
return false;
@lopspower
lopspower / README.md
Last active June 13, 2025 12:18
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store