Skip to content

Instantly share code, notes, and snippets.

@sungwoncho
sungwoncho / cleanup_example.sh
Last active November 11, 2022 21:50
Clean up previous build after a webpack build. Used in production at https://remotebase.io
# Store the filenames of previous build
PREVIOUS_BUILD=(./static/dist/*)
# ...
# build using webpack
# ...
# after the build
regex="([a-zA-Z_0-9]+)-([0-9a-z]+)\.(.*)"
{
"_id",
"name"
}
import React from 'react';
import { connect } from 'react-redux';
/**
* A higher order function that returns a function whose argument is the component
* to be wrapped.
*
* usage example:
* const EnsureLoggedIn = AuthWrapper();
* <EnsureLoggedIn(Profile) />
// Given path and value, get an object
// e.g. getObj('a.b.c', 1)
// { a: { b: { c: 1 } } }
function getObj(path, val) {
const keys = path.split('.');
if (keys.length === 1) {
const current = keys[0];
return {
[current]: val
@sungwoncho
sungwoncho / README.md
Last active January 5, 2016 10:49
Coddee test example

Coddee test example

An example code from coddee. These are a set of tests written using mocha and chai.

In webhook_method_tests.js, I am testing that the method saves a MongoDB document into a collection.

In webhook_tests.js, I am testing that this method is called when a webhook comes in from GitHub.

I wrote two different tests because the middleware that detects the GitHub webhook is an event emitter, and I don't have much control over how long it takes to actually save a document to a collection.