Skip to content

Instantly share code, notes, and snippets.

@sohamkamani
sohamkamani / rsa.js
Last active May 8, 2024 19:32
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})
@keksipurkki
keksipurkki / RSA.md
Last active March 31, 2023 08:41
RSA example in NodeJS
"use strict";

// Requires NodeJS >= 11.6.0

const crypto = require("crypto");
const util = require("util");

const generateKeyPair = util.promisify(crypto.generateKeyPair);
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@rstacruz
rstacruz / README.md
Last active October 23, 2023 09:06
How to install Docker in Mac, Windows, and Linux

Getting Docker

Docker is available for Linux, MacOS, and Windows.

MacOS

Docker for Mac is best installed with Homebrew and Homebrew Cask. For other ways to install on MacOS, see Install Docker for Mac in Docker's docs.

brew cask install docker # Install Docker
@siwalikm
siwalikm / aes-256-cbc.js
Last active May 7, 2024 17:22
AES-256-CBC implementation in nodeJS with built-in Crypto library
'use strict';
const crypto = require('crypto');
const ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b"; // set random encryption key
const IV = "5183666c72eec9e4"; // set random initialisation vector
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex');
const phrase = "who let the dogs out";
var encrypt = ((val) => {
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
@g4d
g4d / gist:c6d0918ca63236ac7ea4
Created March 11, 2015 21:41
NFL Teams in JSON Format
var teams = [
{
"code": "ARI",
"fullName": "Arizona Cardinals",
"shortName": "Arizona"
},
{
"code": "ATL",
"fullName": "Atlanta Falcons",
"shortName": "Atlanta"
@addyosmani
addyosmani / package.json
Last active January 18, 2024 21:31
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@HashNuke
HashNuke / gist:608259
Created October 3, 2010 04:13
to undo push and commits
# to undo a git push
git push -f origin HEAD^:master
# to get to previous commit (preserves working tree)
git reset --soft HEAD
# to get back to previous commit (you'll lose working tree)
git reset --hard HEAD^