Skip to content

Instantly share code, notes, and snippets.

View skrosoft's full-sized avatar

Vincent Guyard skrosoft

View GitHub Profile
@skrosoft
skrosoft / generar_valoruf_bulk_request.js
Created October 10, 2022 16:00
Permite generar el BULK Request del registro de los valores UF con los valores del Banco Central de Chile
/**
* IR a: https://si3.bcentral.cl/Indicadoressiete/secure/IndicadoresDiarios.aspx
* IR a: "Unidad de Reajustabilidad" > "Unidad de fomento (UF)" > "Ver serie"
* Luego ejecutar el siguiente script en la consola del navegador:
*/
const year = parseInt(document.getElementById("lblAnioValor").innerText);
const output = { bulk: [] };
for (let month=1; month<=12; month++){
#!/usr/bin/env bash
# Script to download asset file from tag release using GitHub API v3.
# See: http://stackoverflow.com/a/35688093/55075
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
# Ask for Github API Token
stty -echo
printf "Enter your Github API Token: "
read GITHUB_API_TOKEN
stty echo
@skrosoft
skrosoft / postman-pre-request-signature.min.js
Last active July 30, 2022 06:11
Pre-request Script para Postman para firmar automáticamente las peticiones en POSTMAN
const SECRET="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
const CRYPTOJS_CDN="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js";
const JSONABC_CDN="https://novicelab.org/jsonabc/dist/jsonabc.js";
(()=>{pm.sendRequest(CRYPTOJS_CDN,(e,r)=>{eval(r.text()),pm.sendRequest(JSONABC_CDN,(e,r)=>{const c=eval(r.text())("jsonabc"),g=(r,e)=>{r=c.sortObj(r);let t="";return Object.keys(r).sort().forEach(e=>{"signature"!==e&&r.hasOwnProperty(e)&&(t+=e+JSON.stringify(r[e]))}),CryptoJS.HmacSHA256(t,e).toString(CryptoJS.enc.Hex)};if("GET"===pm.request.method){const p={};pm.request.url.query.each(e=>{e.disabled||(p[e.key]=e.value)}),pm.request.url.query.add({key:"signature",value:g(p,SECRET)})}else{const p=JSON.parse(pm.request.body.raw);p.signature=g(p,SECRET),pm.request.body.raw=JSON.stringify(p)}})})})();
@skrosoft
skrosoft / ezplatform.yml
Created December 2, 2018 02:40
eZ Platform - Symfony language is always "en" even when I change the current site access
imports:
- { resource: image_variations.yml }
- { resource: views.yml }
ezpublish:
locale_conversion:
eng-GB: en_GB
fre-FR: fr_FR
esp-ES: es_ES
@skrosoft
skrosoft / composer.json
Created November 29, 2018 04:41
Use a local dev version of a package
{
"require": {
"onaxis/ezplatform-extra": "@dev"
},
"repositories": {
"dev-package": {
"type": "path",
"url": "../ezplatform-extra",
"options": {
"symlink": true
@skrosoft
skrosoft / viewparametersgenerator_example.html.twig
Created November 21, 2018 05:34
Twig example using ViewParametersGenerator service
<a href="{{ path( "ez_urlalias", {"locationId": 80} ) }}{{ viewparametersgenerator.generate({'item': content.id}) }}">My link</a>
@skrosoft
skrosoft / config.yml
Created November 21, 2018 05:31
ViewParametersGenerator as service into Twig templates
# Twig Configuration
twig:
globals:
viewparametersgenerator: "@app.service.viewparametersgenerator"
@skrosoft
skrosoft / RedirectController.php
Created November 21, 2018 05:27
Using the ViewParametersGenerator symfony/ezplatform service
return new RedirectResponse(
sprintf('%s%s', $this->urlAliasGenerator->getPathPrefixByRootLocationId(
$first_child->locations[0]->contentInfo->mainLocationId
), $this->viewParametersGenerator->getFromRequest($request))
);
@skrosoft
skrosoft / ViewParametersGenerator.php
Created November 21, 2018 05:26
Symfony service that allow you to generate an URI string of ezplatform view parameters
<?php
/**
* Created by PhpStorm.
* User: vguyard
* Date: 11/21/18
* Time: 1:11 AM
*/
namespace AppBundle\Service;
@skrosoft
skrosoft / 60_prime_numbers_ending_with_7.js
Created November 7, 2017 19:30
60 primeros Números Primos terminando por 7
function isPrime(num) {
var prime = num != 1;
for (var i = 2; i < num; i++) {
if (num % i === 0) {
prime = false;
break;
}
}
return prime;
}