Skip to content

Instantly share code, notes, and snippets.

View nitinsareen's full-sized avatar

Nitin Sareen nitinsareen

View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active November 15, 2024 11:25
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@StanBright
StanBright / domain_check.sh
Last active July 23, 2021 04:26
Domain Name Search
#!/bin/bash
# Name: Check for domain name availability (as featured on https://stanbright.com/domain-name-search)
#
# To use this script, add it to your ~/bin directory and make it executable.
# Then you can search for specific domains like this: > domain_check.sh my-new-domain
#
# Alternatively:
# - Generate domain name ideas based on a keyword: https://www.saashub.com/namebounce-alternatives
# - Search domain names as you type: https://www.saashub.com/domaintyper-alternatives
@joepie91
joepie91 / random.md
Last active November 16, 2024 19:07
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@staltz
staltz / introrx.md
Last active November 19, 2024 18:00
The introduction to Reactive Programming you've been missing