Skip to content

Instantly share code, notes, and snippets.


Brian A. Danielak briandk

View GitHub Profile
View renderPropsInReact.jsx
class WrapperComponent extends React.Component {
render() {
const style = { border: "solid 1px " + this.props.color };
return <div style={style}>{this.props.children}</div>;
class HelloMessage extends React.Component {
render() {
var Wrapper = this.props.wrapper;
briandk /
Created Apr 23, 2018
Shell one-liner commands
# Remove untagged docker images
docker rmi (docker images | awk '/<none>/ {print $3}')
briandk /
Last active Jul 19, 2018
Example functions (and arrow functions) in Typescript with target `es2017`

Defining an Object Type

const myObject: { [key: string]: string } = {foo: 'bar'}

Annotating Function Types

With target=es2017 and TypeScript 2.8

briandk /
Last active Apr 17, 2018
Useful git shortcuts
# via
# prunes tracking branches not on the remote.
git remote prune origin
# lists branches that have been merged into the current branch.
git branch --merged
# deletes branches listed on standard input.
xargs git branch -d
briandk / QuillDeltaToString.js
Created Sep 28, 2017
Converting a quill delta into a string
View QuillDeltaToString.js
// Assuming the delta is entirely insert operations,
// this example wouuld convert bolded text to html bolded text.
// The key logic here is mapping over the insert ops,
// then joining the resulting array on the empty string
html = delta.slice(0, 500) {
if (typeof op.insert !== 'string') return '';
let html = op.insert;
if (op.attributes.bold) {
html = '<strong>' + html + '</strong>';
briandk / extendingClassesInJavaScript.js
Created Jun 30, 2017
Extending classes in Quill to create a Timestamp Class
View extendingClassesInJavaScript.js
const Quill = require('quill');
const Link = Quill.import('formats/link');
class Timestamp extends Link {
static create(value) {
let node = super.create(value);
value = this.sanitize(value);
node.setAttribute('href', value);
briandk / college-majors.ipynb
Created Apr 17, 2017
Beginning analysis of 538's college majors data
View college-majors.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
briandk /
Last active Apr 10, 2017
Basic plotting and forest creation functions for the forest fire model in CMSE 201 Spring 2017
import matplotlib.pyplot as plt
from matplotlib import colors
import numpy as np
def make_forest( height, width, density ):
This function will take in a width, height, and density specified by the user and use those values
to generate a forest (2-d numpy array) matching those characteristics. A 0 will represent an empty
space, a 1 will represent a tree
briandk / generate_package_citations.R
Created Apr 9, 2017
Wil Doane's system for automatically generating bibliography entries for the R packages you're using
View generate_package_citations.R
# Early in the script
pkgs_pre_script <- try(devtools::loaded_packages(), silent = TRUE)
# Late in the script
pkgs_used_during_script <- try(devtools::loaded_packages(), silent = TRUE)
cat("* ")
print(citation(), style="text") # or Bibtex or LaTeX
briandk /
Created Mar 27, 2017
Completely (or as completely as I can) uninstalling R on OS X
sudo rm -rf /Library/Frameworks/R.framework \
/Applications/ \
/usr/bin/R /usr/bin/Rscript
pkgutil --regexp --forget org\.r-project*