Skip to content

Instantly share code, notes, and snippets.

View giansalex's full-sized avatar

Giancarlos Salas giansalex

View GitHub Profile
@giansalex
giansalex / Boleta.xml
Last active March 28, 2025 00:49
Comprobantes Facturación Electrónica SUNAT UBL 2.1 (Factura, Boleta, NCR, NDB, ICBPER, Forma Pago), generados con Greenter https://greenter.dev/
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent />
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>2.0</cbc:CustomizationID>
<cbc:ID>B001-1</cbc:ID>
@giansalex
giansalex / docker-php-ext-install.md
Last active October 13, 2024 20:15
docker-php-ext-install Reference
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
@giansalex
giansalex / query-ruc-padron.php
Last active August 16, 2024 02:05
Query RUC list - SUNAT
<?php
// Descargar padron reducido: https://www.sunat.gob.pe/descargaPRR/mrc137_padron_reducido.html
// Resultado al descomprimir: padron_reducido_ruc.txt
set_time_limit(0);
function queryRucPadron($txtPath, $ruc)
{
$handle = fopen($txtPath, "r") or die("No se puede abrir el txt");
@giansalex
giansalex / trama-soap.xml
Last active July 11, 2024 21:47
Ejemplo de trama XML enviada por un cliente SOAP al consultar el estado del CDR
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://service.sunat.gob.pe" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Header>
<ns2:Security>
<ns2:UsernameToken>
<ns2:Username>20000000001MODDATOS</ns2:Username>
<ns2:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">moddatos</ns2:Password>
</ns2:UsernameToken>
</ns2:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
@giansalex
giansalex / main.go
Created August 30, 2020 22:42
Listen new blocks - Tendermint - Cosmos sdk
package main
import (
"context"
"encoding/hex"
"fmt"
"log"
"time"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
@giansalex
giansalex / android-emulator-standalone.md
Last active June 18, 2024 10:37
Run Android Emulator without Android Studio

Android Emulator without Android Studio

  • Download Command line tools only.
  • Configure your ANDROID_SDK_ROOT directory, create inside cmdline-tools and decompress zip downloaded above.
  • Set Environment Variable ANDROID_SDK_ROOT and added to PATH bin tools $ANDROID_SDK_ROOT/cmdline-tools/tools/bin.
  • Install packages for Android API 23 (MARSHMELLOW (6.0), etc) sdkmanager "system-images;android-23;google_apis;x86" "platforms;android-23"
  • Install emulator and tools: sdkmanager "emulator" "platform-tools"
  • Add tools to PATH: $ANDROID_SDK_ROOT/emulator, $ANDROID_SDK_ROOT/platform-tools
  • Create emulator device: avdmanager --verbose create avd --force --name "pixel_6.0" --device "pixel" --package "system-images;android-23;google_apis;x86" --tag "google_apis" --abi "x86"
  • Start emulator: emulator @pixel_6.0
import { SigningStargateClient } from '@cosmjs/stargate'
import { fromBase64 } from "@cosmjs/encoding";
import {
makeAuthInfoBytes,
makeSignDoc,
} from '@cosmjs/proto-signing'
import { Int53, Uint53 } from "@cosmjs/math";
import { Any } from "cosmjs-types/google/protobuf/any";
import { PubKey } from "cosmjs-types/cosmos/crypto/secp256k1/keys";
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
@giansalex
giansalex / cw20-ics20.md
Last active December 14, 2023 18:00
Deploy CW20-ICS20 contract

CW20-ICS20 on Juno

TX_FLAGS="--gas auto --gas-adjustment 1.3 --gas-prices 0.025ujunox"
junod tx wasm store cw20_ics20.wasm --from user $TX_FLAGS

GET Code ID.

  • Instantiate Contract:
@giansalex
giansalex / ProxySoap.php
Last active September 27, 2023 06:49
Use SoapClient PHP with proxy for HTTP/HTTPS connections
<?php
$parameters = [
'proxy_host' => "127.0.0.1",
'proxy_port' => 8888,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
@giansalex
giansalex / Invoice-BTC-cryptocurrency.xml
Created August 19, 2020 03:10
Invoice UBL 2.1 with cryptocurrency payments (BTC).
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent />
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>2.0</cbc:CustomizationID>
<cbc:ID>FBTC-1</cbc:ID>