Skip to content

Instantly share code, notes, and snippets.

View bbstilson's full-sized avatar
🕺

Brandon Stilson bbstilson

🕺
View GitHub Profile
/**
* Custom PropType for checking multiple PropTypes.
*
* Returns an error if the prop does not pass one of the PropType checks.
* Sourced from: http://stackoverflow.com/a/31169012
*
* @param {mixed} any valid React PropType (element|string|arrayOf|shape|...)
*
* @returns {error} returns an error if all fail
*/
(function () {
var body = document.getElementsByTagName('body')[0];
body.addEventListener('animationend', handleAnimEnd);
var path = '';
// fade in on dom load
(function (fn) {
if (document.readyState != 'loading') {
fn();
} else {
.fancydom-in { opacity: 0 !important; animation: fadeIn 0.5s linear forwards; }
.fancydom-out { opacity: 1; animation: fadeOut 0.25s linear forwards; }
@keyframes fadeIn { 0% { opacity: 0; visibility: visible; }
0.1% { opacity: 0; }
100% { opacity: 1; } }
@keyframes fadeOut { 0% { opacity: 1; }
99.9% { opacity: 0; }
100% { opacity: 0; visibility: hidden; } }
@bbstilson
bbstilson / server.js
Created March 1, 2018 03:19
Streaming a file from one node server to another
// transmitter.js
const http = require('http');
const fs = require('fs');
const requestOpts = {
hostname: 'localhost',
port: 1337,
method: 'POST'
};
@bbstilson
bbstilson / hw.js
Created March 16, 2018 20:54
Encrypted homework
const express = require('express');
const app = express();
const crypto = require('crypto');
const supportedAlgos = new Set(['SHA1', 'SHA256', 'SHA512']);
app.use(express.static('./'));
app.get('/encrypt', (req, res) => {
const { algorithm, string } = req.query;
@bbstilson
bbstilson / index.html
Created March 16, 2018 21:02
Encrypted homework
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Encrypt</title>
</head>
<body>
<div>
<p>Text to encrypt:</p>
<input id="text" type="text" placeholder="Plain text here" />

Things to look for when reviewing a React PR

Table of Contents

PropTypes

Be as specific as possible

Let's encrypt some files with Node! - Part 1

What we'll be learning

This tutorial is targeted to people who are very familiar with javascript and are at least somewhat familiar with Node.js.

We'll be learning:

  • How to work with Node streams.
  • How to write custom streams.
{"lastUpload":"2020-07-03T22:26:04.449Z","extensionVersion":"v3.4.3"}
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const AppendInitVect = require('./appendInitVect');
const getCipherKey = require('./getCipherKey');
function encrypt({ file, password }) {
// Generate a secure, pseudo random initialization vector.