Skip to content

Instantly share code, notes, and snippets.

View parzibyte's full-sized avatar
💻
Coding

Parzibyte parzibyte

💻
Coding
View GitHub Profile
await fetch("http://localhost:8000/imprimir_en", {
method: "POST",
body: JSON.stringify({
impresora: "TEST",
operaciones: [{accion: "write", datos: "Datos de prueba\n\nSalto de linea\n"}]
})
})
/*
Cliente HTTP en Go con net/http
Ejemplo de petición HTTP Get en Golang
@author parzibyte
*/
package main
import (
"io/ioutil"
"log"
@parzibyte
parzibyte / averiguar_host.go
Created July 25, 2021 13:58
Averiguar host de petición HTTP con Go
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"strings"
)
public static int minimoComunMultiplo(int a, int b) {
// Y ahora aplicamos la fórmula que dice:
// MCM(a, b) = (a * b) / MCD(a, b)
return (a * b) / maximoComunDivisor(a, b);
}
public static int maximoComunDivisor(int a, int b) {
int temporal;//Para no perder b
while (b != 0) {
temporal = b;
b = a % b;
a = temporal;
}
return a;
}
public class Main {
public static void main(String[] args) {
int a = 50;
int b = 120;
int mcd = maximoComunDivisor(a, b);
System.out.printf("El MCD de %d y %d es %d\n", a, b, mcd);
int mcdRecursivo = maximoComunDivisorRecursivo(a, b);
System.out.printf("El MCD de %d y %d (con recursividad) es %d\n", a, b, mcdRecursivo);
}
public static int maximoComunDivisorRecursivo(int a, int b) {
if (b == 0) return a;
return maximoComunDivisorRecursivo(b, a % b);
}
public static int maximoComunDivisor(int a, int b) {
int temporal;//Para no perder b
while (b != 0) {
temporal = b;
b = a % b;
a = temporal;
}
return a;
}
/*
____ _____ _ _ _
| _ \ | __ \ (_) | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___|
__/ | __/ |
|___/ |___/
public static void main(String[] args) {
String originalText = "parzibyte.me";
System.out.println("Original text: " + originalText);
String translatedText = textToBinary(originalText);
System.out.println("In binary, it is: " + translatedText);
System.out.println("-----------------");