Skip to content

Instantly share code, notes, and snippets.

View chrisbolin's full-sized avatar
❤️

Chris Bolin chrisbolin

❤️
View GitHub Profile
@chrisbolin
chrisbolin / .yarnrc
Last active December 18, 2018 22:44
Bundling specific Yarn version in a project with yarn-path
yarn-path "./yarn-1.12.3.js"
@chrisbolin
chrisbolin / README.md
Created August 15, 2018 06:21
Useful 404 Pages

Suggest sites to user based on URL matching and other information. Might require crawling the site or calling out to a search API like Duck Duck Go.

@chrisbolin
chrisbolin / SnapshotGuidelines.md
Last active May 31, 2018 17:18
Snapshot Guidelines

The Rule: Keep Snapshot Tests Useful

Snapshots can be helpful, but if used improperly they can useless or even a burden.

Make Snapshots Targeted

Don't snapshot things you don't care about. Don't snapshot an entire wrapper component if you are only interested in a single subcomponent. You can use enzyme's find() (available on both shallow and full wrappers).

Make Snapshots of Shallow Components

@chrisbolin
chrisbolin / script.js
Created May 24, 2016 17:28
Documents -> Spreadsheet Array
/*
converts an array of objects into an array of row arrays,
suitable for use in e.g. a csv coversion (npm install csv-stringify)
includes the header row.
e.g.
objectArray = [{a: 1, b: 120}, {a: 2, c: 'horse'}]
toRows(objectArray) -> [ ['a', 'b', 'c'], [1, 120, undefined], [2, undefined, 'horse'] ]
*/
const toRows = objectArray => {
@chrisbolin
chrisbolin / populate.js
Last active May 19, 2016 15:27
Meteor Populate / Join (Quick & Dirty)
// quick and dirty populating ("joining") in Meteor
Mongo.Collection.prototype.findAndPopulate = function (selector, options, populates) {
/*
selector and options: from Mongo.Collection.prototype.find(selector, options)
populates: [Object] or Object
[{id, as, from}] or {id, as, from}
e.g. {id: 'userId', as: 'thisUser', from: Users}
will look up doc.userId in Users and assign to doc.thisUser
--> doc.thisUser = Users.findOne(doc.userId);
*/
@chrisbolin
chrisbolin / index.html
Last active January 25, 2016 05:47
Codepen Preview
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>chris bolin 2</title>
<link rel="stylesheet" href="css/normalize.css">
@chrisbolin
chrisbolin / shell.js
Last active November 12, 2015 21:06
Keystone.js REPL Shell (using Headstone)
var repl = require('repl'),
keystone = require('keystone');
module.exports = function(done) {
var shell = repl.start({
prompt: 'keystone > '
});
// expose keystone to the shell
shell.context.keystone = keystone;
@chrisbolin
chrisbolin / export.sh
Last active January 12, 2016 00:30
Export / Source a .env File
# .env as used in https://github.com/bkeepers/dotenv
export $(cat .env)
@chrisbolin
chrisbolin / mongodb-collection-sizes.js
Last active October 8, 2015 17:28 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of storageSize. Helpful for finding largest collections.
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['storageSize']); }