Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View emafriedrich's full-sized avatar

Emanuel Friedrich emafriedrich

  • Leandro N. Alem, Misiones
View GitHub Profile
@emafriedrich
emafriedrich / random-number-generator.js
Last active April 5, 2024 13:24
Random Number Generator with Chi Squared test
const crypto = require('crypto');
// Can set the game param to fix any bias you find
const randomDecimalFromHash = ({ hash, game, charsToTake = 5, startsFromPosition = 0 }) => {
hash = hash + game;
const cycle = 3;
const cycleOffset = (cycle * 2) % hash.length;
const hashSegmentForInterval = hash.substring(cycleOffset, cycleOffset + 2);
const randomInterval = parseInt(hashSegmentForInterval, 16) % charsToTake + 1;
@emafriedrich
emafriedrich / gist:f06805223fa1d56fb2945ab31b399152
Created January 20, 2021 12:58
If you docker containers do not recreate with updated code...
# docker
docker build --no-cache
# docker-compose
docker-compose up --build --force-recreate --no-deps
@emafriedrich
emafriedrich / .env
Last active August 25, 2020 20:46
env node module. Typescript implementation
MY_ENV_VAR=some-value
@emafriedrich
emafriedrich / README-español.md
Created March 25, 2020 21:03 — forked from Villanuevand/README-español.md
Una plantilla para hacer un buen README.md. Inspirado en el gist de @PurpleBooth => https://gist.github.com/PurpleBooth/109311bb0361f32d87a2

Título del Proyecto

Acá va un párrafo que describa lo que es el proyecto

Comenzando 🚀

Estas instrucciones te permitirán obtener una copia del proyecto en funcionamiento en tu máquina local para propósitos de desarrollo y pruebas.

Mira Deployment para conocer como desplegar el proyecto.

@emafriedrich
emafriedrich / rename_database_mysql.sql
Created November 4, 2019 20:12
This command generate the commands for rename all table names from a database to another database schema.
SELECT CONCAT('RENAME TABLE ',table_schema,'.',table_name,
' TO ','new_database_name',table_name,';')
FROM information_schema.TABLES
WHERE table_schema LIKE 'old_database_name';
@emafriedrich
emafriedrich / order by difference
Last active November 3, 2017 02:17
Sort javascript array by difference beetwen elemtents
function sortByDifference (value, arr) {
return arr.sort(function (x, y) {
let difx = Math.abs(parseFloat(x) - value);
let dify = Math.abs(parseFloat(y) - value);
if (difx < dify) return -1;
if (difx == dify) return 0;
return 1;
});
}
@emafriedrich
emafriedrich / gist:e372444375d483e4f1161ba9709e0e8f
Created August 17, 2017 19:16
JS Date in dd/mm/yyyy without dependencies and large coding
new Date().toJSON().slice(0,10).split('-').reverse().join('/');
Extract from
https://stackoverflow.com/questions/12409299/how-to-get-current-formatted-date-dd-mm-yyyy-in-javascript-and-append-it-to-an-i
@emafriedrich
emafriedrich / .css
Created August 16, 2017 09:37
Print input like label
@media print {
.no-print {
display: none !important;
}
.form-control
{
border: 0;
padding:0;
overflow:visible;
scp -i mykey.pem somefile.txt root@my.ec2.id.amazonaws.com:/
@emafriedrich
emafriedrich / html
Created July 12, 2017 19:55
Break words on overflow on new line
overflow-wrap:break-word;white-space: pre-line;