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);
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.AccessLevel; | |
import lombok.Getter; | |
import lombok.NoArgsConstructor; | |
import lombok.RequiredArgsConstructor; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.regex.Pattern; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author Rodrigo Cananea <rodrigoaguiar35@gmail.com> | |
*/ | |
import java.awt.*; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import org.apache.poi.ss.usermodel.CellStyle; | |
import org.apache.poi.ss.usermodel.FillPatternType; | |
import org.apache.poi.ss.usermodel.Font; | |
import org.apache.poi.ss.usermodel.HorizontalAlignment; | |
import org.apache.poi.ss.usermodel.IndexedColors; | |
import org.apache.poi.ss.usermodel.Row; | |
import org.apache.poi.ss.usermodel.Sheet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.formdev.flatlaf.ui.FlatTextBorder; | |
import java.awt.Color; | |
import java.awt.Font; | |
import java.awt.FontMetrics; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import java.awt.Insets; | |
import java.awt.RenderingHints; | |
import javax.swing.BorderFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.EventQueue; | |
import java.awt.Font; | |
import java.awt.Graphics; | |
import java.awt.event.ComponentAdapter; | |
import java.awt.event.ComponentEvent; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
public class ELabelFontResize extends JLabel { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void abrirGaveta() { | |
javax.print.DocPrintJob dpj = PrinterService.getImpressoraPadrao().createPrintJob(); | |
javax.print.DocFlavor flavor = javax.print.DocFlavor.BYTE_ARRAY.AUTOSENSE; | |
//byte[] bematech = new byte[]{(byte) 29, (byte) 249, (byte) 32, (byte) 0, (byte) 27, (byte) 118, (byte) 140}; | |
byte[] epson = new byte[]{(byte) 27, (byte) 112, (byte) 0, (byte) 10, (byte) 100}; | |
javax.print.Doc doc = new javax.print.SimpleDoc(epson, flavor, null); | |
try { | |
dpj.print(doc, null); | |
//JOptionPane.showMessageDialog(null, "Gaveta aberta!", "Atenção", JOptionPane.INFORMATION_MESSAGE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Stopwatch; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.time.Duration; | |
import javax.swing.Timer; | |
/** | |
* | |
* @author Rodrigo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Days of limit | |
final int limitDays = 5; | |
List<File> files = Files.list(Paths.get("D:\Backup")) | |
.filter(Files::isRegularFile) // only files | |
.filter(path -> path.toString().endsWith(".zip") | |
|| path.toString().endsWith(".sql")) | |
// convert to milliseconds and compare | |
.filter(path -> LocalDateTime.ofInstant(Instant.ofEpochMilli(path.toFile().lastModified()), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.Component; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.MouseEvent; | |
import java.util.EventObject; | |
import javax.swing.JTable; | |
import javax.swing.SwingUtilities; | |
import javax.swing.text.JTextComponent; |
NewerOlder