Skip to content

Instantly share code, notes, and snippets.

View sg-gs's full-sized avatar
📈
Simpler = better

Sergio Gutiérrez sg-gs

📈
Simpler = better
View GitHub Profile
@JAlbertoGonzalez
JAlbertoGonzalez / random.md
Last active October 24, 2022 13:49 — forked from joepie91/random.md
Valores al azar seguros (en Node.js)

No todos los valores aleatorios se obtienen de la misma forma - para código relacionado con la seguridad, necesitas un tipo específico de valores aleatorios.

TL;DR

Resumen rápido, si te da pereza leerlo entero:

  • No uses Math.random(). Hay extremadamente muy pocos casos en los que Math.random() sea la mejor opción. No lo uses, a no ser que leas este artículo completamente, y hayas determinado que sirve para tu caso.
  • No uses crypto.getRandomBytes directamente. Aunque utiliza CSPRNG, es fácil sesgar el resultado cuando se transforma, haciendo que el resultado sea predecible.
  • Si quieres generar tokens al azar o API keys: Usa uuid, específicamente usa el método uuid.v4(). Evita node-uuid - no es la misma librería, y no produce valores aleatorios realmente seguros.
  • Si quieres generar números aleatorios dentro de un rango: Usa random-number-csprng.
@DavidWells
DavidWells / netlify.toml
Last active December 2, 2025 18:22
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
@qwesda
qwesda / hash_large_file.html
Last active September 22, 2022 00:52
asmcrypto - example - hash large file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hash large File Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/asmCrypto/0.22.0/asmcrypto.min.js"></script>
<script type="text/javascript" language="javascript">
function on_hash_done(hash, time_elapsed_seconds) {
document.getElementById('progress').innerText = '';
@santisbon
santisbon / Search my gists.md
Last active April 1, 2026 16:21
How to search gists.

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

How to disable page caching with create-react-app

If you currently not using a service worker resulting in old production caches being used and users not getting new versions of the app.

src/index.js

Use:

import { unregister as unregisterServiceWorker } from './registerServiceWorker'
@Chaser324
Chaser324 / GitHub-Forking.md
Last active June 3, 2026 12:57
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@robnyman
robnyman / arraybuffer-blob-filereader-localStorage.js
Last active January 30, 2024 09:22
Get file as an arraybuffer, create blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR, Blob and FileReader objects
var xhr = new XMLHttpRequest(),