Skip to content

Instantly share code, notes, and snippets.

View bharathvaj-ganesan's full-sized avatar
🏠
Working from home

Bharathvaj bharathvaj-ganesan

🏠
Working from home
View GitHub Profile
@bharathvaj-ganesan
bharathvaj-ganesan / nginx.conf
Created May 2, 2018 01:47 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@bharathvaj-ganesan
bharathvaj-ganesan / README.md
Created January 1, 2018 11:34 — forked from mapsam/README.md
Namecheap > Github pages

Namecheap > Github pages

Pointing your domains to a gh-pages branch requires three steps.

  1. Add the Github IPs as A records on Namecheap. Both Github IPs are 192.30.252.153 and 192.30.252.154.
  2. Add your Github domain as the CNAME alias on Namecheap. your_username.github.io. (mind the extra period!)
  3. Add a CNAME with your new domain name in your repository. lowercase and nothing else
Let's lool at the following example structure for RESTful API using Node.js, Express.js included tesing
app/
|---models/
|---controller/
|---helpers/
|---middlewares/
|---tests/
|---models/
|---controllers/
@bharathvaj-ganesan
bharathvaj-ganesan / random.md
Created October 9, 2017 12:38 — forked from joepie91/random.md
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