Skip to content

Instantly share code, notes, and snippets.

View AshHeskes's full-sized avatar

Ash Heskes AshHeskes

View GitHub Profile
@AshHeskes
AshHeskes / encryption.js
Created November 24, 2021 17:46 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@AshHeskes
AshHeskes / hosts-to-vm.sh
Created June 26, 2018 16:32 — forked from drewreece/hosts-to-vm.sh
Import locally defined hosts into Windows VM hosts file
#!/bin/sh
# hosts-to-vm.sh
#
# Made for use alongside the excellent ievms -
# https://github.com/xdissent/ievms
#
# Will export the local hosts (from /etc/hosts)
# to a batch script & add that batch script to a Windows VM
# The batch script will be executed to import the hosts onto the VM
# The batch file seems convoluted, until you only want to append the new hosts.
@AshHeskes
AshHeskes / package.json
Last active February 19, 2016 18:08 — forked from dsheiko/package.json
jsdom Element.dataset partial polyfill
{
"name": "jsdomdataset",
"version": "1.0.0",
"description": "",
"main": "polyfill-jsdom.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "GPL-3.0",
{
".123" : "application/vnd.lotus-1-2-3",
".3dml" : "text/vnd.in3d.3dml",
".3g2" : "video/3gpp2",
".3gp" : "video/3gpp",
".a" : "application/octet-stream",
".aab" : "application/x-authorware-bin",
".aac" : "audio/x-aac",
".aam" : "application/x-authorware-map",
".aas" : "application/x-authorware-seg",
@AshHeskes
AshHeskes / node-and-npm-in-30-seconds.sh
Created September 21, 2011 18:04 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: undefined is not a function
at CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at Schema.path (/usr/local/lib/node/.npm/mongoose/1.1.0/package/lib/mongoose/schema.js:139:24)
at Schema.add (/usr/local/lib/node/.npm/mongoose/1.1.0/package/lib/mongoose/schema.js:106:12)
at new Schema (/usr/local/lib/node/.npm/mongoose/1.1.0/package/lib/mongoose/schema.js:38:10)