Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
why does github have statuses?

Robert Balicki rbalicki2

💭
why does github have statuses?
  • Facebook
  • NYC
View GitHub Profile
@rbalicki2
rbalicki2 / install-required-packages.sh
Created Sep 10, 2014
npm install's all required packages in a file, using sed and xargs, --save-dev and --save optional
View install-required-packages.sh
#!/bin/bash
#
# npm install all required packages
# example usage
#
# ./install-required-packages.sh gulpfile.sh --save-dev
# ./install-required-packages.sh gulpfile.sh --save
# ./install-required-packages.sh gulpfile.sh
#
# TODO: this matches require's that are commented out. Fix.
View replacejs.sh
replacejs() {
FOLDER_NAME=$(basename $1 | sed 's/\.js\(x\)\{0,1\}$//')
FOLDER=$(dirname $1)/$FOLDER_NAME
SUFFIX=$(basename $1 | sed 's/.*\.//')
mkdir $FOLDER
mv $1 $FOLDER/index.$SUFFIX
}
View How we use cloudfront and next.js.md

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at robert.balicki@gmail.com or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

View rollup.config.js
// this is the top-level rollup config
//
// each child rollup config *must* use full paths, e.g.
// const DESTINATION_FILE = path.join(__dirname, '..', 'lib/index.js');
// const INPUT_FILE = path.join(__dirname, '..', 'src/index.js');
const requireGlob = require('require-glob');
const path = require('path');
const _ = require('lodash');
@rbalicki2
rbalicki2 / QuoteOption.rs
Created May 7, 2018
QuoteOption, possibly updated for nightly
View QuoteOption.rs
use quote::{Tokens, ToTokens};
use proc_macro2::{Term, Span, Group, Delimiter, TokenStream};
pub struct QuoteOption<T>(pub Option<T>);
impl<T> ToTokens for QuoteOption<T>
where T: ToTokens
{
fn to_tokens(&self, tokens: &mut Tokens) {
// tokens.append(Term::new("{", Span::call_site()));
View Resolve.jsx
import { Component } from 'react';
import PropTypes from 'prop-types';
/**
* Resolve
*
* This is the workhorse of how Jetty does async.
* It accepts a promise, and renders one of four render props:
* - before
* - pending
@rbalicki2
rbalicki2 / Resolve.jsx
Created Nov 14, 2018
Resolve.jsx (the one in use)
View Resolve.jsx
import { Component } from 'react';
import PropTypes from 'prop-types';
/**
* Resolve
*
* This is the workhorse of how Jetty does async.
* It accepts a promise, and renders one of four render props:
* - before
* - pending
View gist:b125a403cb327738b35d6a6e42a0191f
// the following two are equivalent:
// First
let my_app = smd!(
on_hash_change={on_hash_change_callback};
post_render={post_render_callback};
// comments can go anywhere
{ interpolated_item }
<div
ref={&mut my_ref}
View Form.js
import React from 'react';
import { Form } from 'react-final-form';
export default ({ render, transform, ...rest })=> <Form
{...rest}
render={({ values, ...renderPropsRest }) => render({ values: transform(values), ...renderPropsRest })}
/>;
// the function passed to transform is x => MyModelSubclass.getFromCache(x)
View promise-state-example.rs
match & *unwrapped_promise.borrow() {
smithy::types::PromiseState::Success(val) => {
let val = val.clone();
smd!({ &mut val })
},
// ...
}