Skip to content

Instantly share code, notes, and snippets.

View grekodev's full-sized avatar
🎯
<grekodev/>

Greck Pastor grekodev

🎯
<grekodev/>
View GitHub Profile
@grekodev
grekodev / ordenamiento_si_es_mayor_al_otro_mes.js
Created September 2, 2022 17:53
COMPLETA EL ARRAY DE MESES Y COMPARA SI EL IMPORTE DEL MES ACTUAL ES MAYOR AL MES ANTERIOR
let arr_mes = [1, 2, 3, 4, 5, 6, 7];
let producto = [{
producto: 'ALEBINO DE PECES',
items: [
{mes: 1, importe: '400', is_mayor: false},
{mes: 6, importe: '200', is_mayor: false}
]
},
{
producto: 'PRODUCTO 2',
@grekodev
grekodev / migrate_data_mysql_to_local_hosting.py
Created February 3, 2021 13:18
Script Python to migrate data from local to server
import pymysql
import pandas as pd
import math
import logging
LOG_FILE = "logging.log"
logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %H:%M:%S')
try:
def set_log(e, block):
@grekodev
grekodev / protip-arguments.js
Created February 24, 2020 22:22
js protip argumentos
// function crearPersona(nombre, apellido) {
// return { nombre, apellido };
// }
const crearPersona = (nombre, apellido) => ({ nombre, apellido });
const persona = crearPersona("Brayan", "Pastor");
console.log(persona);
function imprimeArgumentos() {
```php
public static function updateValues(array $values)
{
$table = MyModel::getModel()->getTable();
$cases = [];
$ids = [];
$params = [];
foreach ($values as $id => $value) {
@grekodev
grekodev / consulta_dni_peru.sh
Created December 16, 2019 20:49
consulta dni
```sh
https://ww1.essalud.gob.pe/sisep/postulante/postulante/postulante_obtenerDatosPostulante.htm?strDni=46879999
```
```sh
curl 'http://aplicaciones007.jne.gob.pe/srop_publico/Consulta/api/AfiliadoApi/GetNombresCiudadano' -H 'RequestVerificationToken: 30OB7qfO2MmL2Kcr1z4S0ttQcQpxH9pDUlZnkJPVgUhZOGBuSbGU4qM83JcSu7DZpZw-IIIfaDZgZ4vDbwE5-L9EPoBIHOOC1aSPi4FS_Sc1:clDOiaq7mKcLTK9YBVGt2R3spEU8LhtXEe_n5VG5VLPfG9UkAQfjL_WT9ZDmCCqtJypoTD26ikncynlMn8fPz_F_Y88WFufli38cUM-24PE1' -H 'Content-Type: application/json;chartset=utf-8' --data-binary '{"CODDNI":"46658592"}';
```
PHP
=======
public function readImage()
{
header('Content-type: image/jpeg');
echo file_get_contents("http://app1.susalud.gob.pe/registro/Home/GeneraCaptcha?accion=image");
}
===================================================================================================
JS
=======
@grekodev
grekodev / clonar_elementos_dom.js
Last active November 24, 2019 00:05
clonar_elementos_dom.js
<script type="text/javascript">
window.addEventListener("load", function(e) {
let templete = document.getElementById("article-template");
let articles = document.getElementById("articles");
for (let i = 1; i <= 5; i++) {
let clonar = templete.cloneNode(true);
clonar.removeAttribute("id");
let h2 = clonar.getElementsByTagName("h2")[0];
h2.innerHTML = h2.textContent + " " + i;
articles.appendChild(clonar);
@grekodev
grekodev / ticket-php1.php
Created November 6, 2019 16:37 — forked from evilnapsis/ticket-php1.php
Formato de ticket para impresora de ticket
<?php
include "fpdf/fpdf.php";
$pdf = new FPDF($orientation='P',$unit='mm', array(45,350));
$pdf->AddPage();
$pdf->SetFont('Arial','B',8); //Letra Arial, negrita (Bold), tam. 20
$textypos = 5;
$pdf->setY(2);
$pdf->setX(2);
$pdf->Cell(5,$textypos,"NOMBRE DE LA EMPRESA");
@grekodev
grekodev / arrays_group.php
Last active October 30, 2019 23:08
functions group arrays php awesome :)
$original = array
(
array
(
"dni" => 98989898,
"email" => "edgra@gmail.com",
"date" => "2016-09-02 20:58:53",
"items" => 7
),
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-min.js"></script>
<script> $(document).ready(() => {
ko.bindingHandlers.nextEnter = {
init: function (element, valueAccessor, allBindingsAccessor) {
$(element).on('keydown', 'input, select', function (e) {
var self = $(this), form = $(element), focusable, next;
if (e.keyCode == 13) {
focusable = form.find('input,a,select,button,textarea').filter(':visible');
var nextIndex = focusable.index(this) == focusable.length - 1 ? 0 : focusable.index(this) + 1;
next = focusable.eq(nextIndex);