Skip to content

Instantly share code, notes, and snippets.

View rivertam's full-sized avatar
🎑
who can keep track

Ben Berman rivertam

🎑
who can keep track
View GitHub Profile
@rivertam
rivertam / gist:8789afd4f97167823325
Created December 23, 2015 04:26
Errors with boilerplate
ERROR in ./src/containers/index.js
Module build failed: SyntaxError: /home/ben/calico/src/containers/index.js: Unexpected token (1:7)
> 1 | export App from './App/App';
| ^
2 | export Chat from './Chat/Chat';
3 | export Home from './Home/Home';
4 | export Widgets from './Widgets/Widgets';
at Parser.pp.raise (/home/ben/calico/node_modules/babylon/lib/parser/location.js:24:13)
at Parser.pp.unexpected (/home/ben/calico/node_modules/babylon/lib/parser/util.js:82:8)
at Parser.pp.expect (/home/ben/calico/node_modules/babylon/lib/parser/util.js:76:33)
@rivertam
rivertam / rescue.rb
Created January 24, 2016 19:13
Maybe a rescue?
thr = Thread.new do
started = false
finished = false
def cleanup
puts '...started cleaning resource' unless started
started = true
sleep 1
puts '...finished cleaning resource' unless finished
finished = true
@rivertam
rivertam / hi.js
Created February 29, 2016 23:25
Test non-async async
const hi = async () => 5;
hi().then(num => console.log(num)); // results in 5... eventually
@rivertam
rivertam / render.js
Created May 16, 2016 16:17
Problematic rendering
render() {
const style = this.getStyles().position ?
this.getStyles() :
absolutePositionStyles(this.props.getCard(), this.getStyles());
const classes = ['bubble'];
if (!this.state.static) {
classes.push('is-animating');
}
@rivertam
rivertam / OpenArticleRender.js
Created May 16, 2016 16:37
Rendering the OpenedArticle
class OpenArticle extends Component {
static propTypes = {
article: PropTypes.article.isRequired,
getCard: PropTypes.func.isRequired,
openArticle: PropTypes.oneOfType([PropTypes.bool, PropTypes.article]).isRequired,
};
shouldComponentUpdate(newProps) {
const oldOpenSlug = this.props.openArticle && this.props.openArticle.slug;
const newOpenSlug = newProps.openArticle && newProps.openArticle.slug;
@rivertam
rivertam / ia_insights.js
Created June 20, 2016 16:59
IA insights
const retrieved = {
"instant_articles_insights": {
"data": [
{
"time": "2016-03-16T08:00:00+0000",
"value": "1"
},
{
"time": "2016-03-17T08:00:00+0000",
"value": "63"
@rivertam
rivertam / t-no-style.html
Last active July 11, 2016 18:22
Taboola's got no style
<!DOCTYPE html>
<html>
<head>
<script async src="http://cdn.taboola.com/libtrc/aplus/loader.js">
</script>
<script>
var inDapIF=true;
</script>
<style type="text/css">
@rivertam
rivertam / newsletter.html
Created November 14, 2016 16:48
Newsletter w/ A Plus LiveIntent
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><!--[if !mso]><!-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><!--<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>A Plus Weekly Newsletter</title><!--[if gte mso 9]>
<style type="text/css">
.img {
@rivertam
rivertam / mongoose-sucks.md
Created May 17, 2017 18:36
Issues I have with Mongoose
  • It adds defaults to models if the schema has them, but does not remove invalid fields from .toJSON when pulling them out of Mongo
    • But it does remove it for the model object
    • .inspect reflects the .toJSONversion, so debugging is basically impossible
  • Can't use object spread with a model to get a new version of it
  • There's no way to have .update update the model in-place
  • I mean I don't want it to be the default, but having the option would be nice
@rivertam
rivertam / pls-projects.md
Created June 8, 2017 06:59
Projects I want to do eventually some day maybe
  • Actually reasonable Mongo driver (with pluggable schema validators)
  • Reasonable Mongo schema validator
  • Nestable routes for zeit/micro
  • Nice test suite ergonomics
    • Ava actually does a much better job than Mocha or Jest here
    • Want context variables (like in Ava)
    • Want chainable middleware context and describe (each can mutate context variables and have their own lifecycle hooks (beforeEach, before, etc.)
  • Babel plugin to transform arrow function class properties to be implemented using prototype and bind rather than making the function in the constructor
  • Doing a bind is cheaper than creating the whole function every time!