Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shivangpatel
shivangpatel / Upload.txt
Created July 16, 2020 13:11 — forked from merlox/Upload.txt
The file upload summary
// Index.html
<div>
<h1>File upload</h1>
<input type="file" multiple onChange={e => uploadFile(e)}/>
</div>
// Index.js
const uploadFile = async e => {
const files = e.target.files
@shivangpatel
shivangpatel / create-efi-keys.sh
Created September 5, 2018 04:15 — forked from Era-Dorta/create-efi-keys.sh
Sign kernel modules on Ubuntu, useful for Nvidia drivers in UEFI system
# VERY IMPORTANT! After each kernel update or dkms rebuild the modules must be signed again with the script
# ~/.ssl/sign-all-modules.sh
# Place all files in ~/.ssl folder
mkdir ~/.ssl
cd ~/.ssl
# Generate custom keys with openssl
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -subj "/CN=Owner/"
{
"filebeat-6.2.3-2018.06.05": {
"mappings": {
"doc": {
"_meta": {
"version": "6.2.3"
},
"dynamic_templates": [
{
"fields": {
@shivangpatel
shivangpatel / encryption.js
Created February 19, 2018 06:47 — 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 bytes (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', new Buffer(ENCRYPTION_KEY), iv);
@shivangpatel
shivangpatel / wss_server.js
Created January 22, 2018 06:36 — forked from MrYsLab/wss_server.js
Scratch wss server example
/* I used this web page as a basis: http://www.chovy.com/web-development/self-signed-certs-with-secure-websockets-in-node-js/
1. I created the key and cert using the instructions.
2. I created a modified secure websocket server - included below
3. I created a simplified Scratch extension - included below.
4. I added the cert to firefox using the instructions in the article for Chrome. This worked
5. I tried to add the cert to chrome by accessing https://0.0.0.0:1234, but this brought me to a search page.
6. I then created a pkc12 cert and used the settings to add it to chrome, but could not get a wss connection.
Bottom line - I got Firefox to work, but not chrome