Skip to content

Instantly share code, notes, and snippets.

View gauravmehla's full-sized avatar
🚀
to the sky and beyond

Gaurav Mehla gauravmehla

🚀
to the sky and beyond
View GitHub Profile
@gauravmehla
gauravmehla / simple-nodejs-iv-encrypt-decrypt.js
Created August 23, 2018 10:40 — forked from yoavniran/simple-nodejs-iv-encrypt-decrypt.js
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@gauravmehla
gauravmehla / AesUtil.js
Created August 23, 2018 10:23 — forked from AndiDittrich/AesUtil.js
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
// AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
// ----------------------------------------------------------------------------------------
// the encrypted datablock is base64 encoded for easy data exchange.
// if you have the option to store data binary save consider to remove the encoding to reduce storage size
// ----------------------------------------------------------------------------------------
// format of encrypted data - used by this example. not an official format
//
// +--------------------+-----------------------+----------------+----------------+
// | SALT | Initialization Vector | Auth Tag | Payload |
// | Used to derive key | AES GCM XOR Init | Data Integrity | Encrypted Data |
@gauravmehla
gauravmehla / The Technical Interview Cheat Sheet.md
Created July 5, 2018 05:05 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
ataPS1="\n$PS1"
export PATH=$PATH:/Users/gaurav/Library/Android/sdk/platform-tools
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
alias lcd="$HOME/Documents/livecheck/development/"
alias lci="$HOME/Documents/livecheck/ionic"
alias ni="npm install && terminal-notifier -title 'npm install' -message 'command execution done' -sound default"
alias f="fuck"
alias t="tree -C -I 'node_modules|dist|files|vendor' -L 4"
export PATH=$PATH:/Users/gaurav/Library/Android/sdk/
@gauravmehla
gauravmehla / PhonecallReceiver.java
Created February 22, 2018 11:30 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@gauravmehla
gauravmehla / frontendDevlopmentBookmarks.md
Created February 15, 2018 16:04 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@gauravmehla
gauravmehla / gist:76d121a4a4f071cd536eb89d16c51fa1
Created February 12, 2018 03:19 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@gauravmehla
gauravmehla / better-nodejs-require-paths.md
Created January 29, 2018 06:54 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@gauravmehla
gauravmehla / a_mongodb_to_s3_backup.sh
Created December 7, 2017 15:37 — forked from lazarofl/a_mongodb_to_s3_backup.sh
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"