Skip to content

Instantly share code, notes, and snippets.

View parzibyte's full-sized avatar
💻
Coding

Parzibyte parzibyte

💻
Coding
View GitHub Profile
@parzibyte
parzibyte / imprimir.js
Last active November 10, 2022 02:52
Print QR on a thermal printer by using JavaScript client side - https://parzibyte.me/blog/2022/09/30/plugin-impresoras-termicas-version-3/
const imprimirQr = async (nombreImpresora) => {
const contenido = $qr.value;
if (!contenido) {
return alert("Escribe el contenido del QR");
}
const conector = new ConectorPluginV3(URLPlugin);
conector.Iniciar();
conector.ImprimirCodigoQr(contenido, 160, 2, ConectorPluginV3.TAMAÑO_IMAGEN_NORMAL);
conector.Iniciar(); //Nota: esto solo es necesario en ocasiones, por ejemplo en mi impresora debo hacerlo siempre que acabo de imprimir una imagen
conector.Feed(1);
const conector = new ConectorPluginV3(URLPlugin);
conector.Iniciar();
conector.EscribirTexto("Hola mundo\nParzibyte.me");
conector.Feed(1);
const respuesta = await conector
.imprimirEn(nombreImpresora);
if (respuesta === true) {
alert("Impreso correctamente");
} else {
alert("Error: " + respuesta);
from PyPDF2 import PdfFileMerger
pdfs = ["PdfFileWriter.pdf", "RectangleObject.pdf"]
nombre_archivo_salida = "salida.pdf"
fusionador = PdfFileMerger()
for pdf in pdfs:
fusionador.append(open(pdf, 'rb'))
with open(nombre_archivo_salida, 'wb') as salida:
Scanner sc = new Scanner(System.in);
int numero, multiplo;
System.out.println("Ingresa un número: ");
numero = sc.nextInt();
System.out.println("Ingresa un múltiplo: ");
multiplo = sc.nextInt();
if (numero % multiplo == 0) {
System.out.printf("%d es múltiplo de %d", numero, multiplo);
} else {
System.out.println("No es múltiplo");
#include <stdio.h>
#include <string.h>
int main(){
char cadena[] = "Hola,mundo",
delimitador[] = ",";
char *token = strtok(cadena, delimitador);
if(token != NULL){
printf("Encontramos un token: %s", token);
}
int main(void) {
int numero = 10, posibleMultiplo = 2;
// Comprobar
int resultado = esMultiplo(numero, posibleMultiplo);
if (resultado) {
printf("%d es multiplo de %d", numero, posibleMultiplo);
} else {
printf("%d NO es multiplo de %d", numero, posibleMultiplo);
}
}
Swal
.fire({
title: "Tu nombre",
input: "text",
showCancelButton: true,
confirmButtonText: "Guardar",
cancelButtonText: "Cancelar",
})
.then(resultado => {
if (resultado.value) {
<!--
El atributo enctype es importante, si no, no nos permitirá subir el archivo
-->
<form action="procesar.php" method="post" enctype="multipart/form-data">
<input type="file" name="archivo">
<br><br>
<input type="submit" value="Enviar">
</form>
private static void burbuja(int[] arreglo) {
for (int x = 0; x < arreglo.length; x++) {
// Aquí "y" se detiene antes de llegar
// a length - 1 porque dentro del for, accedemos
// al siguiente elemento con el índice actual + 1
for (int y = 0; y < arreglo.length - 1; y++) {
int elementoActual = arreglo[y],
elementoSiguiente = arreglo[y + 1];
if (elementoActual > elementoSiguiente) {
// Intercambiar
<?php
include_once "./vendor/autoload.php";
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>Hola mundo</h1><br><a href="https://parzibyte.me/blog">By Parzibyte</a>');
$dompdf->render();
$contenido = $dompdf->output();
$nombreDelDocumento = "1_hola.pdf";
$bytes = file_put_contents($nombreDelDocumento, $contenido);