Skip to content

Instantly share code, notes, and snippets.

@jbroadice
jbroadice / Input.jsx
Last active January 23, 2018 18:14
Based on Bazze's implementation of a drop-in replacement for the "Input" class after it got deprecated in react-bootstrap version 0.29.0.
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import cx from 'classnames';
import { FormGroup, ControlLabel, FormControl, HelpBlock, InputGroup } from 'react-bootstrap';
export default class Input extends Component {
static propTypes = {
name: PropTypes.string,
@jbroadice
jbroadice / save-data-as-attachment.js
Last active September 29, 2021 15:38
JavaScript util to saveData (download as a browser attachment), taking data and allowing output filename.
const saveDataAsAttachment = (() => {
const a = document.createElement('a');
a.style = 'display: none';
document.body.appendChild(a);
return (data, fileName) => {
const blob = new Blob([data], {type: 'octet/stream'});
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
@jbroadice
jbroadice / unpkg-npm.html
Last active September 29, 2021 15:38
unpkg.com JavaScript async module import
<!DOCTYPE html>
<html>
<head>
<title>unpkg.com dynamic import module test</title>
</head>
<body>
<script type="module">
window.module = {
set exports(module) {
window.module.modules.push(module);